-
Notifications
You must be signed in to change notification settings - Fork 490
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
slack multi-config #1833
slack multi-config #1833
Conversation
8c1f15a
to
b121020
Compare
8275586
to
a6ed1d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I have noted a few comments/questions below.
pipeline/alert.go
Outdated
// Example: | ||
// stream | ||
// |alert() | ||
// .slack('opencommunity') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example should be:
.slack()
.workspace('opencommunity')
@@ -52,3 +57,37 @@ func (c Config) Validate() error { | |||
} | |||
return nil | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NewConfig() method is now not sufficient to set defaults.
Because its possible that there are multiple config structs created, the toml parser will create a new one using reflection which will not call the NewConfig method.
The config package we use checks for config structs that implement an ApplyDefaults
method and calls it on newly created config structs.
For example:
func (c *Config) ApplyDefaults() {
if c.Username == "" {
c.Username = DefaultUsername
}
}
It would be best to use the ApplyDefaults method within the NewConfig method to ensure they are the same.
services/slack/service.go
Outdated
if err != nil { | ||
return err | ||
} | ||
client := s.clientValue.Load().(*http.Client) | ||
client := s.clients[workspace] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you protect access to the clients dict here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth creating a Workspace struct that contains both a Config and http.Client so you do not have to maintain and protect access to two maps.
services/slack/service.go
Outdated
@@ -184,6 +226,7 @@ func (s *Service) preparePost(channel, message, username, iconEmoji string, leve | |||
Mrkdwn_in: []string{"text"}, | |||
} | |||
postData := make(map[string]interface{}) | |||
postData["workspace"] = c.Workspace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this part of the slack API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small change and this is good to go. Thanks!
|
||
if c.InsecureSkipVerify { | ||
s.diag.InsecureSkipVerify() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also want this check to be in the Service.Update
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to go.
I tested locally with my existing config and the upgrade worked without issue.
Can you rebase and squash into a single commit before merging?
Oh and it looks like there is one more |
…the workspace name.
a85b422
to
c2be03b
Compare
slack now accepts + generates request for multiple configurations.
Required for all non-trivial PRs