diff --git a/nativelink-config/src/cas_server.rs b/nativelink-config/src/cas_server.rs index 6631dce8d..20cafc6ef 100644 --- a/nativelink-config/src/cas_server.rs +++ b/nativelink-config/src/cas_server.rs @@ -20,6 +20,7 @@ use crate::schedulers::SchedulerConfig; use crate::serde_utils::{ convert_numeric_with_shellexpand, convert_optional_numeric_with_shellexpand, convert_optional_string_with_shellexpand, convert_string_with_shellexpand, + convert_vec_string_with_shellexpand, }; use crate::stores::{ClientTlsConfig, ConfigDigestHashFunction, StoreConfig, StoreRefName}; @@ -378,6 +379,7 @@ pub enum WorkerProperty { /// List of static values. /// Note: Generally there should only ever be 1 value, but if the platform /// property key is PropertyType::Priority it may have more than one value. + #[serde(deserialize_with = "convert_vec_string_with_shellexpand")] values(Vec), /// A dynamic configuration. The string will be executed as a command diff --git a/nativelink-config/src/serde_utils.rs b/nativelink-config/src/serde_utils.rs index 6906f5ff0..8fead477c 100644 --- a/nativelink-config/src/serde_utils.rs +++ b/nativelink-config/src/serde_utils.rs @@ -111,6 +111,20 @@ pub fn convert_string_with_shellexpand<'de, D: Deserializer<'de>>( Ok((*(shellexpand::env(&value).map_err(de::Error::custom)?)).to_string()) } +/// Same as convert_string_with_shellexpand, but supports Vec. +pub fn convert_vec_string_with_shellexpand<'de, D: Deserializer<'de>>( + deserializer: D, +) -> Result, D::Error> { + let vec = Vec::::deserialize(deserializer)?; + vec.into_iter() + .map(|s| { + shellexpand::env(&s) + .map_err(de::Error::custom) + .map(|expanded| expanded.into_owned()) + }) + .collect() +} + /// Same as convert_string_with_shellexpand, but supports Option. pub fn convert_optional_string_with_shellexpand<'de, D: Deserializer<'de>>( deserializer: D,