Skip to content

Commit

Permalink
fix: cluster bot update
Browse files Browse the repository at this point in the history
  • Loading branch information
dtdang committed Jan 8, 2025
1 parent d99cc72 commit ddbf6e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 2 additions & 10 deletions silverback/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -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}")

Expand Down Expand Up @@ -1173,7 +1165,7 @@ def update_bot(
return

bot = bot.update(
name=new_name,
name=name,
image=image,
network=network,
account=account,
Expand Down
2 changes: 1 addition & 1 deletion silverback/cluster/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down

0 comments on commit ddbf6e4

Please sign in to comment.