-
Notifications
You must be signed in to change notification settings - Fork 739
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
Conversation
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:
See our server-side commit conventions here. |
The following commits need their title changed: Please format your commit title into the form:
This allows us to easily generate changelogs & determine semantic version numbers when cutting releases. You can read more about commit conventions 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.
Few minor observations. Also tests are missing :).
gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/SlackController.groovy
Outdated
Show resolved
Hide resolved
gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/SlackConfig.groovy
Outdated
Show resolved
Hide resolved
gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SlackService.groovy
Outdated
Show resolved
Hide resolved
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. |
e39a62e
to
5881973
Compare
gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/SlackController.java
Outdated
Show resolved
Hide resolved
gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/SlackConfig.java
Outdated
Show resolved
Hide resolved
gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/SlackConfig.java
Outdated
Show resolved
Hide resolved
gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/SlackController.java
Show resolved
Hide resolved
7f0b118
to
4527f53
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.
lgtm.
(I personally don't see value in a single unit test that would just assert that a mock got invoked)
slack: | ||
baseUrl: https://slack.com/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.
Can you ensure gate starts up normally even without this config. Just so we don't break folks in OSS
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.
I added another @ConditionalOnProperty
to check for the url as well
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.
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 :)
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.
Confirmed that gate OSS runs without any slack config :)
4527f53
to
d3e0008
Compare
I agree, especially since this is just proxying to slack with no other business logic. |
|
||
@RestController | ||
@RequestMapping("/slack") | ||
@ConditionalOnProperty( |
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.
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)
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.