diff --git a/config/crd/patches/validation_in_linodeclusters.yaml b/config/crd/patches/validation_in_linodeclusters.yaml index 6ec423dca..d0c66017c 100644 --- a/config/crd/patches/validation_in_linodeclusters.yaml +++ b/config/crd/patches/validation_in_linodeclusters.yaml @@ -6,4 +6,4 @@ type: string x-kubernetes-validations: - rule: 3 <= size(self) && size(self) <= 32 - message: linode nodebalancer labels must be between 3..32 characters + message: "custom validation: linode nodebalancer: labels must be between 3..32 characters" diff --git a/config/crd/patches/validation_in_linodemachines.yaml b/config/crd/patches/validation_in_linodemachines.yaml index a2f008594..c5a27e154 100644 --- a/config/crd/patches/validation_in_linodemachines.yaml +++ b/config/crd/patches/validation_in_linodemachines.yaml @@ -7,11 +7,15 @@ x-kubernetes-validations: - rule: 3 <= size(self) && size(self) <= 64 message: linode instance labels must be between 3..64 characters - # TODO: Combine these into one regex to validate ALL constraints on Linode instance labels at once? - # https://www.linode.com/docs/api/linode-instances/#linode-create - - rule: self.contains('^[a-z].*[a-z]$') - message: linode instance labels must begin and end with an alphanumeric character - - rule: self.contains('^[-_.a-z0-9]$') - message: linode instance labels may only consist of alphanumeric characters, hyphens (-), underscores (_) or periods (.) + - rule: self.matches('^[[:alnum:]]([-_.[:alnum:]]+[:alnum:])*$') + message: > + custom validation: linode instance: labels: + must begin and end with an alphanumeric character, + may only consist of alphanumeric characters, hyphens (-), underscores (_) or periods (.), + cannot have two hyphens (--), underscores (__) or periods (..) in a row; + regex used for validation is: '^[[:alnum:]]([-_.[:alnum:]]+[:alnum:])*$', + see: https://www.linode.com/docs/api/linode-instances/#linode-create + # TODO: We need to combine this into one regex to minimize time complexity 🥺 + # See: https://github.com/google/cel-spec/blob/master/doc/langdef.md#time-complexity - rule: "!(self.contains('--') || self.contains('__') || self.contains('..'))" - message: linode instance labels cannot have two hyphens (--), underscores (__) or periods (..) in a row + message: "custom validation: linode instance: labels cannot have two hyphens (--), underscores (__) or periods (..) in a row" diff --git a/config/crd/patches/validation_in_linodevpcs.yaml b/config/crd/patches/validation_in_linodevpcs.yaml index d190af7b0..116b831c0 100644 --- a/config/crd/patches/validation_in_linodevpcs.yaml +++ b/config/crd/patches/validation_in_linodevpcs.yaml @@ -7,9 +7,14 @@ x-kubernetes-validations: - rule: 1 <= size(self) && size(self) <= 64 message: vpc labels must be between 3..64 characters - # TODO: Combine these into one regex to validate ALL constraints on VPC labels at once? - # https://www.linode.com/docs/api/vpcs/#vpc-create - - rule: self.matches('^[-a-z0-9]$') - message: vpc labels can only contain ASCII letters, numbers, and hyphens (-) + - rule: self.matches('^[-[:alnum:]]+$') + message: > + custom validation: linode vpc: labels: + can only contain ASCII letters, numbers, and hyphens (-), + cannot have two consecutive hyphens (--); + regex used for validation is: '^[-[:alnum:]]+$', + see: https://www.linode.com/docs/api/vpcs/#vpc-create + # TODO: We need to combine this into one regex to minimize time complexity 🥺 + # See: https://github.com/google/cel-spec/blob/master/doc/langdef.md#time-complexity - rule: "!self.contains('--')" - message: vpc labels cannot have two consecutive hyphens (--) + message: "custom validation: linode vpc: labels cannot have two consecutive hyphens (--)"