fix(cli): simplify running the CLI by hiding the maestro inside the implemtation #93
							
								
								
									
										49
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								README.md
									
									
									
									
									
								
							| @ -1,5 +1,6 @@ | ||||
| # Harmony : Open-source infrastructure orchestration that treats your platform like first-class code. | ||||
| *By [NationTech](https://nationtech.io)* | ||||
| # Harmony : Open-source infrastructure orchestration that treats your platform like first-class code | ||||
| 
 | ||||
| _By [NationTech](https://nationtech.io)_ | ||||
| 
 | ||||
| [](https://git.nationtech.io/nationtech/harmony) | ||||
| [](LICENSE) | ||||
| @ -24,7 +25,7 @@ From a **developer laptop** to a **global production cluster**, a single **sourc | ||||
| Infrastructure is essential, but it shouldn’t be your core business. Harmony is built on three guiding principles that make modern platforms reliable, repeatable, and easy to reason about. | ||||
| 
 | ||||
| | Principle                              | What it means for you                                                                                                                                                                | | ||||
| |-----------|-----------------------| | ||||
| | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||||
| | **Infrastructure as Resilient Code**   | Replace sprawling YAML and bash scripts with type-safe Rust. Test, refactor, and version your platform just like application code.                                                   | | ||||
| | **Prove It Works — Before You Deploy** | Harmony uses the compiler to verify that your application’s needs match the target environment’s capabilities at **compile-time**, eliminating an entire class of runtime outages.   | | ||||
| | **One Unified Model**                  | Software and infrastructure are a single system. Harmony models them together, enabling deep automation—from bare-metal servers to Kubernetes workloads—with zero context switching. | | ||||
| @ -63,22 +64,20 @@ async fn main() { | ||||
|         }, | ||||
|     }; | ||||
| 
 | ||||
|     // 2. Pick where it should run | ||||
|     let mut maestro = Maestro::<K8sAnywhereTopology>::initialize( | ||||
|         Inventory::autoload(),                // auto-detect hardware / kube-config | ||||
|         K8sAnywhereTopology::from_env(),      // local k3d, CI, staging, prod… | ||||
|     ) | ||||
|     .await | ||||
|     .unwrap(); | ||||
| 
 | ||||
|     // 3. Enhance with extra scores (monitoring, CI/CD, …) | ||||
|     // 2. Enhance with extra scores (monitoring, CI/CD, …) | ||||
|     let mut monitoring = MonitoringAlertingStackScore::new(); | ||||
|     monitoring.namespace = Some(lamp_stack.config.namespace.clone()); | ||||
| 
 | ||||
|     maestro.register_all(vec![Box::new(lamp_stack), Box::new(monitoring)]); | ||||
| 
 | ||||
|     // 4. Launch an interactive CLI / TUI | ||||
|     harmony_cli::init(maestro, None).await.unwrap(); | ||||
|     // 3. Run your scores on the desired topology & inventory | ||||
|     harmony_cli::run( | ||||
|         Inventory::autoload(),                // auto-detect hardware / kube-config | ||||
|         K8sAnywhereTopology::from_env(),      // local k3d, CI, staging, prod… | ||||
|         vec![ | ||||
|           Box::new(lamp_stack), | ||||
|           Box::new(monitoring) | ||||
|         ], | ||||
|         None | ||||
|     ).await.unwrap(); | ||||
| } | ||||
| ``` | ||||
| 
 | ||||
| @ -95,10 +94,10 @@ Harmony analyses the code, shows an execution plan in a TUI, and applies it once | ||||
| ## 3 · Core Concepts | ||||
| 
 | ||||
| | Term             | One-liner                                                                                            | | ||||
| |------|-----------| | ||||
| | ---------------- | ---------------------------------------------------------------------------------------------------- | | ||||
| | **Score<T>**     | Declarative description of the desired state (e.g., `LAMPScore`).                                    | | ||||
| | **Interpret<T>** | Imperative logic that realises a `Score` on a specific environment.                                  | | ||||
| | **Topology** | An environment (local k3d, AWS, bare-metal) exposing verified *Capabilities* (Kubernetes, DNS, …). | | ||||
| | **Topology**     | An environment (local k3d, AWS, bare-metal) exposing verified _Capabilities_ (Kubernetes, DNS, …).   | | ||||
| | **Maestro**      | Orchestrator that compiles Scores + Topology, ensuring all capabilities line up **at compile-time**. | | ||||
| | **Inventory**    | Optional catalogue of physical assets for bare-metal and edge deployments.                           | | ||||
| 
 | ||||
| @ -112,9 +111,9 @@ A visual overview is in the diagram below. | ||||
| 
 | ||||
| Prerequisites: | ||||
| 
 | ||||
| * Rust  | ||||
| * Docker (if you deploy locally) | ||||
| * `kubectl` / `helm` for Kubernetes-based topologies | ||||
| - Rust | ||||
| - Docker (if you deploy locally) | ||||
| - `kubectl` / `helm` for Kubernetes-based topologies | ||||
| 
 | ||||
| ```bash | ||||
| git clone https://git.nationtech.io/nationtech/harmony | ||||
| @ -126,15 +125,15 @@ cargo build --release          # builds the CLI, TUI and libraries | ||||
| 
 | ||||
| ## 5 · Learning More | ||||
| 
 | ||||
| * **Architectural Decision Records** – dive into the rationale   | ||||
| - **Architectural Decision Records** – dive into the rationale | ||||
|   - [ADR-001 · Why Rust](adr/001-rust.md) | ||||
|   - [ADR-003 · Infrastructure Abstractions](adr/003-infrastructure-abstractions.md) | ||||
|   - [ADR-006 · Secret Management](adr/006-secret-management.md) | ||||
|   - [ADR-011 · Multi-Tenant Cluster](adr/011-multi-tenant-cluster.md) | ||||
| 
 | ||||
| * **Extending Harmony** – write new Scores / Interprets, add hardware like OPNsense firewalls, or embed Harmony in your own tooling (`/docs`). | ||||
| - **Extending Harmony** – write new Scores / Interprets, add hardware like OPNsense firewalls, or embed Harmony in your own tooling (`/docs`). | ||||
| 
 | ||||
| * **Community** – discussions and roadmap live in [GitLab issues](https://git.nationtech.io/nationtech/harmony/-/issues). PRs, ideas, and feedback are welcome! | ||||
| - **Community** – discussions and roadmap live in [GitLab issues](https://git.nationtech.io/nationtech/harmony/-/issues). PRs, ideas, and feedback are welcome! | ||||
| 
 | ||||
| --- | ||||
| 
 | ||||
| @ -148,4 +147,4 @@ See [LICENSE](LICENSE) for the full text. | ||||
| 
 | ||||
| --- | ||||
| 
 | ||||
| *Made with ❤️ & 🦀 by the NationTech and the Harmony community* | ||||
| _Made with ❤️ & 🦀 by the NationTech and the Harmony community_ | ||||
|  | ||||
| @ -7,8 +7,8 @@ use harmony::{ | ||||
| #[tokio::main] | ||||
| async fn main() { | ||||
|     harmony_cli::run( | ||||
|         LocalhostTopology::new(), | ||||
|         Inventory::autoload(), | ||||
|         LocalhostTopology::new(), | ||||
|         vec![ | ||||
|             Box::new(SuccessScore {}), | ||||
|             Box::new(ErrorScore {}), | ||||
|  | ||||
| @ -43,8 +43,8 @@ async fn main() { | ||||
|     // locally, to development environment from a CI, to staging, and to production with settings
 | ||||
|     // that automatically adapt to each environment grade.
 | ||||
|     harmony_cli::run( | ||||
|         K8sAnywhereTopology::from_env(), | ||||
|         Inventory::autoload(), | ||||
|         K8sAnywhereTopology::from_env(), | ||||
|         vec![Box::new(lamp_stack)], | ||||
|         None, | ||||
|     ) | ||||
|  | ||||
| @ -75,8 +75,8 @@ async fn main() { | ||||
|     }; | ||||
| 
 | ||||
|     harmony_cli::run( | ||||
|         K8sAnywhereTopology::from_env(), | ||||
|         Inventory::autoload(), | ||||
|         K8sAnywhereTopology::from_env(), | ||||
|         vec![Box::new(alerting_score)], | ||||
|         None, | ||||
|     ) | ||||
|  | ||||
| @ -79,8 +79,8 @@ async fn main() { | ||||
|     }; | ||||
| 
 | ||||
|     harmony_cli::run( | ||||
|         K8sAnywhereTopology::from_env(), | ||||
|         Inventory::autoload(), | ||||
|         K8sAnywhereTopology::from_env(), | ||||
|         vec![Box::new(tenant), Box::new(alerting_score)], | ||||
|         None, | ||||
|     ) | ||||
|  | ||||
| @ -5,8 +5,8 @@ use harmony::{ | ||||
| #[tokio::main] | ||||
| async fn main() { | ||||
|     harmony_cli::run( | ||||
|         K8sAnywhereTopology::from_env(), | ||||
|         Inventory::autoload(), | ||||
|         K8sAnywhereTopology::from_env(), | ||||
|         vec![Box::new(NtfyScore { | ||||
|             namespace: "monitoring".to_string(), | ||||
|             host: "localhost".to_string(), | ||||
|  | ||||
| @ -31,8 +31,8 @@ async fn main() { | ||||
|     }; | ||||
| 
 | ||||
|     harmony_cli::run( | ||||
|         K8sAnywhereTopology::from_env(), | ||||
|         Inventory::autoload(), | ||||
|         K8sAnywhereTopology::from_env(), | ||||
|         vec![Box::new(app)], | ||||
|         None, | ||||
|     ) | ||||
|  | ||||
| @ -16,8 +16,8 @@ async fn main() { | ||||
|     }; | ||||
| 
 | ||||
|     harmony_cli::run( | ||||
|         K8sAnywhereTopology::from_env(), | ||||
|         Inventory::autoload(), | ||||
|         K8sAnywhereTopology::from_env(), | ||||
|         vec![Box::new(tenant)], | ||||
|         None, | ||||
|     ) | ||||
|  | ||||
| @ -87,8 +87,8 @@ fn list_scores_with_index<T: Topology>(scores_vec: &Vec<Box<dyn Score<T>>>) -> S | ||||
| } | ||||
| 
 | ||||
| pub async fn run<T: Topology + Send + Sync + 'static>( | ||||
|     topology: T, | ||||
|     inventory: Inventory, | ||||
|     topology: T, | ||||
|     scores: Vec<Box<dyn Score<T>>>, | ||||
|     args_struct: Option<Args>, | ||||
| ) -> Result<(), Box<dyn std::error::Error>> { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user