Skip to content

Commit

Permalink
Fix CDEvents API usage and tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sunny <[email protected]>
  • Loading branch information
darkowlzz committed Sep 25, 2024
1 parent edb88c6 commit 3585b77
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module github.com/fluxcd/notification-controller

go 1.22.5
go 1.23

toolchain go1.23.1

replace github.com/fluxcd/notification-controller/api => ./api
Expand Down
6 changes: 3 additions & 3 deletions internal/server/receiver_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func Test_handlePayload(t *testing.T) {
"id": "5555",
"source": "github",
"timestamp": "2023-12-07T14:51:29.908479495Z",
"type": "dev.cdevents.change.merged.0.1.2",
"type": "dev.cdevents.change.merged.0.2.0",
},
"subject": map[string]string{
"type": "change",
Expand Down Expand Up @@ -191,7 +191,7 @@ func Test_handlePayload(t *testing.T) {
"id": "5555",
"source": "github",
"timestamp": "2023-12-07T14:51:29.908479495Z",
"type": "dev.cdevents.change.merged.0.1.2",
"type": "dev.cdevents.change.merged.0.2.0",
},
"subject": map[string]string{
"type": "change",
Expand Down Expand Up @@ -236,7 +236,7 @@ func Test_handlePayload(t *testing.T) {
"id": "5555",
"source": "github",
"timestamp": "2023-12-07T14:51:29.908479495Z",
"type": "dev.cdevents.change.merged.0.1.2",
"type": "dev.cdevents.change.merged.0.2.0",
},
"subject": map[string]string{
"type": "change",
Expand Down
3 changes: 2 additions & 1 deletion internal/server/receiver_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"time"

cdevents "github.com/cdevents/sdk-go/pkg/api"
cdevents04 "github.com/cdevents/sdk-go/pkg/api/v04"
"github.com/fluxcd/pkg/apis/meta"
"github.com/fluxcd/pkg/runtime/conditions"
"github.com/go-logr/logr"
Expand Down Expand Up @@ -205,7 +206,7 @@ func (s *ReceiverServer) validate(ctx context.Context, receiver apiv1.Receiver,
return fmt.Errorf("unable to read CDEvent request body: %s", err)
}

cdevent, err := cdevents.NewFromJsonBytes(b)
cdevent, err := cdevents04.NewFromJsonBytes(b)
if err != nil {
return fmt.Errorf("unable to validate CDEvent event: %s", err)
}
Expand Down

0 comments on commit 3585b77

Please sign in to comment.