1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-10-01 08:44:09 +02:00

allow exec in db

This commit is contained in:
Robin Appelman 2021-06-14 18:46:00 +02:00
commit b46291b0f0
3 changed files with 89 additions and 18 deletions

View file

@ -5,7 +5,7 @@ use bollard::models::{EndpointSettings, HostConfig};
use bollard::Docker;
use color_eyre::{eyre::WrapErr, Report, Result};
use maplit::hashmap;
use std::io::Stdout;
use std::io::{stdout, Stdout};
use std::str::FromStr;
use std::time::Duration;
use tokio::time::{sleep, timeout};
@ -209,6 +209,24 @@ impl Database {
Ok(Some(id))
}
pub async fn exec_sh<S: Into<String>>(
&self,
docker: &mut Docker,
cloud_id: &str,
cmd: Vec<S>,
tty: bool,
) -> Result<i64> {
let container = match self.family() {
DatabaseFamily::Sqlite => cloud_id.to_string(),
_ => format!("{}-db", cloud_id.to_string()),
};
if tty {
exec_tty(docker, &container, "root", cmd, vec![]).await
} else {
exec(docker, &container, "root", cmd, vec![], Some(stdout())).await
}
}
pub async fn exec(&self, docker: &mut Docker, cloud_id: &str, root: bool) -> Result<i64> {
match self.family() {
DatabaseFamily::Sqlite => {