diff options
author | openshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com> | 2022-06-27 17:55:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-27 17:55:19 +0000 |
commit | 9c4b8a29b06c179725983e7fa8fadf7ee68d9863 (patch) | |
tree | cd2aa0d35a9479aa8f4afc0f17b941b5fb9c5882 /cmd/podman | |
parent | 278afae1de55a2951b2a4810b100d14e5647977b (diff) | |
parent | 2fab7d169b0714574b6620f454c1408bf8097d4f (diff) | |
download | podman-9c4b8a29b06c179725983e7fa8fadf7ee68d9863.tar.gz podman-9c4b8a29b06c179725983e7fa8fadf7ee68d9863.tar.bz2 podman-9c4b8a29b06c179725983e7fa8fadf7ee68d9863.zip |
Merge pull request #14713 from Luap99/volume-plugin
add podman volume reload to sync volume plugins
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/volumes/reload.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/cmd/podman/volumes/reload.go b/cmd/podman/volumes/reload.go new file mode 100644 index 000000000..d0d76fb88 --- /dev/null +++ b/cmd/podman/volumes/reload.go @@ -0,0 +1,52 @@ +package volumes + +import ( + "fmt" + + "github.com/containers/common/pkg/completion" + "github.com/containers/podman/v4/cmd/podman/registry" + "github.com/containers/podman/v4/cmd/podman/utils" + "github.com/containers/podman/v4/cmd/podman/validate" + "github.com/spf13/cobra" +) + +var ( + reloadDescription = `Check all configured volume plugins and update the libpod database with all available volumes. + + Existing volumes are also removed from the database when they are no longer present in the plugin.` + reloadCommand = &cobra.Command{ + Use: "reload", + Args: validate.NoArgs, + Short: "reload all volumes from volume plugins", + Long: reloadDescription, + RunE: reload, + ValidArgsFunction: completion.AutocompleteNone, + } +) + +func init() { + registry.Commands = append(registry.Commands, registry.CliCommand{ + Command: reloadCommand, + Parent: volumeCmd, + }) +} + +func reload(cmd *cobra.Command, args []string) error { + report, err := registry.ContainerEngine().VolumeReload(registry.Context()) + if err != nil { + return err + } + printReload("Added", report.Added) + printReload("Removed", report.Removed) + errs := (utils.OutputErrors)(report.Errors) + return errs.PrintErrors() +} + +func printReload(typ string, values []string) { + if len(values) > 0 { + fmt.Println(typ + ":") + for _, name := range values { + fmt.Println(name) + } + } +} |