Skip to main content

systemprompt_config/services/
types.rs

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