Skip to content

Commit

Permalink
fix: cluster credentials to fit new schema
Browse files Browse the repository at this point in the history
  • Loading branch information
dtdang committed Jan 6, 2025
1 parent 86dded2 commit a00ed0e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
19 changes: 15 additions & 4 deletions silverback/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,15 +818,20 @@ def credentials_info(cluster: "ClusterClient", name: str):
@click.argument("registry")
@cluster_client
def credentials_new(cluster: "ClusterClient", name: str, registry: str):
"""Add registry private registry credentials. This command will prompt you for a username and
password.
"""Add registry private registry credentials. This command will prompt you for a username,
password, and email.
"""

username = click.prompt("Username")
password = click.prompt("Password", hide_input=True)
email = click.prompt("Email")

creds = cluster.new_credentials(
name=name, hostname=registry, username=username, password=password
name=name,
docker_server=registry,
docker_username=username,
docker_password=password,
docker_email=email
)
click.echo(yaml.safe_dump(creds.model_dump(exclude={"id"})))

Expand All @@ -842,8 +847,14 @@ def credentials_update(cluster: "ClusterClient", name: str, registry: str | None

username = click.prompt("Username")
password = click.prompt("Password", hide_input=True)
email = click.prompt("Email")

creds = creds.update(hostname=registry, username=username, password=password)
creds = creds.update(
docker_server=registry,
docker_username=username,
docker_password=password,
docker_email=email
)
click.echo(yaml.safe_dump(creds.model_dump(exclude={"id"})))


Expand Down
14 changes: 9 additions & 5 deletions silverback/cluster/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,16 @@ def registry_credentials(self) -> dict[str, RegistryCredentials]:
}

def new_credentials(
self, name: str, hostname: str, username: str, password: str
self, name: str, docker_server: str, docker_username: str, docker_password: str, docker_email: str
) -> RegistryCredentials:
response = self.post(
"/credentials",
json=dict(name=name, hostname=hostname, username=username, password=password),
)
form = dict(
name=name,
docker_server=docker_server,
docker_username=docker_username,
docker_password=docker_password,
docker_email=docker_email
)
response = self.post("/credentials", json=form)
handle_error_with_response(response)
return RegistryCredentials.model_validate(response.json())

Expand Down

0 comments on commit a00ed0e

Please sign in to comment.