Add auto network creation & podman secret environment variables
This commit is contained in:
+10
-1
@@ -26,7 +26,12 @@ pub fn generate_openrc(config: &ServiceConfig) -> String {
|
||||
|
||||
// start_pre()
|
||||
script.push_str("start_pre() {\n");
|
||||
script.push_str(&wrap(&format!("podman rm {} --ignore", config.service.name)));
|
||||
let mut start_pre_commands = Vec::new();
|
||||
if let Some(network) = &config.service.network {
|
||||
start_pre_commands.push(format!("podman network create {} --ignore;", network));
|
||||
}
|
||||
start_pre_commands.push(format!("podman rm {} --ignore;", config.service.name));
|
||||
script.push_str(&wrap(&start_pre_commands.join("\n")));
|
||||
script.push_str("\n}\n\n");
|
||||
// }
|
||||
|
||||
@@ -66,6 +71,10 @@ pub fn generate_openrc(config: &ServiceConfig) -> String {
|
||||
arguments.push(format!("--env {}='{}'", key, value));
|
||||
}
|
||||
|
||||
for secret in &config.environment_secrets {
|
||||
arguments.push(format!("--env {}='$(podman secret inspect --showsecret --format {{.SecretData}} {})'", secret.name, secret.secret));
|
||||
}
|
||||
|
||||
for volume in &config.volumes {
|
||||
arguments.push(format!("--volume {}:{}", &volume.volume, &volume.path));
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ pub struct ServiceConfig {
|
||||
#[serde(default)]
|
||||
pub environment: HashMap<String, String>,
|
||||
|
||||
#[serde(default)]
|
||||
pub environment_secrets: Vec<EnvironmentSecret>,
|
||||
|
||||
#[serde(default)]
|
||||
pub ports: Vec<PortMapping>,
|
||||
|
||||
@@ -48,6 +51,12 @@ pub struct Secret {
|
||||
pub target: Option<String>
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct EnvironmentSecret {
|
||||
pub name: String,
|
||||
pub secret: String
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct PortMapping {
|
||||
pub host: u16,
|
||||
|
||||
Reference in New Issue
Block a user