2022-08-10 12:34:04 +02:00
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
use serde::Deserialize;
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
|
|
|
#[serde(untagged)]
|
|
|
|
pub enum CuddleBase {
|
|
|
|
Bool(bool),
|
|
|
|
String(String),
|
|
|
|
}
|
|
|
|
|
2022-08-12 00:54:22 +02:00
|
|
|
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
|
|
|
pub struct CuddleShellScriptArgEnv {
|
|
|
|
pub key: String,
|
2023-07-02 01:00:04 +02:00
|
|
|
pub description: Option<String>,
|
2022-08-12 00:54:22 +02:00
|
|
|
}
|
|
|
|
|
2023-07-02 00:47:14 +02:00
|
|
|
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
|
|
|
pub struct CuddleShellScriptArgFlag {
|
|
|
|
pub name: String,
|
|
|
|
pub description: Option<String>,
|
|
|
|
pub required: Option<bool>,
|
|
|
|
pub default_value: Option<String>,
|
|
|
|
}
|
|
|
|
|
2022-08-12 00:54:22 +02:00
|
|
|
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
|
|
|
#[serde(tag = "type")]
|
|
|
|
pub enum CuddleShellScriptArg {
|
|
|
|
#[serde(alias = "env")]
|
|
|
|
Env(CuddleShellScriptArgEnv),
|
2023-07-02 00:47:14 +02:00
|
|
|
#[serde(alias = "flag")]
|
|
|
|
Flag(CuddleShellScriptArgFlag),
|
2022-08-12 00:54:22 +02:00
|
|
|
}
|
|
|
|
|
2022-08-10 12:34:04 +02:00
|
|
|
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
|
|
|
pub struct CuddleShellScript {
|
|
|
|
pub description: Option<String>,
|
2022-08-12 00:54:22 +02:00
|
|
|
pub args: Option<HashMap<String, CuddleShellScriptArg>>,
|
2022-08-10 12:34:04 +02:00
|
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
|
|
|
pub struct CuddleDaggerScript {
|
|
|
|
pub description: Option<String>,
|
|
|
|
}
|
|
|
|
|
2023-07-02 12:21:12 +02:00
|
|
|
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
|
|
|
pub struct CuddleLuaScript {
|
|
|
|
pub description: Option<String>,
|
|
|
|
}
|
|
|
|
|
2022-08-10 12:34:04 +02:00
|
|
|
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
|
|
|
#[serde(tag = "type")]
|
|
|
|
pub enum CuddleScript {
|
|
|
|
#[serde(alias = "shell")]
|
|
|
|
Shell(CuddleShellScript),
|
|
|
|
#[serde(alias = "dagger")]
|
|
|
|
Dagger(CuddleDaggerScript),
|
2023-07-02 12:21:12 +02:00
|
|
|
#[serde(alias = "lua")]
|
|
|
|
Lua(CuddleLuaScript),
|
2022-08-10 12:34:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
|
|
|
pub struct CuddlePlan {
|
|
|
|
pub base: CuddleBase,
|
2022-08-11 02:03:19 +02:00
|
|
|
pub vars: Option<HashMap<String, String>>,
|
2022-08-10 12:34:04 +02:00
|
|
|
pub scripts: Option<HashMap<String, CuddleScript>>,
|
|
|
|
}
|
2022-08-14 20:19:29 +02:00
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
#[allow(dead_code)]
|
|
|
|
pub struct CuddleVariable {
|
|
|
|
pub name: String,
|
|
|
|
pub value: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl CuddleVariable {
|
|
|
|
pub fn new(name: String, value: String) -> Self {
|
|
|
|
Self { name, value }
|
|
|
|
}
|
|
|
|
}
|