-
Notifications
You must be signed in to change notification settings - Fork 159
Adds a sudo command to remove virtual files via cli #8304
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
Conversation
cli/cmd/sudo/virtualfiles/delete.go
Outdated
| } | ||
|
|
||
| deleteCmd.Flags().BoolVarP(&force, "force", "f", false, "Skip confirmation prompt") | ||
| deleteCmd.PersistentFlags().StringVar(&ch.Org, "org", ch.Org, "Organization Name") |
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.
Sudo commands should not use ch.Org – they should accept org as an explicit positional arg.
The reason is that sudo commands are usually done by internal support on behalf of an external user, so you don't want things to get mixed up with the internal user's own org.
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.
Ahh noted. Initially I did do that approach
cli/cmd/sudo/virtualfiles/get.go
Outdated
| data := string(resp.File.Data) | ||
| var obj interface{} | ||
| if err := yaml.Unmarshal(resp.File.Data, &obj); err != nil { | ||
| // fallback to plain text | ||
| fmt.Println(data) | ||
| return nil | ||
| } | ||
|
|
||
| yamlData, err := yaml.Marshal(obj) | ||
| if err != nil { | ||
| fmt.Println(data) | ||
| } else { | ||
| fmt.Println(string(yamlData)) | ||
| } |
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.
Why not just print it outright, why the need for a YAML roundtrip?
I think just printing the virtual files outright would be better so there's no loss of information (like comments or newlines).
cli/cmd/sudo/virtualfiles/get.go
Outdated
| }, | ||
| } | ||
|
|
||
| getCmd.PersistentFlags().StringVar(&ch.Org, "org", ch.Org, "Organization Name") |
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 comment as earlier – should be a positional arg
cli/cmd/sudo/virtualfiles/list.go
Outdated
| sort.Slice(files, func(i, j int) bool { | ||
| return files[i].Path < files[j].Path | ||
| }) |
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 will be confusing if pagination is applied – you may not realize the next page may have values that interleave this sorting. When pagination is used, it should stick to the ordering that's used for the pagination.
cli/cmd/sudo/virtualfiles/list.go
Outdated
| } | ||
|
|
||
| listCmd.Flags().IntVar(&pageSize, "page-size", 100, "Number of files per page") | ||
| listCmd.PersistentFlags().StringVar(&ch.Org, "org", ch.Org, "Organization Name") |
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 comment as earlier
Enables superusers to remove virtual files via sudo in the cli
List
Get
Delete
Checklist: