Refactor the volume ls command flagging process#1773
Conversation
7d8aaa7 to
413cf25
Compare
413cf25 to
fda89c9
Compare
|
This PR should be merged after #1774 |
|
Since #1779 has been merged, I think this PR is ok to merge after resolve the code conflict |
fda89c9 to
4040932
Compare
|
Shouldn't we add a prefix to the struct inside |
4040932 to
befac3a
Compare
Nice catch, I will add the prefix |
Signed-off-by: Miles Liu <miles@bung.cc>
befac3a to
c79d835
Compare
| return err | ||
| } | ||
| volumeSize, err := cmd.Flags().GetBool("size") | ||
| options.Quiet = quiet |
There was a problem hiding this comment.
nit: instead of storing in local variables everytime, you can do
options.Quiet, err := cmd.Flags().GetBool("quiet")
...same for other options.
There was a problem hiding this comment.
another style I recommand is first storing all flags in local variables and at the end, create the option struct
format, err := cmd.Flags().GetBool("format")
...
quiet, err := cmd.Flags().GetBool("quiet")
...
option := types.VolumeLsCommandOptions{
Format: format,
Quiet: quiet,
}| return nil, err | ||
| } | ||
| return volumestore.New(dataStore, ns) | ||
| return volume.Store(ns, dataRoot, address) |
There was a problem hiding this comment.
seems this getVolumeStore is no longer needed as volume.Store should be preferred.
| return volume.Ls(options) | ||
| } | ||
|
|
||
| func getVolumes(cmd *cobra.Command) (map[string]native.Volume, error) { |
There was a problem hiding this comment.
is this getVolumes func still being used somewhere? This func seems no longer necessary since it only read 4 flags from cmd and call another func.
If it's not common enough (e.g., used a lot by other commands as well), then we should remove this helper and instead prefer calling volume.Volumes directly.
See #1680
Please let me know if I'm doing it incorrectly.