Skip to content

Commit 365ccb5

Browse files
Allow expressions in the constant macro
1 parent d98d95d commit 365ccb5

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
///
1010
/// use stackable_operator::constant;
1111
/// use stackable_operator::v2::types::kubernetes::VolumeName;
12+
/// use stackable_operator::v2::builder::pod::container::EnvVarName;
13+
///
1214
/// constant!(DATA_VOLUME_NAME: VolumeName = "data");
1315
/// constant!(pub CONFIG_VOLUME_NAME: VolumeName = "config");
16+
///
17+
/// const CONFIG_OPTION_SECURITY_ENABLED: &str = "SECURITY_ENABLED";
18+
/// constant!(ENV_VAR_NAME_SECURITY_ENABLED: EnvVarName = CONFIG_OPTION_SECURITY_ENABLED);
1419
/// ```
1520
#[macro_export(local_inner_macros)]
1621
macro_rules! constant {
17-
($qualifier:vis $name:ident: $type:ident = $value:literal) => {
22+
($qualifier:vis $name:ident: $type:ident = $value:expr) => {
1823
$qualifier static $name: std::sync::LazyLock<$type> =
1924
std::sync::LazyLock::new(|| $type::from_str($value).expect("should be a valid $name"));
2025
};

0 commit comments

Comments
 (0)