Skip to content

Commit

Permalink
refactor: move silverback cluster login to silverback login
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Jul 11, 2024
1 parent c83a095 commit 1cd2659
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions silverback/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ def get_auth(profile_name: str = DEFAULT_PROFILE) -> FiefAuth:

def display_login_message(auth: FiefAuth, host: str):
userinfo = auth.current_user()

user_id = userinfo["sub"]
username = userinfo["fields"].get("username")
click.echo(
Expand All @@ -180,6 +179,27 @@ def display_login_message(auth: FiefAuth, host: str):
)


@cli.command()
@click.argument(
"auth",
metavar="PROFILE",
default=DEFAULT_PROFILE,
callback=lambda ctx, param, value: get_auth(value),
)
def login(auth: FiefAuth):
"""
CLI Login to Managed Authorization Service
Initiate a login in to the configured service using the given auth PROFILE.
Defaults to https://account.apeworx.io if PROFILE not provided.
NOTE: You likely do not need to use an auth PROFILE here.
"""

auth.authorize()
display_login_message(auth, auth.client.base_url)


def client_option():
settings = ProfileSettings.from_config_file()

Expand Down Expand Up @@ -229,22 +249,6 @@ def cluster():
"""Connect to hosted application clusters"""


@cluster.command()
@click.option(
"-a",
"--auth-profile",
"auth",
default=DEFAULT_PROFILE,
callback=lambda ctx, param, value: get_auth(value),
help="Authentication profile to use for Platform login.",
)
def login(auth: FiefAuth):
"""Login to hosted clusters"""

auth.authorize()
display_login_message(auth, auth.client.base_url)


@cluster.command()
@client_option()
def workspaces(client: Client):
Expand Down

0 comments on commit 1cd2659

Please sign in to comment.