Skip to content
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

Resuse existing imagestreams with new-app #20052

Merged
merged 1 commit into from
Jun 21, 2018
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
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