File tree Expand file tree Collapse file tree 2 files changed +70
-0
lines changed Expand file tree Collapse file tree 2 files changed +70
-0
lines changed Original file line number Diff line number Diff line change @@ -1282,6 +1282,72 @@ metadata:
1282
1282
}
1283
1283
}
1284
1284
1285
+ func TestSinglePatchWithMultiplePatchDeleteDirectives (t * testing.T ) {
1286
+ th := kusttest_test .MakeHarness (t )
1287
+ makeCommonFilesForMultiplePatchTests (th )
1288
+ th .WriteF ("overlay/staging/deployment-patch1.yaml" , `
1289
+ $patch: delete
1290
+ apiVersion: apps/v1
1291
+ kind: Deployment
1292
+ metadata:
1293
+ name: nginx
1294
+ ---
1295
+ $patch: delete
1296
+ apiVersion: v1
1297
+ kind: Service
1298
+ metadata:
1299
+ name: nginx
1300
+ ` )
1301
+ th .WriteF ("overlay/staging/deployment-patch2.yaml" , `
1302
+ apiVersion: v1
1303
+ kind: ConfigMap
1304
+ metadata:
1305
+ name: configmap-in-base
1306
+ data:
1307
+ foo2: bar2
1308
+ ` )
1309
+ th .WriteK ("overlay/staging" , `
1310
+ namePrefix: staging-
1311
+ commonLabels:
1312
+ env: staging
1313
+ patches:
1314
+ - path: deployment-patch1.yaml
1315
+ - path: deployment-patch2.yaml
1316
+ resources:
1317
+ - ../../base
1318
+ configMapGenerator:
1319
+ - name: configmap-in-overlay
1320
+ literals:
1321
+ - hello=world
1322
+ ` )
1323
+ m := th .Run ("overlay/staging" , th .MakeDefaultOptions ())
1324
+ th .AssertActualEqualsExpected (m , `
1325
+ apiVersion: v1
1326
+ data:
1327
+ foo: bar
1328
+ foo2: bar2
1329
+ kind: ConfigMap
1330
+ metadata:
1331
+ annotations:
1332
+ note: This is a test annotation
1333
+ labels:
1334
+ app: mynginx
1335
+ env: staging
1336
+ org: example.com
1337
+ team: foo
1338
+ name: staging-team-foo-configmap-in-base-8cmgkm9f44
1339
+ ---
1340
+ apiVersion: v1
1341
+ data:
1342
+ hello: world
1343
+ kind: ConfigMap
1344
+ metadata:
1345
+ labels:
1346
+ env: staging
1347
+ name: staging-configmap-in-overlay-dc6fm46dhm
1348
+ ` )
1349
+ }
1350
+
1285
1351
func TestMultiplePatchesBothWithPatchDeleteDirective (t * testing.T ) {
1286
1352
th := kusttest_test .MakeHarness (t )
1287
1353
makeCommonFilesForMultiplePatchTests (th )
Original file line number Diff line number Diff line change @@ -181,6 +181,10 @@ func (m *resWrangler) GetMatchingResourcesByAnyId(
181
181
matches IdMatcher ) []* resource.Resource {
182
182
var result []* resource.Resource
183
183
for _ , r := range m .rList {
184
+ if r .RNode .IsNilOrEmpty () {
185
+ continue
186
+ }
187
+
184
188
for _ , id := range append (r .PrevIds (), r .CurId ()) {
185
189
if matches (id ) {
186
190
result = append (result , r )
You can’t perform that action at this time.
0 commit comments