Open lavalamp opened 2 years ago
cc @jpbetz @apelisse
This is a good motivating example for adding a hash
function to the CEL library. We can add that.
The sanitation can probably be expressed as a RE2 regex replace, maybe combined with substring
to cap the length?
/assign
/triage accepted
/cc @DangerOnTheRanger
This issue has not been updated in over 1 year, and should be re-triaged.
You can:
/triage accepted
(org members only)/close
For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/
/remove-triage accepted
/triage accepted
Scenario: My CRD has fields x, y, and z. I want to ensure that within a given namespace, no two instances of this CRD have the same set of values for those fields.
Solution 1: Require that .metadata.name be x+y+z. (Add a x-kubernetes-validations to the root of the object, and do something like
"[self.metadata.name] == self.spec.x + self.spec.y + self.spec.z"
) Problem 1: The fields might be too long, or not match the rules about names (contain "/" characters, etc)Solution 2: Require that name be of the form sanitized_fields(x,y,z)+unique_hash(x,y,z). Where:
The request here is to add a function or set of functions callable from CEL to do this sanitizing/hashing. Ideally we would like the code to be known ASAP so that people can use them in validating webhooks today and move to CEL when it is available.
For bonus points we would like to default the name to the correct value if it is blank, since it may be hard for clients to determine the correct value. (I suspect this isn't possible with our defaulting stack, but maybe I'm wrong.)
We need the error message to report the expected name, so that at least clients could e.g. send a dry-run POST request to figure out the correct name and then use it in the real request.
/sig api-machinery