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

feat(slack): Add slack service #955

Merged
merged 9 commits into from
Nov 21, 2019

Conversation

caseyhebebrand
Copy link
Contributor

Introduces a Slack service that is conditional on the presence of a token. The initial use case is to fetch public channels within a workspace.

@spinnakerbot
Copy link
Contributor

We prefer that non-test backend code be written in Java or Kotlin, rather than Groovy. The following files have been added and written in Groovy:

  • gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/SlackConfig.groovy

  • gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/SlackController.groovy

  • gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SlackService.groovy

See our server-side commit conventions here.

@spinnakerbot
Copy link
Contributor

The following commits need their title changed:

  • 90e4dc6: Fetch channels from Slack

  • 9c4456b: Remove archived channels

Please format your commit title into the form:

<type>(<scope>): <subject>, e.g. fix(kubernetes): address NPE in status check

This allows us to easily generate changelogs & determine semantic version numbers when cutting releases. You can read more about commit conventions here.

@emjburns emjburns self-requested a review November 6, 2019 19:55
Copy link
Contributor

@srekapalli srekapalli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few minor observations. Also tests are missing :).

@emjburns
Copy link
Contributor

emjburns commented Nov 6, 2019

I'd love for you to convert these files to java. We are trying to not add any more groovy code. That means that parsing the response from slack will be more of a pain in the ass, but it should be fine. Let me know if you need help or an example file to work from

@caseyhebebrand
Copy link
Contributor Author

I'd love for you to convert these files to java. We are trying to not add any more groovy code. That means that parsing the response from slack will be more of a pain in the ass, but it should be fine. Let me know if you need help or an example file to work from

No worries, I can do that.

Copy link
Contributor

@jeyrschabu jeyrschabu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

(I personally don't see value in a single unit test that would just assert that a mock got invoked)

Comment on lines +61 to +63
slack:
baseUrl: https://slack.com/api

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you ensure gate starts up normally even without this config. Just so we don't break folks in OSS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added another @ConditionalOnProperty to check for the url as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speaking from lots of experience, it's best to make sure that gate starts up locally without this property as well as with this property. I've broken OSS several times because I forgot to check that :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that gate OSS runs without any slack config :)

@caseyhebebrand
Copy link
Contributor Author

lgtm.

(I personally don't see value in a single unit test that would just assert that a mock got invoked)

I agree, especially since this is just proxying to slack with no other business logic.


@RestController
@RequestMapping("/slack")
@ConditionalOnProperty(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine since the controller is the only thing depending on SlackService.

Another approach would be to annotate this controller with @ConditionalOnBean(SlackService.class) then annotate SlackConfig.slackService with @ConditionalOnProperty("slack.....") but you don't have to do this. (maybe until slackService gets used elsewhere)

@emjburns emjburns added the ready to merge Approved and ready for merge label Nov 21, 2019
@mergify mergify bot merged commit e70dd50 into spinnaker:master Nov 21, 2019
@mergify mergify bot added the auto merged label Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants