1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-11-25 06:17:50 +00:00
catalog/task/gcs-download/0.1
Scott ae02f26988 Fix small issue with gcs-download README
Prior to this commit an example in the readme for gcs-download
referenced a Task that didn't exist.

This commit updates the broken taskRef to point to the correctly
named Task.
2022-01-06 10:23:00 +00:00
..
samples Modifies directory names based on the proposal 2020-07-14 19:01:58 +01:00
gcs-download.yaml Add linux/amd64 platform annotation to the rest of the tasks 2021-10-29 17:08:38 +01:00
README.md Fix small issue with gcs-download README 2022-01-06 10:23:00 +00:00

Google Cloud Storage Tasks

These Tasks are for copying to and from GCS buckets from Pipelines.

These Tasks do a similar job to the GCS PipelineResource and are intended as its replacement. This is part of our plan to offer replacement Tasks for Pipeline Resources as well as document those replacements.

gcs-download

A Task that fetches files or directories from a GCS bucket and puts them on a Workspace.

Workspaces

  • credentials: A workspace that contains a service account key as a JSON file. This workspace should be populated from a Secret in your TaskRuns and PipelineRuns.
  • output: A workspace for this Task to copy the files from GCS in to.

Parameters

  • path: The path to the file or directory that will be written to the output workspace. (required)
  • location: The address, including "gs://", of the bucket you'd like to copy from. (required)
  • typeDir: Set this to "true" if the object you are copying is a directory. (default: "false")
  • serviceAccountPath: The path to the service account credential file in your credentials workspace. (default: "service_account.json")

Platforms

The Task can be run on linux/amd64 platform.

Usage

gcs-download

This pipeline uses the gcs-download Task to fetch a directory.

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: cat-file
spec:
  workspaces:
  - name: source
    mountPath: /source
  params:
  - name: filePath
    description: Path to file inside "source" to cat.
    default: "README.md"
  steps:
  - name: cat-readme
    image: ubuntu
    script: cat "$(workspaces.source.path)/$(params.filePath)"
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: cat-file
spec:
  workspaces:
  - name: gcs-credentials
    description: A secret containing a gcloud service account key JSON file.
  - name: shared-workspace
    description: The GCS location will be copied into this workspace.
  tasks:
  - name: copy-files
    taskRef:
      name: gcs-download
    workspaces:
    - name: credentials
      workspace: gcs-credentials
    - name: output
      workspace: shared-workspace
    params:
    - name: path
      value: foo
    - name: location
      value: gs://this-is-not-a-real-bucket
    - name: typeDir
      value: "true"
  - name: print-readme
    taskRef:
      name: cat-file
    runAfter:
    - copy-files # required to ensure copy occurs before cat
    workspaces:
    - name: source
      workspace: shared-workspace
    params:
    - name: filePath
      value: "foo/test.txt"

This pipeline can be used as the following PipelineRun does.

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: workspace-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 500Mi
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  name: cat-file-pr
spec:
  pipelineRef:
    name: cat-file
  workspaces:
  - name: gcs-credentials
    secret:
      secretName: my-gcs-credentials
      defaultMode: 0400
  - name: shared-workspace
    persistentVolumeClaim:
      claimName: workspace-pvc