Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
Description
1.Rename files
2.Move Error test cases to samples folder
3.Remove unecessary spaces
  • Loading branch information
pratiktest committed Aug 7, 2023
1 parent 069debb commit 496bc6f
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions task/catlin-validate/0.1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
```
Expand All @@ -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
```
Expand All @@ -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
```
Expand Down
13 changes: 4 additions & 9 deletions task/catlin-validate/0.1/catlin-validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
7 changes: 7 additions & 0 deletions task/catlin-validate/0.1/samples/input-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: catlin-input
data:
input.txt: |
task/hello/0.1/hello.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ data:
image: alpine
script: |
#!/bin/sh
echo "Hello World"
echo "Hello World"
1 change: 0 additions & 1 deletion task/catlin-validate/0.1/tests/input-configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

apiVersion: v1
kind: ConfigMap
metadata:
Expand Down

0 comments on commit 496bc6f

Please sign in to comment.