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

fix(example): update default branch name in examples #1748

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(example): update default branch name in examples
  • Loading branch information
l-qing committed Aug 12, 2024
commit d0ed482e63cc80a47e03bdef3d54716d6bbc8678
1 change: 1 addition & 0 deletions docs/triggertemplates.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ spec:
default: This is the default message
- name: contenttype
description: The Content-Type of the event
default: text/plain
resourcetemplates:
- apiVersion: tekton.dev/v1beta1
kind: PipelineRun
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ of Triggers resources. Many of the sub-folders also contain their own READMEs wi
## Pre-Requisites
To run the examples, you need the following pre-requisites:

1. Ensure you have Tekton Pipelines [installed](https://github.com/tektoncd/pipeline/blob/master/docs/install.md)
1. Ensure you have Tekton Pipelines [installed](https://github.com/tektoncd/pipeline/blob/main/docs/install.md)

2. Create the service account and all associated roles and bindings by running `kubectl apply -f rbac.yaml`.

Expand Down
2 changes: 1 addition & 1 deletion examples/v1alpha1/cron/triggerbinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ metadata:
spec:
params:
- name: gitrevision
value: master
value: main
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this demo, cloning the master branch will fail because it has been renamed to main.

- name: gitrepositoryurl
value: https://github.com/tektoncd/triggers
2 changes: 1 addition & 1 deletion examples/v1alpha1/label-selector/triggers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ spec:
params:
- name: gitrevision
description: The git revision
default: master
default: main
- name: gitrepositoryurl
description: The git repository url
- name: message
Expand Down
2 changes: 1 addition & 1 deletion examples/v1alpha1/namespace-selector/03_trigger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
params:
- name: gitrevision
description: The git revision
default: master
default: main
- name: gitrepositoryurl
description: The git repository url
- name: message
Expand Down
2 changes: 1 addition & 1 deletion examples/v1beta1/cron/triggerbinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ metadata:
spec:
params:
- name: gitrevision
value: master
value: main
- name: gitrepositoryurl
value: https://github.com/tektoncd/triggers
2 changes: 1 addition & 1 deletion examples/v1beta1/label-selector/triggers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
params:
- name: gitrevision
description: The git revision
default: master
default: main
- name: gitrepositoryurl
description: The git repository url
- name: message
Expand Down
2 changes: 1 addition & 1 deletion examples/v1beta1/namespace-selector/03_trigger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec:
params:
- name: gitrevision
description: The git revision
default: master
default: main
- name: gitrepositoryurl
description: The git repository url
- name: message
Expand Down
1 change: 1 addition & 0 deletions examples/v1beta1/triggertemplates/triggertemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ spec:
default: This is the default message
- name: contenttype
description: The Content-Type of the event
default: text/plain
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this demo, without a default value and without assigning value in TriggerBinding, the default value $(tt.params.contenttype) will be retained in TaskRun, which is quite strange.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean to say we get $(tt.params.contenttype) when there's no value in TriggerBinding and no default value? It should during processing of events then,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I understand that this value should be declared in the TriggerBinding as the source of the contenttype variable, which can be either $(body.xxx) or $(extensions.xxx). However, I am not aware of any existing data source to obtain this parameter value, and it is not mentioned in the documentation.

So my current solution is to give it a default value first, which will not affect other TriggerBindings assigning it a suitable value in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I referred to the code here and also added a configuration in TriggerBinding to assign a value to contenttype.

spec:
params:
- name: gitrevision
value: $(body.head_commit.id)
- name: gitrepositoryurl
value: $(body.repository.url)
- name: contenttype
value: $(header.Content-Type)

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @l-qing when there is not default value what is the issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there is no default value, it will not necessarily cause a problem.
It will only cause an issue if there is also no value assigned in the TriggerBinding.

resourcetemplates:
- apiVersion: tekton.dev/v1beta1
kind: PipelineRun
Expand Down