Skip to content

Instantly share code, notes, and snippets.

@dlorenc
Last active October 25, 2019 16:41
Show Gist options
  • Select an option

  • Save dlorenc/96eba6ebdd3aa70ed22f793473a9e777 to your computer and use it in GitHub Desktop.

Select an option

Save dlorenc/96eba6ebdd3aa70ed22f793473a9e777 to your computer and use it in GitHub Desktop.
apiVersion: tekton.dev/v1alpha1
kind: PipelineResourceType
metadata:
name: git
spec:
implementations:
- modes: [ro]
params:
- name: url
type: string
preRunSteps:
- image: someGitImage
command: ['fetch', '-url=${url}', '-mode=download']
results:
- name: clonedCommitSha
description: sha of commit
- modes: [rw]
params:
- name: url
type: string
preRunSteps:
- image: someGitImage
command: ['fetch', '-url=${url}', '-mode=download']
postRunSteps:
- image: someGitImage
command: ['fetch', '-url=${url}', '-mode=upload']
results:
- name: clonedCommitSha
description: sha of commit
- name: pushedCommitSha
description: sha of commit
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResourceType
metadata:
name: image
spec:
implementations:
- modes: [create]
params:
- name: repository
type: string
- name: name
type: string
preRunSteps:
# This step configures credentials so "docker push" would work
- image: someImage
command: ['configure-docker-creds', '-repository=${url}']
results:
- name: outputImageDigest
description: digest of image
- modes: [rw, ro]
params:
- name: repository
type: string
- name: name
type: string
preRunSteps:
# This step configures credentials so "docker pull" would work
- image: someImage
command: ['configure-docker-creds', '-repository=${url}']
# This step writes the image url to a location on disk under /workspace
- image: someImage
command: ['write-image-url', '-repository=${url}', '-path=${params.url.path}']
results:
- name: inputImageDigest
description: digest of image
- name: outputImageDigest
description: digest of image
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResourceType
metadata:
name: pull-request
spec:
implementations:
- modes: [create]
postRunSteps:
# This step pushes the branch
- image: someImage
command: ['push-repo', '-repository=${sourceUrl}', '-branch=${sourceBranch}']
# This step creates the PR
- image: someImage
command: ['create-pr', '-from=${sourceUrl}@${sourceBranch}', '-to=${baseUrl}@${baseBranch}']
- modes: [ro]
params:
- name: url
type: string
description: URL to the PR
preRunSteps:
# This step fetches the PR
- image: someImage
command: ['fetch-pr', '-pr=${url}']
- modes: [rw]
params:
- name: url
type: string
description: URL to the PR
preRunSteps:
# This step fetches the PR
- image: someImage
command: ['fetch-pr', '-pr=${url}']
postRunSteps:
# This step pushes the PR
- image: someImage
command: ['push-pr', '-pr=${url}']
results:
- name: inputImageDigest
description: digest of image
- name: outputImageDigest
description: digest of image
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResourceType
metadata:
name: cluster
spec:
implementations:
- modes: [create]
params:
postRunSteps:
# This step stores the generated .kubeconfig
- image: someImage
command: ['upload-kube-confiig']
results:
- name: clusterAddress
description: address of cluster
- modes: [ro]
params:
- name: clusterRef
type: string
- name: basicAuth
type: string
- name: token
type: string
- name: caData
type: string
preRunSteps:
# This step configures credentials so "kubectl" would work
- image: someImage
command: ['configure-kube-config', '-repository=${url}']
results:
- name: cluster-config
description: config for cluster
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResourceType
metadata:
name: file-set
spec:
implementations:
- modes: [create]
# This boolean indicates that the resource produces contents that should be stored for access by
# other resources, tasks or pipelines. The Tekton administrator is responsible for configuring
# Tekton with information on available storage options (GCS, S3, PVs in k8s, etc.).
# At TaskRun time, users can direct the storage of specific resources.
storage: true
postRunSteps:
# This step copies the globbed files to the required storage directory.
# Tekton is then responsible for placing these files where they should be stored.
# This decouples the storage system from the resource system.
- image: someImage
command: ['copy-glob', '${glob}', '--to-dir=${storage.path}']
results:
- name: file-shas
description: json-formatted filenames and shas
- modes: [ro]
params:
# Any of these parameters can be used to initialize a fileset,
# but they are exclusive.
- name: url
type: string
- name: gitResourceRef
type: string
- name: configMapRef
type: string
- name: secretRef
type: string
# This parameter is used if the fileset is to be initialized from a volume.
# The taskrun should declare the volume so it can be mounted in.
# Then this resource copies from that location to the normal fileset location
- name: path
type string
preRunSteps:
# This step copies the fileset from the desired source.
- image: someImage
command: ['initialize-fileset']
results:
- name: file-shas
description: json formatted map of files and contents
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResourceType
metadata:
name: gcs-bucket
spec:
implementations:
- modes: [ro]
params:
# Any of these parameters can be used to initialize a fileset,
# but they are exclusive.
- name: bucket-name
type: string
- name: subpath
type: string
# This parametter is of type "file"
# Users can provide this secret in a number of ways when creating a GCS resource instance,
# and Tekton is responsible for converting this info into a file mounted into the resource step
# at this specified location.
# For example, when creating this resource, users could do something like:
#
# params:
# - name: google_application_credentials
# . valueFrom:
# . secretKeyRef:
# name: foo
# key: bar
#
# or:
#
# params:
# - name: google_application_credentials
# . value: BAD-IDEA
- name: google_application_credentials
type: file
path: somePath
preRunSteps:
# This step copies the bucket data.
- image: someImage
command: ['copy-bucket', '--sub-path=${params.subpath}', '--bucket=${params.bucket}']
results:
- name: file-shas
description: json formatted map of files and contents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment