-
Notifications
You must be signed in to change notification settings - Fork 78
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
GetPlatform enhancement to the CLI #1791
Conversation
I think this is not necessary to do here, I can fix it in the commands by getting the value of the flag. |
when configuring a command, the default is the value of GetPlatform, unless the platform flag was specified:
|
For flag validation, I think this is working. But for the generic commands being added, like in the code below: skupper/internal/cmd/skupper/site/site.go Lines 27 to 30 in 781927c
The platform is coming straight from |
CmdSiteCreateFactory is calling ConfigureCobraCommand that checks the value of the flag All the factories are calling ConfigureCobracommand that checks the platform flag. |
Correct. But when As an example, looking at the #1778 PR and building the skupper cli, then showing
|
Maybe instead of passing |
Now I understand your scenario, using --help flag in conjunction with --p flag. The cobra help function was not overridden, so I'm hiding commands not in execution but when defining and configuring the command, letting the --help flag not use the platform passed with the -p flag. Let me check how to override the help function first. |
Using the value of the -p flag while executing --help would imply override all the help from all the commands. Which is not a good solution in comparison with this one. My bad! (One of the main points of ConfigureCobraCommand was precisely to avoid parsing the -p flag as a string argument and instead use the cobra methods.) |
internal/config/platform.go
Outdated
platformArg := os.Args[i+1] | ||
platform = types.Platform(platformArg) | ||
break | ||
} else if strings.HasPrefix(arg, "--platform=") { |
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.
The shortcut -p
is missing
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.
Done.
63dd105
to
5c48342
Compare
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.
👋 Once this is merged, I propose we delete pkg/config.
In cleaning up stray prometheus related stuff, I found that platform.go was the only used portion.
Also suspect that ConfigFileHandlerCommon and ConfigFileHandler may be unused.
5c48342
to
7252ab6
Compare
Moving GetPlatform function to internal pkg and including os.Args to be evaluated.
This helps the CLI properly getting the platform when
--platform
flag is provided.