Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

providers/sentry: add environment support #223

Merged
merged 3 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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