Skip to content

Allow setting the build output image reference in oc new-build - #5141

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
rhcarvalho:newbuild-to-ist
Nov 30, 2015
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
rhcarvalho:newbuild-to-ist

Conversation

@rhcarvalho

Copy link
Copy Markdown
Contributor

This makes it possible to do:

oc new-build <source> --to=somenamespace/some:other

The above will define a build output image and works in concert with --to-docker (and --name, too).

Fixes #4980.

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

This alone does not make it possible to have no output for a build.

@smarterclayton do you think we should have another argument like --no-output or a special value of --to?
AFAIK with cobra/pflag there's no obvious way to determine if a flag was user provided or defaulted.

@rhcarvalho
rhcarvalho force-pushed the newbuild-to-ist branch 2 times, most recently from 7aceab7 to 2c52969 Compare October 16, 2015 09:47
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

There was an unreported bug with --to-docker that is being fixed here, as I noted in the PR's description.

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

[test]

@rhcarvalho rhcarvalho changed the title [do not merge] add --to to oc new-build / new-app add --to to oc new-build / new-app Oct 16, 2015
@rhcarvalho rhcarvalho changed the title add --to to oc new-build / new-app Allow setting the build output image reference in oc new-app/build Oct 16, 2015
@rhcarvalho
rhcarvalho force-pushed the newbuild-to-ist branch 4 times, most recently from 7ab3c2c to 5717fd0 Compare October 16, 2015 16:59
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

@smarterclayton PTAL

Comment thread pkg/generate/app/app.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always use len(to) > 0 or len(to) == 0 for this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated that.

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

@smarterclayton thanks for the review, I've updated code accordingly.
Still missing the check for "illegal to specify --to when there are more than two builds defined".

I don't know how to use 'oc new-app' / 'new-build' to create more than 1 build at once, except for doing 'oc new-app template.json'. Is there another way that I'm missing?

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

Ok, I figured what I'm missing, working on it.

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

Comments addressed, added similar checks for --to as there are for --name.

@smarterclayton

Copy link
Copy Markdown
Contributor

oc new-app openshift/php~ openshift/ruby~

On Mon, Oct 19, 2015 at 9:20 AM, Rodolfo Carvalho [email protected]
wrote:

@smarterclayton https://github.com/smarterclayton thanks for the
review, I've updated code accordingly.
Still missing the check for "illegal to specify --to when there are more
than two builds defined".

I don't know how to use 'oc new-app' / 'new-build' to create more than 1
build at once, except for doing 'oc new-app template.json'. Is there
another way that I'm missing?

—
Reply to this email directly or view it on GitHub
#5141 (comment).

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

oc new-app openshift/php~ openshift/ruby~

Yes, I got that. Added similar checks as for --name.

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

Rebased on top of newest kube godep, apparently this PR was not affected by the changes in kube.
@smarterclayton any other change you'd like to see here?

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

@smarterclayton, based on your comments, my most recent push:

PTAL

@smarterclayton

Copy link
Copy Markdown
Contributor

Looks good, you have some failing unit tests in jenkins.

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

@bparees @smarterclayton I've updated test/cmd/builds.sh fixing the merge conflict with #6034, and updating the test code to use the wrapper methods.

Comment thread test/cmd/builds.sh Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smarterclayton @bparees also included this test to check "--to" given two source repos (invalid usage).

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 25, 2015
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

Could anybody re-merge this, please?

Comment thread test/cmd/builds.sh Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, any way to use the test functions directly? Would like to avoid complex per-use bash functions. @stevekuznetsov any suggestions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The smart functions from the util are still used -- lines 26-28. This is to avoid repeating the same pattern over and over.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it fails, what line gets logged? Can we tell which call into the shared function caused it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output will look like three tests are run, I think this should be pretty straight forward. However, no, the line file/line spec will show this function add the source, not the original calls.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an os::cmd::expect_success on the new-build, a function to build the correct template, and a os::cmd::expect_success_and_text on the get with the template should suffice - I'm not sure making the tests less explicit is worth it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very soon (next week?) I will be tweaking the output of the functions to read (Running|SUCCESS|FAILURE): file:line_number: wrapper args, where file:line_number: will be the place where the wrapper is called. For this case, the failure text will bring you to the call inside the function when instead you want the call of os::cmd::builds::expect_build_output_spec. You could still see that from the stack trace, but I'm not sure if it's worth the confusion - especially since jUnit integration will use that line number and file to track flakes, we won't get useful data for flakes using this function.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, small nit - this function should live in hack/builds.sh once #5844 is sorted out, and maybe in hack/cmd_util.sh or hack/util.sh for now, not here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

template='{{with .spec.output.to}}{{.kind}} {{.name}}{{end}}'
os::cmd::expect_success 'oc new-build <args>'
os::cmd::expect_success_and_text "oc get bc/<name> --template '${template}'" '<text>'

This is fairly concise, clear, and doesn't have drawbacks for jUnit. I think it's OK if our tests are verbose, literal, and the less bash trickery we use the better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curiosity, why are we creating a bash test framework?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing cli invocations is (somewhat) reasonably done via bash. We already had a bash framework, we're just trying to make it (more) reasonable to jump in and know exactly what is supposed to be getting checked.

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

Fixed mixing spaces and tabs in test/cmd/builds.sh.

Comment thread test/cmd/builds.sh Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line looks like something this function shouldn't be doing - I wouldn't expect this side effect from the name.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno, I would rather see repeated commands than have to manage another level of indirection. Do we actually need to do the delete all every time if we use different names?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather see repeated commands

I agree. Let test files be verbose.

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

@stevekuznetsov @liggitt I've flattened out the tests PTAL

Comment thread test/cmd/builds.sh Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the oc delete lines are cleanup from the previous test, I'd stick them there instead of them leading the next test. Otherwise these LGTM as far as formatting and readability, can't comment on correctness.

@liggitt

liggitt commented Nov 26, 2015

Copy link
Copy Markdown
Contributor

[test]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 57747fd

@openshift-bot

Copy link
Copy Markdown
Contributor

@bparees

bparees commented Nov 30, 2015

Copy link
Copy Markdown
Contributor

lgtm [merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to 57747fd

openshift-bot pushed a commit that referenced this pull request Nov 30, 2015
@openshift-bot
openshift-bot merged commit fa0a0a1 into openshift:master Nov 30, 2015
@rhcarvalho
rhcarvalho deleted the newbuild-to-ist branch November 30, 2015 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants