1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-11-25 06:17:50 +00:00
catalog/task/black/0.1
vinamra28 e763a4473e Use latest git-clone in Task's tests
With git-clone version 0.8 and onwards, it started running as non-root
and GKE clusters were having some issues, so, we temporarily moved all
tasks to use git-clone version 0.7. Ref: https://github.com/tektoncd/catalog/pull/1079

Since we have now moved to kind clusters in our CI, this issue is now
resolved and thus moving all tasks to use latest version of git-clone

Signed-off-by: vinamra28 <jvinamra776@gmail.com>
2023-09-22 09:32:22 +01:00
..
tests Use latest git-clone in Task's tests 2023-09-22 09:32:22 +01:00
black.yaml Add linux/amd64 platform annotation to the rest of the tasks 2021-10-29 17:08:38 +01:00
README.md [TEP-0110] Update Tekton Catalog installation instructions 2022-08-16 16:25:52 +01:00

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://api.hub.tekton.dev/v1/resource/tekton/task/black/0.1/raw

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 a ConfigMap mounted containing some files.

Platforms

The Task can be run on linux/amd64 platform.

Usage

  1. Create the git-clone task
kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/git-clone/0.1/raw
  1. Create the PVC

  2. Apply the required tasks

  3. 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