Fix 3424 by avoiding a JSON round trip

This commit is contained in:
monopole
2021-01-08 17:26:33 -08:00
parent 497e8038a3
commit 14a1a0e4a8
4 changed files with 36 additions and 7 deletions

View File

@@ -4,6 +4,7 @@
package krusty_test
import (
"fmt"
"testing"
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
@@ -12,6 +13,7 @@ import (
// Demonstrate unwanted quotes added to an integer by a strategic merge patch.
func TestIssue3424Basics(t *testing.T) {
th := kusttest_test.MakeHarness(t)
opts := th.MakeDefaultOptions()
th.WriteF("pdb-patch.yaml", `
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
@@ -51,8 +53,8 @@ patches:
resources:
- my_file.yaml
`)
m := th.Run(".", th.MakeDefaultOptions())
th.AssertActualEqualsExpected(m, `
m := th.Run(".", opts)
expFmt := `
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
@@ -60,7 +62,7 @@ metadata:
faceit-pdb: default
name: championships-api
spec:
maxUnavailable: "1"
maxUnavailable: %s
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
@@ -69,6 +71,9 @@ metadata:
faceit-pdb: default
name: championships-api-2
spec:
maxUnavailable: "1"
`)
maxUnavailable: %s
`
th.AssertActualEqualsExpected(m, opts.IfApiMachineryElseKyaml(
fmt.Sprintf(expFmt, `"1"`, `"1"`),
fmt.Sprintf(expFmt, `1`, `1`)))
}