Skip to content

Commit

Permalink
Merge pull request #223 from BeryJu/sentry-environment
Browse files Browse the repository at this point in the history
providers/sentry: add environment support
  • Loading branch information
stefanprodan authored Jul 26, 2021
2 parents c87f39d + c767aad commit 952d4f4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
17 changes: 17 additions & 0 deletions docs/spec/v1beta1/provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,23 @@ kubectl create secret generic $SECRET_NAME \
--from-file=caFile=ca.crt
```

### Sentry

The sentry provider uses the `channel` field to specify which environment the messages are sent for:

```yaml
apiVersion: notification.toolkit.fluxcd.io/v1beta1
kind: Provider
metadata:
name: sentry
namespace: default
spec:
type: sentry
channel: my-cluster-name
# webhook address (ignored if secretRef is specified)
address: https://[email protected]/12341234
```
### Azure Event Hub
The Azure Event Hub supports two authentication methods, [JWT](https://docs.microsoft.com/en-us/azure/event-hubs/authenticate-application) and [SAS](https://docs.microsoft.com/en-us/azure/event-hubs/authorize-access-shared-access-signature) based.
Expand Down
2 changes: 1 addition & 1 deletion internal/notifier/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (f Factory) Notifier(provider string) (Interface, error) {
case v1beta1.WebexProvider:
n, err = NewWebex(f.URL, f.ProxyURL, f.CertPool)
case v1beta1.SentryProvider:
n, err = NewSentry(f.CertPool, f.URL)
n, err = NewSentry(f.CertPool, f.URL, f.Channel)
case v1beta1.AzureEventHubProvider:
n, err = NewAzureEventHub(f.URL, f.Token, f.Channel)
default:
Expand Down
3 changes: 2 additions & 1 deletion internal/notifier/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Sentry struct {
}

// NewSentry creates a Sentry client from the provided Data Source Name (DSN)
func NewSentry(certPool *x509.CertPool, dsn string) (*Sentry, error) {
func NewSentry(certPool *x509.CertPool, dsn string, environment string) (*Sentry, error) {
tr := &http.Transport{}
if certPool != nil {
tr = &http.Transport{
Expand All @@ -43,6 +43,7 @@ func NewSentry(certPool *x509.CertPool, dsn string) (*Sentry, error) {
}
client, err := sentry.NewClient(sentry.ClientOptions{
Dsn: dsn,
Environment: environment,
HTTPTransport: tr,
})
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion internal/notifier/sentry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ import (
)

func TestNewSentry(t *testing.T) {
s, err := NewSentry(nil, "https://test@localhost/1")
s, err := NewSentry(nil, "https://test@localhost/1", "foo")
require.NoError(t, err)
assert.Equal(t, s.Client.Options().Dsn, "https://test@localhost/1")
assert.Equal(t, s.Client.Options().Environment, "foo")
}

func TestToSentryEvent(t *testing.T) {
Expand Down

0 comments on commit 952d4f4

Please sign in to comment.