-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #946 from Chandan-DK/other-policies-cel-part-1
feat: add other policies in CEL expressions - Part 1
- Loading branch information
Showing
107 changed files
with
3,962 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
other-cel/allowed-annotations/.chainsaw-test/chainsaw-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
creationTimestamp: null | ||
name: allowed-annotations | ||
spec: | ||
steps: | ||
- name: step-01 | ||
try: | ||
- apply: | ||
file: ../allowed-annotations.yaml | ||
- patch: | ||
resource: | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: allowed-annotations | ||
spec: | ||
validationFailureAction: Enforce | ||
- assert: | ||
file: policy-ready.yaml | ||
- name: step-02 | ||
try: | ||
- apply: | ||
file: pod-good.yaml | ||
- apply: | ||
file: podcontroller-good.yaml | ||
- apply: | ||
expect: | ||
- check: | ||
($error != null): true | ||
file: pod-bad.yaml | ||
- apply: | ||
expect: | ||
- check: | ||
($error != null): true | ||
file: podcontroller-bad.yaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
fluxcd.io/cat: meow | ||
name: badpod01 | ||
spec: | ||
containers: | ||
- name: pod01-01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
foo: bar | ||
fluxcd.io/foo: bar | ||
name: badpod02 | ||
spec: | ||
containers: | ||
- name: pod02-01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
fluxcd.io/bar: foo | ||
foo: bar | ||
name: badpod03 | ||
spec: | ||
containers: | ||
- name: pod-01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
fluxcd.io/bar: foo | ||
fluxcd.io/cow: moo | ||
name: badpod04 | ||
spec: | ||
containers: | ||
- name: pod-01 | ||
image: busybox:1.35 | ||
|
45 changes: 45 additions & 0 deletions
45
other-cel/allowed-annotations/.chainsaw-test/pod-good.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: goodpod01 | ||
spec: | ||
containers: | ||
- name: pod01-01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
foo: bar | ||
fluxcd.io/cow: ox | ||
fluxcd.io/dog: cat | ||
name: goodpod02 | ||
spec: | ||
containers: | ||
- name: pod02-01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
foo: bar | ||
name: goodpod03 | ||
spec: | ||
containers: | ||
- name: pod-01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
fluxcd.io/cow: moo | ||
foo: bar | ||
name: goodpod04 | ||
spec: | ||
containers: | ||
- name: pod-01 | ||
image: busybox:1.35 | ||
|
94 changes: 94 additions & 0 deletions
94
other-cel/allowed-annotations/.chainsaw-test/podcontroller-bad.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: busybox | ||
name: baddeployment01 | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: busybox | ||
strategy: {} | ||
template: | ||
metadata: | ||
annotations: | ||
foo: bar | ||
fluxcd.io/foo: bar | ||
labels: | ||
app: busybox | ||
spec: | ||
containers: | ||
- name: bb-01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: busybox | ||
name: baddeployment02 | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: busybox | ||
strategy: {} | ||
template: | ||
metadata: | ||
annotations: | ||
fluxcd.io/cat: meow | ||
fluxcd.io/cow: moo | ||
labels: | ||
app: busybox | ||
spec: | ||
containers: | ||
- name: bb-01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: badcronjob01 | ||
spec: | ||
schedule: "* * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
metadata: | ||
annotations: | ||
foo: bar | ||
fluxcd.io/foo: bar | ||
spec: | ||
containers: | ||
- name: hello | ||
image: busybox:1.35 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- "sleep" | ||
- "3600" | ||
restartPolicy: OnFailure | ||
--- | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: badcronjob02 | ||
spec: | ||
schedule: "* * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
metadata: | ||
annotations: | ||
fluxcd.io/cat: meow | ||
fluxcd.io/cow: moo | ||
spec: | ||
containers: | ||
- name: hello | ||
image: busybox:1.35 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- "sleep" | ||
- "3600" | ||
restartPolicy: OnFailure | ||
|
132 changes: 132 additions & 0 deletions
132
other-cel/allowed-annotations/.chainsaw-test/podcontroller-good.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: busybox | ||
name: gooddeployment01 | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: busybox | ||
strategy: {} | ||
template: | ||
metadata: | ||
annotations: | ||
foo: bar | ||
labels: | ||
app: busybox | ||
spec: | ||
containers: | ||
- name: bb-01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: busybox | ||
name: gooddeployment02 | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: busybox | ||
strategy: {} | ||
template: | ||
metadata: | ||
annotations: | ||
fluxcd.io/cow: moo | ||
fluxcd.io/dog: bark | ||
labels: | ||
app: busybox | ||
spec: | ||
containers: | ||
- name: bb-01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: busybox | ||
name: gooddeployment03 | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: busybox | ||
strategy: {} | ||
template: | ||
metadata: | ||
labels: | ||
app: busybox | ||
spec: | ||
containers: | ||
- name: bb-01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: goodcronjob01 | ||
spec: | ||
schedule: "* * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
metadata: | ||
annotations: | ||
foo: bar | ||
spec: | ||
containers: | ||
- name: hello | ||
image: busybox:1.35 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- "sleep" | ||
- "3600" | ||
restartPolicy: OnFailure | ||
--- | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: goodcronjob02 | ||
spec: | ||
schedule: "* * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
metadata: | ||
annotations: | ||
fluxcd.io/cow: moo | ||
fluxcd.io/dog: bark | ||
spec: | ||
containers: | ||
- name: hello | ||
image: busybox:1.35 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- "sleep" | ||
- "3600" | ||
restartPolicy: OnFailure | ||
--- | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: goodcronjob03 | ||
spec: | ||
schedule: "* * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: hello | ||
image: busybox:1.35 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- "sleep" | ||
- "3600" | ||
restartPolicy: OnFailure | ||
|
7 changes: 7 additions & 0 deletions
7
other-cel/allowed-annotations/.chainsaw-test/policy-ready.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: allowed-annotations | ||
status: | ||
ready: true | ||
|
Oops, something went wrong.