...
1
2
3
4 package krusty_test
5
6 import (
7 "testing"
8
9 "github.com/stretchr/testify/assert"
10 "github.com/stretchr/testify/require"
11 kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
12 )
13
14 func TestDuplicateKeys(t *testing.T) {
15 th := kusttest_test.MakeHarness(t)
16 th.WriteK(".", `
17 resources:
18 - resources.yaml
19 `)
20 th.WriteF("resources.yaml", `
21 apiVersion: apps/v1
22 kind: Deployment
23 metadata:
24 name: podinfo
25 spec:
26 selector:
27 matchLabels:
28 app: podinfo
29 template:
30 spec:
31 containers:
32 - name: podinfod
33 image: ghcr.io/stefanprodan/podinfo:5.0.3
34 command:
35 - ./podinfo
36 env:
37 - name: PODINFO_UI_COLOR
38 value: "#34577c"
39 env:
40 - name: PODINFO_UI_COLOR
41 value: "#34577c"
42 `)
43 m := th.Run(".", th.MakeDefaultOptions())
44 _, err := m.AsYaml()
45 require.Error(t, err)
46 assert.Contains(t, err.Error(), "mapping key \"env\" already defined")
47 }
48
View as plain text