-
Notifications
You must be signed in to change notification settings - Fork 244
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
Errors out if json machine output has not been implemented #2160
Errors out if json machine output has not been implemented #2160
Conversation
@amitkrout if you could please review that'd be great. Keep in mind that this does not remove |
@cdrage storage list is missing the required changes |
b45a29e
to
f1fc55a
Compare
@cdrage seems like odo version also needs the changes too
|
tests/integration/component.go
Outdated
// `odo version` does not have json implemented, and thus we will use this | ||
// as a test | ||
output := helper.CmdShouldFail("odo", "version", "-o", "json") | ||
Expect(output).To(ContainSubstring("Machine readable output is not implemented for this command")) |
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.
Expected
<string>: ✗ Machine readable output is not yet implemented for this command
to contain substring
<string>: Machine readable output is not implemented for this command
is not yet implemented
f1fc55a
to
eff9b35
Compare
/test v4.1-integration |
eff9b35
to
f3953f4
Compare
/retest |
f3953f4
to
a82cb0e
Compare
/retest |
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.
Looking good
/approve
Long: storageListLongDesc, | ||
Example: fmt.Sprintf(storageListExample, fullName), | ||
Args: cobra.MaximumNArgs(1), | ||
Annotations: map[string]string{"machineoutput": "json"}, |
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.
This is mostly for all of them, interesting use of annotations :)
flagChanged := outputFlag != nil && outputFlag.Changed | ||
machineOutput := cmd.Annotations["machineoutput"] | ||
|
||
if flagChanged && outputFlag.Value.String() != "json" { | ||
log.Error("Please input a valid output format for -o, available format: json") |
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.
All these (log.Error + exit 1) could possibly be replaced by alog.Fatal like the standard log package maybe. Anycase more of an implementation detail :)
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.
Yeah, we use log.Error
instead since we're able to modify the output to something more pretty :)
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mohammedzee1000 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 |
I can still see that the help messages are showing the |
@kadel Yes, this is only one half of the issue. This errors out if it's been passed in, but I have not yet updated it to hide the actual flag.. I'll set this as WIP for now. |
We can split it into multiple PRs if you want. I just wanted to make sure that we forgot this part, as it is also really important. |
cbf1b4e
to
ac3cb5a
Compare
ac3cb5a
to
68066ee
Compare
Updated the PR! Ready for review @kadel and @girishramnani I've updated the PR's description and implementing hiding the command. Global Flags has also been renamed to Additional Flags. See below for the changes: github.com/openshift/odo remove-json-from-some-commands ✔ 13m ⍉
▶ ./odo version --help
Print the client version information
Usage:
odo version [flags]
Examples:
# Print the client version of odo
odo version
Flags:
--client Client version only (no server required).
-h, --help Help for version
Additional Flags:
-v, --v Level Log level for V logs. Level varies from 0 to 9 (default 0).
--vmodule moduleSpec Comma-separated list of pattern=N settings for file-filtered logging
▶ ./odo service list --help
List all services in the current application
Usage:
odo service list [flags]
Examples:
# List all services in the application
odo service list
Flags:
--app string Application, defaults to active application
--context string Use given context directory as a source for component settings
-h, --help Help for list
--project string Project, defaults to active project
Additional Flags:
-o, --o string Specify output format, supported format: json (default "json")
-v, --v Level Log level for V logs. Level varies from 0 to 9 (default 0).
--vmodule moduleSpec Comma-separated list of pattern=N settings for file-filtered logging |
68066ee
to
7931acc
Compare
/retest |
/retest |
pkg/odo/cli/component/create.go
Outdated
@@ -593,7 +594,6 @@ func NewCmdCreate(name, fullName string) *cobra.Command { | |||
componentCreateCmd.Flags().StringSliceVarP(&co.componentPorts, "port", "p", []string{}, "Ports to be used when the component is created (ex. 8080,8100/tcp,9100/udp)") | |||
componentCreateCmd.Flags().StringSliceVar(&co.componentEnvVars, "env", []string{}, "Environmental variables for the component. For example --env VariableName=Value") | |||
// Add a defined annotation in order to appear in the help menu |
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.
please remove this comment
pkg/odo/cli/component/delete.go
Outdated
@@ -133,7 +134,6 @@ func NewCmdDelete(name, fullName string) *cobra.Command { | |||
componentDeleteCmd.Flags().BoolVarP(&do.componentDeleteAllFlag, "all", "a", false, "Delete component and local config") | |||
|
|||
// Add a defined annotation in order to appear in the help menu |
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.
please remove this comment
pkg/odo/cli/component/describe.go
Outdated
Long: `Describe component.`, | ||
Example: fmt.Sprintf(describeExample, fullName), | ||
Args: cobra.RangeArgs(0, 1), | ||
Annotations: map[string]string{"machineoutput": "json", "command": "component"}, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
genericclioptions.GenericRun(do, cmd, args) | ||
}, | ||
} | ||
|
||
// Add a defined annotation in order to appear in the help menu |
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.
same as above
pkg/odo/cli/component/link.go
Outdated
@@ -134,7 +135,6 @@ func NewCmdLink(name, fullName string) *cobra.Command { | |||
linkCmd.PersistentFlags().BoolVar(&o.waitForTarget, "wait-for-target", false, "If enabled, the link command will wait for the service to be provisioned (has no effect when linking to a component)") | |||
|
|||
// Add a defined annotation in order to appear in the help menu |
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.
same as above
pkg/odo/cli/component/list.go
Outdated
Long: "List all components in the current application.", | ||
Example: fmt.Sprintf(listExample, fullName), | ||
Args: cobra.NoArgs, | ||
Annotations: map[string]string{"machineoutput": "json", "command": "component"}, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
genericclioptions.GenericRun(o, cmd, args) | ||
}, | ||
} | ||
// Add a defined annotation in order to appear in the help menu |
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.
same as above
pkg/odo/cli/component/log.go
Outdated
@@ -74,7 +75,6 @@ func NewCmdLog(name, fullName string) *cobra.Command { | |||
logCmd.Flags().BoolVarP(&o.logFollow, "follow", "f", false, "Follow logs") | |||
|
|||
// Add a defined annotation in order to appear in the help menu |
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.
same as above
pkg/odo/cli/component/push.go
Outdated
@@ -127,7 +128,6 @@ func NewCmdPush(name, fullName string) *cobra.Command { | |||
pushCmd.Flags().BoolVarP(&po.forceBuild, "force-build", "f", false, "Use force-build flag to force building the component") | |||
|
|||
// Add a defined annotation in order to appear in the help menu |
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.
same as above
pkg/odo/cli/component/unlink.go
Outdated
@@ -87,7 +88,6 @@ func NewCmdUnlink(name, fullName string) *cobra.Command { | |||
unlinkCmd.PersistentFlags().BoolVarP(&o.wait, "wait", "w", false, "If enabled the link will return only when the component is fully running after the link is deleted") | |||
|
|||
// Add a defined annotation in order to appear in the help menu |
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.
same as above
pkg/odo/cli/component/update.go
Outdated
@@ -167,7 +168,6 @@ func NewCmdUpdate(name, fullName string) *cobra.Command { | |||
updateCmd.Flags().StringVarP(&uo.local, "local", "l", "", "Use local directory as a source for component.") | |||
updateCmd.Flags().StringVarP(&uo.ref, "ref", "r", "", "Use a specific ref e.g. commit, branch or tag of the git repository") | |||
// Add a defined annotation in order to appear in the help menu |
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.
same as above
pkg/odo/cli/component/watch.go
Outdated
@@ -162,7 +163,6 @@ func NewCmdWatch(name, fullName string) *cobra.Command { | |||
watchCmd.Flags().IntVar(&wo.delay, "delay", 1, "Time in seconds between a detection of code change and push.delay=0 means changes will be pushed as soon as they are detected which can cause performance issues") | |||
|
|||
// Add a defined annotation in order to appear in the help menu |
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.
same as above
baa7657
to
44a8775
Compare
Thanks @mik-dass for the review! updated the PR again. |
/retest |
/retest |
reviewed the PR just waiting to confirm if all the comments from @mik-dass were resolved |
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
/retest Please review the full test history for this PR and help us cut down flakes. |
/kind bug |
This PR:
&cobra.Command
struct creation rather thanusing the command to add it
-o json
has been passed, but json support has notbeen added
-o json
command if it's not impementedCloses #2031