feat: harmony now defaults to using local k3d cluster. Also created OCICompliant: Application trait to make building images cleaner
#76
@ -16,12 +16,16 @@ async fn main() {
|
||||
let app = RustWebappScore {
|
||||
name: "Example Rust Webapp".to_string(),
|
||||
domain: Url::Url(url::Url::parse("https://rustapp.harmony.example.com").unwrap()),
|
||||
features: vec![Box::new(ContinuousDelivery { application: Arc::new(application.clone()) })],
|
||||
features: vec![Box::new(ContinuousDelivery {
|
||||
application: Arc::new(application.clone()),
|
||||
})],
|
||||
application,
|
||||
|
|
||||
};
|
||||
|
||||
let topology = K8sAnywhereTopology::from_env();
|
||||
let mut maestro = Maestro::initialize(Inventory::autoload(), topology).await.unwrap();
|
||||
let mut maestro = Maestro::initialize(Inventory::autoload(), topology)
|
||||
.await
|
||||
.unwrap();
|
||||
maestro.register_all(vec![Box::new(app)]);
|
||||
harmony_cli::init(maestro, None).await.unwrap();
|
||||
}
|
||||
|
||||
@ -19,7 +19,10 @@ pub struct Maestro<T: Topology> {
|
||||
}
|
||||
|
||||
impl<T: Topology> Maestro<T> {
|
||||
fn new(inventory: Inventory, topology: T) -> Self {
|
||||
/// Creates a bare maestro without initialization.
|
||||
///
|
||||
/// This should rarely be used. Most of the time Maestro::initialize should be used instead.
|
||||
pub fn new_without_initialization(inventory: Inventory, topology: T) -> Self {
|
||||
|
letian
commented
usually we see usually we see `::empty` to initialize something as naked as possible, would that make more sense here?
johnride
commented
makes more sense than I'm very much open to better ideas, but I don't feel like makes more sense than `::new` for sure. `new_without_initialization` I agree is a bit uncanny. But technically the Maestro is not anymore "empty" when created via new than initialize, the only difference is a side-effect happening in initialize where the topology is initialized.
I'm very much open to better ideas, but I don't feel like `empty` is much better... Maestro is not a collection, it's more of an "engine". Maybe something along the idea of "idle" or "stale" but both those options feel less obvious to me than new_without_initialization. But that may be because I know the internals.
|
||||
Self {
|
||||
inventory,
|
||||
topology,
|
||||
@ -29,7 +32,7 @@ impl<T: Topology> Maestro<T> {
|
||||
}
|
||||
|
||||
pub async fn initialize(inventory: Inventory, topology: T) -> Result<Self, InterpretError> {
|
||||
let instance = Self::new(inventory, topology);
|
||||
let instance = Self::new_without_initialization(inventory, topology);
|
||||
instance.prepare_topology().await?;
|
||||
Ok(instance)
|
||||
}
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
mod feature;
|
||||
pub mod features;
|
||||
mod rust;
|
||||
pub mod oci;
|
||||
mod rust;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub use oci::*;
|
||||
pub use feature::*;
|
||||
use log::info;
|
||||
pub use oci::*;
|
||||
pub use rust::*;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
@ -153,7 +153,7 @@ mod test {
|
||||
fn init_test_maestro() -> Maestro<HAClusterTopology> {
|
||||
let inventory = Inventory::autoload();
|
||||
let topology = HAClusterTopology::autoload();
|
||||
let mut maestro = Maestro::new(inventory, topology);
|
||||
let mut maestro = Maestro::new_without_initialization(inventory, topology);
|
||||
|
||||
maestro.register_all(vec![
|
||||
Box::new(SuccessScore {}),
|
||||
|
||||
@ -41,7 +41,7 @@ pub mod tui {
|
||||
/// async fn main() {
|
||||
/// let inventory = Inventory::autoload();
|
||||
/// let topology = HAClusterTopology::autoload();
|
||||
/// let mut maestro = Maestro::new(inventory, topology);
|
||||
/// let mut maestro = Maestro::new_without_initialization(inventory, topology);
|
||||
///
|
||||
/// maestro.register_all(vec![
|
||||
/// Box::new(SuccessScore {}),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user
First impressions: this seems a bit redundant (and heavy) to have to pass the application around like this + having to "duplicate" the name between the score and the app. The clone seems a bit awkward as well.
Just a thought, don't have any better suggestions for now (I saw the previous PR that introduced it and the reasoning).