Skip to content

Commit

Permalink
updated per code review
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Zheng <[email protected]>
  • Loading branch information
Two-Hearts committed Oct 31, 2022
1 parent cb82d6b commit 89858ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/notation/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ notation verify [--plugin-config <key>=<value>...] [--username <username>] [--pa
},
}
opts.ApplyFlags(command.Flags())
command.Flags().StringArrayVarP(&opts.pluginConfig, "plugin-config", "c", []string{}, "{key}={value} pairs that are passed as it is to a plugin, if the verification is associated with a verification plugin, refer plugin documentation to set appropriate values")
command.Flags().StringArrayVarP(&opts.pluginConfig, "plugin-config", "c", nil, "{key}={value} pairs that are passed as it is to a plugin, if the verification is associated with a verification plugin, refer plugin documentation to set appropriate values")
return command
}

Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var (
Usage: "{key}={value} pairs that are passed as it is to a plugin, refer plugin's documentation to set appropriate values",
}
SetPflagPluginConfig = func(fs *pflag.FlagSet, p *[]string) {
fs.StringArrayVarP(p, PflagPluginConfig.Name, PflagPluginConfig.Shorthand, []string{}, PflagPluginConfig.Usage)
fs.StringArrayVarP(p, PflagPluginConfig.Name, PflagPluginConfig.Shorthand, nil, PflagPluginConfig.Usage)
}
)

Expand All @@ -90,11 +90,11 @@ type KeyValueSlice interface {
func ParseFlagPluginConfig(config []string) (map[string]string, error) {
pluginConfig := make(map[string]string, len(config))
for _, pair := range config {
index := strings.Index(pair, "=")
if index <= 0 {
key, val, found := strings.Cut(pair, "=")
if !found || key == "" || val == "" {
return nil, fmt.Errorf("could not parse flag %s: key-value pair requires \"=\" as separator", PflagPluginConfig.Name)
}
pluginConfig[pair[:index]] = pair[index+1:]
pluginConfig[key] = val
}
return pluginConfig, nil
}

0 comments on commit 89858ee

Please sign in to comment.