Skip to content

Commit

Permalink
feat: add cluster status to cluster list (#164)
Browse files Browse the repository at this point in the history
* docs: fix typo

* fix: cluster name

* fix: typo

* feat: add cluster status to cluster list

* feat: add cluster status to cluster list

* fix: mypy

* fix: simplify

* fix: remove status check for cancel stream

* chore: lint
  • Loading branch information
dtdang authored Nov 1, 2024
1 parent 32a819b commit a83e107
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/userguides/managing.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ logging in to the Platform using [`silverback login`][silverback-login].

A Workspace is an area for one or more people to co-manage a set of clusters together. You can manage workspaces from the Silverback CLI using [`silverback cluster workspaces`][silverback-cluster-workspaces].

Using the Silverback CLI you can [list workspaces][silverback-cluster-workspaces-list], [make new ones][silverback-cluster-workspaces-new], [view their configuration information][silverback-cluster-workspaces-info], [update their metadata][silverback-cluster-workspaces-update], as well as [delete them][silverback-cluster-workspaces-delete] workspaces.
Using the Silverback CLI you can [list workspaces][silverback-cluster-workspaces-list], [make new ones][silverback-cluster-workspaces-new], [view their configuration information][silverback-cluster-workspaces-info], [update their metadata][silverback-cluster-workspaces-update], as well as [delete them][silverback-cluster-workspaces-delete].

## Managing a Cluster

Expand Down
10 changes: 4 additions & 6 deletions silverback/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,9 @@ def list_clusters(platform: PlatformClient, workspace: str):
if not (workspace_client := platform.workspaces.get(workspace)):
raise click.BadOptionUsage("workspace", f"Unknown workspace '{workspace}'")

if cluster_names := list(workspace_client.clusters):
click.echo(yaml.safe_dump(cluster_names))
if clusters := workspace_client.clusters.values():
cluster_info = [f"- {cluster.name} ({cluster.status})" for cluster in clusters]
click.echo("\n".join(cluster_info))

else:
click.secho("No clusters for this account", bold=True, fg="red")
Expand Down Expand Up @@ -637,7 +638,7 @@ def fund_payment_stream(
)

elif cluster.status != ResourceStatus.RUNNING:
raise click.UsageError(f"Cannot fund '{cluster_info.name}': cluster is not running.")
raise click.UsageError(f"Cannot fund '{cluster.name}': cluster is not running.")

elif not (stream := workspace_client.get_payment_stream(cluster, network.chain_id)):
raise click.UsageError("Cluster is not funded via ApePay Stream")
Expand Down Expand Up @@ -706,9 +707,6 @@ def cancel_payment_stream(
f"Unknown cluster in workspace '{workspace_name}': '{cluster_name}'"
)

elif cluster.status != ResourceStatus.RUNNING:
raise click.UsageError(f"Cannot fund '{cluster_info.name}': cluster is not running.")

elif not (stream := workspace_client.get_payment_stream(cluster, network.chain_id)):
raise click.UsageError("Cluster is not funded via ApePay Stream")

Expand Down

0 comments on commit a83e107

Please sign in to comment.