WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 48c756b

Browse files
committed
Bugfix for pinned volumes in system reset
* Renames the global variable 'includePinned' to 'resetIncludePinned' to improve code clarity and prevent potential variable shadowing. * Adds SystemResetOptions type alias to the entities package. Signed-off-by: tobwen <[email protected]>
1 parent 3260d5b commit 48c756b

File tree

10 files changed

+18
-19
lines changed

10 files changed

+18
-19
lines changed

cmd/podman/common/completion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,6 +1933,7 @@ func AutocompleteVolumeFilters(cmd *cobra.Command, _ []string, toComplete string
19331933
"label=": nil,
19341934
"name=": func(s string) ([]string, cobra.ShellCompDirective) { return getVolumes(cmd, s) },
19351935
"opt=": nil,
1936+
"pinned=": getBoolCompletion,
19361937
"scope=": local,
19371938
"since=": getImg,
19381939
"until=": nil,

cmd/podman/system/prune.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ func prune(_ *cobra.Command, _ []string) error {
9393
if err != nil {
9494
return err
9595
}
96-
97-
// Set the include pinned flag for volume pruning
98-
if pruneOptions.Volume {
99-
pruneOptions.VolumePruneOptions.IncludePinned = includePinned
100-
}
10196

10297
response, err := registry.ContainerEngine().SystemPrune(context.Background(), pruneOptions)
10398
if err != nil {

cmd/podman/system/reset.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ var (
3333
ValidArgsFunction: completion.AutocompleteNone,
3434
}
3535

36-
forceFlag bool
37-
includePinned bool
36+
forceFlag bool
37+
resetIncludePinned bool
3838
)
3939

4040
func init() {
@@ -44,7 +44,7 @@ func init() {
4444
})
4545
flags := systemResetCommand.Flags()
4646
flags.BoolVarP(&forceFlag, "force", "f", false, "Do not prompt for confirmation")
47-
flags.BoolVar(&includePinned, "include-pinned", false, "Include pinned volumes in reset operation")
47+
flags.BoolVar(&resetIncludePinned, "include-pinned", false, "Include pinned volumes in reset operation")
4848
}
4949

5050
func reset(_ *cobra.Command, _ []string) {
@@ -57,7 +57,7 @@ func reset(_ *cobra.Command, _ []string) {
5757
if !forceFlag {
5858
reader := bufio.NewReader(os.Stdin)
5959
volumeMsg := " - all volumes (excluding pinned volumes)"
60-
if includePinned {
60+
if resetIncludePinned {
6161
volumeMsg = " - all volumes"
6262
}
6363
fmt.Printf(`WARNING! This will remove:
@@ -102,7 +102,7 @@ func reset(_ *cobra.Command, _ []string) {
102102

103103
// ContainerEngine() is unusable and shut down after this.
104104
resetOptions := entities.SystemResetOptions{
105-
IncludePinned: includePinned,
105+
IncludePinned: resetIncludePinned,
106106
}
107107
if err := registry.ContainerEngine().Reset(registry.Context(), resetOptions); err != nil {
108108
logrus.Error(err)

cmd/podman/volumes/prune.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ var (
3030
RunE: prune,
3131
ValidArgsFunction: completion.AutocompleteNone,
3232
}
33-
filter = []string{}
33+
filter = []string{}
34+
pruneOptions = entities.VolumePruneOptions{}
3435
)
3536

3637
func init() {
@@ -44,6 +45,7 @@ func init() {
4445
flags.StringArrayVar(&filter, filterFlagName, []string{}, "Provide filter values (e.g. 'label=<key>=<value>')")
4546
_ = pruneCommand.RegisterFlagCompletionFunc(filterFlagName, common.AutocompleteVolumeFilters)
4647
flags.BoolP("force", "f", false, "Do not prompt for confirmation")
48+
flags.BoolVar(&pruneOptions.IncludePinned, "include-pinned", false, "Do not prune pinned volumes")
4749
}
4850

4951
func prune(cmd *cobra.Command, _ []string) error {

docs/source/markdown/podman-volume-inspect.1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Valid placeholders for the Go template are listed below:
4444
| .Status ... | Status of the volume |
4545
| .StorageID | StorageID of the volume |
4646
| .Timeout | Timeout of the volume |
47-
| .UID | UID the volume was created with |
4847
| .Pinned | Whether the volume is pinned |
48+
| .UID | UID the volume was created with |
4949

5050
#### **--help**
5151

docs/source/markdown/podman-volume-ls.1.md.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ Valid placeholders for the Go template are listed below:
6060
| .Status ... | Status of the volume |
6161
| .StorageID | StorageID of the volume |
6262
| .Timeout | Timeout of the volume |
63-
| .UID | UID of volume |
6463
| .Pinned | Whether the volume is pinned |
64+
| .UID | UID of volume |
6565
| .VolumeConfigResponse ... | Don't use |
6666

6767
#### **--help**

docs/source/markdown/podman-volume-pin.1.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ By default, **podman volume pin** marks volumes as pinned. Use the **--unpin** o
1616

1717
## OPTIONS
1818

19-
#### **--unpin**
20-
21-
Remove the pinned status from the specified volumes instead of pinning them.
22-
2319
#### **--help**
2420

2521
Print usage statement.
2622

23+
#### **--unpin**
24+
25+
Remove the pinned status from the specified volumes instead of pinning them.
26+
2727
## EXAMPLES
2828

2929
Mark a volume as pinned.

pkg/domain/entities/system.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type (
1010
SystemPruneOptions = types.SystemPruneOptions
1111
SystemPruneReport = types.SystemPruneReport
1212
SystemMigrateOptions = types.SystemMigrateOptions
13+
SystemResetOptions = types.SystemResetOptions
1314
SystemCheckOptions = types.SystemCheckOptions
1415
SystemCheckReport = types.SystemCheckReport
1516
SystemDfOptions = types.SystemDfOptions

pkg/domain/infra/abi/volumes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func (ic *ContainerEngine) VolumeExport(_ context.Context, nameOrID string, opti
283283
}
284284

285285
func (ic *ContainerEngine) VolumePin(ctx context.Context, namesOrIds []string, opts entities.VolumePinOptions) ([]*entities.VolumePinReport, error) {
286-
var reports []*entities.VolumePinReport
286+
reports := make([]*entities.VolumePinReport, 0, len(namesOrIds))
287287

288288
for _, nameOrId := range namesOrIds {
289289
report := &entities.VolumePinReport{Id: nameOrId}

pkg/domain/infra/tunnel/volumes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (ic *ContainerEngine) VolumeImport(_ context.Context, nameOrID string, opti
122122
return volumes.Import(ic.ClientCtx, nameOrID, options.Input)
123123
}
124124

125-
func (ic *ContainerEngine) VolumePin(ctx context.Context, namesOrIds []string, opts entities.VolumePinOptions) ([]*entities.VolumePinReport, error) {
125+
func (ic *ContainerEngine) VolumePin(_ context.Context, namesOrIds []string, _ entities.VolumePinOptions) ([]*entities.VolumePinReport, error) {
126126
reports := make([]*entities.VolumePinReport, 0, len(namesOrIds))
127127
for _, nameOrId := range namesOrIds {
128128
report := &entities.VolumePinReport{

0 commit comments

Comments
 (0)