Skip to content

Enhance new-app circular test to handle ImageStreamImage refs #13233

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
Mar 4, 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
9 changes: 9 additions & 0 deletions pkg/generate/app/cmd/newapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,15 @@ func (c *AppConfig) followRefToDockerImage(ref *kapi.ObjectReference, isContext
return &copy, nil
}

if ref.Kind == "ImageStreamImage" {
// even if the associated tag for this ImageStreamImage matches a output ImageStreamTag, when the image
// is built it will have a new sha ... you are essentially using a single/unique older version of a image as the base
// to build future images; all this means we can leave the ref name as is and return with no error
// also do shallow copy like above
copy := *ref
return &copy, nil
}

if ref.Kind != "ImageStreamTag" {
return nil, fmt.Errorf("Unable to follow reference type: %q", ref.Kind)
}
Expand Down
2 changes: 2 additions & 0 deletions test/cmd/newapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ os::cmd::expect_failure_and_text 'oc new-build mysql --source-image-path foo' 'e
# ensure circular ref flagged but allowed for template
os::cmd::expect_success 'oc create -f test/testdata/circular-is.yaml'
os::cmd::expect_success_and_text 'oc new-app -f test/testdata/circular.yaml' 'should be different than input'
# ensure circular does not choke on image stream image
os::cmd::expect_success_and_not_text 'oc new-app -f test/testdata/bc-from-imagestreamimage.json --dry-run' 'Unable to follow reference type'

# do not allow use of non-existent image (should fail)
os::cmd::expect_failure_and_text 'oc new-app openshift/bogusimage https://github.com/openshift/ruby-hello-world.git -o yaml' "no match for"
Expand Down
52 changes: 52 additions & 0 deletions test/testdata/bc-from-imagestreamimage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: v1
kind: Template
metadata:
creationTimestamp: null
name: bc-from-imagestreamimage
objects:
- apiVersion: v1
kind: BuildConfig
metadata:
creationTimestamp: null
labels:
name: bc-from-imagestreamimage
template: application-template-stibuild
name: bc-from-imagestreamimage
spec:
nodeSelector: null
output:
to:
kind: ImageStreamTag
name: origin-ruby-sample:latest
postCommit:
args:
- bundle
- exec
- rake
- test
resources: {}
runPolicy: Serial
source:
git:
uri: https://github.com/openshift/ruby-hello-world.git
type: Git
strategy:
sourceStrategy:
env:
- name: EXAMPLE
value: sample-app
from:
kind: ImageStreamImage
name: ruby@sha256:5dc0856fea9551e102815863cceeabd3aee862ec4ad5f2625eb51564924f0360
type: Source
triggers:
- github:
secret: secret101
type: GitHub
- generic:
allowEnv: true
secret: secret101
type: Generic
- type: ConfigChange
status:
lastVersion: 0