forked from NationTech/harmony
		
	This commit introduces a new topology, `K8sAnywhereTopology`, designed to handle Kubernetes deployments more flexibly. Key changes include: - Introduced `K8sAnywhereTopology` to encapsulate Kubernetes client management and configuration. - Refactored existing Kubernetes-related code to utilize the new topology. - Updated `OcK8sclient` to `K8sclient` across modules (k8s, lamp, deployment, resource) for consistency. - Ensured all relevant modules now interface with Kubernetes through the `K8sclient` trait. This change promotes a more modular and maintainable codebase for Kubernetes integrations within Harmony.
		
			
				
	
	
		
			88 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			88 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
| use std::path::{Path, PathBuf};
 | |
| 
 | |
| use async_trait::async_trait;
 | |
| use serde::Serialize;
 | |
| 
 | |
| use crate::{
 | |
|     data::{Id, Version},
 | |
|     interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome},
 | |
|     inventory::Inventory,
 | |
|     modules::k8s::deployment::K8sDeploymentScore,
 | |
|     score::Score,
 | |
|     topology::{K8sclient, Topology, Url},
 | |
| };
 | |
| 
 | |
| #[derive(Debug, Clone, Serialize)]
 | |
| pub struct LAMPScore {
 | |
|     pub name: String,
 | |
|     pub domain: Url,
 | |
|     pub config: LAMPConfig,
 | |
|     pub php_version: Version,
 | |
| }
 | |
| 
 | |
| #[derive(Debug, Clone, Serialize)]
 | |
| pub struct LAMPConfig {
 | |
|     pub project_root: PathBuf,
 | |
|     pub ssl_enabled: bool,
 | |
| }
 | |
| 
 | |
| impl Default for LAMPConfig {
 | |
|     fn default() -> Self {
 | |
|         LAMPConfig {
 | |
|             project_root: Path::new("./src").to_path_buf(),
 | |
|             ssl_enabled: true,
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| impl<T: Topology> Score<T> for LAMPScore {
 | |
|     fn create_interpret(&self) -> Box<dyn Interpret<T>> {
 | |
|         todo!()
 | |
|     }
 | |
| 
 | |
|     fn name(&self) -> String {
 | |
|         "LampScore".to_string()
 | |
|     }
 | |
| }
 | |
| 
 | |
| #[derive(Debug)]
 | |
| pub struct LAMPInterpret {
 | |
|     score: LAMPScore,
 | |
| }
 | |
| 
 | |
| #[async_trait]
 | |
| impl<T: Topology + K8sclient> Interpret<T> for LAMPInterpret {
 | |
|     async fn execute(
 | |
|         &self,
 | |
|         inventory: &Inventory,
 | |
|         topology: &T,
 | |
|     ) -> Result<Outcome, InterpretError> {
 | |
|         let deployment_score = K8sDeploymentScore {
 | |
|             name: <LAMPScore as Score<T>>::name(&self.score),
 | |
|             image: "local_image".to_string(),
 | |
|         };
 | |
| 
 | |
|         deployment_score
 | |
|             .create_interpret()
 | |
|             .execute(inventory, topology)
 | |
|             .await?;
 | |
|         todo!()
 | |
|     }
 | |
| 
 | |
|     fn get_name(&self) -> InterpretName {
 | |
|         todo!()
 | |
|     }
 | |
| 
 | |
|     fn get_version(&self) -> Version {
 | |
|         todo!()
 | |
|     }
 | |
| 
 | |
|     fn get_status(&self) -> InterpretStatus {
 | |
|         todo!()
 | |
|     }
 | |
| 
 | |
|     fn get_children(&self) -> Vec<Id> {
 | |
|         todo!()
 | |
|     }
 | |
| }
 |