diff --git a/.dagger/versions_pinned.go b/.dagger/versions_pinned.go index 330461c6c..1c97a5fbc 100644 --- a/.dagger/versions_pinned.go +++ b/.dagger/versions_pinned.go @@ -8,7 +8,7 @@ const ( clickhouseVersion = "24.5.5.78" redisVersion = "7.0.12" postgresVersion = "14.9" - svixVersion = "v1.29" + svixVersion = "v1.40" // TODO: add update mechanism for versions below diff --git a/docker-compose.yaml b/docker-compose.yaml index 25d8c4e8b..802b60c40 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -134,7 +134,7 @@ services: retries: 30 svix: - image: svix/svix-server:v1.37 + image: svix/svix-server:v1.40 profiles: - webhook environment: diff --git a/go.mod b/go.mod index f7903d930..946915846 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ require ( github.com/spf13/viper v1.20.0-alpha.6 github.com/stretchr/testify v1.9.0 github.com/stripe/stripe-go/v80 v80.2.1 - github.com/svix/svix-webhooks v1.38.0 + github.com/svix/svix-webhooks v1.40.0 go.opentelemetry.io/contrib/bridges/otelslog v0.6.0 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 go.opentelemetry.io/otel v1.32.0 @@ -83,7 +83,10 @@ require ( sigs.k8s.io/controller-runtime v0.19.1 ) -require github.com/invopop/validation v0.8.0 // indirect +require ( + github.com/invopop/validation v0.8.0 // indirect + gopkg.in/validator.v2 v2.0.1 // indirect +) require ( ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect @@ -297,7 +300,7 @@ require ( github.com/jhump/protoreflect v1.15.6 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect + github.com/json-iterator/go v1.1.12 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/klauspost/compress v1.17.9 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect diff --git a/go.sum b/go.sum index 839f9c258..ec112c7e0 100644 --- a/go.sum +++ b/go.sum @@ -1301,8 +1301,8 @@ github.com/stripe/stripe-go/v80 v80.2.1 h1:1FQP5a/gpC4i0ezS8EPqdme3K/H9UlNWswqNH github.com/stripe/stripe-go/v80 v80.2.1/go.mod h1:n7tsDvdltYlzOLGXlseMSJM6ik5uv3guptqtae/VSak= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= -github.com/svix/svix-webhooks v1.38.0 h1:6f1XD4aB/hrDhV7B+8T6MvnB0hzWxPaldB5YghaK6mQ= -github.com/svix/svix-webhooks v1.38.0/go.mod h1:CteUj578U/Mmem33Hda4lhzQ6mIs8pwmgj3f9NAG7vQ= +github.com/svix/svix-webhooks v1.40.0 h1:/buUGFcG2L0Ha9j5tkaXn3XR4zFEiRUTr2Cnq6HAM+U= +github.com/svix/svix-webhooks v1.40.0/go.mod h1:MHZT9p7h83h+yuSsBBqZjK7YUOJtv/gukZpmvDDtGQg= github.com/testcontainers/testcontainers-go v0.33.0 h1:zJS9PfXYT5O0ZFXM2xxXfk4J5UMw/kRiISng037Gxdw= github.com/testcontainers/testcontainers-go v0.33.0/go.mod h1:W80YpTa8D5C3Yy16icheD01UTDu+LmXIA2Keo+jWtT8= github.com/testcontainers/testcontainers-go/modules/compose v0.33.0 h1:PyrUOF+zG+xrS3p+FesyVxMI+9U+7pwhZhyFozH3jKY= @@ -1894,6 +1894,8 @@ gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYs gopkg.in/square/go-jose.v2 v2.4.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/validator.v2 v2.0.1 h1:xF0KWyGWXm/LM2G1TrEjqOu4pa6coO9AlWSf3msVfDY= +gopkg.in/validator.v2 v2.0.1/go.mod h1:lIUZBlB3Im4s/eYp39Ry/wkR02yOPhZ9IwIRBjuPuG8= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/openmeter/notification/webhook/svix.go b/openmeter/notification/webhook/svix.go index 8ecf08d34..97ec2785f 100644 --- a/openmeter/notification/webhook/svix.go +++ b/openmeter/notification/webhook/svix.go @@ -12,7 +12,6 @@ import ( "time" "github.com/oklog/ulid/v2" - "github.com/samber/lo" svix "github.com/svix/svix-webhooks/go" "k8s.io/utils/strings/slices" @@ -26,7 +25,7 @@ const ( // Channels and EventTypes are used as message filters in Svix // which means that a webhook without any filtering will receive all messages // sent to the application the webhook belongs to. In order to prevent this we - // use the NoMessageChannel as a dummy filter, so it is possible to set up webhook endpoint + // use the NullChannel as a dummy filter, so it is possible to set up webhook endpoint // prior knowing what type of messages are going to be routed to it. NullChannel = "__null_channel" ) @@ -84,7 +83,8 @@ func (h svixWebhookHandler) RegisterEventTypes(ctx context.Context, params Regis Description: eventType.Description, FeatureFlag: *svix.NullableString(nil), GroupName: *svix.NullableString(&eventType.GroupName), - Schemas: lo.ToPtr(eventType.Schemas), + Schemas: eventType.Schemas, + Deprecated: &eventType.Deprecated, } _, err := h.client.EventType.Update(ctx, eventType.Name, input) @@ -252,8 +252,8 @@ func (h svixWebhookHandler) CreateWebhook(ctx context.Context, params CreateWebh Disabled: ¶ms.Disabled, RateLimit: *svix.NullableInt32(params.RateLimit), Secret: *svix.NullableString(params.Secret), - FilterTypes: ¶ms.EventTypes, - Channels: ¶ms.Channels, + FilterTypes: params.EventTypes, + Channels: params.Channels, Metadata: func() *map[string]string { if len(params.Metadata) > 0 { return ¶ms.Metadata @@ -338,8 +338,8 @@ func (h svixWebhookHandler) UpdateWebhook(ctx context.Context, params UpdateWebh Url: params.URL, Disabled: ¶ms.Disabled, RateLimit: *svix.NullableInt32(params.RateLimit), - FilterTypes: lo.ToPtr(params.EventTypes), - Channels: lo.ToPtr(params.Channels), + FilterTypes: params.EventTypes, + Channels: params.Channels, Metadata: func() *map[string]string { if len(params.Metadata) > 0 { return ¶ms.Metadata @@ -504,7 +504,7 @@ func (h svixWebhookHandler) ListWebhooks(ctx context.Context, params ListWebhook if o.FilterTypes != nil { for _, eventType := range params.EventTypes { - if slices.Contains(*o.FilterTypes, eventType) { + if slices.Contains(o.FilterTypes, eventType) { return true } } @@ -512,7 +512,7 @@ func (h svixWebhookHandler) ListWebhooks(ctx context.Context, params ListWebhook if o.Channels != nil { for _, channel := range params.Channels { - if slices.Contains(*o.Channels, channel) { + if slices.Contains(o.Channels, channel) { return true } } @@ -558,7 +558,7 @@ func (h svixWebhookHandler) SendMessage(ctx context.Context, params SendMessageI } input := &svix.MessageIn{ - Channels: lo.ToPtr(params.Channels), + Channels: params.Channels, EventId: *svix.NullableString(eventID), EventType: params.EventType, Payload: params.Payload, @@ -589,7 +589,7 @@ func (h svixWebhookHandler) SendMessage(ctx context.Context, params SendMessageI return "" }(), EventType: o.EventType, - Channels: lo.FromPtr(o.Channels), + Channels: o.Channels, Payload: o.Payload, }, nil } @@ -607,8 +607,8 @@ func WebhookFromSvixEndpointOut(e *svix.EndpointOut) *Webhook { Disabled: defaultx.WithDefault(e.Disabled, false), RateLimit: e.RateLimit.Get(), Description: e.Description, - EventTypes: lo.FromPtr(e.FilterTypes), - Channels: slices.Filter(nil, lo.FromPtr(e.Channels), func(s string) bool { + EventTypes: e.FilterTypes, + Channels: slices.Filter(nil, e.Channels, func(s string) bool { return s != NullChannel }), CreatedAt: e.CreatedAt, diff --git a/openmeter/notification/webhook/webhook.go b/openmeter/notification/webhook/webhook.go index d268ec7c4..879de7fd9 100644 --- a/openmeter/notification/webhook/webhook.go +++ b/openmeter/notification/webhook/webhook.go @@ -250,7 +250,8 @@ type EventType struct { Description string GroupName string // Schemas defines the list of schemas for each event type version - Schemas map[string]map[string]interface{} + Schemas map[string]map[string]interface{} + Deprecated bool } type Handler interface {