mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 13:42:02 +00:00
Merge pull request #32599 from mikedanese/kubectl-selector
Automatic merge from submit-queue allow kubectl -f to filter by selector cc @kubernetes/kubectl Fixes #32544
This commit is contained in:
@@ -992,6 +992,21 @@ __EOF__
|
||||
# Clean up
|
||||
kubectl delete pods test-pod "${kube_flags[@]}"
|
||||
|
||||
|
||||
## kubectl apply -f with label selector should only apply matching objects
|
||||
# Pre-Condition: no POD exists
|
||||
kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" ''
|
||||
# apply
|
||||
kubectl apply -l unique-label=bingbang -f hack/testdata/filter "${kube_flags[@]}"
|
||||
# check right pod exists
|
||||
kube::test::get_object_assert 'pods selector-test-pod' "{{${labels_field}.name}}" 'selector-test-pod'
|
||||
# check wrong pod doesn't exist
|
||||
output_message=$(! kubectl get pods selector-test-pod-dont-apply 2>&1 "${kube_flags[@]}")
|
||||
kube::test::if_has_string "${output_message}" 'pods "selector-test-pod-dont-apply" not found'
|
||||
# cleanup
|
||||
kubectl delete pods selector-test-pod
|
||||
|
||||
|
||||
## kubectl run should create deployments or jobs
|
||||
# Pre-Condition: no Job exists
|
||||
kube::test::get_object_assert jobs "{{range.items}}{{$id_field}}:{{end}}" ''
|
||||
|
Reference in New Issue
Block a user