From ee9a380df5f5df5d261d85736de1580e5cc73d7c Mon Sep 17 00:00:00 2001 From: Jonathan Grahl Date: Wed, 18 Jun 2025 16:53:42 +0200 Subject: [PATCH 1/3] feat: add url to service response --- src/api/types.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/api/types.rs b/src/api/types.rs index 89d4e8c..95acd34 100644 --- a/src/api/types.rs +++ b/src/api/types.rs @@ -64,7 +64,7 @@ pub struct CreateEnvironmentResponse { #[derive(Serialize, Deserialize, Debug)] pub struct ListServicesResponse { - pub services: Vec, + pub services: Vec, } #[derive(Debug, Serialize, Deserialize, PartialEq)] @@ -123,6 +123,22 @@ pub struct ComposeService { pub host_aliases: DisplayVec, } +#[derive(Debug, Serialize, Deserialize, PartialEq, Tabled)] +pub struct ServiceResponse { + pub name: String, + + #[serde(default)] + pub containers: DisplayVec, + + #[serde(default)] + pub volumes: DisplayVec, + + #[serde(default)] + pub host_aliases: DisplayVec, + + pub url: String, +} + #[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Default)] pub struct VolumeMount { pub volume_name: String, From 00e047eea8e3de0f09ef203623ec7b4087e41888 Mon Sep 17 00:00:00 2001 From: Jonathan Grahl Date: Thu, 19 Jun 2025 09:43:05 +0200 Subject: [PATCH 2/3] feat: add get-url command --- src/api/types.rs | 1 + src/commands/services.rs | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/api/types.rs b/src/api/types.rs index 95acd34..1fca75a 100644 --- a/src/api/types.rs +++ b/src/api/types.rs @@ -136,6 +136,7 @@ pub struct ServiceResponse { #[serde(default)] pub host_aliases: DisplayVec, + #[serde(default)] pub url: String, } diff --git a/src/commands/services.rs b/src/commands/services.rs index 8e96d6e..9e69b8b 100644 --- a/src/commands/services.rs +++ b/src/commands/services.rs @@ -44,6 +44,7 @@ impl Services { Some(Commands::ImageName(image_name)) => image_name.execute(base), Some(Commands::List(list)) => list.execute(base), Some(Commands::Delete(delete)) => delete.execute(base), + Some(Commands::GetURL(get_url)) => get_url.execute(base), None => Ok(()), } } @@ -61,6 +62,9 @@ pub enum Commands { List(List), /// Delete a service Delete(Delete), + /// Get the URL of a service + #[command(name = "get-url")] + GetURL(GetURL), } #[derive(Debug, Parser)] @@ -769,3 +773,35 @@ fn write_manifest(path: &str, compose: &ComposeFile) -> Result<()> { file.write_all(yaml.as_bytes())?; Ok(()) } + +#[derive(Debug, Parser)] +pub struct GetURL { + #[arg(help = "Name of the service")] + name: String, + #[arg(long, help = "Environment the service is in")] + env: String, +} + +impl GetURL { + pub fn execute(self, base: CommandBase) -> Result<()> { + let tenant_name = base.get_tenant()?; + let project_name = base.get_project()?; + let token = base + .user_config() + .get_token() + .ok_or_else(|| anyhow!("No token found. Please login first."))?; + + let response = base + .api_client() + .get_services(token, &tenant_name, &project_name, &self.env)?; + + let service = response + .services + .iter() + .find(|s| s.name == self.name) + .ok_or_else(|| anyhow!("Service '{}' not found in environment '{}'", self.name, self.env))?; + + println!("{}", service.url); + Ok(()) + } +} From c4f2523960a32f375fc5786dacf5ebb889e6a5e7 Mon Sep 17 00:00:00 2001 From: Jonathan Grahl Date: Thu, 19 Jun 2025 09:49:21 +0200 Subject: [PATCH 3/3] ci: upgrade version of zig action --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 284fd13..d41fdc4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -39,7 +39,7 @@ jobs: ./target key: build-cargo-registry-${{matrix.TARGET}} - - uses: mlugg/setup-zig@aa9ad5c14eb3452e235a441c4f9a8e89f20d97bd + - uses: mlugg/setup-zig@7dccf5e6d09267c55f815f2db29495f30ba2ebca - name: Install cargo-zigbuild run: cargo install cargo-zigbuild