From b933e007cbb216414afe7bfbaebbeb58ca2dd0dc Mon Sep 17 00:00:00 2001 From: Kelvin Wang Date: Thu, 5 Sep 2019 16:48:34 -0400 Subject: [PATCH] fix(notification/endpoint): remove slack token requirement --- notification/endpoint/endpoint_test.go | 5 +---- notification/endpoint/slack.go | 8 +++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/notification/endpoint/endpoint_test.go b/notification/endpoint/endpoint_test.go index 36d5b74125..f41537867c 100644 --- a/notification/endpoint/endpoint_test.go +++ b/notification/endpoint/endpoint_test.go @@ -81,10 +81,7 @@ func TestValidEndpoint(t *testing.T) { Base: goodBase, URL: "localhost", }, - err: &influxdb.Error{ - Code: influxdb.EInvalid, - Msg: "slack endpoint token is invalid", - }, + err: nil, }, { name: "invalid slack token", diff --git a/notification/endpoint/slack.go b/notification/endpoint/slack.go index 664725c20e..2d122d16c2 100644 --- a/notification/endpoint/slack.go +++ b/notification/endpoint/slack.go @@ -33,9 +33,11 @@ func (s *Slack) BackfillSecretKeys() { // SecretFields return available secret fields. func (s Slack) SecretFields() []influxdb.SecretField { - return []influxdb.SecretField{ - s.Token, + arr := []influxdb.SecretField{} + if s.Token.Key != "" { + arr = append(arr, s.Token) } + return arr } // Valid returns error if some configuration is invalid @@ -56,7 +58,7 @@ func (s Slack) Valid() error { } } // TODO(desa): this requirement seems odd - if s.Token.Key != s.ID.String()+slackTokenSuffix { + if s.Token.Key != "" && s.Token.Key != s.ID.String()+slackTokenSuffix { return &influxdb.Error{ Code: influxdb.EInvalid, Msg: "slack endpoint token is invalid",