diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go index 10d433cf33..5e43f51361 100644 --- a/cmd/podman/common/completion.go +++ b/cmd/podman/common/completion.go @@ -224,6 +224,29 @@ func getImages(cmd *cobra.Command, toComplete string) ([]string, cobra.ShellComp return suggestions, cobra.ShellCompDirectiveNoFileComp } +func getManifestListMembers(cmd *cobra.Command, list, toComplete string) ([]string, cobra.ShellCompDirective) { + suggestions := []string{} + inspectOptions := entities.ManifestInspectOptions{} + + engine, err := setupImageEngine(cmd) + if err != nil { + cobra.CompErrorln(err.Error()) + return nil, cobra.ShellCompDirectiveNoFileComp + } + listData, err := engine.ManifestInspect(registry.GetContext(), list, inspectOptions) + if err != nil { + cobra.CompErrorln(err.Error()) + return nil, cobra.ShellCompDirectiveNoFileComp + } + + for _, item := range listData.Manifests { + if strings.HasPrefix(item.Digest.String(), toComplete) { + suggestions = append(suggestions, item.Digest.String()) + } + } + return suggestions, cobra.ShellCompDirectiveNoFileComp +} + func getSecrets(cmd *cobra.Command, toComplete string, cType completeType) ([]string, cobra.ShellCompDirective) { suggestions := []string{} @@ -611,7 +634,21 @@ func AutocompleteImages(cmd *cobra.Command, args []string, toComplete string) ([ return getImages(cmd, toComplete) } -// AutocompleteImageSearchFilters - Autocomplate `search --filter`. +// AutocompleteManifestListAndMember - Autocomplete names of manifest lists and digests of items in them. +func AutocompleteManifestListAndMember(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + if !validCurrentCmdLine(cmd, args, toComplete) { + return nil, cobra.ShellCompDirectiveNoFileComp + } + if len(args) == 0 { + return getImages(cmd, toComplete) + } + if len(args) == 1 { + return getManifestListMembers(cmd, args[0], toComplete) + } + return nil, cobra.ShellCompDirectiveNoFileComp +} + +// AutocompleteImageSearchFilters - Autocomplete `search --filter`. func AutocompleteImageSearchFilters(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return libimageDefine.SearchFilters, cobra.ShellCompDirectiveNoFileComp } diff --git a/cmd/podman/manifest/remove.go b/cmd/podman/manifest/remove.go index 3e1a4f3dbb..b69f9fbae0 100644 --- a/cmd/podman/manifest/remove.go +++ b/cmd/podman/manifest/remove.go @@ -10,12 +10,12 @@ import ( var ( removeCmd = &cobra.Command{ - Use: "remove LIST IMAGE", - Short: "Remove an entry from a manifest list or image index", - Long: "Removes an image from a manifest list or image index.", + Use: "remove LIST DIGEST", + Short: "Remove an item from a manifest list or image index", + Long: "Removes an item from a manifest list or image index.", RunE: remove, Args: cobra.ExactArgs(2), - ValidArgsFunction: common.AutocompleteImages, + ValidArgsFunction: common.AutocompleteManifestListAndMember, Example: `podman manifest remove mylist:v1.11 sha256:15352d97781ffdf357bf3459c037be3efac4133dc9070c2dce7eca7c05c3e736`, } ) diff --git a/docs/source/markdown/podman-manifest-remove.1.md b/docs/source/markdown/podman-manifest-remove.1.md index dfa6fe080b..c70cca159b 100644 --- a/docs/source/markdown/podman-manifest-remove.1.md +++ b/docs/source/markdown/podman-manifest-remove.1.md @@ -1,13 +1,13 @@ % podman-manifest-remove 1 ## NAME -podman\-manifest\-remove - Remove an image from a manifest list or image index +podman\-manifest\-remove - Remove an item from a manifest list or image index ## SYNOPSIS -**podman manifest remove** *listnameorindexname* *transport:details* +**podman manifest remove** *listnameorindexname* *digest* ## DESCRIPTION -Removes the image with the specified digest from the specified manifest list or image index. +Removes the item with the specified digest from the specified manifest list or image index. ## RETURN VALUE The list image's ID and the digest of the removed image's manifest. @@ -17,7 +17,7 @@ The list image's ID and the digest of the removed image's manifest. Remove specified digest from the manifest list: ``` podman manifest remove mylist:v1.11 sha256:cb8a924afdf0229ef7515d9e5b3024e23b3eb03ddbba287f4a19c6ac90b8d221 -e604eabaaee4858232761b4fef84e2316ed8f93e15eceafce845966ee3400036 :sha256:cb8a924afdf0229ef7515d9e5b3024e23b3eb03ddbba287f4a19c6ac90b8d221 +podman manifest remove e604eabaaee4858232761b4fef84e2316ed8f93e15eceafce845966ee3400036 sha256:cb8a924afdf0229ef7515d9e5b3024e23b3eb03ddbba287f4a19c6ac90b8d221 ``` ## SEE ALSO diff --git a/docs/source/markdown/podman-manifest.1.md b/docs/source/markdown/podman-manifest.1.md index 8b6ef489ad..635233dd9b 100644 --- a/docs/source/markdown/podman-manifest.1.md +++ b/docs/source/markdown/podman-manifest.1.md @@ -21,7 +21,7 @@ The `podman manifest` command provides subcommands which can be used to: | exists | [podman-manifest-exists(1)](podman-manifest-exists.1.md) | Check if the given manifest list exists in local storage | | inspect | [podman-manifest-inspect(1)](podman-manifest-inspect.1.md) | Display a manifest list or image index. | | push | [podman-manifest-push(1)](podman-manifest-push.1.md) | Push a manifest list or image index to a registry. | -| remove | [podman-manifest-remove(1)](podman-manifest-remove.1.md) | Remove an image from a manifest list or image index. | +| remove | [podman-manifest-remove(1)](podman-manifest-remove.1.md) | Remove an item from a manifest list or image index. | | rm | [podman-manifest-rm(1)](podman-manifest-rm.1.md) | Remove manifest list or image index from local storage. | ## EXAMPLES