Skip to content

add test case for private image source inputs #16044

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

Merged
merged 1 commit into from
Aug 31, 2017
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: 0 additions & 1 deletion pkg/build/controller/strategy/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,5 @@ func (bs *DockerBuildStrategy) CreateBuildPod(build *buildapi.Build) (*v1.Pod, e
// location into the working directory.
// TODO: consider moving this into the git-clone container and doing the secret copying there instead.
setupInputSecrets(pod, &pod.Spec.Containers[0], build.Spec.Source.Secrets)

return pod, nil
}
6 changes: 3 additions & 3 deletions pkg/build/controller/strategy/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ func mountSecretVolume(pod *v1.Pod, container *v1.Container, secretName, mountPa
func setupDockerSecrets(pod *v1.Pod, container *v1.Container, pushSecret, pullSecret *kapi.LocalObjectReference, imageSources []buildapi.ImageSource) {
if pushSecret != nil {
mountSecretVolume(pod, container, pushSecret.Name, DockerPushSecretMountPath, "push")
pod.Spec.Containers[0].Env = append(pod.Spec.Containers[0].Env, []v1.EnvVar{
container.Env = append(container.Env, []v1.EnvVar{
{Name: dockercfg.PushAuthType, Value: DockerPushSecretMountPath},
}...)
glog.V(3).Infof("%s will be used for docker push in %s", DockerPushSecretMountPath, pod.Name)
}

if pullSecret != nil {
mountSecretVolume(pod, container, pullSecret.Name, DockerPullSecretMountPath, "pull")
pod.Spec.Containers[0].Env = append(pod.Spec.Containers[0].Env, []v1.EnvVar{
container.Env = append(container.Env, []v1.EnvVar{
{Name: dockercfg.PullAuthType, Value: DockerPullSecretMountPath},
}...)
glog.V(3).Infof("%s will be used for docker pull in %s", DockerPullSecretMountPath, pod.Name)
Expand All @@ -153,7 +153,7 @@ func setupDockerSecrets(pod *v1.Pod, container *v1.Container, pushSecret, pullSe
}
mountPath := filepath.Join(SourceImagePullSecretMountPath, strconv.Itoa(i))
mountSecretVolume(pod, container, imageSource.PullSecret.Name, mountPath, fmt.Sprintf("%s%d", "source-image", i))
pod.Spec.Containers[0].Env = append(pod.Spec.Containers[0].Env, []v1.EnvVar{
container.Env = append(container.Env, []v1.EnvVar{
{Name: fmt.Sprintf("%s%d", dockercfg.PullSourceAuthType, i), Value: mountPath},
}...)
glog.V(3).Infof("%s will be used for docker pull in %s", mountPath, pod.Name)
Expand Down
12 changes: 10 additions & 2 deletions test/extended/builds/image_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ var _ = g.Describe("[builds][Slow] build can have Docker image source", func() {
err := oc.Run("create").Args("-f", buildFixture).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

g.By("starting building the private input image")
br, err := exutil.StartBuildAndWait(oc, "inputimage")
br.AssertSuccess()

g.By("starting the source strategy build")
br, err := exutil.StartBuildAndWait(oc, "imagesourcebuild")
br, err = exutil.StartBuildAndWait(oc, "imagesourcebuild")
br.AssertSuccess()

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

g.By("starting building the private input image")
br, err := exutil.StartBuildAndWait(oc, "inputimage")
br.AssertSuccess()

g.By("starting the docker strategy build")
br, err := exutil.StartBuildAndWait(oc, "imagedockerbuild")
br, err = exutil.StartBuildAndWait(oc, "imagedockerbuild")
br.AssertSuccess()

g.By("expect the pod to deploy successfully")
Expand Down
34 changes: 29 additions & 5 deletions test/extended/testdata/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 29 additions & 5 deletions test/extended/testdata/test-imagesource-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ apiVersion: v1
kind: List
metadata: {}
items:
- apiVersion: v1
kind: BuildConfig
metadata:
labels:
build: inputimage
name: inputimage
spec:
output:
to:
kind: ImageStreamTag
name: inputimage:latest
source:
dockerfile: "FROM foo"
strategy:
dockerStrategy:
from:
kind: ImageStreamTag
name: ruby:2.3
namespace: openshift
- apiVersion: v1
kind: BuildConfig
metadata:
Expand All @@ -19,8 +38,7 @@ items:
images:
- from:
kind: ImageStreamTag
name: ruby:2.3
namespace: openshift
name: inputimage:latest
paths:
- destinationDir: injected/dir
sourcePath: /opt/rh/rh-ruby23/root/usr/bin/ruby
Expand Down Expand Up @@ -48,13 +66,19 @@ items:
images:
- from:
kind: ImageStreamTag
name: ruby:2.3
namespace: openshift
name: inputimage:latest
paths:
- destinationDir: injected/dir
sourcePath: /opt/rh/rh-ruby23/root/usr/bin/ruby
strategy:
dockerStrategy: {}
dockerStrategy:
forcePull: true

- apiVersion: v1
kind: ImageStream
metadata:
name: inputimage
spec: {}
- apiVersion: v1
kind: ImageStream
metadata:
Expand Down