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

Map ImagePullPolicy from build strategy step to TaskRun step #791

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
1 change: 1 addition & 0 deletions pkg/reconciler/buildrun/resources/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func GenerateTaskSpec(
step := v1beta1.Step{
Container: corev1.Container{
Image: taskImage,
ImagePullPolicy: containerValue.ImagePullPolicy,
Name: containerValue.Name,
VolumeMounts: containerValue.VolumeMounts,
Command: taskCommand,
Expand Down
5 changes: 5 additions & 0 deletions pkg/reconciler/buildrun/resources/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var _ = Describe("GenerateTaskrun", func() {

buildStrategy, err = ctl.LoadBuildStrategyFromBytes([]byte(test.MinimalBuildahBuildStrategy))
Expect(err).To(BeNil())
buildStrategy.Spec.BuildSteps[0].ImagePullPolicy = "Always"

expectedCommandOrArg = []string{
"bud", "--tag=$(params.shp-output-image)", fmt.Sprintf("--file=$(inputs.params.%s)", "DOCKERFILE"), "$(params.shp-source-context)",
Expand Down Expand Up @@ -99,6 +100,10 @@ var _ = Describe("GenerateTaskrun", func() {
Expect(got.Steps[1].Container.Image).To(Equal("quay.io/containers/buildah:v1.20.1"))
})

It("should ensure ImagePullPolicy can be set by the build strategy author.", func() {
Expect(got.Steps[1].Container.ImagePullPolicy).To(Equal(corev1.PullPolicy("Always")))
})

It("should ensure command replacements happen when needed", func() {
Expect(got.Steps[1].Container.Command[0]).To(Equal("/usr/bin/buildah"))
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
- /tekton/home
- name: build-and-push
image: moby/buildkit:master-rootless
imagePullPolicy: Always
securityContext:
allowPrivilegeEscalation: true
runAsUser: 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
- /tekton/home
- name: build-and-push
image: moby/buildkit:master-rootless
imagePullPolicy: Always
securityContext:
allowPrivilegeEscalation: true
runAsUser: 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ spec:
buildSteps:
- name: prepare
image: docker.io/paketobuildpacks/builder:full
imagePullPolicy: Always
securityContext:
runAsUser: 0
capabilities:
Expand All @@ -27,6 +28,7 @@ spec:
memory: 65Mi
- name: build-and-push
image: docker.io/paketobuildpacks/builder:full
imagePullPolicy: Always
securityContext:
runAsUser: 1000
runAsGroup: 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ spec:
buildSteps:
- name: prepare
image: docker.io/paketobuildpacks/builder:full
imagePullPolicy: Always
securityContext:
runAsUser: 0
capabilities:
Expand All @@ -27,6 +28,7 @@ spec:
memory: 65Mi
- name: build-and-push
image: docker.io/paketobuildpacks/builder:full
imagePullPolicy: Always
securityContext:
runAsUser: 1000
runAsGroup: 1000
Expand Down
1 change: 1 addition & 0 deletions samples/buildstrategy/ko/buildstrategy_ko_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ spec:
buildSteps:
- name: prepare
image: golang:1.15
imagePullPolicy: Always
securityContext:
runAsUser: 0
capabilities:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ spec:
- $(build.builder.image)
- '--as-dockerfile'
- /gen-source/Dockerfile.gen
image: 'quay.io/openshift-pipeline/s2i:nightly'
image: quay.io/openshift-pipeline/s2i:nightly
imagePullPolicy: Always
name: s2i-build-as-dockerfile
volumeMounts:
- mountPath: /gen-source
Expand Down