Skip to content

Commit

Permalink
chore(deps): bump Svix to v1.40.0 (#1847)
Browse files Browse the repository at this point in the history
* chore: bump Svix to v1.40.0

* refactor: adopt Svix API changes

* feat: add Deprecated flag to Svix Event Type

* ci: bump Svix version in Dagger

* chore: bumps Svix version in Docker Compose
  • Loading branch information
chrisgacsal authored Nov 14, 2024
1 parent bcf4414 commit cc33519
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .dagger/versions_pinned.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ services:
retries: 30

svix:
image: svix/svix-server:v1.37
image: svix/svix-server:v1.40
profiles:
- webhook
environment:
Expand Down
9 changes: 6 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
26 changes: 13 additions & 13 deletions openmeter/notification/webhook/svix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -252,8 +252,8 @@ func (h svixWebhookHandler) CreateWebhook(ctx context.Context, params CreateWebh
Disabled: &params.Disabled,
RateLimit: *svix.NullableInt32(params.RateLimit),
Secret: *svix.NullableString(params.Secret),
FilterTypes: &params.EventTypes,
Channels: &params.Channels,
FilterTypes: params.EventTypes,
Channels: params.Channels,
Metadata: func() *map[string]string {
if len(params.Metadata) > 0 {
return &params.Metadata
Expand Down Expand Up @@ -338,8 +338,8 @@ func (h svixWebhookHandler) UpdateWebhook(ctx context.Context, params UpdateWebh
Url: params.URL,
Disabled: &params.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 &params.Metadata
Expand Down Expand Up @@ -504,15 +504,15 @@ 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
}
}
}

if o.Channels != nil {
for _, channel := range params.Channels {
if slices.Contains(*o.Channels, channel) {
if slices.Contains(o.Channels, channel) {
return true
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion openmeter/notification/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit cc33519

Please sign in to comment.