wip: Fix ArgoApplication
This commit is contained in:
parent
a19b52e690
commit
c11a31c7a9
34
Cargo.lock
generated
34
Cargo.lock
generated
@ -1752,6 +1752,7 @@ dependencies = [
|
|||||||
"non-blank-string-rs",
|
"non-blank-string-rs",
|
||||||
"opnsense-config",
|
"opnsense-config",
|
||||||
"opnsense-config-xml",
|
"opnsense-config-xml",
|
||||||
|
"pretty_assertions",
|
||||||
"rand 0.9.1",
|
"rand 0.9.1",
|
||||||
"reqwest 0.11.27",
|
"reqwest 0.11.27",
|
||||||
"russh",
|
"russh",
|
||||||
@ -1760,6 +1761,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde-value",
|
"serde-value",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"serde_with",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
"similar",
|
"similar",
|
||||||
"strum 0.27.1",
|
"strum 0.27.1",
|
||||||
@ -4080,6 +4082,18 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "schemars"
|
||||||
|
version = "1.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1375ba8ef45a6f15d83fa8748f1079428295d403d6ea991d09ab100155fbc06d"
|
||||||
|
dependencies = [
|
||||||
|
"dyn-clone",
|
||||||
|
"ref-cast",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
@ -4280,22 +4294,36 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_with"
|
name = "serde_with"
|
||||||
version = "3.13.0"
|
version = "3.14.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bf65a400f8f66fb7b0552869ad70157166676db75ed8181f8104ea91cf9d0b42"
|
checksum = "f2c45cd61fefa9db6f254525d46e392b852e0e61d9a1fd36e5bd183450a556d5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"chrono",
|
"chrono",
|
||||||
"hex",
|
"hex",
|
||||||
"indexmap 1.9.3",
|
"indexmap 1.9.3",
|
||||||
"indexmap 2.10.0",
|
"indexmap 2.10.0",
|
||||||
"schemars",
|
"schemars 0.9.0",
|
||||||
|
"schemars 1.0.3",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"serde_with_macros",
|
||||||
"time",
|
"time",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_with_macros"
|
||||||
|
version = "3.14.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "de90945e6565ce0d9a25098082ed4ee4002e047cb59892c318d66821e14bb30f"
|
||||||
|
dependencies = [
|
||||||
|
"darling",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_yaml"
|
name = "serde_yaml"
|
||||||
version = "0.9.34+deprecated"
|
version = "0.9.34+deprecated"
|
||||||
|
@ -52,3 +52,4 @@ convert_case = "0.8"
|
|||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
similar = "2"
|
similar = "2"
|
||||||
uuid = { version = "1.11", features = ["v4", "fast-rng", "macro-diagnostics"] }
|
uuid = { version = "1.11", features = ["v4", "fast-rng", "macro-diagnostics"] }
|
||||||
|
pretty_assertions = "1.4.1"
|
||||||
|
@ -58,3 +58,7 @@ futures-util = "0.3.31"
|
|||||||
tokio-util = "0.7.15"
|
tokio-util = "0.7.15"
|
||||||
strum = { version = "0.27.1", features = ["derive"] }
|
strum = { version = "0.27.1", features = ["derive"] }
|
||||||
tempfile = "3.20.0"
|
tempfile = "3.20.0"
|
||||||
|
serde_with = "3.14.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
pretty_assertions.workspace = true
|
||||||
|
@ -3,11 +3,13 @@ use std::{backtrace, collections::HashMap};
|
|||||||
use k8s_openapi::{Metadata, NamespaceResourceScope, Resource};
|
use k8s_openapi::{Metadata, NamespaceResourceScope, Resource};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use serde_with::skip_serializing_none;
|
||||||
use serde_yaml::Value;
|
use serde_yaml::Value;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::modules::application::features::CDApplicationConfig;
|
use crate::modules::application::features::CDApplicationConfig;
|
||||||
|
|
||||||
|
#[skip_serializing_none]
|
||||||
#[derive(Clone, Debug, Serialize)]
|
#[derive(Clone, Debug, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Helm {
|
pub struct Helm {
|
||||||
@ -27,9 +29,11 @@ pub struct Helm {
|
|||||||
pub namespace: Option<String>,
|
pub namespace: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[skip_serializing_none]
|
||||||
#[derive(Clone, Debug, Serialize)]
|
#[derive(Clone, Debug, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Source {
|
pub struct Source {
|
||||||
|
#[serde(rename = "repoURL")]
|
||||||
pub repo_url: Url,
|
pub repo_url: Url,
|
||||||
pub target_revision: Option<String>,
|
pub target_revision: Option<String>,
|
||||||
pub chart: String,
|
pub chart: String,
|
||||||
@ -67,6 +71,7 @@ pub struct SyncPolicy {
|
|||||||
pub retry: Retry,
|
pub retry: Retry,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[skip_serializing_none]
|
||||||
#[derive(Clone, Debug, Serialize)]
|
#[derive(Clone, Debug, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct ArgoApplication {
|
pub struct ArgoApplication {
|
||||||
@ -135,7 +140,7 @@ impl From<CDApplicationConfig> for ArgoApplication {
|
|||||||
source: Source {
|
source: Source {
|
||||||
repo_url: Url::parse(value.helm_chart_repo_url.to_string().as_str())
|
repo_url: Url::parse(value.helm_chart_repo_url.to_string().as_str())
|
||||||
.expect("couldn't convert to URL"),
|
.expect("couldn't convert to URL"),
|
||||||
target_revision: None,
|
target_revision: Some(value.version.to_string()),
|
||||||
chart: value.helm_chart_name,
|
chart: value.helm_chart_name,
|
||||||
helm: Helm {
|
helm: Helm {
|
||||||
pass_credentials: None,
|
pass_credentials: None,
|
||||||
@ -145,7 +150,7 @@ impl From<CDApplicationConfig> for ArgoApplication {
|
|||||||
value_files: vec![],
|
value_files: vec![],
|
||||||
ignore_missing_value_files: None,
|
ignore_missing_value_files: None,
|
||||||
values: None,
|
values: None,
|
||||||
values_object: Some(value.values_overrides),
|
values_object: value.values_overrides,
|
||||||
skip_crds: None,
|
skip_crds: None,
|
||||||
skip_schema_validation: None,
|
skip_schema_validation: None,
|
||||||
version: None,
|
version: None,
|
||||||
@ -252,6 +257,7 @@ spec:
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::modules::application::features::{
|
use crate::modules::application::features::{
|
||||||
@ -315,24 +321,14 @@ spec:
|
|||||||
server: https://kubernetes.default.svc
|
server: https://kubernetes.default.svc
|
||||||
namespace: test-ns
|
namespace: test-ns
|
||||||
source:
|
source:
|
||||||
repoUrl: http://test/
|
repoURL: http://test/
|
||||||
targetRevision: null
|
|
||||||
chart: test-chart
|
chart: test-chart
|
||||||
helm:
|
helm:
|
||||||
passCredentials: null
|
|
||||||
parameters: []
|
parameters: []
|
||||||
fileParameters: []
|
fileParameters: []
|
||||||
releaseName: test-release-neame
|
releaseName: test-release-neame
|
||||||
valueFiles: []
|
valueFiles: []
|
||||||
ignoreMissingValueFiles: null
|
|
||||||
values: null
|
|
||||||
valuesObject: null
|
|
||||||
skipCrds: null
|
|
||||||
skipSchemaValidation: null
|
|
||||||
version: null
|
|
||||||
kubeVersion: null
|
|
||||||
apiVersions: []
|
apiVersions: []
|
||||||
namespace: null
|
|
||||||
syncPolicy:
|
syncPolicy:
|
||||||
automated:
|
automated:
|
||||||
prune: false
|
prune: false
|
||||||
|
@ -161,6 +161,7 @@ impl<
|
|||||||
let helm_chart = self.application.build_push_helm_package(&image).await?;
|
let helm_chart = self.application.build_push_helm_package(&image).await?;
|
||||||
info!("Pushed new helm chart {helm_chart}");
|
info!("Pushed new helm chart {helm_chart}");
|
||||||
|
|
||||||
|
error!("TODO Make building image configurable/skippable");
|
||||||
let image = self.application.build_push_oci_image().await?;
|
let image = self.application.build_push_oci_image().await?;
|
||||||
info!("Pushed new docker image {image}");
|
info!("Pushed new docker image {image}");
|
||||||
|
|
||||||
@ -194,7 +195,7 @@ impl<
|
|||||||
version: Version::from("0.1.0").unwrap(),
|
version: Version::from("0.1.0").unwrap(),
|
||||||
helm_chart_repo_url: Url::Url(url::Url::parse("oci://hub.nationtech.io/harmony/harmony-example-rust-webapp-chart/harmony-example-rust-webapp-chart").unwrap()),
|
helm_chart_repo_url: Url::Url(url::Url::parse("oci://hub.nationtech.io/harmony/harmony-example-rust-webapp-chart/harmony-example-rust-webapp-chart").unwrap()),
|
||||||
helm_chart_name: "harmony-example-rust-webapp-chart".to_string(),
|
helm_chart_name: "harmony-example-rust-webapp-chart".to_string(),
|
||||||
values_overrides: Value::Null,
|
values_overrides: None,
|
||||||
name: "harmony-demo-rust-webapp".to_string(),
|
name: "harmony-demo-rust-webapp".to_string(),
|
||||||
namespace: "harmonydemo-staging".to_string(),
|
namespace: "harmonydemo-staging".to_string(),
|
||||||
})],
|
})],
|
||||||
@ -226,7 +227,7 @@ pub struct CDApplicationConfig {
|
|||||||
pub version: Version,
|
pub version: Version,
|
||||||
pub helm_chart_repo_url: Url,
|
pub helm_chart_repo_url: Url,
|
||||||
pub helm_chart_name: String,
|
pub helm_chart_name: String,
|
||||||
pub values_overrides: Value,
|
pub values_overrides: Option<Value>,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub namespace: String,
|
pub namespace: String,
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use k8s_openapi::Resource;
|
use k8s_openapi::Resource;
|
||||||
|
use log::error;
|
||||||
use non_blank_string_rs::NonBlankString;
|
use non_blank_string_rs::NonBlankString;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
@ -50,6 +51,7 @@ impl<T: Topology + K8sclient + HelmCommand> Interpret<T> for ArgoInterpret {
|
|||||||
inventory: &Inventory,
|
inventory: &Inventory,
|
||||||
topology: &T,
|
topology: &T,
|
||||||
) -> Result<Outcome, InterpretError> {
|
) -> Result<Outcome, InterpretError> {
|
||||||
|
error!("Uncomment below, only disabled for debugging");
|
||||||
self.score
|
self.score
|
||||||
.create_interpret()
|
.create_interpret()
|
||||||
.execute(inventory, topology)
|
.execute(inventory, topology)
|
||||||
|
@ -22,4 +22,4 @@ tokio-util = { version = "0.7.13", features = [ "codec" ] }
|
|||||||
tokio-stream = "0.1.17"
|
tokio-stream = "0.1.17"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions = "1.4.1"
|
pretty_assertions.workspace = true
|
||||||
|
Loading…
Reference in New Issue
Block a user