Skip to content

Instantly share code, notes, and snippets.

@sub-mod
Created March 23, 2020 21:52
Show Gist options
  • Save sub-mod/cfd426cbbe83c6fdcaf938f3f85890a3 to your computer and use it in GitHub Desktop.
Save sub-mod/cfd426cbbe83c6fdcaf938f3f85890a3 to your computer and use it in GitHub Desktop.
tekton_issue

some thing like this would cause invalid input params: param types don''t match the user-specified type in pipeline webhook controller which simply can't parse the type

---
apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
  name: params-example
spec:
  serviceAccountName: tekton-demo
  pipelineRef:
    name: params-ex
  params:
    - name: "builder-image"
      value: "quay.io/buildah/stable:latest"
  resources:
    - name: source
      resourceRef:
        name: git-source
    - name: image
      resourceRef:
        name: image
 
---
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
  name: params-ex
spec:
  params:
    - name: builder-image
      type: image
  resources:
    - name: source
      type: git
    - name: image
      type: image
  tasks:
    - name: build-image
      resources:
        inputs:
          - name: source
            resource: source
        outputs:
          - name: image
            resource: image
      params:
         - name: "BUILDER_IMAGE"
           value: "$(params.builder-image)"
      taskRef:
        name: buildah
 
---
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: buildah
spec:
  inputs:
    params:
    - name: BUILDER_IMAGE
      description: The location of the buildah builder image.
      default: quay.io/buildah/stable:v1.11.0
    - name: DOCKERFILE
      description: Path to the Dockerfile to build.
      default: ./Dockerfile
    - name: CONTEXT
      description: Path to the directory to use as context.
      default: .
    - name: TLSVERIFY
      description: Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)
      default: "true"
    - name: FORMAT
      description: The format of the built container, oci or docker
      default: "oci"
 
    resources:
    - name: source
      type: git
 
  outputs:
    resources:
    - name: image
      type: image
 
  steps:
  - name: build
    image: $(inputs.params.BUILDER_IMAGE)
    workingDir: /workspace/source
    command: ['buildah', 'bud', '--format=$(inputs.params.FORMAT)', '--tls-verify=$(inputs.params.TLSVERIFY)', '--layers', '-f', '$(inputs.params.DOCKERFILE)', '-t', '$(outputs.resources.image.url)', '$(inputs.params.CONTEXT)']
    volumeMounts:
    - name: varlibcontainers
      mountPath: /var/lib/containers
    securityContext:
      privileged: true
 
  - name: push
    image: $(inputs.params.BUILDER_IMAGE)
    workingDir: /workspace/source
    command: ['buildah', 'push', '--tls-verify=$(inputs.params.TLSVERIFY)', '$(outputs.resources.image.url)', 'docker://$(outputs.resources.image.url)']
    volumeMounts:
    - name: varlibcontainers
      mountPath: /var/lib/containers
    securityContext:
      privileged: true
 
  volumes:
  - name: varlibcontainers
    emptyDir: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment