feat: WIP application module that will allow easy design of application/solution scores with standard delivery features like CI/CD/Backups/Multisite

This commit is contained in:
Jean-Gabriel Gill-Couture 2025-06-24 11:19:46 -04:00
parent e06548ac44
commit 22847fc42a
2 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,83 @@
use async_trait::async_trait;
use serde::Serialize;
use crate::{
data::{Id, Version},
interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome},
inventory::Inventory,
score::Score,
topology::Topology,
};
#[derive(Clone, Serialize, Debug)]
pub struct GoApplicationConfig {}
#[derive(Clone, Serialize, Debug)]
pub struct GoApplicationScore {
pub config: GoApplicationConfig,
}
impl<T: Topology> Score<T> for GoApplicationScore {
fn create_interpret(&self) -> Box<dyn crate::interpret::Interpret<T>> {
todo!()
}
fn name(&self) -> String {
todo!()
}
}
#[derive(Debug)]
pub struct ApplicationInterpret {
pub features: Vec<Box<dyn ApplicationFeature>>,
}
#[async_trait]
impl<T: Topology> Interpret<T> for ApplicationInterpret {
async fn execute(&self, _inventory: &Inventory, _topology: &T) -> Result<Outcome, InterpretError> {
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!()
}
}
/// An ApplicationFeature provided by harmony, such as Backups, Monitoring, MultisiteAvailability,
/// ContinuousIntegration, ContinuousDelivery
#[async_trait]
pub trait ApplicationFeature: std::fmt::Debug + Send + Sync {
async fn ensure_installed(&self) -> Result<(), String>;
async fn is_installed(&self) -> Result<bool, String>;
async fn uninstall(&self) -> Result<(), String>;
}
#[derive(Debug)]
pub struct BackupFeature;
#[async_trait]
impl ApplicationFeature for BackupFeature {
async fn ensure_installed(&self) -> Result<(), String> {
todo!()
}
async fn is_installed(&self) -> Result<bool, String> {
todo!()
}
async fn uninstall(&self) -> Result<(), String> {
todo!()
}
}

View File

@ -14,3 +14,4 @@ pub mod okd;
pub mod opnsense;
pub mod tenant;
pub mod tftp;
pub mod application;