Skip to content

Commit

Permalink
fix: ensure describe shows the service version + service URL (#139)
Browse files Browse the repository at this point in the history
* fix: ensure describe shows the service version

* fix: add servie URL for create and describe commands
  • Loading branch information
glihm authored Nov 21, 2024
1 parent 99b577b commit 894a6d2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cli/src/command/deployments/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,20 @@ impl CreateArgs {
let user = Credentials::load()?;
let client = Client::new_with_token(user.access_token);

let _: ResponseData = client.query(&request_body).await?;

println!("Deployment success 🚀");

let service = match &self.create_commands {
CreateServiceCommands::Katana(_) => "katana",
CreateServiceCommands::Torii(_) => "torii",
CreateServiceCommands::Saya(_) => "saya",
};

println!(
"Deploying {}...",
super::service_url(&self.project, service)
);

let _: ResponseData = client.query(&request_body).await?;

println!("\nDeployment success 🚀");
println!(
"\nStream logs with `slot deployments logs {} {service} -f`",
self.project
Expand Down
7 changes: 7 additions & 0 deletions cli/src/command/deployments/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,20 @@ impl DescribeArgs {
);
println!("Tier: {:?}", deployment.tier);

println!(
"Url: {}",
super::service_url(&deployment.project, &self.service.to_string())
);

match deployment.config {
ToriiConfig(config) => {
println!("Version: {}", config.version);
if let Some(config_file) = config.config_file {
print_config_file(&config_file);
}
}
KatanaConfig(config) => {
println!("Version: {}", config.version);
if let Some(config_file) = config.config_file {
print_config_file(&config_file);
}
Expand Down
7 changes: 7 additions & 0 deletions cli/src/command/deployments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ mod logs;
mod services;
mod update;

pub const CARTRIDGE_BASE_URL: &str = "https://api.cartridge.gg/x";

#[derive(Subcommand, Debug)]
pub enum Deployments {
#[command(about = "Create a new deployment.")]
Expand Down Expand Up @@ -60,6 +62,11 @@ pub enum Tier {
Epic,
}

/// Returns the service url for a given project and service.
pub(crate) fn service_url(project: &str, service: &str) -> String {
format!("{}/{}/{}", CARTRIDGE_BASE_URL, project, service)
}

/// Prints the configuration file for a given project and service.
pub(crate) fn print_config_file(config: &str) {
println!("\n─────────────── Configuration ───────────────");
Expand Down
10 changes: 10 additions & 0 deletions cli/src/command/deployments/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,13 @@ pub enum Service {
Torii,
Saya,
}

impl std::fmt::Display for Service {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Service::Katana => write!(f, "katana"),
Service::Torii => write!(f, "torii"),
Service::Saya => write!(f, "saya"),
}
}
}

0 comments on commit 894a6d2

Please sign in to comment.