redhat-developer / kam

GitOps Application Manager: An opinionated CLI that generates the Kubernetes resources for managing your Tekton-based CI manifests, ArgoCD-based CD manifests and Application manifests in Git.
Apache License 2.0
145 stars 83 forks source link

fix: Update trigger binding to use the new extensions field #191

Closed chetan-rns closed 3 years ago

chetan-rns commented 3 years ago

What type of PR is this?

/kind bug

What does this PR do / why we need it:

The Overlays in the Tekton event listener will add elements to a new field known as "extensions" instead of modifying the existing fields in the incoming payload. This PR updates the trigger binding to extract the branch name from the new extensions field.

Overlays Ref: https://github.com/tektoncd/triggers/blob/v0.10.2/docs/eventlisteners.md#overlays

Signed-off-by: Chetan Banavikalmutt chetanrns1997@gmail.com

Have you updated the necessary documentation?

How to test changes / Special notes to the reviewer:

  1. Follow Day 1 docs and bootstrap a gitops repository
  2. Add webhooks to gitops and service repository
  3. Raise PRs to your gitops and service repositories, observe if both the pipelines are successfully executed

Screenshot from 2021-03-12 11-47-38

chetan-rns commented 3 years ago

/ok-to-test

wtam2018 commented 3 years ago

There are a few "body.ref" reminded in the code and doc. Can you please review/confirm them if they need to be updated.

chetan-rns commented 3 years ago

@wtam2018 Just checked. The existing body.ref in the codebase is for the eventlistener.

openshift-ci-robot commented 3 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wtam2018

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/redhat-developer/kam/blob/master/OWNERS)~~ [wtam2018] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
keithchong commented 3 years ago

@chetan-rns , @wtam2018 , how did you know that the new extensions field was added? eg. what was your process that led up to this finding?

wtam2018 commented 3 years ago

Sadly, you know it until you hit the wall currently.

On Mon, Mar 15, 2021 at 11:36 AM Keith Chong @.***> wrote:

@chetan-rns https://github.com/chetan-rns , @wtam2018 https://github.com/wtam2018 , how did you know that the new extensions field was added? eg. what was your process that led up to this finding?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/redhat-developer/kam/pull/191#issuecomment-799517795, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKQAJIPSJIN54I53QBDZ5Z3TDYSPXANCNFSM4ZBVIBBQ .

chetan-rns commented 3 years ago

Hi @keithchong,

The error we faced was an invalid tag being added to the image built by our pipeline. We expect the images to have the tag of the form image:<branch_name>-<commit_id>, but the images were getting built with the tag image:refs/heads/<branch_name>-<commit_id>.

Basically, refs/heads/<branch_name> from the incoming JSON payload was not being trimmed down to <branch_name>. This logic is handled by the Tekton event listener here. The Tekton triggers doc suggested the trimmed field was being added to this new extension field