Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 18 additions & 1 deletion src/api/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub struct CreateEnvironmentResponse {

#[derive(Serialize, Deserialize, Debug)]
pub struct ListServicesResponse {
pub services: Vec<ComposeService>,
pub services: Vec<ServiceResponse>,
}

#[derive(Debug, Serialize, Deserialize, PartialEq)]
Expand Down Expand Up @@ -123,6 +123,23 @@ pub struct ComposeService {
pub host_aliases: DisplayVec<HostAlias>,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Tabled)]
pub struct ServiceResponse {
pub name: String,

#[serde(default)]
pub containers: DisplayVec<Container>,

#[serde(default)]
pub volumes: DisplayVec<Volume>,

#[serde(default)]
pub host_aliases: DisplayVec<HostAlias>,

#[serde(default)]
pub url: String,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Default)]
pub struct VolumeMount {
pub volume_name: String,
Expand Down
36 changes: 36 additions & 0 deletions src/commands/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(()),
}
}
Expand All @@ -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)]
Expand Down Expand Up @@ -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(())
}
}
Loading