Add check for using askpass
This commit is contained in:
parent
883090ee85
commit
4537e29b55
2 changed files with 25 additions and 41 deletions
|
|
@ -5,7 +5,10 @@ use std::{
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use blue_build_utils::{credentials::Credentials, running_as_root, semver::Version};
|
use blue_build_utils::{
|
||||||
|
constants::SUDO_ASKPASS, credentials::Credentials, has_env_var, running_as_root,
|
||||||
|
semver::Version,
|
||||||
|
};
|
||||||
use cached::proc_macro::cached;
|
use cached::proc_macro::cached;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use comlexr::{cmd, pipe};
|
use comlexr::{cmd, pipe};
|
||||||
|
|
@ -141,10 +144,8 @@ impl BuildDriver for PodmanDriver {
|
||||||
} else {
|
} else {
|
||||||
"podman"
|
"podman"
|
||||||
},
|
},
|
||||||
if use_sudo => [
|
if use_sudo && has_env_var(SUDO_ASKPASS) => "-A",
|
||||||
"-A",
|
if use_sudo => "podman",
|
||||||
"podman",
|
|
||||||
],
|
|
||||||
"build",
|
"build",
|
||||||
if !matches!(opts.platform, Platform::Native) => [
|
if !matches!(opts.platform, Platform::Native) => [
|
||||||
"--platform",
|
"--platform",
|
||||||
|
|
@ -185,10 +186,8 @@ impl BuildDriver for PodmanDriver {
|
||||||
} else {
|
} else {
|
||||||
"podman"
|
"podman"
|
||||||
},
|
},
|
||||||
if use_sudo => [
|
if use_sudo && has_env_var(SUDO_ASKPASS) => "-A",
|
||||||
"-A",
|
if use_sudo => "podman",
|
||||||
"podman",
|
|
||||||
],
|
|
||||||
"tag",
|
"tag",
|
||||||
opts.src_image.to_string(),
|
opts.src_image.to_string(),
|
||||||
&dest_image_str
|
&dest_image_str
|
||||||
|
|
@ -217,10 +216,8 @@ impl BuildDriver for PodmanDriver {
|
||||||
} else {
|
} else {
|
||||||
"podman"
|
"podman"
|
||||||
},
|
},
|
||||||
if use_sudo => [
|
if use_sudo && has_env_var(SUDO_ASKPASS) => "-A",
|
||||||
"-A",
|
if use_sudo => "podman",
|
||||||
"podman",
|
|
||||||
],
|
|
||||||
"push",
|
"push",
|
||||||
format!(
|
format!(
|
||||||
"--compression-format={}",
|
"--compression-format={}",
|
||||||
|
|
@ -386,10 +383,8 @@ impl ContainerMountDriver for PodmanDriver {
|
||||||
} else {
|
} else {
|
||||||
"podman"
|
"podman"
|
||||||
},
|
},
|
||||||
if use_sudo => [
|
if use_sudo && has_env_var(SUDO_ASKPASS) => "-A",
|
||||||
"-A",
|
if use_sudo => "podman",
|
||||||
"podman",
|
|
||||||
],
|
|
||||||
"mount",
|
"mount",
|
||||||
opts.container_id,
|
opts.container_id,
|
||||||
);
|
);
|
||||||
|
|
@ -417,10 +412,8 @@ impl ContainerMountDriver for PodmanDriver {
|
||||||
} else {
|
} else {
|
||||||
"podman"
|
"podman"
|
||||||
},
|
},
|
||||||
if use_sudo => [
|
if use_sudo && has_env_var(SUDO_ASKPASS) => "-A",
|
||||||
"-A",
|
if use_sudo => "podman",
|
||||||
"podman",
|
|
||||||
],
|
|
||||||
"unmount",
|
"unmount",
|
||||||
opts.container_id
|
opts.container_id
|
||||||
);
|
);
|
||||||
|
|
@ -446,10 +439,8 @@ impl ContainerMountDriver for PodmanDriver {
|
||||||
} else {
|
} else {
|
||||||
"podman"
|
"podman"
|
||||||
},
|
},
|
||||||
if use_sudo => [
|
if use_sudo && has_env_var(SUDO_ASKPASS) => "-A",
|
||||||
"-A",
|
if use_sudo => "podman",
|
||||||
"podman",
|
|
||||||
],
|
|
||||||
"volume",
|
"volume",
|
||||||
"rm",
|
"rm",
|
||||||
&*opts.volume_id
|
&*opts.volume_id
|
||||||
|
|
@ -519,10 +510,8 @@ impl RunDriver for PodmanDriver {
|
||||||
} else {
|
} else {
|
||||||
"podman"
|
"podman"
|
||||||
},
|
},
|
||||||
if use_sudo => [
|
if use_sudo && has_env_var(SUDO_ASKPASS) => "-A",
|
||||||
"-A",
|
if use_sudo => "podman",
|
||||||
"podman",
|
|
||||||
],
|
|
||||||
"create",
|
"create",
|
||||||
opts.image.to_string(),
|
opts.image.to_string(),
|
||||||
"bash"
|
"bash"
|
||||||
|
|
@ -553,10 +542,8 @@ impl RunDriver for PodmanDriver {
|
||||||
} else {
|
} else {
|
||||||
"podman"
|
"podman"
|
||||||
},
|
},
|
||||||
if use_sudo => [
|
if use_sudo && has_env_var(SUDO_ASKPASS) => "-A",
|
||||||
"-A",
|
if use_sudo => "podman",
|
||||||
"podman",
|
|
||||||
],
|
|
||||||
"rm",
|
"rm",
|
||||||
opts.container_id,
|
opts.container_id,
|
||||||
);
|
);
|
||||||
|
|
@ -584,10 +571,8 @@ impl RunDriver for PodmanDriver {
|
||||||
} else {
|
} else {
|
||||||
"podman"
|
"podman"
|
||||||
},
|
},
|
||||||
if use_sudo => [
|
if use_sudo && has_env_var(SUDO_ASKPASS) => "-A",
|
||||||
"-A",
|
if use_sudo => "podman",
|
||||||
"podman",
|
|
||||||
],
|
|
||||||
"rmi",
|
"rmi",
|
||||||
opts.image.to_string()
|
opts.image.to_string()
|
||||||
);
|
);
|
||||||
|
|
@ -621,10 +606,8 @@ impl RunDriver for PodmanDriver {
|
||||||
} else {
|
} else {
|
||||||
"podman"
|
"podman"
|
||||||
},
|
},
|
||||||
if use_sudo => [
|
if use_sudo && has_env_var(SUDO_ASKPASS) => "-A",
|
||||||
"-A",
|
if use_sudo => "podman",
|
||||||
"podman",
|
|
||||||
],
|
|
||||||
"images",
|
"images",
|
||||||
"--format",
|
"--format",
|
||||||
"json"
|
"json"
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ pub const LC_TERMINAL: &str = "LC_TERMINAL";
|
||||||
pub const TERM_PROGRAM_VERSION: &str = "TERM_PROGRAM_VERSION";
|
pub const TERM_PROGRAM_VERSION: &str = "TERM_PROGRAM_VERSION";
|
||||||
pub const LC_TERMINAL_VERSION: &str = "LC_TERMINAL_VERSION";
|
pub const LC_TERMINAL_VERSION: &str = "LC_TERMINAL_VERSION";
|
||||||
pub const XDG_RUNTIME_DIR: &str = "XDG_RUNTIME_DIR";
|
pub const XDG_RUNTIME_DIR: &str = "XDG_RUNTIME_DIR";
|
||||||
|
pub const SUDO_ASKPASS: &str = "SUDO_ASKPASS";
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
pub const BUILD_SCRIPTS_IMAGE_REF: &str = "ghcr.io/blue-build/cli/build-scripts";
|
pub const BUILD_SCRIPTS_IMAGE_REF: &str = "ghcr.io/blue-build/cli/build-scripts";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue