Commit 7c3af58
Likios
fix: add CEL validation to require template field in RoleSpec
Add Kubernetes CEL (Common Expression Language) validation to ensure
that when Template is optional (pointer type), users cannot create
RoleBasedGroups without specifying a valid template.
The validation rule ensures:
1. The template field must be present (has(self.template))
2. The template must not be null (self.template != null)
3. The template must have at least one container
(size(self.template.spec.containers) > 0)
This prevents runtime errors where Pods would be created without any
containers, which would fail to schedule.
The CEL validation runs at the Kubernetes API server level when CRDs
are applied, providing early feedback to users before the resource
reaches the controller.
Fixes the issue where Template pointer migration made the field optional
without corresponding validation, potentially allowing invalid resources.1 parent 67e62e9 commit 7c3af58
File tree
5 files changed
+21
-0
lines changed- api/workloads/v1alpha1
- config/crd/bases
- deploy/helm/rbgs/crds
5 files changed
+21
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
148 | 149 | | |
149 | 150 | | |
150 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8925 | 8925 | | |
8926 | 8926 | | |
8927 | 8927 | | |
| 8928 | + | |
| 8929 | + | |
| 8930 | + | |
| 8931 | + | |
| 8932 | + | |
8928 | 8933 | | |
8929 | 8934 | | |
8930 | 8935 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9077 | 9077 | | |
9078 | 9078 | | |
9079 | 9079 | | |
| 9080 | + | |
| 9081 | + | |
| 9082 | + | |
| 9083 | + | |
| 9084 | + | |
9080 | 9085 | | |
9081 | 9086 | | |
9082 | 9087 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8925 | 8925 | | |
8926 | 8926 | | |
8927 | 8927 | | |
| 8928 | + | |
| 8929 | + | |
| 8930 | + | |
| 8931 | + | |
| 8932 | + | |
8928 | 8933 | | |
8929 | 8934 | | |
8930 | 8935 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9077 | 9077 | | |
9078 | 9078 | | |
9079 | 9079 | | |
| 9080 | + | |
| 9081 | + | |
| 9082 | + | |
| 9083 | + | |
| 9084 | + | |
9080 | 9085 | | |
9081 | 9086 | | |
9082 | 9087 | | |
| |||
0 commit comments