Skip to content

Commit 5b464bf

Browse files
committed
Enhance new-app circular test to handle ImageStreamImage refs
bug 1422378 https://bugzilla.redhat.com/show_bug.cgi?id=1422378
1 parent dd3fe18 commit 5b464bf

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

pkg/generate/app/cmd/newapp.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,15 @@ func (c *AppConfig) followRefToDockerImage(ref *kapi.ObjectReference, isContext
823823
return &copy, nil
824824
}
825825

826+
if ref.Kind == "ImageStreamImage" {
827+
// even if the associated tag for this ImageStreamImage matches a output ImageStreamTag, when the image
828+
// is built it will have a new sha ... you are essentially using a single/unique older version of a image as the base
829+
// to build future images; all this means we can leave the ref name as is and return with no error
830+
// also do shallow copy like above
831+
copy := *ref
832+
return &copy, nil
833+
}
834+
826835
if ref.Kind != "ImageStreamTag" {
827836
return nil, fmt.Errorf("Unable to follow reference type: %q", ref.Kind)
828837
}

test/cmd/newapp.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ os::cmd::expect_failure_and_text 'oc new-build mysql --source-image-path foo' 'e
377377
# ensure circular ref flagged but allowed for template
378378
os::cmd::expect_success 'oc create -f test/testdata/circular-is.yaml'
379379
os::cmd::expect_success_and_text 'oc new-app -f test/testdata/circular.yaml' 'should be different than input'
380+
# ensure circular does not choke on image stream image
381+
os::cmd::expect_success_and_not_text 'oc new-app -f test/testdata/bc-from-imagestreamimage.json --dry-run' 'Unable to follow reference type'
380382

381383
# do not allow use of non-existent image (should fail)
382384
os::cmd::expect_failure_and_text 'oc new-app openshift/bogusimage https://github.com/openshift/ruby-hello-world.git -o yaml' "no match for"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
apiVersion: v1
2+
kind: Template
3+
metadata:
4+
creationTimestamp: null
5+
name: bc-from-imagestreamimage
6+
objects:
7+
- apiVersion: v1
8+
kind: BuildConfig
9+
metadata:
10+
creationTimestamp: null
11+
labels:
12+
name: bc-from-imagestreamimage
13+
template: application-template-stibuild
14+
name: bc-from-imagestreamimage
15+
spec:
16+
nodeSelector: null
17+
output:
18+
to:
19+
kind: ImageStreamTag
20+
name: origin-ruby-sample:latest
21+
postCommit:
22+
args:
23+
- bundle
24+
- exec
25+
- rake
26+
- test
27+
resources: {}
28+
runPolicy: Serial
29+
source:
30+
git:
31+
uri: https://github.com/openshift/ruby-hello-world.git
32+
type: Git
33+
strategy:
34+
sourceStrategy:
35+
env:
36+
- name: EXAMPLE
37+
value: sample-app
38+
from:
39+
kind: ImageStreamImage
40+
name: ruby@sha256:5dc0856fea9551e102815863cceeabd3aee862ec4ad5f2625eb51564924f0360
41+
type: Source
42+
triggers:
43+
- github:
44+
secret: secret101
45+
type: GitHub
46+
- generic:
47+
allowEnv: true
48+
secret: secret101
49+
type: Generic
50+
- type: ConfigChange
51+
status:
52+
lastVersion: 0

0 commit comments

Comments
 (0)