Skip to content

Commit c541acc

Browse files
committed
rename functions
1 parent 897b751 commit c541acc

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

crates/stackable-operator/src/builder/pod/container.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use {k8s_openapi::api::core::v1::PodSpec, std::collections::BTreeMap};
1212

1313
use crate::{
1414
commons::product_image_selection::ResolvedProductImage,
15-
validation::{self, is_rfc_1123_label},
15+
validation::{self, is_lowercase_rfc_1123_label},
1616
};
1717

1818
type Result<T, E = Error> = std::result::Result<T, E>;
@@ -351,10 +351,11 @@ impl ContainerBuilder {
351351
}
352352
}
353353

354-
/// Validates a container name is according to the [RFC 1123](https://www.ietf.org/rfc/rfc1123.txt) standard.
354+
/// Validates a container name is according to the kubernetes-specific [RFC 1123](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names) standard.
355355
/// Returns [Ok] if the name is according to the standard, and [Err] if not.
356356
fn validate_container_name(container_name: &str) -> Result<()> {
357-
is_rfc_1123_label(container_name).context(InvalidContainerNameSnafu { container_name })
357+
is_lowercase_rfc_1123_label(container_name)
358+
.context(InvalidContainerNameSnafu { container_name })
358359
}
359360
}
360361

crates/stackable-operator/src/validation.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ pub fn is_domain(value: &str) -> Result {
219219
/// Tests for a string that conforms to the kubernetes-specific definition of a label in DNS (RFC 1123)
220220
/// used in Namespace names, see: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names
221221
/// Maximum label length supported by k8s is 63 characters (minimum required).
222-
pub fn is_rfc_1123_label(value: &str) -> Result {
222+
pub fn is_lowercase_rfc_1123_label(value: &str) -> Result {
223223
validate_all([
224224
validate_str_length(value, RFC_1123_LABEL_MAX_LENGTH),
225225
validate_str_regex(
@@ -233,7 +233,7 @@ pub fn is_rfc_1123_label(value: &str) -> Result {
233233

234234
/// Tests for a string that conforms to the kubernetes-specific definition of a subdomain in DNS (RFC 1123)
235235
/// used in ConfigMap names, see https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names
236-
pub fn is_rfc_1123_subdomain(value: &str) -> Result {
236+
pub fn is_lowercase_rfc_1123_subdomain(value: &str) -> Result {
237237
validate_all([
238238
validate_str_length(value, RFC_1123_SUBDOMAIN_MAX_LENGTH),
239239
validate_str_regex(
@@ -247,7 +247,7 @@ pub fn is_rfc_1123_subdomain(value: &str) -> Result {
247247

248248
/// Tests for a string that conforms to the kubernetes-specific definition of a label in DNS (RFC 1035)
249249
/// used in Service names, see: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#rfc-1035-label-names
250-
pub fn is_rfc_1035_label(value: &str) -> Result {
250+
pub fn is_lowercase_rfc_1035_label(value: &str) -> Result {
251251
validate_all([
252252
validate_str_length(value, RFC_1035_LABEL_MAX_LENGTH),
253253
validate_str_regex(
@@ -295,7 +295,7 @@ pub fn name_is_dns_label(name: &str, prefix: bool) -> Result {
295295
name = mask_trailing_dash(name);
296296
}
297297

298-
is_rfc_1035_label(&name)
298+
is_lowercase_rfc_1035_label(&name)
299299
}
300300

301301
/// Validates a namespace name.
@@ -373,7 +373,7 @@ mod tests {
373373
#[case("a$b")]
374374
#[case(&"a".repeat(254))]
375375
fn is_rfc_1123_subdomain_fail(#[case] value: &str) {
376-
assert!(is_rfc_1123_subdomain(value).is_err());
376+
assert!(is_lowercase_rfc_1123_subdomain(value).is_err());
377377
}
378378

379379
#[rstest]
@@ -419,7 +419,7 @@ mod tests {
419419
#[case("11.22.33.44.55")]
420420
#[case(&"a".repeat(253))]
421421
fn is_rfc_1123_subdomain_pass(#[case] value: &str) {
422-
assert!(is_rfc_1123_subdomain(value).is_ok());
422+
assert!(is_lowercase_rfc_1123_subdomain(value).is_ok());
423423
// Every valid RFC1123 is also a valid domain
424424
assert!(is_domain(value).is_ok());
425425
}
@@ -483,7 +483,7 @@ mod tests {
483483
#[case("1 2")]
484484
#[case(&"a".repeat(64))]
485485
fn is_rfc_1035_label_fail(#[case] value: &str) {
486-
assert!(is_rfc_1035_label(value).is_err());
486+
assert!(is_lowercase_rfc_1035_label(value).is_err());
487487
}
488488

489489
#[rstest]
@@ -495,6 +495,6 @@ mod tests {
495495
#[case("a--1--2--b")]
496496
#[case(&"a".repeat(63))]
497497
fn is_rfc_1035_label_pass(#[case] value: &str) {
498-
assert!(is_rfc_1035_label(value).is_ok());
498+
assert!(is_lowercase_rfc_1035_label(value).is_ok());
499499
}
500500
}

0 commit comments

Comments
 (0)