Skip to content

Commit 8e15112

Browse files
committed
Added git backup feature
1 parent 2746996 commit 8e15112

9 files changed

Lines changed: 992 additions & 8 deletions

File tree

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ FROM linuxcontainers/debian-slim:latest AS backend
5555
# Pass the build profile to the final stage
5656
ARG BUILD_PROFILE=debug
5757

58-
# We need libssl for the curl worker
58+
# We need libssl for the curl worker and git for VCS backups
5959
RUN apt update
60-
RUN apt -y install libssl3
60+
RUN apt -y install libssl3 git
6161

6262
WORKDIR /moor
6363

vcs-worker/src/config.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ pub struct Config {
1010
pub wizard_api_key: String,
1111
/// Name of the game/world
1212
pub game_name: String,
13+
/// Git backup repository URL or local path (optional)
14+
pub git_backup_repo: Option<String>,
15+
/// Git backup authentication token (optional)
16+
pub git_backup_token: Option<String>,
1317
}
1418

1519
impl Config {
@@ -18,6 +22,8 @@ impl Config {
1822
let db_path = Self::get_db_path();
1923
let wizard_api_key = Self::get_wizard_api_key();
2024
let game_name = Self::get_game_name();
25+
let git_backup_repo = Self::get_git_backup_repo();
26+
let git_backup_token = Self::get_git_backup_token();
2127
tracing::info!("VCS database path: {:?}", db_path);
2228
tracing::info!(
2329
"Wizard API key configured: {}",
@@ -28,10 +34,20 @@ impl Config {
2834
}
2935
);
3036
tracing::info!("Game name: {}", game_name);
37+
tracing::info!(
38+
"Git backup configured: {}",
39+
if git_backup_repo.is_some() {
40+
"enabled"
41+
} else {
42+
"disabled"
43+
}
44+
);
3145
Self {
3246
db_path,
3347
wizard_api_key,
3448
game_name,
49+
git_backup_repo,
50+
git_backup_token,
3551
}
3652
}
3753

@@ -40,6 +56,8 @@ impl Config {
4056
pub fn with_db_path(db_path: PathBuf) -> Self {
4157
let wizard_api_key = Self::get_wizard_api_key();
4258
let game_name = Self::get_game_name();
59+
let git_backup_repo = Self::get_git_backup_repo();
60+
let git_backup_token = Self::get_git_backup_token();
4361
tracing::info!("VCS database path (explicit): {:?}", db_path);
4462
tracing::info!(
4563
"Wizard API key configured: {}",
@@ -50,10 +68,20 @@ impl Config {
5068
}
5169
);
5270
tracing::info!("Game name: {}", game_name);
71+
tracing::info!(
72+
"Git backup configured: {}",
73+
if git_backup_repo.is_some() {
74+
"enabled"
75+
} else {
76+
"disabled"
77+
}
78+
);
5379
Self {
5480
db_path,
5581
wizard_api_key,
5682
game_name,
83+
git_backup_repo,
84+
git_backup_token,
5785
}
5886
}
5987

@@ -79,6 +107,16 @@ impl Config {
79107
fn get_game_name() -> String {
80108
env::var("VCS_GAME_NAME").unwrap_or_else(|_| "Unknown Game".to_string())
81109
}
110+
111+
/// Get the git backup repository from environment (optional)
112+
fn get_git_backup_repo() -> Option<String> {
113+
env::var("VCS_GIT_BACKUP_REPO").ok().filter(|s| !s.is_empty())
114+
}
115+
116+
/// Get the git backup token from environment (optional)
117+
fn get_git_backup_token() -> Option<String> {
118+
env::var("VCS_GIT_BACKUP_TOKEN").ok().filter(|s| !s.is_empty())
119+
}
82120
}
83121

84122
impl Default for Config {

0 commit comments

Comments
 (0)