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: introduces a new resource "http" #1773

Merged
merged 3 commits into from
Nov 21, 2023

Conversation

dduportal
Copy link
Contributor

@dduportal dduportal commented Nov 18, 2023

Implements #268

This PR introduces a new resource of type http with source and condition capability.

The initial UX proposal has been updated to ensure separation between source and condition are easier (see the E2E test).

Here is a "complete reference example":

sources:
  getWithCustomRequest:
    kind: http
    spec:
      url: https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/maven-metadata.xml
      request:
        headers:
          Authorization: 'Bearer Token'
          Accept: 'application/xml'
        verb: GET

conditions:
  checkWithCustomRequest:
    kind: http
    sourceid: getJenkinsWarArtifactMetadatas
    spec:
      url: https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/maven-metadata.xml
      request:
        headers:
          Authorization: 'Bearer Token'
          Accept: 'application/xml'
        verb: HEAD
      responseasserts:
        statuscode: 302
        headers:
          Content-Type: "text/html; charset=utf-8"

Test

To test this pull request, you can run the following commands:

cd ./pkg/plugins/resources/updateclihttp/
go test

Additional Information

  • For a source, both HTTP/4xx and HTTP/5xx response status code are considered a failure (as both client and server side errors are not expected to provide a body). This behavior can be adapted on a subsequent PR if we have a use case to retrieve a body on a HTTP/404 error.
  • For a condition there are 2 cases:
    • If no assertion is provided, HTTP/5xx is considered an error, while HTTP/4xx is considered a non passing condition.
    • If assertion is provided, then the status code is compared to the provided status code assertion

@dduportal dduportal added enhancement New feature or request source condition Modify condition resource http labels Nov 18, 2023
Signed-off-by: Damien Duportal <damien.duportal@gmail.com>
@dduportal dduportal marked this pull request as ready for review November 20, 2023 08:58
olblak
olblak previously approved these changes Nov 20, 2023
Copy link
Member

@olblak olblak left a comment

Choose a reason for hiding this comment

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

This plugin is awesome. I tested locally and it works great.
I also like the unit tests

I made a few suggestion to the plugin comment as I think they can be improve a bit but it's not a blocker

I am just wondering how we should communicate if it's better to fetch content using the http plugin or the file with the http protocol in the path

Feel free to resolve the conversations and the merge whenever you want

Co-authored-by: Olivier Vernin <olivier@vernin.me>
Signed-off-by: Damien Duportal <damien.duportal@gmail.com>
@dduportal
Copy link
Contributor Author

This plugin is awesome. I tested locally and it works great. I also like the unit tests

I made a few suggestion to the plugin comment as I think they can be improve a bit but it's not a blocker

Thanks! I've taken your suggestions. If you see further improvement (on the comment particularly) don't hesitate to comment the PR, even if merged: i'll send a subsequent PR if need be.

I am just wondering how we should communicate if it's better to fetch content using the http plugin or the file with the http protocol in the path

Proposal, WDYT?

@dduportal
Copy link
Contributor Author

Self merging because:

Feel free to resolve the conversations and the merge whenever you want

from @olblak

and I only changed comments since his last review

@dduportal dduportal merged commit 771e028 into updatecli:main Nov 21, 2023
6 checks passed
@dduportal dduportal deleted the feat/http-resource branch November 21, 2023 10:59
@dduportal dduportal changed the title feat: introduces a new resource "http" (source only) feat: introduces a new resource "http" Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
condition Modify condition resource enhancement New feature or request http source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants