This repository was archived by the owner on Feb 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.rs
78 lines (69 loc) · 1.77 KB
/
main.rs
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
use crate::arguments::CliCommand;
use arguments::CliArgs;
use clap::{IntoApp, Parser};
use lazy_static::lazy_static;
use log::error;
use std::{error::Error, process::exit, sync::Mutex};
mod arguments;
mod demo;
mod helm;
mod helpers;
mod ionos;
mod kind;
mod kube;
mod operator;
mod release;
mod services;
mod stack;
const AVAILABLE_OPERATORS: &[&str] = &[
"airflow",
"commons",
"druid",
"hbase",
"hdfs",
"hive",
"kafka",
"listener",
"nifi",
"opa",
"secret",
"spark-k8s",
"superset",
"trino",
"zookeeper",
];
lazy_static! {
pub static ref NAMESPACE: Mutex<String> = Mutex::new(String::new());
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let args = CliArgs::parse();
env_logger::builder()
.format_timestamp(None)
.format_target(false)
.filter_level(args.log_level.into())
.init();
let namespace = &args.namespace;
*(NAMESPACE.lock()?) = namespace.to_string();
helm::handle_common_cli_args(&args);
release::handle_common_cli_args(&args);
stack::handle_common_cli_args(&args);
demo::handle_common_cli_args(&args);
let result = match &args.cmd {
CliCommand::Operator(command) => command.handle().await,
CliCommand::Release(command) => command.handle().await,
CliCommand::Stack(command) => command.handle().await,
CliCommand::Demo(command) => command.handle().await,
CliCommand::Services(command) => command.handle().await,
CliCommand::Completion(command) => {
let mut cmd = CliArgs::command();
arguments::print_completions(command.shell, &mut cmd);
Ok(())
}
};
if let Err(err) = &result {
error!("{err}");
exit(-1);
}
result
}