Compare commits
2 Commits
8469a6ed9b
...
4cc0a0b9e0
Author | SHA1 | Date | |
---|---|---|---|
|
4cc0a0b9e0 | ||
932959bc5c |
66
CHANGELOG.md
66
CHANGELOG.md
@ -6,6 +6,72 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.2.0] - 2024-11-20
|
||||
|
||||
### Added
|
||||
- add support for raw reading of variables
|
||||
- add replicas
|
||||
- set interval down to a minute
|
||||
- with native roots
|
||||
- with explicit install
|
||||
- with install
|
||||
- with ring
|
||||
- enable stuff
|
||||
- update packages
|
||||
- update packages
|
||||
- add actual grpc service
|
||||
- fix typo
|
||||
- revert to actual label
|
||||
- fix scheme
|
||||
- trying with h2c service
|
||||
- add grpc ports as well
|
||||
- fix name
|
||||
- rename
|
||||
- remove suffix
|
||||
- add ingress
|
||||
- add ingress wip
|
||||
- use lower case
|
||||
- use actual service name
|
||||
- cannot use lowe case
|
||||
- update filename
|
||||
- add namespace
|
||||
- update env
|
||||
- add crdb
|
||||
- add webroots
|
||||
- with tls
|
||||
- use new tokio stream
|
||||
- update client
|
||||
- more debugging
|
||||
- update
|
||||
- update flux releaser
|
||||
- actually set registry
|
||||
- add option for releaser
|
||||
- add slot for upload strategy
|
||||
- add user variables to input
|
||||
- without remove all
|
||||
- plan -> base
|
||||
- add sync
|
||||
- add send
|
||||
- use arc instead
|
||||
|
||||
### Fixed
|
||||
- *(deps)* update rust crate serde to v1.0.215
|
||||
- *(deps)* update rust crate futures to v0.3.31
|
||||
- *(deps)* update rust crate minijinja to v2.3.1
|
||||
- *(deps)* update rust crate minijinja to v2.3.0
|
||||
- *(deps)* update rust crate serde to v1.0.203
|
||||
- only create vault secret template if actual secret found
|
||||
|
||||
### Other
|
||||
- *(deps)* update all dependencies
|
||||
- *(deps)* update rust crate clap to v4.5.20
|
||||
- *(deps)* update rust crate clap to v4.5.19
|
||||
- *(deps)* update rust crate clap to v4.5.18
|
||||
- *(deps)* update rust crate anyhow to v1.0.89
|
||||
- *(deps)* update rust crate anyhow to v1.0.88
|
||||
- *(deps)* update all dependencies
|
||||
- move crdb to own file
|
||||
|
||||
## [0.1.1] - 2024-05-25
|
||||
|
||||
### Other
|
||||
|
@ -14,4 +14,4 @@ dotenv = { version = "0.15" }
|
||||
flux-releaser = { git = "https://git.front.kjuulh.io/kjuulh/flux-releaser", branch = "main" }
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.1"
|
||||
version = "0.2.0"
|
||||
|
@ -1,7 +1,24 @@
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
|
||||
use serde_yaml::Value;
|
||||
|
||||
use crate::Component;
|
||||
|
||||
use super::cuddle_vars::CuddleVariables;
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub enum RawClusterVariable {
|
||||
Map(RawClusterVariables),
|
||||
List(RawClusterVariableList),
|
||||
String(String),
|
||||
Bool(bool),
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Default)]
|
||||
pub struct RawClusterVariables(BTreeMap<String, RawClusterVariable>);
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Default)]
|
||||
pub struct RawClusterVariableList(Vec<RawClusterVariable>);
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
pub enum ClusterVariable {
|
||||
String(String),
|
||||
@ -18,6 +35,9 @@ pub struct ClusterVariables {
|
||||
name: String,
|
||||
namespace: String,
|
||||
replicas: u64,
|
||||
|
||||
raw: RawClusterVariables,
|
||||
// raw: CuddleVariables,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@ -42,8 +62,6 @@ impl Component for ClusterVars {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
// TODO: actually extract values
|
||||
|
||||
if let Some(mapping) = value.as_mapping() {
|
||||
if let Some(env) = mapping.get("env") {
|
||||
if let Some(env_entries) = env.as_mapping() {
|
||||
@ -63,6 +81,11 @@ impl Component for ClusterVars {
|
||||
}
|
||||
}
|
||||
}
|
||||
// vars.raw = match value.clone().try_into() {
|
||||
// Ok(o) => o,
|
||||
// Err(e) => panic!("{}", e),
|
||||
// };
|
||||
vars.raw = value.into();
|
||||
|
||||
vars.name = environment.into();
|
||||
vars.namespace = environment.into();
|
||||
@ -78,6 +101,10 @@ impl minijinja::value::Object for ClusterVariables {
|
||||
"name" => minijinja::Value::from_safe_string(self.name.clone()),
|
||||
"namespace" => minijinja::Value::from_safe_string(self.namespace.clone()),
|
||||
"replicas" => minijinja::Value::from_safe_string(self.replicas.to_string()),
|
||||
"raw" => {
|
||||
tracing::info!("returning raw: {:?}", self.raw);
|
||||
minijinja::Value::from_object(self.raw.clone())
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
@ -103,3 +130,95 @@ impl minijinja::value::Object for ClusterEnv {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Value> for RawClusterVariables {
|
||||
fn from(value: &Value) -> Self {
|
||||
match value {
|
||||
Value::Mapping(mapping) => RawClusterVariables(
|
||||
mapping
|
||||
.into_iter()
|
||||
.map(|(k, v)| {
|
||||
(
|
||||
k.as_str()
|
||||
.expect("keys to always be valid strings")
|
||||
.to_string(),
|
||||
v.into(),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
Value::Null => RawClusterVariables::default(),
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Value> for RawClusterVariable {
|
||||
fn from(value: &Value) -> Self {
|
||||
match value {
|
||||
Value::Null => Self::Map(RawClusterVariables::default()),
|
||||
Value::Bool(b) => Self::Bool(*b),
|
||||
Value::Number(number) => Self::String(number.to_string()),
|
||||
Value::String(s) => Self::String(s.into()),
|
||||
Value::Sequence(vec) => Self::List(RawClusterVariableList(
|
||||
vec.iter().map(|i| i.into()).collect(),
|
||||
)),
|
||||
Value::Mapping(mapping) => Self::Map(RawClusterVariables(
|
||||
mapping
|
||||
.into_iter()
|
||||
.map(|(k, v)| {
|
||||
(
|
||||
k.as_str()
|
||||
.expect("keys to always be valid strings")
|
||||
.to_string(),
|
||||
v.into(),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
)),
|
||||
Value::Tagged(_tagged_value) => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl minijinja::value::Object for RawClusterVariables {
|
||||
fn get_value(self: &std::sync::Arc<Self>, key: &minijinja::Value) -> Option<minijinja::Value> {
|
||||
self.0.get(key.as_str()?).map(|o| match o {
|
||||
RawClusterVariable::Map(raw_cluster_variables) => {
|
||||
minijinja::Value::from_object(raw_cluster_variables.clone())
|
||||
}
|
||||
RawClusterVariable::List(list) => minijinja::Value::from_object(list.clone()),
|
||||
RawClusterVariable::String(s) => minijinja::Value::from_safe_string(s.clone()),
|
||||
RawClusterVariable::Bool(b) => minijinja::Value::from_safe_string(b.to_string()),
|
||||
})
|
||||
}
|
||||
|
||||
fn enumerate(self: &std::sync::Arc<Self>) -> minijinja::value::Enumerator {
|
||||
minijinja::value::Enumerator::Values(
|
||||
self.0
|
||||
.keys()
|
||||
.map(|key| minijinja::Value::from_safe_string(key.clone()))
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl minijinja::value::Object for RawClusterVariableList {
|
||||
fn enumerate(self: &std::sync::Arc<Self>) -> minijinja::value::Enumerator {
|
||||
minijinja::value::Enumerator::Values(
|
||||
self.0
|
||||
.iter()
|
||||
.map(|i| match i {
|
||||
RawClusterVariable::Map(raw_cluster_variables) => {
|
||||
minijinja::Value::from_object(raw_cluster_variables.clone())
|
||||
}
|
||||
RawClusterVariable::List(list) => minijinja::Value::from_object(list.clone()),
|
||||
RawClusterVariable::String(s) => minijinja::Value::from_safe_string(s.clone()),
|
||||
RawClusterVariable::Bool(b) => {
|
||||
minijinja::Value::from_safe_string(b.to_string())
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -34,12 +34,13 @@ impl TryFrom<serde_yaml::Value> for CuddleVariable {
|
||||
serde_yaml::Value::String(s) => Ok(Self::String(s)),
|
||||
serde_yaml::Value::Number(num) => Ok(Self::String(num.to_string())),
|
||||
serde_yaml::Value::Bool(bool) => Ok(Self::String(bool.to_string())),
|
||||
serde_yaml::Value::Null => Ok(Self::Object(Box::default())),
|
||||
_ => Err(anyhow::anyhow!("cannot handle type of serde value")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Default)]
|
||||
pub struct CuddleVariables(pub HashMap<String, CuddleVariable>);
|
||||
|
||||
impl TryFrom<serde_yaml::Mapping> for CuddleVariables {
|
||||
@ -68,7 +69,7 @@ impl TryFrom<serde_yaml::Value> for CuddleVariables {
|
||||
|
||||
fn try_from(value: serde_yaml::Value) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
serde_yaml::Value::Null => anyhow::bail!("cannot handle null"),
|
||||
serde_yaml::Value::Null => Ok(Self::default()),
|
||||
serde_yaml::Value::Bool(_) => anyhow::bail!("cannot handle bool"),
|
||||
serde_yaml::Value::Number(_) => anyhow::bail!("cannot handle number"),
|
||||
serde_yaml::Value::String(_) => anyhow::bail!("cannot handle string"),
|
||||
|
@ -3,10 +3,14 @@ vars:
|
||||
cuddle/clusters:
|
||||
dev:
|
||||
replicas: 1
|
||||
list:
|
||||
- listItem: listValue
|
||||
env:
|
||||
vault: true
|
||||
something.something: something
|
||||
something:
|
||||
# ignored
|
||||
something: "something"
|
||||
vault: true
|
||||
prod:
|
||||
env:
|
||||
|
||||
|
@ -3,3 +3,7 @@ namespace: dev
|
||||
replicas: 1
|
||||
items:
|
||||
- something.something
|
||||
listValue
|
||||
|
||||
|
||||
something: something
|
||||
|
@ -2,3 +2,4 @@ name: prod
|
||||
namespace: prod
|
||||
replicas: 3
|
||||
items:
|
||||
|
||||
|
@ -6,3 +6,12 @@ items:
|
||||
- {{val}}
|
||||
{%- endfor %}
|
||||
|
||||
{%- if vars.cluster_vars.raw.list -%}
|
||||
{%- for val in vars.cluster_vars.raw.list %}
|
||||
{{ val.listItem }}
|
||||
{%- endfor -%}
|
||||
{%- endif %}
|
||||
|
||||
{% if vars.cluster_vars.raw.env.something %}
|
||||
something: {{ vars.cluster_vars.raw.env.something.something }}
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user