Compare commits

..

No commits in common. "ad1aa897b1256513cefe059c615956ccfdda018a" and "9345e63a322af3bdf2845d9e70bae4374aed4f3c" have entirely different histories.

12 changed files with 34 additions and 23 deletions

View File

@ -4,13 +4,13 @@ use harmony_macros::yaml;
use k8s_openapi::{ use k8s_openapi::{
api::{ api::{
apps::v1::{Deployment, DeploymentSpec}, apps::v1::{Deployment, DeploymentSpec},
core::v1::{Container, PodSpec, PodTemplateSpec}, core::v1::{Container, Node, Pod, PodSpec, PodTemplateSpec},
}, },
apimachinery::pkg::apis::meta::v1::LabelSelector, apimachinery::pkg::apis::meta::v1::LabelSelector,
}; };
use kube::{ use kube::{
Api, Client, ResourceExt, Api, Client, Config, ResourceExt,
api::{ObjectMeta, PostParams}, api::{ListParams, ObjectMeta, PostParams},
}; };
#[tokio::main] #[tokio::main]
@ -42,7 +42,8 @@ async fn main() {
// println!("found node {} status {:?}", n.name_any(), n.status.unwrap()) // println!("found node {} status {:?}", n.name_any(), n.status.unwrap())
// } // }
assert_eq!(nginx_deployment(), nginx_macro()); let nginxdeployment = nginx_deployment_2();
let nginxdeployment = nginx_deployment_serde();
assert_eq!(nginx_deployment_2(), nginx_macro()); assert_eq!(nginx_deployment_2(), nginx_macro());
assert_eq!(nginx_deployment_serde(), nginx_macro()); assert_eq!(nginx_deployment_serde(), nginx_macro());
let nginxdeployment = nginx_macro(); let nginxdeployment = nginx_macro();
@ -148,7 +149,6 @@ fn nginx_deployment_2() -> Deployment {
deployment deployment
} }
fn nginx_deployment() -> Deployment { fn nginx_deployment() -> Deployment {
let deployment = Deployment { let deployment = Deployment {
metadata: ObjectMeta { metadata: ObjectMeta {

View File

@ -1,7 +1,10 @@
use harmony::{ use harmony::{
inventory::Inventory, inventory::Inventory,
maestro::Maestro, maestro::Maestro,
modules::dummy::{ErrorScore, PanicScore, SuccessScore}, modules::{
dummy::{ErrorScore, PanicScore, SuccessScore},
k8s::deployment::K8sDeploymentScore,
},
topology::HAClusterTopology, topology::HAClusterTopology,
}; };

View File

@ -7,6 +7,7 @@ use harmony::{
dns::DnsScore, dns::DnsScore,
dummy::{ErrorScore, PanicScore, SuccessScore}, dummy::{ErrorScore, PanicScore, SuccessScore},
load_balancer::LoadBalancerScore, load_balancer::LoadBalancerScore,
okd::load_balancer::OKDLoadBalancerScore,
}, },
topology::{ topology::{
BackendServer, HAClusterTopology, HealthCheck, HttpMethod, HttpStatusCode, BackendServer, HAClusterTopology, HealthCheck, HttpMethod, HttpStatusCode,

View File

@ -7,6 +7,7 @@ use super::{
data::{Id, Version}, data::{Id, Version},
executors::ExecutorError, executors::ExecutorError,
inventory::Inventory, inventory::Inventory,
topology::Topology,
}; };
pub enum InterpretName { pub enum InterpretName {

View File

@ -82,7 +82,7 @@ where
}; };
let formatted_val = self.format_value_as_string(v, indent + 1); let formatted_val = self.format_value_as_string(v, indent + 1);
let lines = formatted_val.lines().map(|line| line.trim_start()); let mut lines = formatted_val.lines().map(|line| line.trim_start());
let wrapped_lines: Vec<_> = lines let wrapped_lines: Vec<_> = lines
.flat_map(|line| self.wrap_or_truncate(line.trim_start(), 48)) .flat_map(|line| self.wrap_or_truncate(line.trim_start(), 48))

View File

@ -1,3 +1,5 @@
use std::io;
use async_trait::async_trait; use async_trait::async_trait;
use inquire::Confirm; use inquire::Confirm;
use log::{info, warn}; use log::{info, warn};
@ -14,13 +16,15 @@ use crate::{
use super::{Topology, k8s::K8sClient}; use super::{Topology, k8s::K8sClient};
struct K8sState { struct K8sState {
_client: K8sClient, client: K8sClient,
_source: K8sSource, source: K8sSource,
message: String, message: String,
} }
enum K8sSource { enum K8sSource {
RemoteCluster,
LocalK3d, LocalK3d,
// TODO: Add variants for cloud providers like AwsEks, Gke, Aks
} }
pub struct K8sAnywhereTopology { pub struct K8sAnywhereTopology {
@ -58,14 +62,14 @@ impl K8sAnywhereTopology {
if k8s_anywhere_config.use_system_kubeconfig { if k8s_anywhere_config.use_system_kubeconfig {
match self.try_load_system_kubeconfig().await { match self.try_load_system_kubeconfig().await {
Some(_client) => todo!(), Some(client) => todo!(),
None => todo!(), None => todo!(),
} }
} }
if let Some(kubeconfig) = k8s_anywhere_config.kubeconfig { if let Some(kubeconfig) = k8s_anywhere_config.kubeconfig {
match self.try_load_kubeconfig(&kubeconfig).await { match self.try_load_kubeconfig(&kubeconfig).await {
Some(_client) => todo!(), Some(client) => todo!(),
None => todo!(), None => todo!(),
} }
} }
@ -89,8 +93,8 @@ impl K8sAnywhereTopology {
info!("Starting K8sAnywhere installation"); info!("Starting K8sAnywhere installation");
match self.try_install_k3d().await { match self.try_install_k3d().await {
Ok(client) => Ok(Some(K8sState { Ok(client) => Ok(Some(K8sState {
_client: client, client,
_source: K8sSource::LocalK3d, source: K8sSource::LocalK3d,
message: "Successfully installed K3D cluster and acquired client".to_string(), message: "Successfully installed K3D cluster and acquired client".to_string(),
})), })),
Err(_) => todo!(), Err(_) => todo!(),

View File

@ -8,7 +8,9 @@ use helm_wrapper_rs;
use helm_wrapper_rs::blocking::{DefaultHelmExecutor, HelmExecutor}; use helm_wrapper_rs::blocking::{DefaultHelmExecutor, HelmExecutor};
use non_blank_string_rs::NonBlankString; use non_blank_string_rs::NonBlankString;
use serde::Serialize; use serde::Serialize;
use serde::de::DeserializeOwned;
use std::collections::HashMap; use std::collections::HashMap;
use std::path::PathBuf;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub struct HelmChartScore { pub struct HelmChartScore {

View File

@ -38,14 +38,14 @@ impl<T: Topology> Score<T> for K3DInstallationScore {
} }
#[derive(Debug)] #[derive(Debug)]
pub struct K3dInstallationInterpret {} struct K3dInstallationInterpret {}
#[async_trait] #[async_trait]
impl<T: Topology> Interpret<T> for K3dInstallationInterpret { impl<T: Topology> Interpret<T> for K3dInstallationInterpret {
async fn execute( async fn execute(
&self, &self,
_inventory: &Inventory, inventory: &Inventory,
_topology: &T, topology: &T,
) -> Result<Outcome, InterpretError> { ) -> Result<Outcome, InterpretError> {
todo!() todo!()
} }

View File

@ -13,7 +13,7 @@ use crate::{
}; };
impl std::fmt::Display for OKDLoadBalancerScore { impl std::fmt::Display for OKDLoadBalancerScore {
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
todo!() todo!()
} }
} }

View File

@ -2,15 +2,15 @@ use crate::data::Version;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct OKDUpgradeScore { pub struct OKDUpgradeScore {
_current_version: Version, current_version: Version,
_target_version: Version, target_version: Version,
} }
impl OKDUpgradeScore { impl OKDUpgradeScore {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
_current_version: Version::from("4.17.0-okd-scos.0").unwrap(), current_version: Version::from("4.17.0-okd-scos.0").unwrap(),
_target_version: Version::from("").unwrap(), target_version: Version::from("").unwrap(),
} }
} }
} }

View File

@ -27,7 +27,7 @@ pub struct OPNsenseShellCommandScore {
} }
impl Serialize for OPNsenseShellCommandScore { impl Serialize for OPNsenseShellCommandScore {
fn serialize<S>(&self, _serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where
S: serde::Serializer, S: serde::Serializer,
{ {

View File

@ -17,7 +17,7 @@ pub struct OPNSenseLaunchUpgrade {
} }
impl Serialize for OPNSenseLaunchUpgrade { impl Serialize for OPNSenseLaunchUpgrade {
fn serialize<S>(&self, _serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where
S: serde::Serializer, S: serde::Serializer,
{ {