mirror of
https://github.com/containers/podman.git
synced 2025-10-27 03:06:22 +08:00
Merge pull request #16243 from alexlarsson/volume-create-ignore
Add podman volume create --ignore
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user