Skip to content

Commit

Permalink
fix(modules): ignore unix domain socket path from Docker Context
Browse files Browse the repository at this point in the history
fix #5548
  • Loading branch information
ananta committed Dec 16, 2023
1 parent e79014a commit 851cbb5
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/modules/docker_context.rs
Expand Up @@ -72,7 +72,9 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
_ => None,
})
.map(|variable| match variable {
"context" => Some(Ok(ctx.as_str())),
"context" => {
Some(Ok(if ctx.contains("unix://") { "" } else { ctx.as_str() }))
},
_ => None,
})
.parse(None, Some(context))
Expand Down Expand Up @@ -293,6 +295,27 @@ mod tests {
cfg_dir.close()
}

#[test]
fn test_docker_host_env_with_unix_path() -> io::Result<()> {
let cfg_dir = tempfile::tempdir()?;

let actual = ModuleRenderer::new("docker_context")
.env("DOCKER_HOST", "unix:///run/user/1001/podman/podman.sock")
.config(toml::toml! {
[docker_context]
only_with_files = false
})
.collect();
let expected = Some(format!(
"via {} ",
Color::Blue.bold().paint("馃惓 ")
));

assert_eq!(expected, actual);

cfg_dir.close()
}

#[test]
fn test_docker_context_env() -> io::Result<()> {
let cfg_dir = tempfile::tempdir()?;
Expand Down

0 comments on commit 851cbb5

Please sign in to comment.