mirror of
https://github.com/tektoncd/catalog.git
synced 2024-11-22 06:02:51 +00:00
7c2d503b48
This task will be used to format python code after doing a lint check and will not complain for the errors. Signed-off-by: vinamra28 <vinjain@redhat.com> |
||
---|---|---|
.. | ||
tests | ||
black.yaml | ||
README.md |
Black (Python Code Prettier)
This task can be used to format the python source code using Black which is an Opinionate Code Formatter.
Installing the Task
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/black/0.1/black.yaml
Parameters
- args: The extra params along with the file path needs to be provided as the part of
args
. (Default:["--help"]
)
Workspaces
- shared-workspace: The workspace containing python source code which we want to format. It can be a shared workspace with the
git-clone
task or aConfigMap
mounted containing some files.
Usage
- Create the
git-clone
task
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/git-clone/0.1/git-clone.yaml
-
Create the PVC
-
Apply the required tasks
-
Create the Pipeline and PipelineRun for
Black
(Python Code Formatter)
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: python-formatter-pipeline
spec:
workspaces:
- name: shared-workspace
tasks:
- name: fetch-repository
taskRef:
name: git-clone
workspaces:
- name: output
workspace: shared-workspace
params:
- name: url
value: https://github.com/wumaxd/pylint-pytest-example
- name: subdirectory
value: ""
- name: deleteExisting
value: "true"
- name: python-black-run #python code prettier
taskRef:
name: black
runAfter:
- fetch-repository
workspaces:
- name: shared-workspace
workspace: shared-workspace
params:
- name: args
value: ["."]
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: python-formatter-pipeline-run
spec:
pipelineRef:
name: python-formatter-pipeline
workspaces:
- name: shared-workspace
persistentvolumeclaim:
claimName: black-python-pvc