1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//! Functionality for installing, managing, and deleting Fluvio clusters.
//!
//! The primary use of this crate is to install Fluvio clusters on
//! Kubernetes using a [`ClusterInstaller`], which provides a fluid
//! interface for cluster specification.
//!
//! # Example
//!
//! To install a basic Fluvio cluster, just do the following:
//!
//! ```
//! use fluvio_cluster::{ClusterInstaller, ClusterConfig, ClusterError};
//! # async fn example() -> Result<(), ClusterError> {
//! let config = ClusterConfig::builder("0.7.0-alpha.1").build()?;
//! let installer = ClusterInstaller::from_config(config)?;
//! installer.install_fluvio().await?;
//! # Ok(())
//! # }
//! ```
//!
//! [`ClusterInstaller`]: ./struct.ClusterInstaller.html

#![warn(missing_docs)]
#![deny(broken_intra_doc_links)]

use std::path::PathBuf;

mod check;
mod start;
mod delete;
mod error;
mod sys;

/// extensions
#[cfg(feature = "cli")]
pub mod cli;

use fluvio_helm as helm;

pub use start::k8::{ClusterInstaller, ClusterConfig, ClusterConfigBuilder};
pub use start::local::{LocalInstaller, LocalConfig, LocalConfigBuilder};
pub use error::{ClusterError, K8InstallError, LocalInstallError, UninstallError, SysInstallError};
pub use helm::HelmError;
pub use check::{ClusterChecker, CheckStatus, CheckStatuses, CheckResult, CheckResults};
pub use check::{RecoverableCheck, UnrecoverableCheck, CheckFailed, CheckSuggestion};
pub use delete::ClusterUninstaller;
pub use sys::{SysConfig, SysConfigBuilder, SysInstaller};

pub(crate) const DEFAULT_NAMESPACE: &str = "default";
pub(crate) const DEFAULT_HELM_VERSION: &str = "3.3.4";
pub(crate) const DEFAULT_CHART_SYS_REPO: &str = "fluvio-sys";
pub(crate) const DEFAULT_CHART_APP_REPO: &str = "fluvio";
pub(crate) const DEFAULT_CHART_REMOTE: &str = "https://charts.fluvio.io";

/// The result of a successful startup of a Fluvio cluster
///
/// A `StartStatus` carries additional information about the startup
/// process beyond the simple fact that the startup succeeded. It
/// contains the address of the Streaming Controller (SC) of the new
/// cluster as well as the results of any pre-startup checks that
/// were run (if any).
/// TODO: In future release, we should return address without port
pub struct StartStatus {
    address: String,
    port: u16,
    #[allow(unused)]
    pub(crate) checks: Option<CheckStatuses>,
}

impl StartStatus {
    /// The address where the newly-started Fluvio cluster lives
    pub fn address(&self) -> &str {
        &self.address
    }

    /// get port
    #[allow(unused)]
    pub fn port(&self) -> u16 {
        self.port
    }
}

/// Distinguishes between a Local and Remote helm chart
#[derive(Debug, Clone)]
pub enum ChartLocation {
    /// Local charts must be located at a valid filesystem path.
    Local(PathBuf),
    /// Remote charts will be located at a URL such as `https://...`
    Remote(String),
}