Back to Policies

Application Field Validation

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.

View on GitHub

Policy Definition

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
background: true
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): null
- spec:
source:
X(path): null
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): null
- spec:
destination:
X(server): null
name: "?*"

Related Policies