github.1git.de/docker/cli@v26.1.3+incompatible/cli/command/manifest/rm.go (about) 1 package manifest 2 3 import ( 4 "context" 5 "strings" 6 7 "github.com/docker/cli/cli" 8 "github.com/docker/cli/cli/command" 9 "github.com/pkg/errors" 10 "github.com/spf13/cobra" 11 ) 12 13 func newRmManifestListCommand(dockerCli command.Cli) *cobra.Command { 14 cmd := &cobra.Command{ 15 Use: "rm MANIFEST_LIST [MANIFEST_LIST...]", 16 Short: "Delete one or more manifest lists from local storage", 17 Args: cli.RequiresMinArgs(1), 18 RunE: func(cmd *cobra.Command, args []string) error { 19 return runRm(cmd.Context(), dockerCli, args) 20 }, 21 } 22 23 return cmd 24 } 25 26 func runRm(_ context.Context, dockerCli command.Cli, targets []string) error { 27 var errs []string 28 for _, target := range targets { 29 targetRef, refErr := normalizeReference(target) 30 if refErr != nil { 31 errs = append(errs, refErr.Error()) 32 continue 33 } 34 _, searchErr := dockerCli.ManifestStore().GetList(targetRef) 35 if searchErr != nil { 36 errs = append(errs, searchErr.Error()) 37 continue 38 } 39 rmErr := dockerCli.ManifestStore().Remove(targetRef) 40 if rmErr != nil { 41 errs = append(errs, rmErr.Error()) 42 } 43 } 44 if len(errs) > 0 { 45 return errors.New(strings.Join(errs, "\n")) 46 } 47 return nil 48 }