refact: Rename HttpScore into StaticFileHttpScore and add minimal documentation
All checks were successful
Run Check Script / check (pull_request) Successful in 1m43s

This commit is contained in:
Jean-Gabriel Gill-Couture 2025-07-04 21:05:32 -04:00
parent 3eca409f8d
commit 98f3f82ad5
3 changed files with 21 additions and 10 deletions

View File

@ -10,7 +10,7 @@ use harmony::{
inventory::Inventory,
maestro::Maestro,
modules::{
http::HttpScore,
http::StaticFilesHttpScore,
ipxe::IpxeScore,
okd::{
bootstrap_dhcp::OKDBootstrapDhcpScore,
@ -126,7 +126,7 @@ async fn main() {
harmony::modules::okd::load_balancer::OKDLoadBalancerScore::new(&topology);
let tftp_score = TftpScore::new(Url::LocalFolder("./data/watchguard/tftpboot".to_string()));
let http_score = HttpScore::new(Url::LocalFolder(
let http_score = StaticFilesHttpScore::new(Url::LocalFolder(
"./data/watchguard/pxe-http-files".to_string(),
));
let ipxe_score = IpxeScore::new();

View File

@ -11,7 +11,7 @@ use harmony::{
maestro::Maestro,
modules::{
dummy::{ErrorScore, PanicScore, SuccessScore},
http::HttpScore,
http::StaticFilesHttpScore,
okd::{dhcp::OKDDhcpScore, dns::OKDDnsScore, load_balancer::OKDLoadBalancerScore},
opnsense::OPNsenseShellCommandScore,
tftp::TftpScore,
@ -81,7 +81,7 @@ async fn main() {
let load_balancer_score = OKDLoadBalancerScore::new(&topology);
let tftp_score = TftpScore::new(Url::LocalFolder("./data/watchguard/tftpboot".to_string()));
let http_score = HttpScore::new(Url::LocalFolder(
let http_score = StaticFilesHttpScore::new(Url::LocalFolder(
"./data/watchguard/pxe-http-files".to_string(),
));
let mut maestro = Maestro::initialize(inventory, topology).await.unwrap();

View File

@ -10,14 +10,25 @@ use crate::{
topology::{HttpServer, Topology, Url},
};
/// Configure an HTTP server that is provided by the Topology
///
/// This Score will let you easily specify a file path to be served by the HTTP server
///
/// For example, if you have a folder of assets at `/var/www/assets` simply do :
///
/// ```rust,ignore
/// StaticFilesHttpScore {
/// files_to_serve: url!("file:///var/www/assets"),
/// }
/// ```
#[derive(Debug, new, Clone, Serialize)]
pub struct HttpScore {
pub struct StaticFilesHttpScore {
files_to_serve: Url,
}
impl<T: Topology + HttpServer> Score<T> for HttpScore {
impl<T: Topology + HttpServer> Score<T> for StaticFilesHttpScore {
fn create_interpret(&self) -> Box<dyn Interpret<T>> {
Box::new(HttpInterpret::new(self.clone()))
Box::new(StaticFilesHttpInterpret::new(self.clone()))
}
fn name(&self) -> String {
@ -26,12 +37,12 @@ impl<T: Topology + HttpServer> Score<T> for HttpScore {
}
#[derive(Debug, new, Clone)]
pub struct HttpInterpret {
score: HttpScore,
pub struct StaticFilesHttpInterpret {
score: StaticFilesHttpScore,
}
#[async_trait]
impl<T: Topology + HttpServer> Interpret<T> for HttpInterpret {
impl<T: Topology + HttpServer> Interpret<T> for StaticFilesHttpInterpret {
async fn execute(
&self,
_inventory: &Inventory,