Skip to content

Commit 641bb5a

Browse files
committed
containerenv: small error message fix
This tweaks the error message when `.containerenv` cannot be found so that a fully-qualified path is included in the error. Previously, the error message would just show `run/.containerenv` as the path to the file, which is not entirely clear. I tried to change the `const PATH` to be an absolute path, but doing so breaks the ability for `open_optional()` to open the file successfully; returns an error `a path led outside of the filesystem`. Signed-off-by: Micah Abbott <[email protected]>
1 parent 48325ba commit 641bb5a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/src/containerenv.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use cap_std_ext::cap_std::fs::Dir;
77
use cap_std_ext::prelude::CapStdExtDirExt;
88
use fn_error_context::context;
99

10+
/// Path is relative to container rootfs (assumed to be /)
1011
const PATH: &str = "run/.containerenv";
1112

1213
#[derive(Debug, Default)]
@@ -25,7 +26,9 @@ pub(crate) fn get_container_execution_info(rootfs: &Dir) -> Result<ContainerExec
2526
let f = match rootfs.open_optional(PATH)? {
2627
Some(f) => BufReader::new(f),
2728
None => {
28-
anyhow::bail!("This command must be executed inside a podman container (missing {PATH}")
29+
anyhow::bail!(
30+
"This command must be executed inside a podman container (missing /{PATH})"
31+
)
2932
}
3033
};
3134
let mut r = ContainerExecutionInfo::default();

0 commit comments

Comments
 (0)