Files
homelab/components/kyverno/overlays/policies/application-field-validation.yaml
rblundon fe564d7227 Squashed 'cluster-config/' content from commit 654f2390
git-subtree-dir: cluster-config
git-subtree-split: 654f23903bd1f9a27a4810bd289d165b6cfdbb0c
2025-03-30 15:46:16 -05:00

58 lines
1.7 KiB
YAML

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: application-field-validation
annotations:
policies.kyverno.io/title: Application Field Validation
policies.kyverno.io/category: Argo
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Application
kyverno.io/kyverno-version: 1.6.0
policies.kyverno.io/minversion: 1.6.0
kyverno.io/kubernetes-version: "1.23"
policies.kyverno.io/description: >-
This policy performs some best practices validation on Application fields.
Path or chart must be specified but never both. And destination.name or
destination.server must be specified but never both.
spec:
validationFailureAction: audit
failurePolicy: Ignore
background: false
rules:
- name: source-path-chart
match:
any:
- resources:
kinds:
- Application
validate:
message: >-
`spec.source.path` OR `spec.source.chart` should be specified but never both.
anyPattern:
- spec:
source:
path: '?*'
X(chart):
- spec:
source:
X(path):
chart: '?*'
- name: destination-server-name
match:
any:
- resources:
kinds:
- Application
validate:
message: >-
`spec.destination.server` OR `spec.destination.name` should be specified but never both.
anyPattern:
- spec:
destination:
server: '?*'
X(name):
- spec:
destination:
X(server):
name: '?*'