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