From a0ef3c9aa7aa7d898f8d3ccfc47e0a01ec416ff0 Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Sat, 9 Nov 2024 05:03:39 -0600 Subject: [PATCH] autodeploy add profiles Signed-off-by: eternal-flame-AD --- yume-mods/misskey-auto-deploy/config.toml | 31 +++++++++++++++++++++++ yume-mods/misskey-auto-deploy/src/lib.rs | 14 +++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 yume-mods/misskey-auto-deploy/config.toml diff --git a/yume-mods/misskey-auto-deploy/config.toml b/yume-mods/misskey-auto-deploy/config.toml new file mode 100644 index 0000000000..a5b12d9b8f --- /dev/null +++ b/yume-mods/misskey-auto-deploy/config.toml @@ -0,0 +1,31 @@ +[service] +listen = "[::]:7070" + +[auth] +secret = "$2b$12$B7krtFJwRlxYVgUQT.9ZA.0CibHt31YKq1r47uXpLt4WVowjHtxnO" + +[refs."develop"] +ref = "refs/heads/develop" +working_dir = "/var/lib/misskey/test0/yumechi-no-kuni" +uid = 970 +gid = 968 + +[refs."develop".env] +MISSKEY_UID = "970" +MISSKEY_GID = "968" +MTLS_REDIS_SNI = "redis.replicate.test0.mi.yumechi.jp" +MTLS_POSTGRES_SNI = "psql.replicate.test0.mi.yumechi.jp" + + +# [refs."main"] +# ref = "refs/heads/main" +# working_dir = "/var/lib/misskey/prod/yumechi-no-kuni" +# uid = 971 +# gid = 968 + +# [refs."main".env] +# MISSKEY_UID = "971" +# MISSKEY_GID = "968" +# MTLS_REDIS_SNI = "redis.replicate.mi.yumechi.jp" +# MTLS_POSTGRES_SNI = "psql.replicate.mi.yumechi.jp" + diff --git a/yume-mods/misskey-auto-deploy/src/lib.rs b/yume-mods/misskey-auto-deploy/src/lib.rs index d23c209f94..93f3ae5153 100644 --- a/yume-mods/misskey-auto-deploy/src/lib.rs +++ b/yume-mods/misskey-auto-deploy/src/lib.rs @@ -49,6 +49,7 @@ pub struct RefConfig { pub stdout: Option, pub stderr: Option, pub working_dir: PathBuf, + pub profiles: Option>, pub compose_flags: Option>, pub env: Option>, pub uid: u32, @@ -200,6 +201,17 @@ impl App { let mut command = Command::new("docker") .arg("compose") + .args( + matched_ref + .config + .profiles + .as_ref() + .map(|profiles| + profiles.iter() + .flat_map(|profiles| ["--profile", profiles.as_str()]) + .collect::>()) + .unwrap_or(Vec::new()), + ) .arg("up") .arg("--detach") .arg("--build") @@ -289,7 +301,7 @@ impl App { State(state): State, Query(query): Query, ) -> Result, ApiError> { - let ref_ = match (&query.ref_, &query.branch) { + let ref_ = match (query.ref_.as_ref(), query.branch.as_ref()) { (Some(ref_), None) => ref_.clone(), (None, Some(branch)) => format!("refs/heads/{}", branch), _ => {