Skip to content

Commit

Permalink
Merge pull request containers#21248 from TomSweeneyRedHat/dev/tsweene…
Browse files Browse the repository at this point in the history
…y/kubecommafix

[v4.8] podman kube play: fix broken annotation parsing
  • Loading branch information
openshift-merge-bot[bot] authored Jan 15, 2024
2 parents dce6d7e + 03ba154 commit 721d9ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/podman/kube/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func play(cmd *cobra.Command, args []string) error {

for _, annotation := range playOptions.annotations {
splitN := strings.SplitN(annotation, "=", 2)
if len(splitN) > 2 {
if len(splitN) != 2 {
return fmt.Errorf("annotation %q must include an '=' sign", annotation)
}
if playOptions.Annotations == nil {
Expand Down
4 changes: 4 additions & 0 deletions test/system/700-play.bats
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ _EOF
run_podman inspect --format "{{ .Config.Annotations }}" test_pod-test
is "$output" ".*name:$RANDOMSTRING" "Annotation should be added to pod"

# invalid annotation
run_podman 125 kube play --annotation "val" $PODMAN_TMPDIR/test.yaml
assert "$output" == "Error: annotation \"val\" must include an '=' sign" "invalid annotation error"

run_podman stop -a -t 0
run_podman pod rm -t 0 -f test_pod
}
Expand Down

0 comments on commit 721d9ee

Please sign in to comment.