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

Publish webhook or something similar #153

Open
jfro opened this issue Dec 4, 2023 · 4 comments
Open

Publish webhook or something similar #153

jfro opened this issue Dec 4, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@jfro
Copy link

jfro commented Dec 4, 2023

Was thinking it'd be nice to have kellnr hit a webhook or run a script upon successful publish, notifying of newly published crate/version to something like Slack.

@secana
Copy link
Contributor

secana commented Dec 4, 2023

That's a cool idea and doesn't seem too much work. I'll look into it.

@secana secana added the enhancement New feature or request label Dec 4, 2023
@secana
Copy link
Contributor

secana commented Apr 18, 2024

To support a webhook we need:

  • POST endpoint /api/v1/webhook to register a hook with register body
  • DELETE endpoint /api/v1/webhook?id=x to remove a webhook
  • GET endpoint /api/v1/webhook to list all registered hooks or /api/v1/webhook?id=x to get info about a specific hook
  • All API calls have to be authenticated and only admin accounts are allowed
  • A library that contains the events to be used to serialize and deserialize events. Public on crates.io
  • Store all registered events in the database to be persistent
  • Add UI to see registered hooks
  • Add UI to register hooks
  • Add UI to delete hooks
  • Add documentation to https://kellnr.io for the webhook API

The register event needs to contain all relevant data for kellnr, to be able to call the client in case, a event occurs.

// register event
{
   "url": "the url that gets a POST event",
   "name": "optional name for the hook",
   "events": [
       "crate_add",
       "crate_update",
       "crate_delete"
    ]
}

If the register event was send to kellnr, it responses with a HTTP OK and an ID that the client can use to identify the hook.

In case of an event, kellnr sends a HTTP POST to the registered urls.
To distinguish the event types, append a parameter to the url, e.g. https://url?event=crate_add

// event
{
   "id": "x",
    "name": "optional name",
    "event": "crate_add",
     "data": {
     // relevant data for the event
     }
}

@secana
Copy link
Contributor

secana commented Apr 18, 2024

The webhook API can be a first step to support a separate builder container, to keep the kellnr image small. If a new crate/version is uploaded, call a webhook to the builder container. #276

@secana
Copy link
Contributor

secana commented May 9, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

2 participants