From 3c61e4cfde877d2f94f72e47bda7e7eed43033b2 Mon Sep 17 00:00:00 2001 From: Chris <15219900+Ninjagod1251@users.noreply.github.com> Date: Fri, 3 Jan 2025 15:22:46 -0800 Subject: [PATCH 1/2] fix: delete method (#180) * fix: delete method * fix: update * chore: lint * chore: undo testname * chore: restore update --- silverback/cluster/client.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/silverback/cluster/client.py b/silverback/cluster/client.py index f8e8d8e0..4c8f5c09 100644 --- a/silverback/cluster/client.py +++ b/silverback/cluster/client.py @@ -100,17 +100,16 @@ def __hash__(self) -> int: def update( self, name: str | None = None, variables: dict[str, str | None] | None = None ) -> "VariableGroup": + if name is not None: # Update metadata response = self.cluster.put(f"/vars/{self.id}", json=dict(name=name)) handle_error_with_response(response) - if variables is not None: # Create a new revision response = self.cluster.post(f"/vars/{self.id}", json=dict(variables=variables)) handle_error_with_response(response) return VariableGroup.model_validate(response.json()) - return self def get_revision(self, revision: int | Literal["latest"] = "latest") -> VariableGroupInfo: @@ -123,7 +122,7 @@ def get_revision(self, revision: int | Literal["latest"] = "latest") -> Variable return VariableGroupInfo.model_validate(response.json()) def remove(self): - response = self.cluster.delete(f"/vars/{self.id}") + response = self.cluster.delete(f"/vars/{self.name}") handle_error_with_response(response) From d83f581cfaca79a6fd97398d87fb27fcc2f23467 Mon Sep 17 00:00:00 2001 From: Dalena Date: Mon, 6 Jan 2025 16:00:13 -0600 Subject: [PATCH 2/2] refactor: simplify registry cli (#182) --- docs/commands/cluster.rst | 4 ++-- docs/userguides/deploying.md | 4 ++-- silverback/_cli.py | 15 +++++---------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/docs/commands/cluster.rst b/docs/commands/cluster.rst index ac5a4679..5a5ef0ab 100644 --- a/docs/commands/cluster.rst +++ b/docs/commands/cluster.rst @@ -21,8 +21,8 @@ CLI commands for interacting with the Silverback Platform. :nested: full :commands: new, list, info, update, remove -.. click:: silverback._cli:registry_auth - :prog: silverback cluster registry auth +.. click:: silverback._cli:registry + :prog: silverback cluster registry :nested: full :commands: new, list, info, update, remove diff --git a/docs/userguides/deploying.md b/docs/userguides/deploying.md index 22c84cb9..231e59cf 100644 --- a/docs/userguides/deploying.md +++ b/docs/userguides/deploying.md @@ -105,7 +105,7 @@ Once you have created all the Variable Group(s) that you need to operate your Bo ## Private Container Registries If you are using a private container registry to store your images, you will need to provide your bot with the necessary credentials to access it. -First you will need to add your credentials to the cluster with the [`silverback cluster registry auth new`][silverback-cluster-registry-auth-new] command. +First you will need to add your credentials to the cluster with the [`silverback cluster registry new`][silverback-cluster-registry-new] command. Then you can provide the name of these credentials when creating your bot with the [`silverback cluster bots new`][silverback-cluster-bots-new] or [`silverback cluster bots update`][silverback-cluster-bots-update] commands. @@ -198,7 +198,7 @@ TODO: Downloading metrics from your Bot [silverback-cluster-bots-start]: ../commands/cluster.html#silverback-cluster-bots-start [silverback-cluster-bots-stop]: ../commands/cluster.html#silverback-cluster-bots-stop [silverback-cluster-bots-update]: ../commands/cluster.html#silverback-cluster-bots-update -[silverback-cluster-registry-auth-new]: ../commands/cluster.html#silverback-cluster-registry-auth-new +[silverback-cluster-registry-new]: ../commands/cluster.html#silverback-cluster-registry-new [silverback-cluster-vars]: ../commands/cluster.html#silverback-cluster-vars [silverback-cluster-vars-info]: ../commands/cluster.html#silverback-cluster-vars-info [silverback-cluster-vars-list]: ../commands/cluster.html#silverback-cluster-vars-list diff --git a/silverback/_cli.py b/silverback/_cli.py index 7ab31b30..df45a1bd 100644 --- a/silverback/_cli.py +++ b/silverback/_cli.py @@ -784,12 +784,7 @@ def registry(): """Manage container registry configuration""" -@registry.group(cls=SectionedHelpGroup, name="auth") -def registry_auth(): - """Manage private container registry credentials""" - - -@registry_auth.command(name="list") +@registry.command(name="list") @cluster_client def credentials_list(cluster: "ClusterClient"): """List container registry credentials""" @@ -801,7 +796,7 @@ def credentials_list(cluster: "ClusterClient"): click.secho("No registry credentials present in this cluster", bold=True, fg="red") -@registry_auth.command(name="info") +@registry.command(name="info") @click.argument("name") @cluster_client def credentials_info(cluster: "ClusterClient", name: str): @@ -813,7 +808,7 @@ def credentials_info(cluster: "ClusterClient", name: str): click.echo(yaml.safe_dump(creds.model_dump(exclude={"id", "name"}))) -@registry_auth.command(name="new") +@registry.command(name="new") @click.argument("name") @click.argument("registry") @cluster_client @@ -831,7 +826,7 @@ def credentials_new(cluster: "ClusterClient", name: str, registry: str): click.echo(yaml.safe_dump(creds.model_dump(exclude={"id"}))) -@registry_auth.command(name="update") +@registry.command(name="update") @click.argument("name") @click.option("-r", "--registry") @cluster_client @@ -847,7 +842,7 @@ def credentials_update(cluster: "ClusterClient", name: str, registry: str | None click.echo(yaml.safe_dump(creds.model_dump(exclude={"id"}))) -@registry_auth.command(name="remove") +@registry.command(name="remove") @click.argument("name") @cluster_client def credentials_remove(cluster: "ClusterClient", name: str):