From ddbf6e4ab1dc82b56f250644aee879427726f055 Mon Sep 17 00:00:00 2001 From: Dalena Date: Wed, 8 Jan 2025 11:55:26 -0600 Subject: [PATCH] fix: cluster bot update --- silverback/_cli.py | 12 ++---------- silverback/cluster/client.py | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/silverback/_cli.py b/silverback/_cli.py index b3b65677..b8aece5e 100644 --- a/silverback/_cli.py +++ b/silverback/_cli.py @@ -1098,9 +1098,8 @@ def bot_info(cluster: "ClusterClient", bot_name: str): @bots.command(name="update", section="Configuration Commands") -@click.option("--new-name", "new_name") # NOTE: No shorthand, because conflicts w/ `--network` @click.option("-i", "--image") -@click.option("-n", "--network") +@click.option("-n", "--network", required=True) @click.option("-a", "--account") @click.option("-g", "--group", "vargroups", multiple=True) @click.option( @@ -1113,7 +1112,6 @@ def bot_info(cluster: "ClusterClient", bot_name: str): @cluster_client def update_bot( cluster: "ClusterClient", - new_name: str | None, image: str | None, network: str | None, account: str | None, @@ -1125,15 +1123,9 @@ def update_bot( NOTE: Some configuration updates will trigger a redeploy""" - if new_name in cluster.bots: - raise click.UsageError(f"Cannot use name '{new_name}' to update bot '{name}'") - if not (bot := cluster.bots.get(name)): raise click.UsageError(f"Unknown bot '{name}'.") - if new_name: - click.echo(f"Name:\n old: {name}\n new: {new_name}") - if network: click.echo(f"Network:\n old: {bot.network}\n new: {network}") @@ -1173,7 +1165,7 @@ def update_bot( return bot = bot.update( - name=new_name, + name=name, image=image, network=network, account=account, diff --git a/silverback/cluster/client.py b/silverback/cluster/client.py index 0adb0399..898f24c0 100644 --- a/silverback/cluster/client.py +++ b/silverback/cluster/client.py @@ -153,7 +153,7 @@ def update( if registry_credentials_id: form["registry_credentials_id"] = registry_credentials_id - response = self.cluster.put(f"/bots/{self.name}", json=form) + response = self.cluster.put(f"/bots/network/{network}/bot/{self.name}", json=form) handle_error_with_response(response) return Bot.model_validate(response.json())