fix/argoApplication #84
| @ -10,7 +10,7 @@ use harmony::{ | |||||||
|     inventory::Inventory, |     inventory::Inventory, | ||||||
|     maestro::Maestro, |     maestro::Maestro, | ||||||
|     modules::{ |     modules::{ | ||||||
|         http::HttpScore, |         http::StaticFilesHttpScore, | ||||||
|         ipxe::IpxeScore, |         ipxe::IpxeScore, | ||||||
|         okd::{ |         okd::{ | ||||||
|             bootstrap_dhcp::OKDBootstrapDhcpScore, |             bootstrap_dhcp::OKDBootstrapDhcpScore, | ||||||
| @ -126,7 +126,7 @@ async fn main() { | |||||||
|         harmony::modules::okd::load_balancer::OKDLoadBalancerScore::new(&topology); |         harmony::modules::okd::load_balancer::OKDLoadBalancerScore::new(&topology); | ||||||
| 
 | 
 | ||||||
|     let tftp_score = TftpScore::new(Url::LocalFolder("./data/watchguard/tftpboot".to_string())); |     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(), |         "./data/watchguard/pxe-http-files".to_string(), | ||||||
|     )); |     )); | ||||||
|     let ipxe_score = IpxeScore::new(); |     let ipxe_score = IpxeScore::new(); | ||||||
|  | |||||||
| @ -11,7 +11,7 @@ use harmony::{ | |||||||
|     maestro::Maestro, |     maestro::Maestro, | ||||||
|     modules::{ |     modules::{ | ||||||
|         dummy::{ErrorScore, PanicScore, SuccessScore}, |         dummy::{ErrorScore, PanicScore, SuccessScore}, | ||||||
|         http::HttpScore, |         http::StaticFilesHttpScore, | ||||||
|         okd::{dhcp::OKDDhcpScore, dns::OKDDnsScore, load_balancer::OKDLoadBalancerScore}, |         okd::{dhcp::OKDDhcpScore, dns::OKDDnsScore, load_balancer::OKDLoadBalancerScore}, | ||||||
|         opnsense::OPNsenseShellCommandScore, |         opnsense::OPNsenseShellCommandScore, | ||||||
|         tftp::TftpScore, |         tftp::TftpScore, | ||||||
| @ -81,7 +81,7 @@ async fn main() { | |||||||
|     let load_balancer_score = OKDLoadBalancerScore::new(&topology); |     let load_balancer_score = OKDLoadBalancerScore::new(&topology); | ||||||
| 
 | 
 | ||||||
|     let tftp_score = TftpScore::new(Url::LocalFolder("./data/watchguard/tftpboot".to_string())); |     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(), |         "./data/watchguard/pxe-http-files".to_string(), | ||||||
|     )); |     )); | ||||||
|     let mut maestro = Maestro::initialize(inventory, topology).await.unwrap(); |     let mut maestro = Maestro::initialize(inventory, topology).await.unwrap(); | ||||||
|  | |||||||
| @ -10,14 +10,25 @@ use crate::{ | |||||||
|     topology::{HttpServer, Topology, Url}, |     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)] | #[derive(Debug, new, Clone, Serialize)] | ||||||
| pub struct HttpScore { | pub struct StaticFilesHttpScore { | ||||||
|     files_to_serve: Url, |     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>> { |     fn create_interpret(&self) -> Box<dyn Interpret<T>> { | ||||||
|         Box::new(HttpInterpret::new(self.clone())) |         Box::new(StaticFilesHttpInterpret::new(self.clone())) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn name(&self) -> String { |     fn name(&self) -> String { | ||||||
| @ -26,12 +37,12 @@ impl<T: Topology + HttpServer> Score<T> for HttpScore { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[derive(Debug, new, Clone)] | #[derive(Debug, new, Clone)] | ||||||
| pub struct HttpInterpret { | pub struct StaticFilesHttpInterpret { | ||||||
|     score: HttpScore, |     score: StaticFilesHttpScore, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[async_trait] | #[async_trait] | ||||||
| impl<T: Topology + HttpServer> Interpret<T> for HttpInterpret { | impl<T: Topology + HttpServer> Interpret<T> for StaticFilesHttpInterpret { | ||||||
|     async fn execute( |     async fn execute( | ||||||
|         &self, |         &self, | ||||||
|         _inventory: &Inventory, |         _inventory: &Inventory, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user