cli: podman kube play --annotation use StringArray()

This option accepts arbitrary input so we should allow commas in it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2023-12-08 18:01:29 +01:00
parent 47b65086ee
commit e916f49f0b
2 changed files with 5 additions and 2 deletions

View File

@ -98,7 +98,7 @@ func playFlags(cmd *cobra.Command) {
flags.SetNormalizeFunc(utils.AliasFlags)
annotationFlagName := "annotation"
flags.StringSliceVar(
flags.StringArrayVar(
&playOptions.annotations,
annotationFlagName, []string{},
"Add annotations to pods (key=value)",

View File

@ -435,11 +435,14 @@ _EOF
@test "podman kube --annotation" {
TESTDIR=$PODMAN_TMPDIR/testdir
RANDOMSTRING=$(random_string 15)
ANNOTATION_WITH_COMMA="comma,$(random_string 5)"
mkdir -p $TESTDIR
echo "$testYaml" | sed "s|TESTDIR|${TESTDIR}|g" > $PODMAN_TMPDIR/test.yaml
run_podman kube play --annotation "name=$RANDOMSTRING" $PODMAN_TMPDIR/test.yaml
run_podman kube play --annotation "name=$RANDOMSTRING" \
--annotation "anno=$ANNOTATION_WITH_COMMA" $PODMAN_TMPDIR/test.yaml
run_podman inspect --format "{{ .Config.Annotations }}" test_pod-test
is "$output" ".*name:$RANDOMSTRING" "Annotation should be added to pod"
is "$output" ".*anno:$ANNOTATION_WITH_COMMA" "Annotation with comma should be added to pod"
run_podman stop -a -t 0
run_podman pod rm -t 0 -f test_pod