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

slack multi-config #1833

Merged
merged 1 commit into from
Mar 21, 2018
Merged

slack multi-config #1833

merged 1 commit into from
Mar 21, 2018

Conversation

aanthony1243
Copy link
Contributor

@aanthony1243 aanthony1243 commented Mar 6, 2018

slack now accepts + generates request for multiple configurations.

Required for all non-trivial PRs
  • Rebased/mergable
  • Tests pass
  • CHANGELOG.md updated

@aanthony1243 aanthony1243 requested a review from nathanielc March 6, 2018 22:08
@aanthony1243 aanthony1243 changed the title [WIP] slack multi-config slack multi-config Mar 15, 2018
Copy link
Contributor

@nathanielc nathanielc left a 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.

// Example:
// stream
// |alert()
// .slack('opencommunity')
Copy link
Contributor

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
}

Copy link
Contributor

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.

if err != nil {
return err
}
client := s.clientValue.Load().(*http.Client)
client := s.clients[workspace]
Copy link
Contributor

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?

Copy link
Contributor

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.

@@ -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
Copy link
Contributor

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?

Copy link
Contributor

@nathanielc nathanielc left a 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()
}
Copy link
Contributor

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.

Copy link
Contributor

@nathanielc nathanielc left a 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?

@nathanielc
Copy link
Contributor

Oh and it looks like there is one more Fatal -> Fatalf change that needs to be made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants