| 1 |
// Copyright 2020 The Kubernetes Authors. |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package krusty_test |
| 5 |
|
| 6 |
import ( |
| 7 |
"testing" |
| 8 |
|
| 9 |
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest" |
| 10 |
) |
| 11 |
|
| 12 |
// This test shows numeric-looking strings correctly handled as strings |
| 13 |
func TestNumericCommonLabels(t *testing.T) { |
| 14 |
th := kusttest_test.MakeHarness(t) |
| 15 |
|
| 16 |
// A basic deployment just used to put labels into |
| 17 |
th.WriteF("default/deployment.yaml", ` |
| 18 |
apiVersion: apps/v1 |
| 19 |
kind: Deployment |
| 20 |
metadata: |
| 21 |
name: the-deployment |
| 22 |
`) |
| 23 |
|
| 24 |
// Combine these custom transformers in one kustomization file. |
| 25 |
// This kustomization file has a string-valued commonLabel that |
| 26 |
// should always be quoted to remain a string |
| 27 |
th.WriteK("default", ` |
| 28 |
commonLabels: |
| 29 |
version: "1" |
| 30 |
resources: |
| 31 |
- deployment.yaml |
| 32 |
`) |
| 33 |
|
| 34 |
m := th.Run("default", th.MakeDefaultOptions()) |
| 35 |
th.AssertActualEqualsExpected(m, ` |
| 36 |
apiVersion: apps/v1 |
| 37 |
kind: Deployment |
| 38 |
metadata: |
| 39 |
labels: |
| 40 |
version: "1" |
| 41 |
name: the-deployment |
| 42 |
spec: |
| 43 |
selector: |
| 44 |
matchLabels: |
| 45 |
version: "1" |
| 46 |
template: |
| 47 |
metadata: |
| 48 |
labels: |
| 49 |
version: "1" |
| 50 |
`) |
| 51 |
} |