Skip to content

Commit

Permalink
Updates development docs
Browse files Browse the repository at this point in the history
Signed-off-by: PuneetPunamiya <[email protected]>
  • Loading branch information
PuneetPunamiya authored and openshift-merge-bot[bot] committed May 3, 2024
1 parent 8bf350f commit 2834934
Showing 1 changed file with 55 additions and 42 deletions.
97 changes: 55 additions & 42 deletions docs/DEVELOPEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,67 @@ NOTE:- You need to install [tektoncd/pipeline](https://github.com/tektoncd/pipel
```

2. Install a pipelineRun which has approval task as one of the task in the pipelin
- For example
- For example

```yaml
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: pr-custom-task-beta-
spec:
pipelineSpec:
tasks:
- name: before
taskSpec:
steps:
- image: busybox
name: before
script: echo before wait
- name: wait 👈 Wait task with kind as `ApprovalTask`
taskRef:
apiVersion: openshift-pipelines.org/v1alpha1
kind: ApprovalTask
runAfter: ['before']
- name: after
taskSpec:
steps:
- image: busybox
name: after
script: echo after wait
runAfter: ['wait']

apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
generateName: test-
spec:
pipelineSpec:
tasks:
- name: before
taskSpec:
steps:
- image: busybox
name: before
script: echo before wait
- name: wait
taskRef:
apiVersion: openshift-pipelines.org/v1alpha1
kind: ApprovalTask
params:
- name: approvers
value:
- foo
- bar
- kubernetes-admin
- name: numberOfApprovalsRequired
value: 2
- name: description
value: Approval Task Rocks!!!
timeout: 2m
runAfter: ['before']
- name: after
taskSpec:
steps:
- image: busybox
name: after
script: echo after wait
runAfter: ['wait']

```
Install the above pipelineRun

```shell
kubectl create -f <pipeline.yaml>
```

**NOTE** :- _Once the pipelineRun is started after the execution of first task is done, it will create a customRun for that approval task and the pipeline will be in wait state till it gets the approval from the user. The name of the approvalTask is the same of customRun which is created.
As of today only `"true"` and `"false"` are supported. If user passes the approval as `"true"` then pipeline will proceed to execute the further tasks and if `"false"` is provided then in that case it will fail the pipeline_

**NOTE** :- _Once the pipelineRun is started after the execution of first task is done, it will create a customRun for that approval task and the pipeline will be in `pending` state till it gets the approval from the user. The name of the approvalTask is the same of customRun which is created.
As of today only `"approve"` and `"reject"` are supported. If user passes the approval as `"approve"` then pipeline will proceed to execute the further tasks and if `"reject"` is provided then in that case it will fail the pipeline_

3. Now start the api server
```shell
go run ./cmd/approver/main.go
```
4. Now approve/reject the approval task using curl request

```shell
curl --header "Content-Type: application/json" \
--request POST \
--data '{"approved":"false", "namespace":"default"}' \
http://localhost:8000/approvaltask/<approvalTaskName>
```
3. Now `approve/reject` the approval task by using `kubectl edit` command by updating the `input` field under `approvers` section fo your username

To get the approvalTask name you can use this command

```bash
kubectl get approvaltask
```

**NOTE** :- If you are using a kind cluster and you need to approve/reject for that particular user then in that case you can run the following command

```bash
kubectl edit approvaltask <approvalTaskname> --as=<username>
```

0 comments on commit 2834934

Please sign in to comment.