-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove limitation of only creating Tekton resources with TriggerTempl…
…ates Fix name of listener And another which should becom dynamic instead of set Remove empty line Add e2e for custom resources Go imports Fix a few references Use dynamic client instead of set to make it possible to create non tekton resources Remove dead code after removing type validation Removal of tekton type resource validation on v1beta1 as well Remove note about tekton resources but leave the validation First removal of the allowed type validation Remove dynamic client set because its not used anymore Better docs Change name in test examples Rename to create-configmap
- Loading branch information
1 parent
f6f77f4
commit 1d3e7b0
Showing
18 changed files
with
192 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## Create Configmap with EventListener | ||
|
||
Creates an EventListener that will create a configmap as an example how to create non tekton resources with Triggers. | ||
|
||
### Try it out locally: | ||
|
||
1. To create the Custom trigger and all related resources, run: | ||
|
||
```bash | ||
kubectl apply -f . | ||
``` | ||
|
||
1. Port forward: | ||
|
||
```bash | ||
kubectl port-forward service/el-create-configmap-listener 8080 | ||
``` | ||
|
||
1. Test by sending the sample payload. | ||
|
||
```bash | ||
curl -v \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{"action": "opened"}' \ | ||
http://localhost:8080 | ||
``` | ||
|
||
The response status code should be `202 Accepted` | ||
|
||
1. You should see a new ConfigMap that got created: | ||
|
||
```bash | ||
kubectl get configmaps | grep sample- | ||
``` |
58 changes: 58 additions & 0 deletions
58
examples/v1beta1/create-configmap/create-configmap-interceptor.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
apiVersion: triggers.tekton.dev/v1beta1 | ||
kind: EventListener | ||
metadata: | ||
name: create-configmap-listener | ||
spec: | ||
triggers: | ||
- name: create-configmap-listener | ||
interceptors: | ||
- name: "only when field is something" | ||
ref: | ||
name: "cel" | ||
params: | ||
- name: "filter" | ||
value: "body.action in ['opened']" | ||
bindings: | ||
- ref: create-configmap-binding | ||
template: | ||
ref: create-configmap-template | ||
resources: | ||
kubernetesResource: | ||
spec: | ||
template: | ||
spec: | ||
serviceAccountName: tekton-triggers-example-sa | ||
containers: | ||
- resources: | ||
requests: | ||
memory: "64Mi" | ||
cpu: "250m" | ||
limits: | ||
memory: "128Mi" | ||
cpu: "500m" | ||
--- | ||
apiVersion: triggers.tekton.dev/v1beta1 | ||
kind: TriggerBinding | ||
metadata: | ||
name: create-configmap-binding | ||
spec: | ||
params: | ||
- name: action | ||
value: $(body.action) | ||
|
||
--- | ||
apiVersion: triggers.tekton.dev/v1beta1 | ||
kind: TriggerTemplate | ||
metadata: | ||
name: create-configmap-template | ||
spec: | ||
params: | ||
- name: action | ||
resourcetemplates: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
generateName: sample- | ||
data: | ||
field: "Action is : $(tt.params.action)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
curl -v \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{"action": "opened"}' \ | ||
http://localhost:8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: tekton-triggers-example-sa | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: triggers-example-eventlistener-binding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: tekton-triggers-example-sa | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: tekton-triggers-eventlistener-roles | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: triggers-example-eventlistener-clusterbinding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: tekton-triggers-example-sa | ||
namespace: default | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: tekton-triggers-eventlistener-clusterroles | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: tekton-triggers-configmap-roles | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["configmaps"] | ||
verbs: ["create"] | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: triggers-example-configmap-eventlistener-binding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: tekton-triggers-example-sa | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: tekton-triggers-configmap-roles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.