github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/cmd/podmanV2/pods/unpause.go (about) 1 package pods 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/containers/libpod/cmd/podmanV2/parse" 8 "github.com/containers/libpod/cmd/podmanV2/registry" 9 "github.com/containers/libpod/cmd/podmanV2/utils" 10 "github.com/containers/libpod/pkg/domain/entities" 11 "github.com/spf13/cobra" 12 ) 13 14 var ( 15 podUnpauseDescription = `The podman unpause command will unpause all "paused" containers assigned to the pod. 16 17 The pod name or ID can be used.` 18 unpauseCommand = &cobra.Command{ 19 Use: "unpause [flags] POD [POD...]", 20 Short: "Unpause one or more pods", 21 Long: podUnpauseDescription, 22 RunE: unpause, 23 Args: func(cmd *cobra.Command, args []string) error { 24 return parse.CheckAllLatestAndCIDFile(cmd, args, false, false) 25 }, 26 Example: `podman pod unpause podID1 podID2 27 podman pod unpause --all 28 podman pod unpause --latest`, 29 } 30 ) 31 32 var ( 33 unpauseOptions entities.PodunpauseOptions 34 ) 35 36 func init() { 37 registry.Commands = append(registry.Commands, registry.CliCommand{ 38 Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, 39 Command: unpauseCommand, 40 Parent: podCmd, 41 }) 42 flags := unpauseCommand.Flags() 43 flags.BoolVarP(&unpauseOptions.All, "all", "a", false, "Pause all running pods") 44 flags.BoolVarP(&unpauseOptions.Latest, "latest", "l", false, "Act on the latest pod podman is aware of") 45 if registry.IsRemote() { 46 _ = flags.MarkHidden("latest") 47 } 48 } 49 func unpause(cmd *cobra.Command, args []string) error { 50 var ( 51 errs utils.OutputErrors 52 ) 53 responses, err := registry.ContainerEngine().PodUnpause(context.Background(), args, unpauseOptions) 54 if err != nil { 55 return err 56 } 57 // in the cli, first we print out all the successful attempts 58 for _, r := range responses { 59 if len(r.Errs) == 0 { 60 fmt.Println(r.Id) 61 } else { 62 errs = append(errs, r.Errs...) 63 } 64 } 65 return errs.PrintErrors() 66 }