From 9146046b918071d9d04a7ba334cb463144f60e46 Mon Sep 17 00:00:00 2001 From: Maurice Date: Wed, 13 Aug 2025 10:45:03 +0200 Subject: [PATCH] Add multiple networks --- README.md | 3 ++- src/main.rs | 4 ++-- src/service.rs | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 887ea5d..6dfbe6a 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,13 @@ The format is like this: ```toml user = "" # Optional property, set if you don't want to run the Podman command with the root user +capabilities = ["NET_BIND_SERVICE"] # Optional property, add Linux capabilities if you need some # Required section [service] name = "" # Container name, required image = "" # Podman image name -network = "" # Optional, if you want to run the container within a specific network. Set to "host" if you don't want to use the podman networking. +networks = [""] # Optional, if you want to run the container within a specific network. Set to "host" if you don't want to use the podman networking. depend = [""] # Name of any service in /etc/init.d to depend on restart = "unless-stopped" # Restart, optional. Defaults to "unless-stopped" detach = true # Run container in detach mode, optional, default true. Recommended. diff --git a/src/main.rs b/src/main.rs index fb35816..c49cfeb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,7 +27,7 @@ pub fn generate_openrc(config: &ServiceConfig) -> String { // start_pre() script.push_str("start_pre() {\n"); let mut start_pre_commands = Vec::new(); - if let Some(network) = &config.service.network { + for network in &config.service.networks { start_pre_commands.push(format!("podman network create {} --ignore;", network)); } start_pre_commands.push(format!("podman rm {} --ignore;", config.service.name)); @@ -51,7 +51,7 @@ pub fn generate_openrc(config: &ServiceConfig) -> String { arguments.push("--detach".to_string()); } - if let Some(network) = &config.service.network { + for network in &config.service.networks { arguments.push(format!("--network {}", network)); } diff --git a/src/service.rs b/src/service.rs index 3802b8b..7240eef 100644 --- a/src/service.rs +++ b/src/service.rs @@ -35,7 +35,10 @@ pub struct Service { pub name: String, pub hostname: Option, pub image: String, - pub network: Option, + + #[serde(default)] + pub networks: Vec, + pub restart: Option, pub detach: Option, pub healthcheck: Option,