Compare commits

...

2 Commits

12 changed files with 23 additions and 34 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, Node, Pod, PodSpec, PodTemplateSpec}, core::v1::{Container, PodSpec, PodTemplateSpec},
}, },
apimachinery::pkg::apis::meta::v1::LabelSelector, apimachinery::pkg::apis::meta::v1::LabelSelector,
}; };
use kube::{ use kube::{
Api, Client, Config, ResourceExt, Api, Client, ResourceExt,
api::{ListParams, ObjectMeta, PostParams}, api::{ObjectMeta, PostParams},
}; };
#[tokio::main] #[tokio::main]
@ -42,8 +42,7 @@ async fn main() {
// println!("found node {} status {:?}", n.name_any(), n.status.unwrap()) // println!("found node {} status {:?}", n.name_any(), n.status.unwrap())
// } // }
let nginxdeployment = nginx_deployment_2(); assert_eq!(nginx_deployment(), nginx_macro());
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();
@ -149,6 +148,7 @@ 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,10 +1,7 @@
use harmony::{ use harmony::{
inventory::Inventory, inventory::Inventory,
maestro::Maestro, maestro::Maestro,
modules::{ modules::dummy::{ErrorScore, PanicScore, SuccessScore},
dummy::{ErrorScore, PanicScore, SuccessScore},
k8s::deployment::K8sDeploymentScore,
},
topology::HAClusterTopology, topology::HAClusterTopology,
}; };

View File

@ -7,7 +7,6 @@ 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,7 +7,6 @@ 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 mut lines = formatted_val.lines().map(|line| line.trim_start()); let 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,5 +1,3 @@
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};
@ -16,15 +14,13 @@ 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 {
@ -62,14 +58,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!(),
} }
} }
@ -93,8 +89,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,9 +8,7 @@ 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)]
struct K3dInstallationInterpret {} pub 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,
{ {