Set field manager for kubectl diff --server-side.
Bonus: check diff only dry-runs without persisting. Co-authored-by: Takahiro HATORI <tahatori@zlab.co.jp>
This commit is contained in:

committed by
Julian V. Modesto

parent
e865c0b219
commit
bacc2c4960
@@ -29,8 +29,11 @@ run_kubectl_diff_tests() {
|
||||
# Test that it works when the live object doesn't exist
|
||||
output_message=$(! kubectl diff -f hack/testdata/pod.yaml)
|
||||
kube::test::if_has_string "${output_message}" 'test-pod'
|
||||
# Ensure diff only dry-runs and doesn't persist change
|
||||
kube::test::get_object_assert 'pod' "{{range.items}}{{ if eq ${id_field:?} \\\"test-pod\\\" }}found{{end}}{{end}}:" ':'
|
||||
|
||||
kubectl apply -f hack/testdata/pod.yaml
|
||||
kube::test::get_object_assert 'pod' "{{range.items}}{{ if eq ${id_field:?} \\\"test-pod\\\" }}found{{end}}{{end}}:" 'found:'
|
||||
|
||||
# Make sure that diffing the resource right after returns nothing (0 exit code).
|
||||
kubectl diff -f hack/testdata/pod.yaml
|
||||
@@ -41,6 +44,11 @@ run_kubectl_diff_tests() {
|
||||
output_message=$(kubectl diff -f hack/testdata/pod-changed.yaml || test $? -eq 1)
|
||||
kube::test::if_has_string "${output_message}" 'k8s.gcr.io/pause:3.0'
|
||||
|
||||
# Test found diff with server-side apply
|
||||
kubectl apply -f hack/testdata/pod.yaml
|
||||
output_message=$(kubectl diff -f hack/testdata/pod-changed.yaml --server-side --force-conflicts || test $? -eq 1)
|
||||
kube::test::if_has_string "${output_message}" 'k8s.gcr.io/pause:3.0'
|
||||
|
||||
# Test that we have a return code bigger than 1 if there is an error when diffing
|
||||
kubectl diff -f hack/testdata/invalid-pod.yaml || test $? -gt 1
|
||||
|
||||
|
Reference in New Issue
Block a user