mirror of
https://github.com/tektoncd/catalog.git
synced 2024-11-22 06:02:51 +00:00
buildpacks: use workspace instead of GitResource 🐐
This migrate buildpacks to use `workspace` instead of an input `GitResource`. This also updates e2e tests to use a `Pipeline` in order to clone the repository in the workspace. Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
This commit is contained in:
parent
6796957fea
commit
0d3bea41a5
@ -38,19 +38,19 @@ kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/build
|
||||
|
||||
## Resources
|
||||
|
||||
### Inputs
|
||||
|
||||
* **`source`**: A `git`-type `PipelineResource` specifying the location of the
|
||||
source to build. See `SOURCE_SUBPATH` above if source is located within a subpath of this input.
|
||||
|
||||
### Outputs
|
||||
|
||||
* **`image`**: An `image`-type `PipelineResource` specifying the image that should
|
||||
be built.
|
||||
|
||||
## Workspaces
|
||||
|
||||
The `source` workspace holds the source that will be used by buildpack
|
||||
to build and publish the container image.
|
||||
|
||||
## Usage
|
||||
|
||||
This `TaskRun` will use the `buildpacks-v3` task to fetch source code from a Git repo, build the source code, then publish a container image.
|
||||
This `TaskRun` will use the `buildpacks-v3` task to build the source code, then publish a container image.
|
||||
|
||||
```
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
@ -75,20 +75,18 @@ spec:
|
||||
# - name: CACHE
|
||||
# value: my-cache
|
||||
resources:
|
||||
inputs:
|
||||
- name: source
|
||||
resourceSpec:
|
||||
type: git
|
||||
params:
|
||||
- name: url
|
||||
value: <your git repo, e.g. "https://github.com/buildpacks/samples">
|
||||
outputs:
|
||||
- name: image
|
||||
resourceSpec:
|
||||
type: image
|
||||
params:
|
||||
- name: url
|
||||
value: <your output image tag, e.g. "gcr.io/app-repo/app-image:app-tag">
|
||||
value: <your output image tag,
|
||||
e.g. "gcr.io/app-repo/app-image:app-tag">
|
||||
workspaces:
|
||||
- name: source
|
||||
persistentVolumeClaim:
|
||||
claimName: my-source
|
||||
```
|
||||
|
||||
### Example builders
|
||||
|
@ -24,13 +24,13 @@ spec:
|
||||
default: ""
|
||||
|
||||
resources:
|
||||
inputs:
|
||||
- name: source
|
||||
type: git
|
||||
outputs:
|
||||
- name: image
|
||||
type: image
|
||||
|
||||
workspaces:
|
||||
- name: source
|
||||
|
||||
stepTemplate:
|
||||
env:
|
||||
- name: CNB_PLATFORM_API
|
||||
@ -47,7 +47,7 @@ spec:
|
||||
chown -R "$(params.USER_ID):$(params.GROUP_ID)" "/tekton/home" &&
|
||||
chown -R "$(params.USER_ID):$(params.GROUP_ID)" "/layers" &&
|
||||
chown -R "$(params.USER_ID):$(params.GROUP_ID)" "/cache" &&
|
||||
chown -R "$(params.USER_ID):$(params.GROUP_ID)" "/workspace/source"
|
||||
chown -R "$(params.USER_ID):$(params.GROUP_ID)" "$(workspaces.source.path)"
|
||||
volumeMounts:
|
||||
- name: layers-dir
|
||||
mountPath: /layers
|
||||
@ -61,7 +61,7 @@ spec:
|
||||
imagePullPolicy: Always
|
||||
command: ["/cnb/lifecycle/detector"]
|
||||
args:
|
||||
- "-app=/workspace/source/$(params.SOURCE_SUBPATH)"
|
||||
- "-app=$(workspaces.source.path)/$(params.SOURCE_SUBPATH)"
|
||||
- "-group=/layers/group.toml"
|
||||
- "-plan=/layers/plan.toml"
|
||||
volumeMounts:
|
||||
@ -103,7 +103,7 @@ spec:
|
||||
imagePullPolicy: Always
|
||||
command: ["/cnb/lifecycle/builder"]
|
||||
args:
|
||||
- "-app=/workspace/source/$(params.SOURCE_SUBPATH)"
|
||||
- "-app=$(workspaces.source.path)/$(params.SOURCE_SUBPATH)"
|
||||
- "-layers=/layers"
|
||||
- "-group=/layers/group.toml"
|
||||
- "-plan=/layers/plan.toml"
|
||||
@ -116,7 +116,7 @@ spec:
|
||||
imagePullPolicy: Always
|
||||
command: ["/cnb/lifecycle/exporter"]
|
||||
args:
|
||||
- "-app=/workspace/source/$(params.SOURCE_SUBPATH)"
|
||||
- "-app=$(workspaces.source.path)/$(params.SOURCE_SUBPATH)"
|
||||
- "-layers=/layers"
|
||||
- "-helpers=$(params.USE_CRED_HELPERS)"
|
||||
- "-group=/layers/group.toml"
|
||||
|
@ -1,5 +1,8 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Add an internal registry as sidecar to the task so we can upload it directly
|
||||
# from our tests withouth having to go to an external registry.
|
||||
# from our tests without having to go to an external registry.
|
||||
add_sidecar_registry ${TMPF}
|
||||
|
||||
# Add git-clone
|
||||
kubectl -n ${tns} apply -f ./git/git-clone.yaml
|
||||
|
@ -1,16 +1,3 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: PipelineResource
|
||||
metadata:
|
||||
name: buildpacks-samples
|
||||
spec:
|
||||
type: git
|
||||
params:
|
||||
- name: url
|
||||
value: https://github.com/buildpacks/samples
|
||||
- name: revision
|
||||
value: master
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: PipelineResource
|
||||
metadata:
|
||||
@ -23,6 +10,17 @@ spec:
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: buildpacks-source-pvc
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 500Mi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: buildpacks-cache-pvc
|
||||
spec:
|
||||
|
@ -1,16 +1,36 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: TaskRun
|
||||
kind: Pipeline
|
||||
metadata:
|
||||
name: buildpacks-run
|
||||
name: buildpacks-test-pipeline
|
||||
spec:
|
||||
workspaces:
|
||||
- name: shared-workspace
|
||||
resources:
|
||||
- name: build-image
|
||||
type: image
|
||||
tasks:
|
||||
- name: fetch-repository
|
||||
taskRef:
|
||||
name: git-clone
|
||||
workspaces:
|
||||
- name: output
|
||||
workspace: shared-workspace
|
||||
params:
|
||||
- name: url
|
||||
value: https://github.com/buildpacks/samples
|
||||
- name: subdirectory
|
||||
value: ""
|
||||
- name: deleteExisting
|
||||
value: "true"
|
||||
- name: buildpacks-v3
|
||||
taskRef:
|
||||
name: buildpacks-v3
|
||||
podTemplate:
|
||||
volumes:
|
||||
- name: buildpacks-cache
|
||||
persistentVolumeClaim:
|
||||
claimName: buildpacks-cache-pvc
|
||||
runAfter:
|
||||
- fetch-repository
|
||||
workspaces:
|
||||
- name: source
|
||||
workspace: shared-workspace
|
||||
params:
|
||||
- name: SOURCE_SUBPATH
|
||||
value: apps/java-maven
|
||||
@ -19,11 +39,27 @@ spec:
|
||||
- name: CACHE
|
||||
value: buildpacks-cache
|
||||
resources:
|
||||
inputs:
|
||||
- name: source
|
||||
resourceRef:
|
||||
name: buildpacks-samples
|
||||
outputs:
|
||||
- name: image
|
||||
resource: build-image
|
||||
---
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: PipelineRun
|
||||
metadata:
|
||||
name: buildpacks-test-pipeline-run
|
||||
spec:
|
||||
pipelineRef:
|
||||
name: buildpacks-test-pipeline
|
||||
workspaces:
|
||||
- name: shared-workspace
|
||||
persistentvolumeclaim:
|
||||
claimName: buildpacks-source-pvc
|
||||
resources:
|
||||
- name: build-image
|
||||
resourceRef:
|
||||
name: buildpacks-app-image
|
||||
podTemplate:
|
||||
volumes:
|
||||
- name: buildpacks-cache
|
||||
persistentVolumeClaim:
|
||||
claimName: buildpacks-cache-pvc
|
||||
|
Loading…
Reference in New Issue
Block a user