Skip to content

Commit 2c8db85

Browse files
committed
fix: adapt pathes
1 parent a3829c4 commit 2c8db85

3 files changed

Lines changed: 55 additions & 60 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use stackable_operator::{
1111
};
1212
use strum::{EnumDiscriminants, IntoStaticStr};
1313

14-
use crate::framework::types::kubernetes::{ConfigMapKey, ConfigMapName, ContainerName};
14+
use crate::v2::types::kubernetes::{ConfigMapKey, ConfigMapName, ContainerName};
1515

1616
#[derive(Snafu, Debug, EnumDiscriminants)]
1717
#[strum_discriminants(derive(IntoStaticStr))]

crates/stackable-operator/src/v2/macros/attributed_string_type.rs

Lines changed: 50 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use strum::{EnumDiscriminants, IntoStaticStr};
33

44
/// Maximum length of label values
55
///
6-
/// Duplicates the private constant [`stackable_operator::kvp::LABEL_VALUE_MAX_LEN`]
6+
/// Duplicates the private constant [`crate::kvp::LABEL_VALUE_MAX_LEN`]
77
pub const MAX_LABEL_VALUE_LENGTH: usize = 63;
88

99
#[derive(Debug, EnumDiscriminants, Snafu)]
@@ -23,24 +23,16 @@ pub enum Error {
2323
RegexNotMatched { value: String, regex: &'static str },
2424

2525
#[snafu(display("not a valid label value"))]
26-
InvalidLabelValue {
27-
source: stackable_operator::kvp::LabelValueError,
28-
},
26+
InvalidLabelValue { source: crate::kvp::LabelValueError },
2927

3028
#[snafu(display("not a valid label name as defined in RFC 1035"))]
31-
InvalidRfc1035LabelName {
32-
source: stackable_operator::validation::Errors,
33-
},
29+
InvalidRfc1035LabelName { source: crate::validation::Errors },
3430

3531
#[snafu(display("not a valid DNS subdomain name as defined in RFC 1123"))]
36-
InvalidRfc1123DnsSubdomainName {
37-
source: stackable_operator::validation::Errors,
38-
},
32+
InvalidRfc1123DnsSubdomainName { source: crate::validation::Errors },
3933

4034
#[snafu(display("not a valid label name as defined in RFC 1123"))]
41-
InvalidRfc1123LabelName {
42-
source: stackable_operator::validation::Errors,
43-
},
35+
InvalidRfc1123LabelName { source: crate::validation::Errors },
4436

4537
#[snafu(display("not a valid UUID"))]
4638
InvalidUid { source: uuid::Error },
@@ -106,10 +98,10 @@ macro_rules! attributed_string_type {
10698
/// The regular expression
10799
///
108100
/// This field is not meant to be used outside of this macro.
109-
pub const REGEX: $crate::framework::macros::attributed_string_type::Regex = attributed_string_type!(@regex $($attribute)*);
101+
pub const REGEX: $crate::v2::macros::attributed_string_type::Regex = attributed_string_type!(@regex $($attribute)*);
110102
}
111103

112-
impl stackable_operator::config::merge::Atomic for $name {}
104+
impl crate::config::merge::Atomic for $name {}
113105

114106
impl std::fmt::Display for $name {
115107
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@@ -136,7 +128,7 @@ macro_rules! attributed_string_type {
136128
}
137129

138130
impl std::str::FromStr for $name {
139-
type Err = $crate::framework::macros::attributed_string_type::Error;
131+
type Err = $crate::v2::macros::attributed_string_type::Error;
140132

141133
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
142134
// ResultExt::context is used on most but not all usages of this macro
@@ -169,13 +161,13 @@ macro_rules! attributed_string_type {
169161
}
170162

171163
// The JsonSchema implementation requires `max_length`.
172-
impl stackable_operator::schemars::JsonSchema for $name {
164+
impl crate::schemars::JsonSchema for $name {
173165
fn schema_name() -> std::borrow::Cow<'static, str> {
174166
std::stringify!($name).into()
175167
}
176168

177-
fn json_schema(_generator: &mut stackable_operator::schemars::generate::SchemaGenerator) -> stackable_operator::schemars::Schema {
178-
stackable_operator::schemars::json_schema!({
169+
fn json_schema(_generator: &mut crate::schemars::generate::SchemaGenerator) -> crate::schemars::Schema {
170+
crate::schemars::json_schema!({
179171
"type": "string",
180172
"minLength": $name::MIN_LENGTH,
181173
"maxLength": if $name::MAX_LENGTH != usize::MAX {
@@ -185,7 +177,7 @@ macro_rules! attributed_string_type {
185177
None
186178
},
187179
"pattern": match $name::REGEX {
188-
$crate::framework::macros::attributed_string_type::Regex::Expression(regex) => Some(regex),
180+
$crate::v2::macros::attributed_string_type::Regex::Expression(regex) => Some(regex),
189181
_ => None
190182
}
191183
})
@@ -214,7 +206,7 @@ macro_rules! attributed_string_type {
214206
let length = $s.len() as usize;
215207
snafu::ensure!(
216208
length >= $name::MIN_LENGTH,
217-
$crate::framework::macros::attributed_string_type::MinimumLengthNotMetSnafu {
209+
$crate::v2::macros::attributed_string_type::MinimumLengthNotMetSnafu {
218210
length,
219211
min_length: $name::MIN_LENGTH,
220212
}
@@ -224,36 +216,36 @@ macro_rules! attributed_string_type {
224216
let length = $s.len() as usize;
225217
snafu::ensure!(
226218
length <= $name::MAX_LENGTH,
227-
$crate::framework::macros::attributed_string_type::LengthExceededSnafu {
219+
$crate::v2::macros::attributed_string_type::LengthExceededSnafu {
228220
length,
229221
max_length: $name::MAX_LENGTH,
230222
}
231223
);
232224
};
233225
(@from_str $name:ident, $s:expr, (regex = $regex:expr)) => {
234-
let regex = regex::Regex::new($regex).context($crate::framework::macros::attributed_string_type::InvalidRegexSnafu)?;
226+
let regex = regex::Regex::new($regex).context($crate::v2::macros::attributed_string_type::InvalidRegexSnafu)?;
235227
snafu::ensure!(
236228
regex.is_match($s),
237-
$crate::framework::macros::attributed_string_type::RegexNotMatchedSnafu {
229+
$crate::v2::macros::attributed_string_type::RegexNotMatchedSnafu {
238230
value: $s,
239231
regex: $regex
240232
}
241233
);
242234
};
243235
(@from_str $name:ident, $s:expr, is_rfc_1035_label_name) => {
244-
stackable_operator::validation::is_lowercase_rfc_1035_label($s).context($crate::framework::macros::attributed_string_type::InvalidRfc1035LabelNameSnafu)?;
236+
crate::validation::is_lowercase_rfc_1035_label($s).context($crate::v2::macros::attributed_string_type::InvalidRfc1035LabelNameSnafu)?;
245237
};
246238
(@from_str $name:ident, $s:expr, is_rfc_1123_dns_subdomain_name) => {
247-
stackable_operator::validation::is_lowercase_rfc_1123_subdomain($s).context($crate::framework::macros::attributed_string_type::InvalidRfc1123DnsSubdomainNameSnafu)?;
239+
crate::validation::is_lowercase_rfc_1123_subdomain($s).context($crate::v2::macros::attributed_string_type::InvalidRfc1123DnsSubdomainNameSnafu)?;
248240
};
249241
(@from_str $name:ident, $s:expr, is_rfc_1123_label_name) => {
250-
stackable_operator::validation::is_lowercase_rfc_1123_label($s).context($crate::framework::macros::attributed_string_type::InvalidRfc1123LabelNameSnafu)?;
242+
crate::validation::is_lowercase_rfc_1123_label($s).context($crate::v2::macros::attributed_string_type::InvalidRfc1123LabelNameSnafu)?;
251243
};
252244
(@from_str $name:ident, $s:expr, is_valid_label_value) => {
253-
stackable_operator::kvp::LabelValue::from_str($s).context($crate::framework::macros::attributed_string_type::InvalidLabelValueSnafu)?;
245+
crate::kvp::LabelValue::from_str($s).context($crate::v2::macros::attributed_string_type::InvalidLabelValueSnafu)?;
254246
};
255247
(@from_str $name:ident, $s:expr, is_uid) => {
256-
uuid::Uuid::try_parse($s).context($crate::framework::macros::attributed_string_type::InvalidUidSnafu)?;
248+
uuid::Uuid::try_parse($s).context($crate::v2::macros::attributed_string_type::InvalidUidSnafu)?;
257249
};
258250

259251
// MIN_LENGTH
@@ -263,7 +255,7 @@ macro_rules! attributed_string_type {
263255
0
264256
};
265257
(@min_length (min_length = $min_length:expr) $($attribute:tt)*) => {
266-
$crate::framework::macros::attributed_string_type::max(
258+
$crate::v2::macros::attributed_string_type::max(
267259
$min_length,
268260
attributed_string_type!(@min_length $($attribute)*)
269261
)
@@ -277,31 +269,31 @@ macro_rules! attributed_string_type {
277269
attributed_string_type!(@min_length $($attribute)*)
278270
};
279271
(@min_length is_rfc_1035_label_name $($attribute:tt)*) => {
280-
$crate::framework::macros::attributed_string_type::max(
272+
$crate::v2::macros::attributed_string_type::max(
281273
1,
282274
attributed_string_type!(@min_length $($attribute)*)
283275
)
284276
};
285277
(@min_length is_rfc_1123_dns_subdomain_name $($attribute:tt)*) => {
286-
$crate::framework::macros::attributed_string_type::max(
278+
$crate::v2::macros::attributed_string_type::max(
287279
1,
288280
attributed_string_type!(@min_length $($attribute)*)
289281
)
290282
};
291283
(@min_length is_rfc_1123_label_name $($attribute:tt)*) => {
292-
$crate::framework::macros::attributed_string_type::max(
284+
$crate::v2::macros::attributed_string_type::max(
293285
1,
294286
attributed_string_type!(@min_length $($attribute)*)
295287
)
296288
};
297289
(@min_length is_valid_label_value $($attribute:tt)*) => {
298-
$crate::framework::macros::attributed_string_type::max(
290+
$crate::v2::macros::attributed_string_type::max(
299291
1,
300292
attributed_string_type!(@min_length $($attribute)*)
301293
)
302294
};
303295
(@min_length is_uid $($attribute:tt)*) => {
304-
$crate::framework::macros::attributed_string_type::max(
296+
$crate::v2::macros::attributed_string_type::max(
305297
uuid::fmt::Hyphenated::LENGTH,
306298
attributed_string_type!(@min_length $($attribute)*)
307299
)
@@ -318,7 +310,7 @@ macro_rules! attributed_string_type {
318310
attributed_string_type!(@max_length $($attribute)*)
319311
};
320312
(@max_length (max_length = $max_length:expr) $($attribute:tt)*) => {
321-
$crate::framework::macros::attributed_string_type::min(
313+
$crate::v2::macros::attributed_string_type::min(
322314
$max_length,
323315
attributed_string_type!(@max_length $($attribute)*)
324316
)
@@ -328,31 +320,31 @@ macro_rules! attributed_string_type {
328320
attributed_string_type!(@max_length $($attribute)*)
329321
};
330322
(@max_length is_rfc_1035_label_name $($attribute:tt)*) => {
331-
$crate::framework::macros::attributed_string_type::min(
332-
stackable_operator::validation::RFC_1035_LABEL_MAX_LENGTH,
323+
$crate::v2::macros::attributed_string_type::min(
324+
crate::validation::RFC_1035_LABEL_MAX_LENGTH,
333325
attributed_string_type!(@max_length $($attribute)*)
334326
)
335327
};
336328
(@max_length is_rfc_1123_dns_subdomain_name $($attribute:tt)*) => {
337-
$crate::framework::macros::attributed_string_type::min(
338-
stackable_operator::validation::RFC_1123_SUBDOMAIN_MAX_LENGTH,
329+
$crate::v2::macros::attributed_string_type::min(
330+
crate::validation::RFC_1123_SUBDOMAIN_MAX_LENGTH,
339331
attributed_string_type!(@max_length $($attribute)*)
340332
)
341333
};
342334
(@max_length is_rfc_1123_label_name $($attribute:tt)*) => {
343-
$crate::framework::macros::attributed_string_type::min(
344-
stackable_operator::validation::RFC_1123_LABEL_MAX_LENGTH,
335+
$crate::v2::macros::attributed_string_type::min(
336+
crate::validation::RFC_1123_LABEL_MAX_LENGTH,
345337
attributed_string_type!(@max_length $($attribute)*)
346338
)
347339
};
348340
(@max_length is_valid_label_value $($attribute:tt)*) => {
349-
$crate::framework::macros::attributed_string_type::min(
350-
$crate::framework::macros::attributed_string_type::MAX_LABEL_VALUE_LENGTH,
341+
$crate::v2::macros::attributed_string_type::min(
342+
$crate::v2::macros::attributed_string_type::MAX_LABEL_VALUE_LENGTH,
351343
attributed_string_type!(@max_length $($attribute)*)
352344
)
353345
};
354346
(@max_length is_uid $($attribute:tt)*) => {
355-
$crate::framework::macros::attributed_string_type::min(
347+
$crate::v2::macros::attributed_string_type::min(
356348
uuid::fmt::Hyphenated::LENGTH,
357349
attributed_string_type!(@max_length $($attribute)*)
358350
)
@@ -362,7 +354,7 @@ macro_rules! attributed_string_type {
362354

363355
(@regex) => {
364356
// Everything is allowed if there is no other regular expression.
365-
$crate::framework::macros::attributed_string_type::Regex::MatchAll
357+
$crate::v2::macros::attributed_string_type::Regex::MatchAll
366358
};
367359
(@regex (min_length = $min_length:expr) $($attribute:tt)*) => {
368360
// min_length has no influence on the regular expression.
@@ -373,31 +365,31 @@ macro_rules! attributed_string_type {
373365
attributed_string_type!(@regex $($attribute)*)
374366
};
375367
(@regex (regex = $regex:expr) $($attribute:tt)*) => {
376-
$crate::framework::macros::attributed_string_type::Regex::Expression($regex)
368+
$crate::v2::macros::attributed_string_type::Regex::Expression($regex)
377369
.combine(attributed_string_type!(@regex $($attribute)*))
378370
};
379371
(@regex is_rfc_1035_label_name $($attribute:tt)*) => {
380372
// 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])?$")
373+
$crate::v2::macros::attributed_string_type::Regex::Expression("^[a-z]([-a-z0-9]*[a-z0-9])?$")
382374
.combine(attributed_string_type!(@regex $($attribute)*))
383375
};
384376
(@regex is_rfc_1123_dns_subdomain_name $($attribute:tt)*) => {
385377
// 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])?)*$")
378+
$crate::v2::macros::attributed_string_type::Regex::Expression("^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$")
387379
.combine(attributed_string_type!(@regex $($attribute)*))
388380
};
389381
(@regex is_rfc_1123_label_name $($attribute:tt)*) => {
390382
// 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])?$")
383+
$crate::v2::macros::attributed_string_type::Regex::Expression("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
392384
.combine(attributed_string_type!(@regex $($attribute)*))
393385
};
394386
(@regex is_valid_label_value $($attribute:tt)*) => {
395-
// regular expression from stackable_operator::kvp::label::LABEL_VALUE_REGEX
396-
$crate::framework::macros::attributed_string_type::Regex::Expression("^[a-z0-9A-Z]([a-z0-9A-Z-_.]*[a-z0-9A-Z]+)?$")
387+
// regular expression from crate::kvp::label::LABEL_VALUE_REGEX
388+
$crate::v2::macros::attributed_string_type::Regex::Expression("^[a-z0-9A-Z]([a-z0-9A-Z-_.]*[a-z0-9A-Z]+)?$")
397389
.combine(attributed_string_type!(@regex $($attribute)*))
398390
};
399391
(@regex is_uid $($attribute:tt)*) => {
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}$")
392+
$crate::v2::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}$")
401393
.combine(attributed_string_type!(@regex $($attribute)*))
402394
};
403395

@@ -432,7 +424,7 @@ macro_rules! attributed_string_type {
432424
pub const IS_VALID_LABEL_VALUE: bool = true;
433425
}
434426

435-
impl $crate::framework::NameIsValidLabelValue for $name {
427+
impl $crate::v2::NameIsValidLabelValue for $name {
436428
fn to_label_value(&self) -> String {
437429
self.0.clone()
438430
}
@@ -490,11 +482,13 @@ mod tests {
490482
use std::str::FromStr;
491483

492484
use serde_json::{Number, Value, json};
493-
use stackable_operator::schemars::{JsonSchema, SchemaGenerator};
494485
use uuid::uuid;
495486

496487
use super::{ErrorDiscriminants, Regex};
497-
use crate::framework::NameIsValidLabelValue;
488+
use crate::{
489+
schemars::{JsonSchema, SchemaGenerator},
490+
v2::NameIsValidLabelValue,
491+
};
498492

499493
attributed_string_type! {
500494
MinLengthWithoutConstraintsTest,

crates/stackable-operator/src/v2/types/kubernetes.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//! Kubernetes (resource) names
22
use std::str::FromStr;
33

4-
use stackable_operator::validation::{RFC_1123_LABEL_MAX_LENGTH, RFC_1123_SUBDOMAIN_MAX_LENGTH};
5-
6-
use crate::attributed_string_type;
4+
use crate::{
5+
attributed_string_type,
6+
validation::{RFC_1123_LABEL_MAX_LENGTH, RFC_1123_SUBDOMAIN_MAX_LENGTH},
7+
};
78

89
attributed_string_type! {
910
ConfigMapName,

0 commit comments

Comments
 (0)