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

add support for generic webhooks #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

goedelsoup
Copy link
Contributor

Adds support for webhook notifications with a minimal authorization provider implementation.

@codecov-io
Copy link

Codecov Report

Merging #183 into master will decrease coverage by 0.2%.
The diff coverage is 39.62%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #183      +/-   ##
==========================================
- Coverage   55.48%   55.27%   -0.21%     
==========================================
  Files         132      134       +2     
  Lines        4351     4400      +49     
  Branches      107      112       +5     
==========================================
+ Hits         2414     2432      +18     
- Misses       1937     1968      +31
Impacted Files Coverage Δ
core/src/main/scala/notifications/WebHook.scala 0% <0%> (ø)
...re/src/main/scala/notifications/Notification.scala 100% <100%> (ø) ⬆️
core/src/main/scala/Config.scala 76.8% <100%> (+0.17%) ⬆️
core/src/main/scala/notifications/Notify.scala 53.65% <33.33%> (-1.9%) ⬇️
...c/main/scala/notifications/NotificationEvent.scala 4.76% <4.76%> (ø)
core/src/main/scala/yaml/ManifestV1Parser.scala 78.47% <93.33%> (+0.69%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8186eef...3a6ef5a. Read the comment docs.

d: Datacenter.Deployment
) extends NotificationEvent

object NotificationEvent {
Copy link
Member

Choose a reason for hiding this comment

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

So it looks like for webhooks you're sending big deploy and destroy blobs to the endpoint - I assume the intention is for (presumably custom) endpoints to then take that blob and do something useful with it? Put differently, this isn't specific to any specific kind of webhook for some service right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Precisely, the goal is to provide real-time context for events occurring within Nelson to any desired consumer.

}

def send(s: WebHookSubscription, ev: NotificationEvent): IO[Unit] =
client.expect[String](Request[IO](
Copy link
Member

Choose a reason for hiding this comment

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

Double checking, does client.expect[String] accept any response, or specifically only strings (e.g. if the webhook sent back a JSON blob will this fail? I seem to vaguely remember some edge cases here but maybe I'm crazy. Is there a way to make this fire-and-forget or something, if that is desirable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a great point, this should be fire and forget. We really shouldn't care about the response body, only the response code and that should only drive different logging behaviors imo.

val env = plan.environment
val unit = ev.unit

("namespace" := ns.name.asString) ->:
Copy link
Member

Choose a reason for hiding this comment

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

More a note for the future than a review comment, since we're moving to Protobuf (#159) we may want these as protocols as well, esp. since this is quite a bit of information. But fine for now :)

@goedelsoup
Copy link
Contributor Author

Realized this requires users to configure secrets into the manifest, which is unacceptable. I'll research having named hooks, which are set up in the nelson config, or allowing a configuration routine that fetches credentials securely from Vault.

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.

3 participants