Skip to content

Commit

Permalink
wait: don't lowercase condition in --for argument
Browse files Browse the repository at this point in the history
  • Loading branch information
soltysh committed Aug 12, 2024
1 parent 60c4c2b commit fad6c42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions staging/src/k8s.io/kubectl/pkg/cmd/wait/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ func conditionFuncFor(condition string, errOut io.Writer) (ConditionFunc, error)
case lowercaseCond == "create":
return IsCreated, nil

case strings.HasPrefix(lowercaseCond, "condition="):
conditionName := lowercaseCond[len("condition="):]
case strings.HasPrefix(condition, "condition="):
conditionName := strings.TrimPrefix(condition, "condition=")
conditionValue := "true"
if equalsIndex := strings.Index(conditionName, "="); equalsIndex != -1 {
conditionValue = conditionName[equalsIndex+1:]
Expand All @@ -209,8 +209,8 @@ func conditionFuncFor(condition string, errOut io.Writer) (ConditionFunc, error)
errOut: errOut,
}.IsConditionMet, nil

case strings.HasPrefix(lowercaseCond, "jsonpath="):
jsonPathInput := strings.TrimPrefix(lowercaseCond, "jsonpath=")
case strings.HasPrefix(condition, "jsonpath="):
jsonPathInput := strings.TrimPrefix(condition, "jsonpath=")
jsonPathExp, jsonPathValue, err := processJSONPathInput(jsonPathInput)
if err != nil {
return nil, err
Expand Down
6 changes: 6 additions & 0 deletions test/cmd/wait.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ run_wait_tests() {
# Post-Condition: Wait failed
kube::test::if_has_string "${output_message}" 'timed out'

# wait with mixed case jsonpath
output_message=$(kubectl wait --for=jsonpath=.status.unavailableReplicas=1 deploy/test-1 2>&1)

# Post-Condition: Wait failed
kube::test::if_has_string "${output_message}" 'test-1 condition met'

# Delete all deployments async to kubectl wait
( sleep 2 && kubectl delete deployment --all ) &

Expand Down

0 comments on commit fad6c42

Please sign in to comment.