chore: Refactor application module after code review
Some checks failed
Run Check Script / check (pull_request) Failing after -39s

This commit is contained in:
Jean-Gabriel Gill-Couture 2025-07-01 10:18:52 -04:00
parent 34abe3af24
commit ae95c44867
5 changed files with 60 additions and 121 deletions

View File

@ -0,0 +1,37 @@
/// ContinuousDelivery in Harmony provides this functionality :
///
/// - **Package** the application
/// - **Push** to an artifact registry
/// - **Deploy** to a testing environment
/// - **Deploy** to a production environment
///
/// It is intended to be used as an application feature passed down to an ApplicationInterpret. For
/// example :
///
/// ```rust
/// let app = RustApplicationScore {
/// name: "My Rust App".to_string(),
/// features: vec![ContinuousDelivery::default()],
/// };
/// ```
///
/// *Note :*
///
/// By default, the Harmony Opinionated Pipeline is built using these technologies :
///
/// - Gitea Action (executes pipeline steps)
/// - Docker to build an OCI container image
/// - Helm chart to package Kubernetes resources
/// - Harbor as artifact registru
/// - ArgoCD to install/upgrade/rollback/inspect k8s resources
/// - Kubernetes for runtime orchestration
#[derive(Debug, Default)]
pub struct ContinuousDelivery {}
#[async_trait]
impl <T: Topology + 'static> ApplicationFeature<T> for ContinuousDelivery {
async fn ensure_installed(&self, _topology: &T) -> Result<(), String> {
info!("Installing ContinuousDelivery feature");
todo!()
}
}

View File

@ -1,7 +1,10 @@
use async_trait::async_trait;
use log::info;
use crate::{modules::application::{Application, ApplicationFeature}, topology::{K8sclient, Topology}};
use crate::{
modules::application::ApplicationFeature,
topology::{K8sclient, Topology},
};
#[derive(Debug)]
pub struct PublicEndpoint {
@ -25,17 +28,12 @@ impl Default for PublicEndpoint {
/// For now we only suport K8s ingress, but we will support more stuff at some point
#[async_trait]
impl <T: Topology + K8sclient + 'static> ApplicationFeature<T> for PublicEndpoint {
impl<T: Topology + K8sclient + 'static> ApplicationFeature<T> for PublicEndpoint {
async fn ensure_installed(&self, _topology: &T) -> Result<(), String> {
info!("Making sure public endpoint is installed for port {}", self.application_port);
todo!()
}
async fn is_installed(&self) -> Result<bool, String> {
todo!()
}
async fn uninstall(&self) -> Result<(), String> {
info!(
"Making sure public endpoint is installed for port {}",
self.application_port
);
todo!()
}
}

View File

@ -1,102 +1,6 @@
mod endpoint;
use async_trait::async_trait;
pub use endpoint::*;
use log::info;
use crate::topology::{HelmCommand, Topology};
use super::ApplicationFeature;
#[derive(Debug, Default)]
pub struct SoftwareQualityChecks {}
#[async_trait]
impl<T: Topology + 'static> ApplicationFeature<T> for SoftwareQualityChecks {
// Either allow ApplicationFeature to self-install, which means passing Topology and Inventory
// here. This would be a very easy thing to be done reliably by the ApplicationInterpret.
// However, I feel like this would probably better be a list of Scores (or some sort of
// executable) to be orchestrated by the maestro. We will soon have to manage more complex
// lifecycles, dependencies, parallelism, etc.
//
//
// Or change the ApplicationFeature trait to a Score trait.
//
// For now I'll go with the first option
async fn ensure_installed(&self, _topology: &T) -> Result<(), String> {
info!("Ensuring SoftwareQualityChecks are installed for application");
todo!()
}
async fn is_installed(&self) -> Result<bool, String> {
todo!()
}
async fn uninstall(&self) -> Result<(), String> {
todo!()
}
}
/// ContinuousDelivery in Harmony provides this functionality :
///
/// - **Package** the application
/// - **Push** to an artifact registry
/// - **Deploy** to a testing environment
/// - **Deploy** to a production environment
///
/// It is intended to be used as an application feature passed down to an ApplicationInterpret. For
/// example :
///
/// ```rust
/// let app = RustApplicationScore {
/// name: "My Rust App".to_string(),
/// features: vec![ContinuousDelivery::default()],
/// };
/// ```
///
/// *Note :*
///
/// By default, the Harmony Opinionated Pipeline is built using these technologies :
///
/// - Gitea Action (executes pipeline steps)
/// - Docker to build an OCI container image
/// - Helm chart to package Kubernetes resources
/// - Harbor as artifact registru
/// - ArgoCD to install/upgrade/rollback/inspect k8s resources
/// - Kubernetes for runtime orchestration
#[derive(Debug, Default)]
pub struct ContinuousDelivery {}
#[async_trait]
impl <T: Topology + 'static> ApplicationFeature<T> for ContinuousDelivery {
async fn ensure_installed(&self, _topology: &T) -> Result<(), String> {
info!("Installing ContinuousDelivery feature");
todo!()
}
async fn is_installed(&self) -> Result<bool, String> {
todo!()
}
async fn uninstall(&self) -> Result<(), String> {
todo!()
}
}
#[derive(Debug, Default)]
pub struct Monitoring {}
#[async_trait]
impl <T: Topology + HelmCommand + 'static> ApplicationFeature<T> for Monitoring {
async fn ensure_installed(&self, _topology: &T) -> Result<(), String> {
info!("Ensuring monitoring is available for application");
todo!("create and execute k8s prometheus score, depends on Will's work")
}
async fn is_installed(&self) -> Result<bool, String> {
todo!()
}
async fn uninstall(&self) -> Result<(), String> {
todo!()
}
}
mod monitoring;
pub use monitoring::*;
mod continuous_delivery;
pub use endpoint::*;

View File

@ -0,0 +1,10 @@
#[derive(Debug, Default)]
pub struct Monitoring {}
#[async_trait]
impl <T: Topology + HelmCommand + 'static> ApplicationFeature<T> for Monitoring {
async fn ensure_installed(&self, _topology: &T) -> Result<(), String> {
info!("Ensuring monitoring is available for application");
todo!("create and execute k8s prometheus score, depends on Will's work")
}
}

View File

@ -70,8 +70,6 @@ trait Application {}
#[async_trait]
pub trait ApplicationFeature<T: Topology>: std::fmt::Debug + Send + Sync {
async fn ensure_installed(&self, topology: &T) -> Result<(), String>;
async fn is_installed(&self) -> Result<bool, String>;
async fn uninstall(&self) -> Result<(), String>;
}
impl<T: Topology> Serialize for Box<dyn ApplicationFeature<T>> {
@ -97,12 +95,4 @@ impl <T: Topology > ApplicationFeature<T> for BackupFeature {
async fn ensure_installed(&self, _topology: &T) -> Result<(), String> {
todo!()
}
async fn is_installed(&self) -> Result<bool, String> {
todo!()
}
async fn uninstall(&self) -> Result<(), String> {
todo!()
}
}