-
Notifications
You must be signed in to change notification settings - Fork 4.8k
make build output optional #1119
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "log" | ||
| "os" | ||
|
|
||
| "github.com/fsouza/go-dockerclient" | ||
| "github.com/golang/glog" | ||
| "github.com/openshift/origin/pkg/api/latest" | ||
| "github.com/openshift/origin/pkg/build/api" | ||
| bld "github.com/openshift/origin/pkg/build/builder" | ||
|
|
@@ -29,34 +29,40 @@ type factoryFunc func( | |
| func run(builderFactory factoryFunc) { | ||
| client, endpoint, err := dockerutil.NewHelper().GetClient() | ||
| if err != nil { | ||
| log.Fatalf("Error obtaining docker client: %v", err) | ||
| glog.Fatalf("Error obtaining docker client: %v", err) | ||
| } | ||
| buildStr := os.Getenv("BUILD") | ||
| build := api.Build{} | ||
| if err := latest.Codec.DecodeInto([]byte(buildStr), &build); err != nil { | ||
| log.Fatalf("Unable to parse build: %v", err) | ||
| glog.Fatalf("Unable to parse build: %v", err) | ||
| } | ||
|
|
||
| var ( | ||
| authcfg docker.AuthConfiguration | ||
| authPresent bool | ||
| ) | ||
| output := true | ||
| if len(build.Parameters.Output.DockerImageReference) == 0 { | ||
| if build.Parameters.Output.To != nil { | ||
| log.Fatalf("Cannot determine an output image reference. Make sure a registry service is running.") | ||
| glog.Fatalf("Cannot determine an output image reference. Make sure a registry service is running.") | ||
| } | ||
| log.Fatal("Build output has an empty Docker image reference.") | ||
| output = false | ||
| } | ||
| registry, _, _, _, err := image.SplitDockerPullSpec(build.Parameters.Output.DockerImageReference) | ||
| if err != nil { | ||
| log.Fatalf("Build output does not have a valid Docker image reference: %v", err) | ||
| if output { | ||
| registry, _, _, _, err := image.SplitDockerPullSpec(build.Parameters.Output.DockerImageReference) | ||
| if err != nil { | ||
| glog.Fatalf("Build output does not have a valid Docker image reference: %v", err) | ||
| } | ||
| authcfg, authPresent = dockercfg.NewHelper().GetDockerAuth(registry) | ||
| } | ||
| authcfg, authPresent = dockercfg.NewHelper().GetDockerAuth(registry) | ||
|
|
||
| b := builderFactory(client, endpoint, authcfg, authPresent, &build) | ||
| if err = b.Build(); err != nil { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. STI build will fail here, since not passing the name of the output image which is required (see sti.go#34).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, we pass the name, so we're missing a TC for this one, please 😸
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like you better make the output optional when that loophole gets fixed. what sort of a test case are you asking for? an origin test case that runs sti-type builds w/ no output defined?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's the issue openshift/source-to-image#146, I'll be working on PR for that, so you can assign me to that bug. |
||
| log.Fatalf("Build error: %v", err) | ||
| glog.Fatalf("Build error: %v", err) | ||
| } | ||
| if !output { | ||
| glog.Warning("Build does not have an Output defined, no output image was pushed to a registry.") | ||
| } | ||
|
|
||
| } | ||
|
|
||
| // RunDockerBuild creates a docker builder and runs its build | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this condition you'll still end build when
Tois not defined and if I understood @smarterclayton correctly he wanted to have no output defined at all.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, if Output.To==nil we'll fall through to "output=false" but still run the build, which is as desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K