Skip to main content

systemprompt_config/services/
types.rs

1//! Shared value types for the config services.
2
3use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6
7use crate::error::{ConfigError, ConfigResult};
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum DeployEnvironment {
11    Local,
12    DockerDev,
13    Production,
14}
15
16impl DeployEnvironment {
17    #[must_use]
18    pub const fn as_str(&self) -> &'static str {
19        match self {
20            Self::Local => "local",
21            Self::DockerDev => "docker-dev",
22            Self::Production => "production",
23        }
24    }
25
26    pub fn parse(s: &str) -> ConfigResult<Self> {
27        match s {
28            "local" => Ok(Self::Local),
29            "docker" | "docker-dev" => Ok(Self::DockerDev),
30            "production" | "prod" => Ok(Self::Production),
31            other => Err(ConfigError::other(format!("Invalid environment: {other}"))),
32        }
33    }
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct DeploymentConfig {
38    #[serde(flatten)]
39    pub vars: HashMap<String, serde_yaml::Value>,
40}
41
42#[derive(Debug, Clone)]
43pub struct EnvironmentConfig {
44    pub environment: DeployEnvironment,
45    pub variables: HashMap<String, String>,
46}