Skip to content

Commit 912eb90

Browse files
committed
chore: add policy to prevent changing personal organization display name
1 parent b194b86 commit 912eb90

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

config/default/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ resources:
1818
#- ../crd
1919
- ../rbac
2020
- ../manager
21+
- ../policies
2122
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
2223
# crd/kustomization.yaml
2324
#- ../webhook

config/policies/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
resources:
2+
- validation/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
resources:
2+
- organization-update-policy.yaml
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: admissionregistration.k8s.io/v1
2+
kind: ValidatingAdmissionPolicy
3+
metadata:
4+
name: "organization-update-policy.miloapis.com"
5+
spec:
6+
failurePolicy: Fail
7+
matchConstraints:
8+
resourceRules:
9+
- apiGroups: ["resourcemanager.miloapis.com"]
10+
apiVersions: ["v1alpha1"]
11+
operations: ["UPDATE"]
12+
resources: ["organizations"]
13+
validations:
14+
- expression: "object.spec.type != 'Personal' || oldObject.metadata.annotations.get('kubernetes.io/display-name', '') == object.metadata.annotations.get('kubernetes.io/display-name', '')"
15+
message: "The display name of a personal organization cannot be changed."

0 commit comments

Comments
 (0)