Repository navigation
Solves the issue #7749 - #7753
mattfarina merged 4 commits into
Conversation
…short(-q) option was used with other formating options like json, yaml Signed-off-by: Anshul Verma <[email protected]>
…short(-q) option was used with other formating options like json, yaml Signed-off-by: Anshul Verma <[email protected]>
…short(-q) option was used with other formating options like json, yaml Signed-off-by: Anshul Verma <[email protected]>
mattfarina
left a comment
There was a problem hiding this comment.
Thanks for working on this. I found an issue in the code block and I think the design can use a little improvement to clean up the issue and duplicate code. See below...
| outputFlag := cmd.Flag("output") | ||
| if outputFlag.Changed { | ||
| switch outputFlag.Value.String() { | ||
| case "json": | ||
| output.EncodeJSON(out, names) | ||
| return nil | ||
| case "yaml": | ||
| output.EncodeYAML(out, names) | ||
| return nil | ||
| default: | ||
| return outfmt.Write(out, newReleaseListWriter(results)) | ||
| } | ||
| } | ||
|
|
||
| for _, res := range results { | ||
| fmt.Fprintln(out, res.Name) | ||
| } |
There was a problem hiding this comment.
If I use helm list --short the default value for the output is used of table. This shows a different result from the use of helm list --short --output table which is currently showing the same result as if it were not short.
I would suggest a few changes to this block...
- Remove the
if outputFlag.Changed {block. This section can format for all the types including the default. - Add a case for
table(the default) and have its contents be the for loop currently listed after the if changed block. - Change the default case (not a known output format) to return an error of
fmt.Errorf("Unknown output format \"%s\"", outputFlag.Value.String()). This is based on what's in Helm v2.
This would make the case statement handle all short forms in all cases.
There was a problem hiding this comment.
If I use
helm list --shortthe default value for the output is used oftable. This shows a different result from the use ofhelm list --short --output tablewhich is currently showing the same result as if it were not short.
Actually, I deployed Helm 2 and saw that there was no output format as table in helm.
$ ./helm version
Client: &version.Version{SemVer:"v2.16.3", GitCommit:"1ee0254c86d4ed6887327dabed7aa7da29d7eb0d", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.16.3", GitCommit:"1ee0254c86d4ed6887327dabed7aa7da29d7eb0d", GitTreeState:"clean"
$ ./helm list --short --output table
Error: Unknown output format "table
Hence thought that if the output is table then it should be the table, but ya you are right, if default format is table then helm list --short --output table should also be the same as the output of helm list --short.
I will make the changes as given in your 1st and 2nd point.
Regarding the 3rd point. What I think is that in the default case of the switch if we return outfmt.Write(out, newReleaseListWriter(results)) the if will throw the normal Helm 3 error message of bad format.
╭─ansverma@localhost ~/contribution/helm/7749/helm2/helm ‹helm/7749/helm_list_short_listing_format*›
╰─$ bin/helm list --short --output table
mysql
yoursql
╭─ansverma@localhost ~/contribution/helm/7749/helm2/helm ‹helm/7749/helm_list_short_listing_format*›
╰─$ bin/helm list --short --output json
["mysql","yoursql"]
╭─ansverma@localhost ~/contribution/helm/7749/helm2/helm ‹helm/7749/helm_list_short_listing_format*›
╰─$ bin/helm list --short --output yaml
- mysql
- yoursql
╭─ansverma@localhost ~/contribution/helm/7749/helm2/helm ‹helm/7749/helm_list_short_listing_format*›
╰─$ bin/helm list --short --output asdflkj
Error: invalid argument "asdflkj" for "-o, --output" flag: invalid format type
I think, the error message Error: invalid argument "asdflkj" for "-o, --output" flag: invalid format type is better than the one in Helm 2.
I am currently making the changes. Please let me know if you want to have that particular error message which you mentioned anyways, I will do that.
…short(-q) option was used with other formating options like json, yaml Signed-off-by: Anshul Verma <[email protected]>
|
@mattfarina any update? |
|
@mattfarina , Hello, Any update on this? @bacongobbler , Can you please have a look at this? |
|
Thank you for the ping. At this time, I do not have enough time in my work schedule to review your code. I am busy with other work. Sorry! |
|
@bacongobbler , No Problem Matthew. |
mattfarina
left a comment
There was a problem hiding this comment.
lgtm. thanks for working this out.
Resolves the issue where proper formatting was not being done if short(-q) option was used with other formatting options like json, yaml.
@mattfarina , Can you please review this.
Please do let me know if any change is required.
Thank You very much.