Skip to content

Commit feecf60

Browse files
Add missing start and end tags to regular expressions
1 parent e51634c commit feecf60

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

rust/operator-binary/src/crd/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ attributed_string_type! {
457457
"Key in an OpenSearch keystore",
458458
"s3.client.default.access_key",
459459
(min_length = 1),
460-
(regex = "[A-Za-z0-9_\\-.]+")
460+
(regex = "^[A-Za-z0-9_\\-.]+$")
461461
}
462462

463463
#[cfg(test)]

rust/operator-binary/src/framework/macros/attributed_string_type.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,24 +377,27 @@ macro_rules! attributed_string_type {
377377
.combine(attributed_string_type!(@regex $($attribute)*))
378378
};
379379
(@regex is_rfc_1035_label_name $($attribute:tt)*) => {
380-
$crate::framework::macros::attributed_string_type::Regex::Expression(stackable_operator::validation::LOWERCASE_RFC_1035_LABEL_FMT)
380+
// see https://github.com/kubernetes/kubernetes/blob/v1.35.0/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L228
381+
$crate::framework::macros::attributed_string_type::Regex::Expression("^[a-z]([-a-z0-9]*[a-z0-9])?$")
381382
.combine(attributed_string_type!(@regex $($attribute)*))
382383
};
383384
(@regex is_rfc_1123_dns_subdomain_name $($attribute:tt)*) => {
384-
$crate::framework::macros::attributed_string_type::Regex::Expression(stackable_operator::validation::LOWERCASE_RFC_1123_SUBDOMAIN_FMT)
385+
// see https://github.com/kubernetes/kubernetes/blob/v1.35.0/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L193
386+
$crate::framework::macros::attributed_string_type::Regex::Expression("^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$")
385387
.combine(attributed_string_type!(@regex $($attribute)*))
386388
};
387389
(@regex is_rfc_1123_label_name $($attribute:tt)*) => {
388-
$crate::framework::macros::attributed_string_type::Regex::Expression(stackable_operator::validation::LOWERCASE_RFC_1123_LABEL_FMT)
390+
// see https://github.com/kubernetes/kubernetes/blob/v1.35.0/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L163
391+
$crate::framework::macros::attributed_string_type::Regex::Expression("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
389392
.combine(attributed_string_type!(@regex $($attribute)*))
390393
};
391394
(@regex is_valid_label_value $($attribute:tt)*) => {
392395
// regular expression from stackable_operator::kvp::label::LABEL_VALUE_REGEX
393-
$crate::framework::macros::attributed_string_type::Regex::Expression("[a-z0-9A-Z]([a-z0-9A-Z-_.]*[a-z0-9A-Z]+)?")
396+
$crate::framework::macros::attributed_string_type::Regex::Expression("^[a-z0-9A-Z]([a-z0-9A-Z-_.]*[a-z0-9A-Z]+)?$")
394397
.combine(attributed_string_type!(@regex $($attribute)*))
395398
};
396399
(@regex is_uid $($attribute:tt)*) => {
397-
$crate::framework::macros::attributed_string_type::Regex::Expression("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}")
400+
$crate::framework::macros::attributed_string_type::Regex::Expression("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")
398401
.combine(attributed_string_type!(@regex $($attribute)*))
399402
};
400403

0 commit comments

Comments
 (0)