| 1 |
// Copyright 2022 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 |
func TestKustomizationMetadata(t *testing.T) { |
| 13 |
th := kusttest_test.MakeHarness(t) |
| 14 |
th.WriteF("/app/resources.yaml", ` |
| 15 |
apiVersion: apps/v1 |
| 16 |
kind: Deployment |
| 17 |
metadata: |
| 18 |
name: testing123 |
| 19 |
spec: |
| 20 |
replicas: 1 |
| 21 |
selector: null |
| 22 |
template: |
| 23 |
spec: |
| 24 |
containers: |
| 25 |
- name: event |
| 26 |
image: testing123 |
| 27 |
imagePullPolicy: IfNotPresent |
| 28 |
imagePullSecrets: []`) |
| 29 |
|
| 30 |
th.WriteK("/app", ` |
| 31 |
metadata: |
| 32 |
annotations: |
| 33 |
config.kubernetes.io/local-config: "true" |
| 34 |
labels: |
| 35 |
foo: bar |
| 36 |
name: test_kustomization |
| 37 |
resources: |
| 38 |
- resources.yaml |
| 39 |
`) |
| 40 |
|
| 41 |
m := th.Run("/app", th.MakeDefaultOptions()) |
| 42 |
th.AssertActualEqualsExpected(m, ` |
| 43 |
apiVersion: apps/v1 |
| 44 |
kind: Deployment |
| 45 |
metadata: |
| 46 |
name: testing123 |
| 47 |
spec: |
| 48 |
replicas: 1 |
| 49 |
selector: null |
| 50 |
template: |
| 51 |
spec: |
| 52 |
containers: |
| 53 |
- image: testing123 |
| 54 |
imagePullPolicy: IfNotPresent |
| 55 |
name: event |
| 56 |
imagePullSecrets: [] |
| 57 |
`) |
| 58 |
} |