1
0
mirror of https://github.com/tektoncd/catalog.git synced 2025-01-04 10:08:37 +00:00

refactor code

Description
1.Rename files
2.Move Error test cases to samples folder
3.Remove unecessary spaces
This commit is contained in:
pratiktest 2023-08-07 13:07:29 -07:00
parent 069debbf96
commit 496bc6fb3c
10 changed files with 18 additions and 18 deletions

View File

@ -12,7 +12,7 @@
* Without downloading catlin or having any knowledge on how to run catlin you can check if your task passes all catlin checks by simply running a taskrun
* A working taskrun is provided in the [tests](../0.1/tests/taskrun-success.yaml) folder.
* [This](../0.1/tests/taskrun-success.yaml) taskrun validates a sample hello task.
* The hello task yaml which we want to validate is injected in the source workspace in the appropriate folder structure using [this](../0.1/tests/source-success-configmap.yaml) configMap.
* The hello task yaml which we want to validate is injected in the source workspace in the appropriate folder structure using [this](../0.1/tests/source-success-task-configmap.yaml) configMap.
* The filepath of the hello.yaml is supplied as a catlin-input using [this](../0.1/tests/input-configmap.yaml) configMap
* Thus without knowing anything about how to run catlin validate you can quickly lint your task yaml by simply following above steps
@ -43,7 +43,7 @@ Ignores any warnings in catlin output. If catlin output has only success and war
## Workspaces
### source
This workspace contains files on which catlin will be run. This can be the git repo of your tekton catalog. task yamls in this folder should have a path that follows tekton-catalog folder structure. Check [this](../0.1/tests/source-success-configmap.yaml) configmap and how it is injected into the cource workspace in [this](../0.1/tests/taskrun-success.yaml) taskrun as an example
This workspace contains files on which catlin will be run. This can be the git repo of your tekton catalog. task yamls in this folder should have a path that follows tekton-catalog folder structure. Check [this](../0.1/tests/source-success-task-configmap.yaml) configmap and how it is injected into the cource workspace in [this](../0.1/tests/taskrun-success.yaml) taskrun as an example
### catlin-input
A workspace that contains [$(params.inputFile)](#inputfile) Check [this](../0.1/tests/input-configmap.yaml) configmap and how it is injected onto the catlin-input workspace in [this](../0.1/tests/taskrun-success.yaml) taskrun as an example
### catlin-output
@ -73,7 +73,7 @@ The Task can be run on `linux/amd64` platform.
git clone https://github.com/tektoncd/catalog.git
cd catalog/task/catlin-validate/0.1/tests
kubectl apply -f input-configmap.yaml
kubectl apply -f source-success-configmap.yaml
kubectl apply -f source-success-task-configmap.yaml
kubectl create -f taskrun-success.yaml
kubectl logs catlin-run-pod
```
@ -94,7 +94,7 @@ FILE: /workspace/source/task/hello/0.1/hello.yaml
git clone https://github.com/tektoncd/catalog.git
cd catalog/task/catlin-validate/0.1/tests
kubectl apply -f input-configmap.yaml
kubectl apply -f source-warn-configmap.yaml
kubectl apply -f source-warn-task-configmap.yaml
kubectl create -f taskrun-warn.yaml
kubectl logs catlin-run-pod
```
@ -114,9 +114,9 @@ WARN : Step "echo" uses image "$(params.image)" that contains variables; skippin
* **Note** Error will result in [catlin-status](#catlin-status) having the value as failure.
```
git clone https://github.com/tektoncd/catalog.git
cd catalog/task/catlin-validate/0.1/tests
cd catalog/task/catlin-validate/0.1/samples
kubectl apply -f input-configmap.yaml
kubectl apply -f source-error-configmap.yaml
kubectl apply -f source-error-task-configmap.yaml
kubectl create -f taskrun-error.yaml
kubectl logs catlin-run-pod
```

View File

@ -29,20 +29,20 @@ spec:
task/git-clone/0.9/git-clone.yaml
task/git-clone/0.1/git-comment.yaml
it will run catlin on the above paths in the source workspace one after another and store its output in catlin-output workspace
final command run will be
final command run will be
'catlin validate $(workspaces.source.path)/task/git-clone/0.9/git-clone.yaml >> $(workspaces.catlin-output.path)/output.txt'
'catlin validate $(workspaces.source.path)/task/git-clone/0.1/git-comment.yaml >> $(workspaces.catlin-output.path)/output.txt'
type: string
- name: ignoreWarnings
description: |
Ignores any warnings in catlin output.
Ignores any warnings in catlin output.
If catlin output has only success and warnings, all warnings are ignored and final catlin output will be success
type: string
default: "false"
results:
- name: catlin-status
description: |
final status of catlin command. If all catlin validate command succeeds status will be set to 'success', if any one command validate command fails
final status of catlin command. If all catlin validate command succeeds status will be set to 'success', if any one command validate command fails
status will be set to 'failure', If there is no failure and atleast one catline validate command is warning the status will be set to 'warning'
workspaces:
- name: source
@ -87,7 +87,6 @@ spec:
STR=$(cat "$CATLIN_OUTPUT_WORKSPACE_PATH"/"$OUTPUT_FILE")
ERROR='ERROR'
WARN='WARN'
if [[ "$IGNORE_WARNINGS" == "true" ]]; then
echo "Ignore Warnings is set to true, any warnings in catlin output will be ignored"
fi
@ -105,8 +104,4 @@ spec:
echo "success" | tr -d "\n" > "$(results.catlin-status.path)"
echo ""
echo "Final output of catlin validate is success."
fi
fi

View File

@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: catlin-input
data:
input.txt: |
task/hello/0.1/hello.yaml

View File

@ -14,4 +14,4 @@ data:
image: alpine
script: |
#!/bin/sh
echo "Hello World"
echo "Hello World"

View File

@ -1,4 +1,3 @@
apiVersion: v1
kind: ConfigMap
metadata:

View File

@ -1,4 +1,3 @@
apiVersion: v1
kind: ConfigMap
metadata: