From caec71f06d5f2e7e11a2cf462f68f8c9bf90bdea Mon Sep 17 00:00:00 2001 From: Jean-Gabriel Gill-Couture Date: Wed, 22 Jan 2025 10:32:22 -0500 Subject: [PATCH] feat(k8s): add initial Resource module structure Introduce the initial structure for the Kubernetes (K8s) resource module, including `K8sResourceScore` and `K8sResourceInterpret`. Additionally, update the module paths to include the new K8s module. --- .../harmony/src/modules/k8s/Resource.rs | 42 +++++++++++++++++++ harmony-rs/harmony/src/modules/k8s/mod.rs | 3 ++ harmony-rs/harmony/src/modules/mod.rs | 1 + harmony-rs/harmony/src/modules/okd/mod.rs | 1 + harmony-rs/harmony/src/modules/okd/upgrade.rs | 33 +++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 harmony-rs/harmony/src/modules/k8s/Resource.rs create mode 100644 harmony-rs/harmony/src/modules/k8s/mod.rs create mode 100644 harmony-rs/harmony/src/modules/okd/upgrade.rs diff --git a/harmony-rs/harmony/src/modules/k8s/Resource.rs b/harmony-rs/harmony/src/modules/k8s/Resource.rs new file mode 100644 index 0000000..787a9b1 --- /dev/null +++ b/harmony-rs/harmony/src/modules/k8s/Resource.rs @@ -0,0 +1,42 @@ +use async_trait::async_trait; + +use crate::{data::{Id, Version}, interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome}, inventory::Inventory, score::Score, topology::HAClusterTopology}; + +#[derive(Debug)] +pub struct K8sResourceScore {} + +impl Score for K8sResourceScore { + type InterpretType = K8sResourceInterpret; + + fn create_interpret(self) -> Self::InterpretType { + todo!() + } +} + +#[derive(Debug)] +pub struct K8sResourceInterpret { + score: K8sResourceScore, +} + +#[async_trait] +impl Interpret for K8sResourceInterpret { + async fn execute( + &self, + inventory: &Inventory, + topology: &HAClusterTopology, + ) -> Result { + todo!() + } + fn get_name(&self) -> InterpretName { + todo!() + } + fn get_version(&self) -> Version { + todo!() + } + fn get_status(&self) -> InterpretStatus { + todo!() + } + fn get_children(&self) -> Vec { + todo!() + } +} diff --git a/harmony-rs/harmony/src/modules/k8s/mod.rs b/harmony-rs/harmony/src/modules/k8s/mod.rs new file mode 100644 index 0000000..eea7ad8 --- /dev/null +++ b/harmony-rs/harmony/src/modules/k8s/mod.rs @@ -0,0 +1,3 @@ + +pub mod Resource; + diff --git a/harmony-rs/harmony/src/modules/mod.rs b/harmony-rs/harmony/src/modules/mod.rs index a4f93b3..08e2f3f 100644 --- a/harmony-rs/harmony/src/modules/mod.rs +++ b/harmony-rs/harmony/src/modules/mod.rs @@ -4,3 +4,4 @@ pub mod okd; pub mod load_balancer; pub mod tftp; pub mod http; +pub mod k8s; diff --git a/harmony-rs/harmony/src/modules/okd/mod.rs b/harmony-rs/harmony/src/modules/okd/mod.rs index 0f34a0e..e22ed67 100644 --- a/harmony-rs/harmony/src/modules/okd/mod.rs +++ b/harmony-rs/harmony/src/modules/okd/mod.rs @@ -3,4 +3,5 @@ pub mod dns; pub mod load_balancer; pub mod bootstrap_load_balancer; pub mod bootstrap_dhcp; +pub mod upgrade; diff --git a/harmony-rs/harmony/src/modules/okd/upgrade.rs b/harmony-rs/harmony/src/modules/okd/upgrade.rs new file mode 100644 index 0000000..8a101eb --- /dev/null +++ b/harmony-rs/harmony/src/modules/okd/upgrade.rs @@ -0,0 +1,33 @@ +use crate::{data::Version, score::Score}; + +#[derive(Debug)] +pub struct OKDUpgradeScore { + current_version: Version, + target_version: Version, +} + +impl OKDUpgradeScore { + pub fn new() -> Self { + Self { + current_version: Version::from("4.17.0-okd-scos.0").unwrap(), + target_version: Version::from("").unwrap(), + } + } +} + +// impl Score for OKDUpgradeScore { +// type InterpretType; +// +// fn create_interpret(self) -> Self::InterpretType { +// // Should this be a specialized interpret for OKD upgrades or rather a set of interprets +// // such as : +// // +// // MultiStageInterpret : +// // stages : vec![ +// // vec![CheckOperatorsUpgraded, CheckClusterHealthy, CheckOtherPrecondition], +// // vec![PerformUpgrade], +// // vec![VerifyUpgrade, CheckClusterHealth], +// // ] +// todo!() +// } +// }