Skip to content

Commit

Permalink
feat: Support writing config changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian May authored and brianmay committed Apr 11, 2024
1 parent a7f8258 commit b500e6b
Show file tree
Hide file tree
Showing 9 changed files with 532 additions and 287 deletions.
126 changes: 117 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ url = "2.5.0"
futures = "0.3.30"
hyper-util = "0.1.3"
tap = "1.0.1"
reqwest = { version = "=0.12.2", default-features = false, features = ["json", "rustls-tls"] }
reqwest = { version = "=0.12.2", default-features = false, features = ["json", "rustls-tls"] }
nondestructive = "0.0.21"
76 changes: 36 additions & 40 deletions src/depends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,22 @@ pub fn is_depends_ok(installation: &Installation, done: &InstallationSet) -> boo
mod tests {
use std::path::PathBuf;

use crate::config::AnnouncePolicy;
use crate::config::{AnnouncePolicy, ChartReference};

#[allow(clippy::wildcard_imports)]
use crate::{
config::ReleaseReference,
depends::*,
helm::{HelmChart, HelmRepo, Installation},
};
use crate::{config::ReleaseReference, depends::*, helm::Installation};

#[test]
fn test_get_depends_order_good() {
let todo = vec![
Installation {
name: "ingress-nginx-ext".to_string(),
config_file: "config.yaml".into(),
values_files: vec![],
env_name: "dev".to_string(),
cluster_name: "spartan".to_string(),
chart: HelmChart::HelmRepo {
repo: HelmRepo {
name: "ingress-nginx".to_string(),
url: "https://kubernetes.github.io/ingress-nginx".to_string(),
},
chart_reference: ChartReference::Helm {
repo_url: "https://kubernetes.github.io/ingress-nginx".to_string(),
chart_name: "ingress-nginx".to_string(),
chart_version: "4.0.10".to_string(),
},
Expand All @@ -104,14 +98,12 @@ mod tests {
},
Installation {
name: "ingress-nginx-ext-2".to_string(),
config_file: "config.yaml".into(),
values_files: vec![],
env_name: "dev".to_string(),
cluster_name: "spartan".to_string(),
chart: HelmChart::HelmRepo {
repo: HelmRepo {
name: "ingress-nginx".to_string(),
url: "https://kubernetes.github.io/ingress-nginx".to_string(),
},
chart_reference: ChartReference::Helm {
repo_url: "https://kubernetes.github.io/ingress-nginx".to_string(),
chart_name: "ingress-nginx".to_string(),
chart_version: "4.0.10".to_string(),
},
Expand All @@ -124,10 +116,13 @@ mod tests {
},
Installation {
name: "exporter-blackbox".to_string(),
config_file: "config.yaml".into(),
values_files: vec![],
env_name: "dev".to_string(),
cluster_name: "spartan".to_string(),
chart: HelmChart::Dir(PathBuf::from("charts/prometheus-blackbox-exporter")),
chart_reference: ChartReference::Local {
path: PathBuf::from("charts/prometheus-blackbox-exporter"),
},
depends: vec![ReleaseReference {
namespace: "kube-system".to_string(),
name: "ingress-nginx-ext".to_string(),
Expand All @@ -140,10 +135,13 @@ mod tests {
},
Installation {
name: "exporter-blackbox-2".to_string(),
config_file: "config.yaml".into(),
values_files: vec![],
env_name: "dev".to_string(),
cluster_name: "spartan".to_string(),
chart: HelmChart::Dir(PathBuf::from("charts/prometheus-blackbox-exporter")),
chart_reference: ChartReference::Local {
path: PathBuf::from("charts/prometheus-blackbox-exporter"),
},
depends: vec![ReleaseReference {
namespace: "kube-system".to_string(),
name: "ingress-nginx-ext".to_string(),
Expand Down Expand Up @@ -174,14 +172,12 @@ mod tests {
let todo = vec![
Installation {
name: "ingress-nginx-ext".to_string(),
config_file: "config.yaml".into(),
values_files: vec![],
env_name: "dev".to_string(),
cluster_name: "spartan".to_string(),
chart: HelmChart::HelmRepo {
repo: HelmRepo {
name: "ingress-nginx".to_string(),
url: "https://kubernetes.github.io/ingress-nginx".to_string(),
},
chart_reference: ChartReference::Helm {
repo_url: "https://kubernetes.github.io/ingress-nginx".to_string(),
chart_name: "ingress-nginx".to_string(),
chart_version: "4.0.10".to_string(),
},
Expand All @@ -194,10 +190,13 @@ mod tests {
},
Installation {
name: "exporter-blackbox".to_string(),
config_file: "config.yaml".into(),
values_files: vec![],
env_name: "dev".to_string(),
cluster_name: "spartan".to_string(),
chart: HelmChart::Dir(PathBuf::from("charts/prometheus-blackbox-exporter")),
chart_reference: ChartReference::Local {
path: PathBuf::from("charts/prometheus-blackbox-exporter"),
},
depends: vec![
ReleaseReference {
namespace: "kube-system".to_string(),
Expand Down Expand Up @@ -235,14 +234,12 @@ mod tests {
let todo = vec![
Installation {
name: "ingress-nginx-ext".to_string(),
config_file: "config.yaml".into(),
values_files: vec![],
env_name: "dev".to_string(),
cluster_name: "spartan".to_string(),
chart: HelmChart::HelmRepo {
repo: HelmRepo {
name: "ingress-nginx".to_string(),
url: "https://kubernetes.github.io/ingress-nginx".to_string(),
},
chart_reference: ChartReference::Helm {
repo_url: "https://kubernetes.github.io/ingress-nginx".to_string(),
chart_name: "ingress-nginx".to_string(),
chart_version: "4.0.10".to_string(),
},
Expand All @@ -258,10 +255,13 @@ mod tests {
},
Installation {
name: "exporter-blackbox".to_string(),
config_file: "config.yaml".into(),
values_files: vec![],
env_name: "dev".to_string(),
cluster_name: "spartan".to_string(),
chart: HelmChart::Dir(PathBuf::from("charts/prometheus-blackbox-exporter")),
chart_reference: ChartReference::Local {
path: PathBuf::from("charts/prometheus-blackbox-exporter"),
},
depends: vec![ReleaseReference {
namespace: "kube-system".to_string(),
name: "ingress-nginx-ext".to_string(),
Expand Down Expand Up @@ -292,14 +292,12 @@ mod tests {
// test item depends on itself
let todo = vec![Installation {
name: "ingress-nginx-ext".to_string(),
config_file: "config.yaml".into(),
values_files: vec![],
env_name: "dev".to_string(),
cluster_name: "spartan".to_string(),
chart: HelmChart::HelmRepo {
repo: HelmRepo {
name: "ingress-nginx".to_string(),
url: "https://kubernetes.github.io/ingress-nginx".to_string(),
},
chart_reference: ChartReference::Helm {
repo_url: "https://kubernetes.github.io/ingress-nginx".to_string(),
chart_name: "ingress-nginx".to_string(),
chart_version: "4.0.10".to_string(),
},
Expand All @@ -326,14 +324,12 @@ mod tests {
// test item depends on non-existant install
let todo = vec![Installation {
name: "ingress-nginx-ext".to_string(),
config_file: "config.yaml".into(),
values_files: vec![],
env_name: "dev".to_string(),
cluster_name: "spartan".to_string(),
chart: HelmChart::HelmRepo {
repo: HelmRepo {
name: "ingress-nginx".to_string(),
url: "https://kubernetes.github.io/ingress-nginx".to_string(),
},
chart_reference: ChartReference::Helm {
repo_url: "https://kubernetes.github.io/ingress-nginx".to_string(),
chart_name: "ingress-nginx".to_string(),
chart_version: "4.0.10".to_string(),
},
Expand Down
Loading

0 comments on commit b500e6b

Please sign in to comment.