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
mod install;
mod uninstall;
mod minikube;
mod util;
mod check;
mod releases;

pub use process::process_cluster;

use structopt::StructOpt;

use minikube::SetMinikubeContext;
pub use install::InstallCommand;
use uninstall::UninstallCommand;
use check::CheckCommand;
use releases::ReleasesCommand;

#[allow(clippy::large_enum_variant)]
#[derive(Debug, StructOpt)]
#[structopt(about = "Available Commands")]
pub enum ClusterCommands {
    /// set my own context
    #[structopt(name = "set-minikube-context")]
    SetMinikubeContext(SetMinikubeContext),

    /// install cluster
    #[structopt(name = "install")]
    Install(InstallCommand),

    /// uninstall cluster
    #[structopt(name = "uninstall")]
    Uninstall(UninstallCommand),

    /// perform checks
    #[structopt(name = "check")]
    Check(CheckCommand),

    /// release information
    #[structopt(name = "releases")]
    Releases(ReleasesCommand),
}

mod process {

    use crate::CliError;
    use crate::Terminal;

    use super::*;

    use install::process_install;
    use uninstall::process_uninstall;
    use minikube::process_minikube_context;
    use check::run_checks;
    use releases::process_releases;

    pub async fn process_cluster<O>(
        out: std::sync::Arc<O>,
        cmd: ClusterCommands,
    ) -> Result<String, CliError>
    where
        O: Terminal,
    {
        match cmd {
            ClusterCommands::SetMinikubeContext(ctx) => process_minikube_context(ctx),
            ClusterCommands::Install(install) => process_install(out, install).await,
            ClusterCommands::Uninstall(uninstall) => process_uninstall(out, uninstall).await,
            ClusterCommands::Check(check) => run_checks(check).await,
            ClusterCommands::Releases(releases) => process_releases(releases),
        }
    }
}