Skip to content

Commit

Permalink
Merge pull request #11721 from Luap99/image-completion
Browse files Browse the repository at this point in the history
shell completion: do not show images without tag
  • Loading branch information
openshift-merge-robot authored Sep 23, 2021
2 parents 6b8371b + b6e5a49 commit c2beea6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
7 changes: 0 additions & 7 deletions cmd/podman/common/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,14 @@ func getImages(cmd *cobra.Command, toComplete string) ([]string, cobra.ShellComp
} else {
// suggested "registry.fedoraproject.org/f29/httpd:latest" as
// - "registry.fedoraproject.org/f29/httpd:latest"
// - "registry.fedoraproject.org/f29/httpd"
// - "f29/httpd:latest"
// - "f29/httpd"
// - "httpd:latest"
// - "httpd"
paths := strings.Split(repo, "/")
for i := range paths {
suggestionWithTag := strings.Join(paths[i:], "/")
if strings.HasPrefix(suggestionWithTag, toComplete) {
suggestions = append(suggestions, suggestionWithTag)
}
suggestionWithoutTag := strings.SplitN(strings.SplitN(suggestionWithTag, ":", 2)[0], "@", 2)[0]
if strings.HasPrefix(suggestionWithoutTag, toComplete) {
suggestions = append(suggestions, suggestionWithoutTag)
}
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions test/system/600-completion.bats
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,10 @@ function check_shell_completion() {
is "$output" ".*localhost/$random_image_name:$random_image_tag${nl}" \
"$* $cmd: actual image listed in suggestions"

# check that we complete the image with and without tag after at least one char is typed
# check that we complete the image with tag after at least one char is typed
run_completion "$@" $cmd "${extra_args[@]}" "${random_image_name:0:1}"
is "$output" ".*$random_image_name:$random_image_tag${nl}" \
"$* $cmd: image name:tag included in suggestions"
is "$output" ".*$random_image_name${nl}" \
"$* $cmd: image name(w/o tag) included in suggestions"

# check that we complete the image id after at least two chars are typed
run_completion "$@" $cmd "${extra_args[@]}" "${random_image_id:0:2}"
Expand Down

0 comments on commit c2beea6

Please sign in to comment.