Merge pull request #16243 from alexlarsson/volume-create-ignore

Add podman volume create --ignore
This commit is contained in:
OpenShift Merge Robot
2022-10-26 15:00:51 -04:00
committed by GitHub
11 changed files with 80 additions and 18 deletions

View File

@ -30,8 +30,9 @@ var (
var (
createOpts = entities.VolumeCreateOptions{}
opts = struct {
Label []string
Opts []string
Label []string
Opts []string
Ignore bool
}{}
)
@ -53,6 +54,9 @@ func init() {
optFlagName := "opt"
flags.StringArrayVarP(&opts.Opts, optFlagName, "o", []string{}, "Set driver specific options (default [])")
_ = createCommand.RegisterFlagCompletionFunc(optFlagName, completion.AutocompleteNone)
ignoreFlagName := "ignore"
flags.BoolVar(&opts.Ignore, ignoreFlagName, false, "Don't fail if volume already exists")
}
func create(cmd *cobra.Command, args []string) error {
@ -62,6 +66,9 @@ func create(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
createOpts.Name = args[0]
}
createOpts.IgnoreIfExists = opts.Ignore
createOpts.Label, err = parse.GetAllLabels([]string{}, opts.Label)
if err != nil {
return fmt.Errorf("unable to process labels: %w", err)