mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 17:14:08 +02:00
add exec root option
This commit is contained in:
parent
242cf54a74
commit
6a3058888f
2 changed files with 41 additions and 13 deletions
28
src/main.rs
28
src/main.rs
|
|
@ -4,7 +4,7 @@ use crate::args::{ExecService, HazeArgs};
|
|||
use crate::cloud::{Cloud, CloudOptions};
|
||||
use crate::config::HazeConfig;
|
||||
use crate::database::DatabaseFamily;
|
||||
use crate::exec::container_logs;
|
||||
use crate::exec::{container_logs, exec, exec_tty};
|
||||
use crate::git::checkout_all;
|
||||
use crate::help::help;
|
||||
use crate::image::update_image;
|
||||
|
|
@ -117,22 +117,24 @@ async fn main() -> Result<ExitCode> {
|
|||
filter,
|
||||
service,
|
||||
command,
|
||||
root,
|
||||
} => {
|
||||
let cloud = Cloud::get_by_filter(&docker, filter, &config).await?;
|
||||
match service {
|
||||
None => {
|
||||
cloud
|
||||
.exec(
|
||||
&docker,
|
||||
if command.is_empty() {
|
||||
vec!["bash".to_string()]
|
||||
} else {
|
||||
command
|
||||
},
|
||||
atty::is(atty::Stream::Stdout),
|
||||
get_forward_env(),
|
||||
)
|
||||
.await?;
|
||||
let command = if command.is_empty() {
|
||||
vec!["bash".to_string()]
|
||||
} else {
|
||||
command
|
||||
};
|
||||
let env = get_forward_env();
|
||||
let tty = atty::is(atty::Stream::Stdout);
|
||||
let user = if root { "root" } else { "haze" };
|
||||
if tty {
|
||||
exec_tty(&docker, &cloud.id, user, command, env).await?;
|
||||
} else {
|
||||
exec(&docker, &cloud.id, user, command, env, Some(stdout())).await?;
|
||||
}
|
||||
}
|
||||
Some(ExecService::Db) => {
|
||||
cloud
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue