-
Notifications
You must be signed in to change notification settings - Fork 243
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
added check for conflicting flags #2515
Conversation
added @kadel as approver |
@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 |
/retest |
/retest |
project := stringFlagLookup(cmd, "project") | ||
context := stringFlagLookup(cmd, "context") | ||
component := stringFlagLookup(cmd, "component") | ||
if (context != "") && (app != "" || project != "" || component != "") { |
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.
read if context flag is provided and with that either of app, project or component are also provided
then return error.
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.
/lgtm
@@ -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) |
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.
we were using backendContext
while we were trying to link to backend
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.
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.
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.
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.
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.
we were using
backendContext
while we were trying to link tobackend
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.
@@ -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) |
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.
we were using
backendContext
while we were trying to link tobackend
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.
We got saved by the precedence of --component over context |
/lgtm |
/approve |
[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 |
What type of PR is this?
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 forodo create
orodo 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: