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

added check for conflicting flags #2515

Merged

Conversation

girishramnani
Copy link
Contributor

What type of PR is this?

/kind feature

What does does this PR do / why we need it:
We check if the --context flag is provided with any of the conflicting flags --app, --project or --component. This is allowed for odo create or odo component create as that's when the user actually sets the values.

Which issue(s) this PR fixes:

Fixes #2443

How to test changes / Special notes to the reviewer:

odo create nodejs --app asdf --project asdf --context test  // should work
odo list --context test --project asdf // should fail

@girishramnani girishramnani requested review from dharmit and kadel and removed request for cdrage January 17, 2020 08:55
@girishramnani
Copy link
Contributor Author

added @kadel as approver

@girishramnani
Copy link
Contributor Author

girishramnani commented Jan 17, 2020

@amitkrout no unit tests needed as all the functions added are un-exported and the exported functions that are using the added functions can only be effectively integration tested.

@girishramnani
Copy link
Contributor Author

girishramnani commented Jan 17, 2020

error: unable to read image registry.svc.ci.openshift.org/ci-op-dk9tz5q6/stable@sha256:a86de9cc57733bb2f38dd25fb3c1e4de355b8bc2aa59b23901679227060323bb: received unexpected HTTP status: 504 Gateway Time-out
---

/retest

@girishramnani
Copy link
Contributor Author

/retest

project := stringFlagLookup(cmd, "project")
context := stringFlagLookup(cmd, "context")
component := stringFlagLookup(cmd, "component")
if (context != "") && (app != "" || project != "" || component != "") {
Copy link
Contributor Author

@girishramnani girishramnani Jan 17, 2020

Choose a reason for hiding this comment

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

read if context flag is provided and with that either of app, project or component are also provided then return error.

Copy link
Member

@dharmit dharmit left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jan 17, 2020
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jan 17, 2020
@@ -104,9 +105,9 @@ var _ = Describe("odo link and unlink command tests", func() {
oc.WaitForDCRollout(dcName, project, 20*time.Second)
helper.HttpWaitFor(frontendURL, "Hello world from node.js!", 20, 1)

outputErr := helper.CmdShouldFail("odo", "link", "backend", "--component", "frontend", "--project", project, "--port", "8778", "--context", backendContext)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we were using backendContext while we were trying to link to backend

Copy link
Member

Choose a reason for hiding this comment

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

Have you verified the working of this one? It's using both --component and --context which means it's a hybrid of:

# Link component 'nodejs' to the 'my-postgresql' service
$ odo link my-postgresql --component nodejs

and

# Link current component to the 'backend' component (backend must have a single exposed port)
$ odo link backend

which are kind of opposite ways of linking things.

Copy link
Member

Choose a reason for hiding this comment

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

I'm asking because if someone were to quiz me which component will be attached to which in the line you've removed, I would not be sure and would have to rely on a guess.

Copy link
Member

Choose a reason for hiding this comment

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

we were using backendContext while we were trying to link to backend

The original command was correct but confusing. This is exactly the reason why we don't want to allow using --context and --component flag together.

odo link backend --component frontend --project project --port 8778 --context backendContext

Which means: take component defined in backendContext dir, and overwide the component name with frontend and project with project and link this to backend.
So this will actually link frontend to the backend.

tests/integration/cmd_link_unlink_test.go Outdated Show resolved Hide resolved
@@ -104,9 +105,9 @@ var _ = Describe("odo link and unlink command tests", func() {
oc.WaitForDCRollout(dcName, project, 20*time.Second)
helper.HttpWaitFor(frontendURL, "Hello world from node.js!", 20, 1)

outputErr := helper.CmdShouldFail("odo", "link", "backend", "--component", "frontend", "--project", project, "--port", "8778", "--context", backendContext)
Copy link
Member

Choose a reason for hiding this comment

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

we were using backendContext while we were trying to link to backend

The original command was correct but confusing. This is exactly the reason why we don't want to allow using --context and --component flag together.

odo link backend --component frontend --project project --port 8778 --context backendContext

Which means: take component defined in backendContext dir, and overwide the component name with frontend and project with project and link this to backend.
So this will actually link frontend to the backend.

@girishramnani
Copy link
Contributor Author

girishramnani commented Jan 17, 2020

overwide the component name with frontend.

We got saved by the precedence of --component over context

@dharmit
Copy link
Member

dharmit commented Jan 20, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jan 20, 2020
@kadel
Copy link
Member

kadel commented Jan 20, 2020

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kadel

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Jan 20, 2020
@openshift-merge-robot openshift-merge-robot merged commit 44699f5 into redhat-developer:master Jan 20, 2020
@rm3l rm3l added the estimated-size/M (10-20) Rough sizing for Epics. About 1 sprint of work for one person label Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. estimated-size/M (10-20) Rough sizing for Epics. About 1 sprint of work for one person lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not allow combination of --context with (project, app and component) flags
6 participants