feat: WIP argocd_score #78
174
harmony/src/modules/application/features/argo_types.rs
Normal file
174
harmony/src/modules/application/features/argo_types.rs
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
use std::{backtrace, collections::HashMap};
|
||||||
|
|
||||||
|
use serde::Serialize;
|
||||||
|
use serde_yaml::{Mapping, Value};
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
use crate::modules::application::features::CDApplicationConfig;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Helm {
|
||||||
|
pub pass_credentials: Option<bool>,
|
||||||
|
pub parameters: Vec<Value>,
|
||||||
|
pub file_parameters: Vec<Value>,
|
||||||
|
pub release_name: Option<String>,
|
||||||
|
pub value_files: Vec<String>,
|
||||||
|
pub ignore_missing_value_files: Option<bool>,
|
||||||
|
pub values: Option<String>,
|
||||||
|
pub values_object: Option<Value>,
|
||||||
|
pub skip_crds: Option<bool>,
|
||||||
|
pub skip_schema_validation: Option<bool>,
|
||||||
|
pub version: Option<String>,
|
||||||
|
pub kube_version: Option<String>,
|
||||||
|
pub api_versions: Vec<String>,
|
||||||
|
pub namespace: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Source {
|
||||||
|
pub repo_url: Url,
|
||||||
|
pub target_revision: Option<String>,
|
||||||
|
pub chart: String,
|
||||||
|
pub helm: Helm,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Automated {
|
||||||
|
pub prune: bool,
|
||||||
|
pub self_heal: bool,
|
||||||
|
pub allow_empty: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Backoff {
|
||||||
|
pub duration: String,
|
||||||
|
pub factor: u32,
|
||||||
|
pub max_duration: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Retry {
|
||||||
|
pub limit: u32,
|
||||||
|
pub backoff: Backoff,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct SyncPolicy {
|
||||||
|
pub automated: Automated,
|
||||||
|
pub sync_options: Vec<String>,
|
||||||
|
pub retry: Retry,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct ArgoApplication {
|
||||||
|
pub name: String,
|
||||||
|
pub namespace: Option<String>,
|
||||||
|
pub project: String,
|
||||||
|
pub source: Source,
|
||||||
|
pub sync_policy: SyncPolicy,
|
||||||
|
pub revision_history_limit: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ArgoApplication {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
name: Default::default(),
|
||||||
|
namespace: Default::default(),
|
||||||
|
project: Default::default(),
|
||||||
|
source: Source {
|
||||||
|
repo_url: Url::parse("http://asdf").expect("Couldn't parse to URL"),
|
||||||
|
target_revision: None,
|
||||||
|
chart: "".to_string(),
|
||||||
|
helm: Helm {
|
||||||
|
pass_credentials: None,
|
||||||
|
parameters: vec![],
|
||||||
|
file_parameters: vec![],
|
||||||
|
release_name: None,
|
||||||
|
value_files: vec![],
|
||||||
|
ignore_missing_value_files: None,
|
||||||
|
values: None,
|
||||||
|
values_object: None,
|
||||||
|
skip_crds: None,
|
||||||
|
skip_schema_validation: None,
|
||||||
|
version: None,
|
||||||
|
kube_version: None,
|
||||||
|
api_versions: vec![],
|
||||||
|
namespace: None,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sync_policy: SyncPolicy {
|
||||||
|
automated: Automated {
|
||||||
|
prune: false,
|
||||||
|
self_heal: false,
|
||||||
|
allow_empty: false,
|
||||||
|
},
|
||||||
|
sync_options: vec![],
|
||||||
|
retry: Retry {
|
||||||
|
limit: 5,
|
||||||
|
backoff: Backoff {
|
||||||
|
duration: "5s".to_string(),
|
||||||
|
factor: 2,
|
||||||
|
max_duration: "3m".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
revision_history_limit: 10,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<CDApplicationConfig> for ArgoApplication {
|
||||||
|
fn from(value: CDApplicationConfig) -> Self {
|
||||||
|
Self {
|
||||||
|
name: value.name,
|
||||||
|
namespace: Some(value.namespace),
|
||||||
|
project: "default".to_string(),
|
||||||
|
source: Source {
|
||||||
|
repo_url: Url::parse(value.helm_chart_repo_url.to_string().as_str())
|
||||||
|
.expect("couldn't convert to URL"),
|
||||||
|
target_revision: None,
|
||||||
|
chart: value.helm_chart_name,
|
||||||
|
helm: Helm {
|
||||||
|
pass_credentials: None,
|
||||||
|
parameters: vec![],
|
||||||
|
file_parameters: vec![],
|
||||||
|
release_name: None,
|
||||||
|
value_files: vec![],
|
||||||
|
ignore_missing_value_files: None,
|
||||||
|
values: None,
|
||||||
|
values_object: Some(value.values_overrides),
|
||||||
|
skip_crds: None,
|
||||||
|
skip_schema_validation: None,
|
||||||
|
version: None,
|
||||||
|
kube_version: None,
|
||||||
|
api_versions: vec![],
|
||||||
|
namespace: None,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sync_policy: SyncPolicy {
|
||||||
|
automated: Automated {
|
||||||
|
prune: false,
|
||||||
|
self_heal: false,
|
||||||
|
allow_empty: true,
|
||||||
|
},
|
||||||
|
sync_options: vec![],
|
||||||
|
retry: Retry {
|
||||||
|
limit: 5,
|
||||||
|
backoff: Backoff {
|
||||||
|
duration: "5s".to_string(),
|
||||||
|
factor: 2,
|
||||||
|
max_duration: "3m".to_string(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
..Self::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use log::info;
|
use log::info;
|
||||||
use serde_json::Value;
|
use serde_yaml::Value;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::Version,
|
data::Version,
|
||||||
@ -74,9 +74,12 @@ impl<T: Topology + HelmCommand + 'static> ApplicationFeature<T> for ContinuousDe
|
|||||||
/// For now this is entirely bound to K8s / ArgoCD, will have to be revisited when we support
|
/// For now this is entirely bound to K8s / ArgoCD, will have to be revisited when we support
|
||||||
/// more CD systems
|
/// more CD systems
|
||||||
pub struct CDApplicationConfig {
|
pub struct CDApplicationConfig {
|
||||||
version: Version,
|
pub version: Version,
|
||||||
helm_chart_url: Url,
|
pub helm_chart_repo_url: Url,
|
||||||
values_overrides: Value,
|
pub helm_chart_name: String,
|
||||||
|
pub values_overrides: Value,
|
||||||
|
pub name: String,
|
||||||
|
pub namespace: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ContinuousDeliveryApplication {
|
pub trait ContinuousDeliveryApplication {
|
||||||
|
|||||||
@ -9,3 +9,6 @@ pub use continuous_delivery::*;
|
|||||||
|
|
||||||
mod helm_argocd_score;
|
mod helm_argocd_score;
|
||||||
pub use helm_argocd_score::*;
|
pub use helm_argocd_score::*;
|
||||||
|
|
||||||
|
mod argo_types;
|
||||||
|
pub use argo_types::*;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user