Volume prune should not pass down the force flag

podman volume prune -f

Should just tell the prune command to not prompt for confirmation.
It should not be passing the prune flag into the API.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh 2020-10-01 06:31:36 -04:00
parent 556117c2e9
commit 686ea56480
No known key found for this signature in database
GPG Key ID: A2DF901DABE2C028
5 changed files with 10 additions and 14 deletions

View File

@ -29,10 +29,6 @@ var (
}
)
var (
pruneOptions entities.VolumePruneOptions
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
@ -40,12 +36,16 @@ func init() {
Parent: volumeCmd,
})
flags := pruneCommand.Flags()
flags.BoolVarP(&pruneOptions.Force, "force", "f", false, "Do not prompt for confirmation")
flags.BoolP("force", "f", false, "Do not prompt for confirmation")
}
func prune(cmd *cobra.Command, args []string) error {
// Prompt for confirmation if --force is not set
if !pruneOptions.Force {
force, err := cmd.Flags().GetBool("force")
if err != nil {
return err
}
if !force {
reader := bufio.NewReader(os.Stdin)
fmt.Println("WARNING! This will remove all volumes not used by at least one container.")
fmt.Print("Are you sure you want to continue? [y/N] ")
@ -57,7 +57,7 @@ func prune(cmd *cobra.Command, args []string) error {
return nil
}
}
responses, err := registry.ContainerEngine().VolumePrune(context.Background(), pruneOptions)
responses, err := registry.ContainerEngine().VolumePrune(context.Background())
if err != nil {
return err
}

View File

@ -78,6 +78,6 @@ type ContainerEngine interface {
VolumeCreate(ctx context.Context, opts VolumeCreateOptions) (*IDOrNameResponse, error)
VolumeInspect(ctx context.Context, namesOrIds []string, opts VolumeInspectOptions) ([]*VolumeInspectReport, error)
VolumeList(ctx context.Context, opts VolumeListOptions) ([]*VolumeListReport, error)
VolumePrune(ctx context.Context, opts VolumePruneOptions) ([]*VolumePruneReport, error)
VolumePrune(ctx context.Context) ([]*VolumePruneReport, error)
VolumeRm(ctx context.Context, namesOrIds []string, opts VolumeRmOptions) ([]*VolumeRmReport, error)
}

View File

@ -113,10 +113,6 @@ type VolumeInspectReport struct {
*VolumeConfigResponse
}
type VolumePruneOptions struct {
Force bool
}
type VolumePruneReport struct {
Err error
Id string //nolint

View File

@ -120,7 +120,7 @@ func (ic *ContainerEngine) VolumeInspect(ctx context.Context, namesOrIds []strin
return reports, nil
}
func (ic *ContainerEngine) VolumePrune(ctx context.Context, opts entities.VolumePruneOptions) ([]*entities.VolumePruneReport, error) {
func (ic *ContainerEngine) VolumePrune(ctx context.Context) ([]*entities.VolumePruneReport, error) {
return ic.pruneVolumesHelper(ctx)
}

View File

@ -56,7 +56,7 @@ func (ic *ContainerEngine) VolumeInspect(ctx context.Context, namesOrIds []strin
return reports, nil
}
func (ic *ContainerEngine) VolumePrune(ctx context.Context, opts entities.VolumePruneOptions) ([]*entities.VolumePruneReport, error) {
func (ic *ContainerEngine) VolumePrune(ctx context.Context) ([]*entities.VolumePruneReport, error) {
return volumes.Prune(ic.ClientCxt)
}