Skip to content

Instantly share code, notes, and snippets.

@pivotaljohn
Created November 11, 2022 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pivotaljohn/62ed26b8de51183d2bd55cdbb80207cc to your computer and use it in GitHub Desktop.
Save pivotaljohn/62ed26b8de51183d2bd55cdbb80207cc to your computer and use it in GitHub Desktop.
Writing assertion without modifying target using an overlay.
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.subset({"kind": "ClusterRole", "metadata":{"name":"my-meow"}})
---
rules:
#@overlay/match by=overlay.all
-
#@overlay/assert via=lambda given,expects: (given[0]==expects[0], "Given '{}', expects '{}'".format(given[0],expects[0]))
resourceNames:
#@overlay/match by=overlay.all
- "meow"
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: my-meow
rules:
- apiGroups:
- cat.meow.io
resourceNames:
- meow
resources:
- meowResource
verbs:
- use
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment