Skip to content

Commit 665899f

Browse files
Merge pull request #16044 from bparees/imagesource
Automatic merge from submit-queue add test case for private image source inputs
2 parents 2015896 + ad210dd commit 665899f

File tree

5 files changed

+71
-16
lines changed

5 files changed

+71
-16
lines changed

pkg/build/controller/strategy/docker.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,5 @@ func (bs *DockerBuildStrategy) CreateBuildPod(build *buildapi.Build) (*v1.Pod, e
163163
// location into the working directory.
164164
// TODO: consider moving this into the git-clone container and doing the secret copying there instead.
165165
setupInputSecrets(pod, &pod.Spec.Containers[0], build.Spec.Source.Secrets)
166-
167166
return pod, nil
168167
}

pkg/build/controller/strategy/util.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ func mountSecretVolume(pod *v1.Pod, container *v1.Container, secretName, mountPa
133133
func setupDockerSecrets(pod *v1.Pod, container *v1.Container, pushSecret, pullSecret *kapi.LocalObjectReference, imageSources []buildapi.ImageSource) {
134134
if pushSecret != nil {
135135
mountSecretVolume(pod, container, pushSecret.Name, DockerPushSecretMountPath, "push")
136-
pod.Spec.Containers[0].Env = append(pod.Spec.Containers[0].Env, []v1.EnvVar{
136+
container.Env = append(container.Env, []v1.EnvVar{
137137
{Name: dockercfg.PushAuthType, Value: DockerPushSecretMountPath},
138138
}...)
139139
glog.V(3).Infof("%s will be used for docker push in %s", DockerPushSecretMountPath, pod.Name)
140140
}
141141

142142
if pullSecret != nil {
143143
mountSecretVolume(pod, container, pullSecret.Name, DockerPullSecretMountPath, "pull")
144-
pod.Spec.Containers[0].Env = append(pod.Spec.Containers[0].Env, []v1.EnvVar{
144+
container.Env = append(container.Env, []v1.EnvVar{
145145
{Name: dockercfg.PullAuthType, Value: DockerPullSecretMountPath},
146146
}...)
147147
glog.V(3).Infof("%s will be used for docker pull in %s", DockerPullSecretMountPath, pod.Name)
@@ -153,7 +153,7 @@ func setupDockerSecrets(pod *v1.Pod, container *v1.Container, pushSecret, pullSe
153153
}
154154
mountPath := filepath.Join(SourceImagePullSecretMountPath, strconv.Itoa(i))
155155
mountSecretVolume(pod, container, imageSource.PullSecret.Name, mountPath, fmt.Sprintf("%s%d", "source-image", i))
156-
pod.Spec.Containers[0].Env = append(pod.Spec.Containers[0].Env, []v1.EnvVar{
156+
container.Env = append(container.Env, []v1.EnvVar{
157157
{Name: fmt.Sprintf("%s%d", dockercfg.PullSourceAuthType, i), Value: mountPath},
158158
}...)
159159
glog.V(3).Infof("%s will be used for docker pull in %s", mountPath, pod.Name)

test/extended/builds/image_source.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ var _ = g.Describe("[builds][Slow] build can have Docker image source", func() {
3636
err := oc.Run("create").Args("-f", buildFixture).Execute()
3737
o.Expect(err).NotTo(o.HaveOccurred())
3838

39+
g.By("starting building the private input image")
40+
br, err := exutil.StartBuildAndWait(oc, "inputimage")
41+
br.AssertSuccess()
42+
3943
g.By("starting the source strategy build")
40-
br, err := exutil.StartBuildAndWait(oc, "imagesourcebuild")
44+
br, err = exutil.StartBuildAndWait(oc, "imagesourcebuild")
4145
br.AssertSuccess()
4246

4347
g.By("expecting the pod to deploy successfully")
@@ -59,8 +63,12 @@ var _ = g.Describe("[builds][Slow] build can have Docker image source", func() {
5963
err := oc.Run("create").Args("-f", buildFixture).Execute()
6064
o.Expect(err).NotTo(o.HaveOccurred())
6165

66+
g.By("starting building the private input image")
67+
br, err := exutil.StartBuildAndWait(oc, "inputimage")
68+
br.AssertSuccess()
69+
6270
g.By("starting the docker strategy build")
63-
br, err := exutil.StartBuildAndWait(oc, "imagedockerbuild")
71+
br, err = exutil.StartBuildAndWait(oc, "imagedockerbuild")
6472
br.AssertSuccess()
6573

6674
g.By("expect the pod to deploy successfully")

test/extended/testdata/bindata.go

Lines changed: 29 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/extended/testdata/test-imagesource-build.yaml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@ apiVersion: v1
22
kind: List
33
metadata: {}
44
items:
5+
- apiVersion: v1
6+
kind: BuildConfig
7+
metadata:
8+
labels:
9+
build: inputimage
10+
name: inputimage
11+
spec:
12+
output:
13+
to:
14+
kind: ImageStreamTag
15+
name: inputimage:latest
16+
source:
17+
dockerfile: "FROM foo"
18+
strategy:
19+
dockerStrategy:
20+
from:
21+
kind: ImageStreamTag
22+
name: ruby:2.3
23+
namespace: openshift
524
- apiVersion: v1
625
kind: BuildConfig
726
metadata:
@@ -19,8 +38,7 @@ items:
1938
images:
2039
- from:
2140
kind: ImageStreamTag
22-
name: ruby:2.3
23-
namespace: openshift
41+
name: inputimage:latest
2442
paths:
2543
- destinationDir: injected/dir
2644
sourcePath: /opt/rh/rh-ruby23/root/usr/bin/ruby
@@ -48,13 +66,19 @@ items:
4866
images:
4967
- from:
5068
kind: ImageStreamTag
51-
name: ruby:2.3
52-
namespace: openshift
69+
name: inputimage:latest
5370
paths:
5471
- destinationDir: injected/dir
5572
sourcePath: /opt/rh/rh-ruby23/root/usr/bin/ruby
5673
strategy:
57-
dockerStrategy: {}
74+
dockerStrategy:
75+
forcePull: true
76+
77+
- apiVersion: v1
78+
kind: ImageStream
79+
metadata:
80+
name: inputimage
81+
spec: {}
5882
- apiVersion: v1
5983
kind: ImageStream
6084
metadata:

0 commit comments

Comments
 (0)