Some checks reported errors
continuous-integration/drone/push Build encountered an error
Signed-off-by: kjuulh <contact@kjuulh.io>
85 lines
2.1 KiB
Rust
85 lines
2.1 KiB
Rust
use clap::{Parser, Subcommand};
|
|
use std::net::SocketAddr;
|
|
|
|
use crate::services::flux_local_cluster::extensions::FluxLocalClusterManagerExt;
|
|
|
|
pub mod client;
|
|
pub mod server;
|
|
|
|
#[derive(Parser)]
|
|
#[command(author, version, about, long_about = None, subcommand_required = true)]
|
|
pub struct Command {
|
|
#[command(subcommand)]
|
|
pub command: Option<Commands>,
|
|
}
|
|
|
|
#[derive(Subcommand)]
|
|
pub enum Commands {
|
|
Serve {
|
|
#[arg(env = "SERVICE_HOST", long, default_value = "127.0.0.1:3000")]
|
|
host: SocketAddr,
|
|
#[arg(env = "SERVICE_GRPC_HOST", long, default_value = "127.0.0.1:7900")]
|
|
grpc_host: SocketAddr,
|
|
},
|
|
|
|
Commit {
|
|
#[arg(long)]
|
|
app: String,
|
|
#[arg(long)]
|
|
branch: String,
|
|
#[arg(long)]
|
|
include: String,
|
|
#[arg(env = "FLUX_RELEASER_REGISTRY", long)]
|
|
registry: String,
|
|
},
|
|
|
|
Release {
|
|
#[arg(long)]
|
|
app: String,
|
|
|
|
#[arg(long)]
|
|
branch: String,
|
|
#[arg(env = "FLUX_RELEASER_REGISTRY", long)]
|
|
registry: String,
|
|
},
|
|
}
|
|
|
|
impl Command {
|
|
pub async fn run() -> anyhow::Result<()> {
|
|
let cli = Command::parse();
|
|
|
|
match cli.command {
|
|
Some(Commands::Serve { host, grpc_host }) => {
|
|
server::run_server(host, grpc_host).await?;
|
|
}
|
|
Some(Commands::Commit {
|
|
app,
|
|
branch,
|
|
include,
|
|
registry,
|
|
}) => {
|
|
let app = client::get_local_app(registry).await?;
|
|
|
|
let upload_id = app
|
|
.flux_local_cluster_manager()
|
|
.package_clusters(include)
|
|
.await?;
|
|
}
|
|
Some(Commands::Release {
|
|
app: service_app,
|
|
branch,
|
|
registry,
|
|
}) => {
|
|
let app = client::get_local_app(registry).await?;
|
|
|
|
app.flux_local_cluster_manager()
|
|
.trigger_release(service_app, branch)
|
|
.await?;
|
|
}
|
|
None => (),
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
}
|