Skip to content

Initial http reaction #253

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

danielgerlag
Copy link
Contributor

@danielgerlag danielgerlag commented Jun 10, 2025

Description

Initial implementation of an Http reaction. This enables the user to craft Http calls that will be invoked when query result set changes occur.

The URL of the request and the payload can be constructed from a handlebars template.

For example, the following configuration will post to https://api.github.com/repos/{{repo}}/issues/{{issue_number}}/comments, where the variables are sourced from the result set item that was added. The JSON body of the request is also constructed using handlebars.

kind: Reaction
apiVersion: v1
name: test-http
spec:
  kind: Http
  properties:
    baseUrl: "https://api.github.com"
    token: xxxx
  queries:
    issue-comments: >
      added:
        url: "/repos/{{after.repo}}/issues/{{after.issue_number}}/comments"
        method: "POST"
        body: > 
          {
            "body": "Hello! @{{after.creator}}"
          }
        headers:
          X-GitHub-Api-Version: "2022-11-28"
      updated: 
            ....
      deleted: 
            ....

Configuration Schema

Reaction-Level configuration

  • baseUrl: The base URL to use for all Http requests that will be made. eg. https://api.github.com. Query specific requests will build on this URL by adding a path,
  • token (optional): The bearer token to use for authentication.

Per-Query Configuration

The following 3 sections can be included per query

  • added (optional): Describes the Http request for items added to the result set.
  • updated (optional): Describes the Http request for items updated the result set.
  • deleted (optional): Describes the Http request for items deleted from the result set.

Each of these will describe the Http request to make for added, updated, and deleted changes respectively.
The configuration for each of these is as follows:

  • url: The path to append to the baseUrl for the request. This can be a handlebars template, where you can merge data from the result set diff. Added results will have an after field that contains an object that is the added item, updated results will have before and after objects, and deleted results will only have a before object. For example: /repos/{{after.repo}}/issues/{{after.issue_number}}/comments
  • method: The Http method to use, PUT, POST, GET, DELETE, etc.
  • body: The body of the request. This can be a handlebars template, where you can merge data from the result set diff. Added results will have an after field that contains an object that is the added item, updated results will have before and after objects, and deleted results will only have a before object.
  • headers: An object containing any additional custom headers to include in the Http request.

What is missing

  • Currently, we do not have support for resilience/retry strategies.
  • Currently, we only support bearer token auth for the target endpoint.

Copy link
Member

@amansinghoriginal amansinghoriginal left a comment

Choose a reason for hiding this comment

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

Can you create an issue for this with various config options supported?

@danielgerlag
Copy link
Contributor Author

Can you create an issue for this with various config options supported?

Added to the PR description.

@amansinghoriginal
Copy link
Member

Can you create an issue for this with various config options supported?

Added to the PR description.

Yes, thanks for adding it. Can we please also create issue - as anyways for major changes we require the PR to link to an issue.
An added benefit is that OSS community can easily track what's going on in the project - and we can also create a board from issues - so better tracking?

@danielgerlag
Copy link
Contributor Author

Can you create an issue for this with various config options supported?

Added to the PR description.

Yes, thanks for adding it. Can we please also create issue - as anyways for major changes we require the PR to link to an issue. An added benefit is that OSS community can easily track what's going on in the project - and we can also create a board from issues - so better tracking?

#260

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