Skip to content

Commit

Permalink
feat(bolt): list datacenter CLI command
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelOnFira committed Apr 23, 2024
1 parent 1c64480 commit 1be54ee
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
34 changes: 34 additions & 0 deletions lib/bolt/cli/src/commands/admin/cluster/datacenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ pub enum SubCommand {
#[clap(long)]
build_delivery_method: DatacenterBuildDeliveryMethod,
},
List {
/// The name id of the cluster
#[clap(long, short = 'c')]
cluster_name_id: String,
},
Taint {
/// The name id of the cluster
#[clap(long, short = 'c')]
Expand Down Expand Up @@ -114,6 +119,35 @@ impl SubCommand {

rivet_term::status::success("Datacenter created", "");
}
Self::List { cluster_name_id } => {
let clusters =
admin_clusters_api::admin_clusters_get(&ctx.openapi_config_cloud().await?)
.await?.clusters;

let cluster = clusters
.iter()
.find(|cluster| cluster.name_id == cluster_name_id);

let cluster = match cluster {
Some(cluster) => cluster,
None => bail!("cluster with the name id {} not found", cluster_name_id),
};

let datacenters =
admin_clusters_datacenters_api::admin_clusters_datacenters_get(
&ctx.openapi_config_cloud().await?,
&cluster.cluster_id.to_string(),
)
.await?.datacenters;

rivet_term::status::success("Datacenters", "");
rivet_term::format::table(datacenters.iter().map(|d| {
DatacenterTableRow {
name_id: d.name_id.clone(),
datacenter_id: d.datacenter_id,
}
}));
}
Self::Taint {
cluster_name_id,
datacenter_name_id,
Expand Down
4 changes: 2 additions & 2 deletions lib/bolt/cli/src/commands/admin/cluster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub enum SubCommand {
}

#[derive(Tabled)]
struct AdminClusterRow {
struct ClusterTableRow {
name_id: String,
cluster_id: Uuid,
}
Expand Down Expand Up @@ -62,7 +62,7 @@ impl SubCommand {
.clusters;

rivet_term::status::success("Clusters", "");
rivet_term::format::table(clusters.iter().map(|c| AdminClusterRow {
rivet_term::format::table(clusters.iter().map(|c| ClusterTableRow {
name_id: c.name_id.clone(),
cluster_id: c.cluster_id,
}));
Expand Down
4 changes: 2 additions & 2 deletions sdks/full/typescript/archive.tgz

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1be54ee

Please sign in to comment.