Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/cli/src/docker_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ pub async fn handle_docker_init(config_path: PathBuf, output_dir: PathBuf) -> Re

if let Some(mux_config) = cb_config.muxes {
for mux in mux_config.muxes.iter() {
if let Some((env_name, actual_path, internal_path)) = mux.loader_env() {
if let Some((env_name, actual_path, internal_path)) = mux.loader_env()? {
let (key, val) = get_env_val(&env_name, &internal_path);
pbs_envs.insert(key, val);
pbs_volumes.push(Volumes::Simple(format!("{}:{}:ro", actual_path, internal_path)));
Expand Down
34 changes: 26 additions & 8 deletions crates/common/src/config/mux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,36 @@ pub struct MuxConfig {
impl MuxConfig {
/// Returns the env, actual path, and internal path to use for the file
/// loader
pub fn loader_env(&self) -> Option<(String, String, String)> {
self.loader.as_ref().and_then(|loader| match loader {
pub fn loader_env(&self) -> eyre::Result<Option<(String, String, String)>> {
let Some(loader) = self.loader.as_ref() else {
return Ok(None);
};

match loader {
MuxKeysLoader::File(path_buf) => {
let path =
path_buf.to_str().unwrap_or_else(|| panic!("invalid path: {:?}", path_buf));
ensure!(
path_buf.try_exists().is_ok_and(|exists| exists),
"path doesn't exist: {:?}",
path_buf
);

ensure!(
path_buf.extension().is_some_and(|ext| ext == "json"),
"file doesn't have a .json extension: {:?}",
path_buf
);

let Some(path) = path_buf.to_str() else {
bail!("invalid path: {:?}", path_buf);
};

let internal_path = get_mux_path(&self.id);

Some((get_mux_env(&self.id), path.to_owned(), internal_path))
Ok(Some((get_mux_env(&self.id), path.to_owned(), internal_path)))
}
MuxKeysLoader::HTTP { .. } => None,
MuxKeysLoader::Registry { .. } => None,
})
MuxKeysLoader::HTTP { .. } => Ok(None),
MuxKeysLoader::Registry { .. } => Ok(None),
}
}
}

Expand Down