File tree Expand file tree Collapse file tree 2 files changed +104
-20
lines changed Expand file tree Collapse file tree 2 files changed +104
-20
lines changed Original file line number Diff line number Diff line change @@ -61,8 +61,6 @@ metadata:
61
61
apiVersion: example.com/v1alpha1
62
62
kind: MyResourceList
63
63
metadata:
64
- annotations:
65
- kustomize.config.k8s.io/convertToInlineList: "false"
66
64
name: test
67
65
rules: []
68
66
` )
@@ -77,8 +75,6 @@ metadata:
77
75
apiVersion: example.com/v1alpha1
78
76
kind: MyResourceList
79
77
metadata:
80
- annotations:
81
- kustomize.config.k8s.io/convertToInlineList: "false"
82
78
name: test
83
79
rules: []
84
80
` )
@@ -95,8 +91,6 @@ resources:
95
91
apiVersion: infra.protonbase.io/v1alpha1
96
92
kind: AccessWhiteList
97
93
metadata:
98
- annotations:
99
- kustomize.config.k8s.io/convertToInlineList: "false"
100
94
name: wlmls5769f
101
95
namespace: dc7i4hyxzw
102
96
spec:
@@ -110,13 +104,111 @@ spec:
110
104
apiVersion: infra.protonbase.io/v1alpha1
111
105
kind: AccessWhiteList
112
106
metadata:
113
- annotations:
114
- kustomize.config.k8s.io/convertToInlineList: "false"
115
107
name: wlmls5769f
116
108
namespace: dc7i4hyxzw
117
109
spec:
118
110
rules:
119
111
- sourceIps: 0.0.0.0/16
120
112
` )
121
113
114
+ }
115
+
116
+ func TestListToIndividualResources (t * testing.T ) {
117
+ th := kusttest_test .MakeHarness (t )
118
+ th .WriteK ("." , `
119
+ resources:
120
+ - list.yaml
121
+ ` )
122
+
123
+ th .WriteF ("list.yaml" , `
124
+ apiVersion: v1
125
+ kind: PodList
126
+ items:
127
+ - apiVersion: v1
128
+ kind: Pod
129
+ metadata:
130
+ name: my-pod-1
131
+ namespace: default
132
+ labels:
133
+ app: my-app
134
+ spec:
135
+ containers:
136
+ - name: my-container
137
+ image: nginx:1.19.10
138
+ ports:
139
+ - containerPort: 80
140
+ - apiVersion: v1
141
+ kind: Pod
142
+ metadata:
143
+ name: my-pod-2
144
+ namespace: default
145
+ labels:
146
+ app: my-app
147
+ spec:
148
+ containers:
149
+ - name: my-container
150
+ image: nginx:1.19.10
151
+ ports:
152
+ - containerPort: 80
153
+ - apiVersion: v1
154
+ kind: Pod
155
+ metadata:
156
+ name: my-pod-3
157
+ namespace: default
158
+ labels:
159
+ app: my-app
160
+ spec:
161
+ containers:
162
+ - name: my-container
163
+ image: nginx:1.19.10
164
+ ports:
165
+ - containerPort: 80
166
+ ` )
167
+
168
+ m := th .Run ("." , th .MakeDefaultOptions ())
169
+
170
+
171
+ th .AssertActualEqualsExpected (m , `
172
+ apiVersion: v1
173
+ kind: Pod
174
+ metadata:
175
+ labels:
176
+ app: my-app
177
+ name: my-pod-1
178
+ namespace: default
179
+ spec:
180
+ containers:
181
+ - image: nginx:1.19.10
182
+ name: my-container
183
+ ports:
184
+ - containerPort: 80
185
+ ---
186
+ apiVersion: v1
187
+ kind: Pod
188
+ metadata:
189
+ labels:
190
+ app: my-app
191
+ name: my-pod-2
192
+ namespace: default
193
+ spec:
194
+ containers:
195
+ - image: nginx:1.19.10
196
+ name: my-container
197
+ ports:
198
+ - containerPort: 80
199
+ ---
200
+ apiVersion: v1
201
+ kind: Pod
202
+ metadata:
203
+ labels:
204
+ app: my-app
205
+ name: my-pod-3
206
+ namespace: default
207
+ spec:
208
+ containers:
209
+ - image: nginx:1.19.10
210
+ name: my-container
211
+ ports:
212
+ - containerPort: 80
213
+ ` )
122
214
}
Original file line number Diff line number Diff line change 7
7
"encoding/json"
8
8
"fmt"
9
9
"log"
10
- "strconv"
11
10
"strings"
12
11
13
12
"sigs.k8s.io/kustomize/api/ifc"
@@ -190,16 +189,6 @@ func (rf *Factory) inlineAnyEmbeddedLists(
190
189
var n0 * yaml.RNode
191
190
for len (nodes ) > 0 {
192
191
n0 , nodes = nodes [0 ], nodes [1 :]
193
- annotations := n0 .GetAnnotations ()
194
- convertToInlineList , err := strconv .ParseBool (annotations ["kustomize.config.k8s.io/convertToInlineList" ])
195
- if err != nil {
196
- convertToInlineList = true
197
- }
198
- if ! convertToInlineList {
199
- // if the annotation is set to true, then we should not convert the list to inline
200
- result = append (result , n0 )
201
- continue
202
- }
203
192
kind := n0 .GetKind ()
204
193
if ! strings .HasSuffix (kind , "List" ) {
205
194
result = append (result , n0 )
@@ -213,7 +202,10 @@ func (rf *Factory) inlineAnyEmbeddedLists(
213
202
}
214
203
items , ok := m ["items" ]
215
204
if ! ok {
216
- // treat as an empty list
205
+ // Items field is not present.
206
+ // This is not a collections resource.
207
+ // read more https://kubernetes.io/docs/reference/using-api/api-concepts/#collections
208
+ result = append (result , n0 )
217
209
continue
218
210
}
219
211
slice , ok := items .([]interface {})
You can’t perform that action at this time.
0 commit comments