@@ -325,12 +325,86 @@ Successfully executed 5 function(s) in 2 package(s).
325
325
Note that the `ensure-name-substring` function is applied only to the
326
326
resources matching the selection criteria.
327
327
328
+ If you have resources with particular labels or annotations that you want to use to
329
+ select your resources, you can do so. For example, here is a function that will only
330
+ be applied to resources matching the label `foo : bar`:
331
+
332
+ ` ` ` yaml
333
+ apiVersion: kpt.dev/v1
334
+ kind: Kptfile
335
+ metadata:
336
+ name: wordpress
337
+ pipeline:
338
+ mutators:
339
+ - image: gcr.io/kpt-fn/set-annotations:v0.1
340
+ configMap:
341
+ tier: mysql
342
+ selectors:
343
+ - labels:
344
+ foo: bar
345
+ validators:
346
+ - image: gcr.io/kpt-fn/kubeval:v0.1
347
+ ` ` `
348
+
328
349
The following are the matchers you can specify in a selector :
329
350
330
351
1. `apiVersion` : ` apiVersion` field value of resources to be selected.
331
352
2. `kind` : ` kind` field value of resources to be selected.
332
353
3. `name` : ` metadata.name` field value of resources to be selected.
333
354
4. `namespace` : ` metadata.namespace` field of resources to be selected.
355
+ 5. `annotations` : resources with matching annotations will be selected.
356
+ 6. `labels` : resources with matching labels will be selected.
357
+
358
+ # ## Specifying exclusions
359
+
360
+ Similar to `selectors`, you can also specify resources that should be excluded from functions.
361
+
362
+ For example, you can exclude a resource if it has both kind "Deployment" and name "nginx" :
363
+
364
+ ` ` ` yaml
365
+ apiVersion: kpt.dev/v1
366
+ kind: Kptfile
367
+ metadata:
368
+ name: wordpress
369
+ pipeline:
370
+ mutators:
371
+ - image: gcr.io/kpt-fn/set-annotations:v0.1
372
+ configMap:
373
+ tier: mysql
374
+ exclude:
375
+ - kind: Deployment
376
+ name: nginx
377
+ validators:
378
+ - image: gcr.io/kpt-fn/kubeval:v0.1
379
+ ` ` `
380
+
381
+ This is distinct from the following, which excludes a resource if it has either kind "Deployment" or name "nginx" :
382
+
383
+ ` ` ` yaml
384
+ apiVersion: kpt.dev/v1
385
+ kind: Kptfile
386
+ metadata:
387
+ name: wordpress
388
+ pipeline:
389
+ mutators:
390
+ - image: gcr.io/kpt-fn/set-annotations:v0.1
391
+ configMap:
392
+ tier: mysql
393
+ exclude:
394
+ - kind: Deployment
395
+ - name: nginx
396
+ validators:
397
+ - image: gcr.io/kpt-fn/kubeval:v0.1
398
+ ` ` `
399
+
400
+ The following are the matchers you can specify in an exclusion :
401
+
402
+ 1. `apiVersion` : ` apiVersion` field value of resources to be excluded.
403
+ 2. `kind` : ` kind` field value of resources to be excluded.
404
+ 3. `name` : ` metadata.name` field value of resources to be excluded.
405
+ 4. `namespace` : ` metadata.namespace` field of resources to be excluded.
406
+ 5. `annotations` : resources with matching annotations will be excluded.
407
+ 6. `labels` : resources with matching labels will be excluded.
334
408
335
409
[chapter 2] : /book/02-concepts/03-functions
336
410
[render-doc] : /reference/cli/fn/render/
0 commit comments