Skip to content

Commit

Permalink
Merge pull request #20052 from coreydaley/trello_1559_reuse_exiting_i…
Browse files Browse the repository at this point in the history
…magestreams_with_new_app

Resuse existing imagestreams with new-app
  • Loading branch information
openshift-merge-robot authored Jun 21, 2018
2 parents b693fe0 + cbdbed8 commit c8924fa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions pkg/oc/generate/app/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ func (p *Pipeline) Objects(accept, objectAccept Acceptor) (Objects, error) {
}
if objectAccept.Accept(repo) {
objects = append(objects, repo)
} else {
tag, err := p.InputImage.ImageStreamTag()
if err != nil {
return nil, err
}
if objectAccept.Accept(tag) {
objects = append(objects, tag)
}
}
}
if p.Image != nil && p.Image.AsImageStream && accept.Accept(p.Image) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/oc/generate/cmd/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ func describeBuildPipelineWithImage(out io.Writer, ref app.ComponentReference, p
if pipeline.Build == nil {
trackedImage := extractFirstImageStreamTag(true, pipeline.InputImage, pipeline.Image)
if len(trackedImage) > 0 {
fmt.Fprintf(out, " * An image stream will be created as %q that will track this image\n", trackedImage)
fmt.Fprintf(out, " * An image stream tag will be created as %q that will track this image\n", trackedImage)
}
} else {
trackedImage := extractFirstImageStreamTag(true, pipeline.InputImage)
if len(trackedImage) > 0 {
fmt.Fprintf(out, " * An image stream will be created as %q that will track the source image\n", trackedImage)
fmt.Fprintf(out, " * An image stream tag will be created as %q that will track the source image\n", trackedImage)
}
if refInput.Uses != nil && refInput.Uses.Info() != nil {
matches := []string{}
Expand Down Expand Up @@ -171,7 +171,7 @@ func describeBuildPipelineWithImage(out io.Writer, ref app.ComponentReference, p
if buildOut, err := pipeline.Build.Output.BuildOutput(); err == nil && buildOut != nil && buildOut.To != nil {
switch to := buildOut.To; {
case to.Kind == "ImageStreamTag":
fmt.Fprintf(out, " * The resulting image will be pushed to image stream %q\n", to.Name)
fmt.Fprintf(out, " * The resulting image will be pushed to image stream tag %q\n", to.Name)
case to.Kind == "DockerImage":
fmt.Fprintf(out, " * The resulting image will be pushed with Docker to %q\n", to.Name)
default:
Expand Down
10 changes: 10 additions & 0 deletions test/cmd/newapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ os::cmd::expect_failure 'oc get dc/mysql'
os::cmd::expect_failure 'oc get dc/php'
os::cmd::expect_success_and_text 'oc new-app -f test/testdata/template-without-app-label.json -o yaml' 'app: ruby-helloworld-sample'

# check reuse imagestreams
os::cmd::expect_success "oc new-build -D $'FROM node:8\nRUN echo \"Test\"' --name=node8"
os::cmd::try_until_success 'oc get imagestreamtags node:8'
os::cmd::expect_success "oc new-build -D $'FROM node:10\nRUN echo \"Test\"' --name=node10"
os::cmd::try_until_success 'oc get imagestreamtags node:10'
os::cmd::expect_success 'oc delete is node'
os::cmd::expect_success 'oc delete is node8'
os::cmd::expect_success 'oc delete is node10'


# check object namespace handling
# hardcoded values should be stripped
os::cmd::expect_success_and_not_text 'oc new-app -f test/testdata/template-with-namespaces.json -o jsonpath="{.items[?(@.metadata.name==\"stripped\")].metadata.namespace}"' 'STRIPPED'
Expand Down

0 comments on commit c8924fa

Please sign in to comment.