summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2021-02-10 10:41:51 +0100
committerPaul Holzinger <paul.holzinger@web.de>2021-02-10 10:41:51 +0100
commit1cc387bf780d47a65bc82519e449cfbead70a015 (patch)
treeb0d5906ad9c4c6c378e22f34f267be1e2ff04598
parent055e2dda3a1888d319d542abe8735e791e736451 (diff)
downloadpodman-1cc387bf780d47a65bc82519e449cfbead70a015.tar.gz
podman-1cc387bf780d47a65bc82519e449cfbead70a015.tar.bz2
podman-1cc387bf780d47a65bc82519e449cfbead70a015.zip
Add shell completion tests for secrets
Add the SECRET keyword to the shell completion test. Also update the use line for podman secret create to use `NAME` instead of `SECRET`. This matches the other commands such as network/volume create. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
-rw-r--r--cmd/podman/secrets/create.go2
-rw-r--r--test/system/600-completion.bats22
2 files changed, 22 insertions, 2 deletions
diff --git a/cmd/podman/secrets/create.go b/cmd/podman/secrets/create.go
index e58ab57cd..ef5d703ca 100644
--- a/cmd/podman/secrets/create.go
+++ b/cmd/podman/secrets/create.go
@@ -16,7 +16,7 @@ import (
var (
createCmd = &cobra.Command{
- Use: "create [options] SECRET FILE|-",
+ Use: "create [options] NAME FILE|-",
Short: "Create a new secret",
Long: "Create a secret. Input can be a path to a file or \"-\" (read from stdin). Default driver is file (unencrypted).",
RunE: create,
diff --git a/test/system/600-completion.bats b/test/system/600-completion.bats
index 8cac2c9aa..fbb0da231 100644
--- a/test/system/600-completion.bats
+++ b/test/system/600-completion.bats
@@ -157,7 +157,17 @@ function check_shell_completion() {
# resume
;;&
- *PATH* | *CONTEXT* | *KUBEFILE* | *COMMAND* | *ARG...* | *URI*)
+ *SECRET*)
+ run_completion "$@" $cmd "${extra_args[@]}" ""
+ is "$output" ".*$random_secret_name${nl}" \
+ "$* $cmd: actual secret listed in suggestions"
+ _check_completion_end NoFileComp
+
+ match=true
+ # resume
+ ;;&
+
+ *PATH* | *CONTEXT* | *FILE* | *COMMAND* | *ARG...* | *URI*)
# default shell completion should be done for everything which accepts a path
run_completion "$@" $cmd "${extra_args[@]}" ""
@@ -232,6 +242,11 @@ function _check_completion_end() {
random_image_tag=$(random_string 5)
random_network_name=$(random_string 30)
random_volume_name=$(random_string 30)
+ random_secret_name=$(random_string 30)
+ random_secret_content=$(random_string 30)
+ secret_file=$PODMAN_TMPDIR/$(random_string 10)
+
+ echo $random_secret_content > $secret_file
# create a container for each state since some commands are only suggesting running container for example
run_podman create --name created-$random_container_name $IMAGE
@@ -263,6 +278,8 @@ function _check_completion_end() {
# create volume
run_podman volume create $random_volume_name
+ # create secret
+ run_podman secret create $random_secret_name $secret_file
# $PODMAN may be a space-separated string, e.g. if we include a --url.
local -a podman_as_array=($PODMAN)
@@ -274,6 +291,9 @@ function _check_completion_end() {
check_shell_completion
# cleanup
+ run_podman secret rm $random_secret_name
+ rm -f $secret_file
+
run_podman volume rm $random_volume_name
run_podman network rm $random_network_name