Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proxy option for CLI #1115

Merged
merged 2 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions regtests/client/python/cli/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class Arguments:
LOCATION = 'location'
REGION = 'region'
PROFILE = 'profile'
PROXY = 'proxy'


class Hints:
Expand Down
1 change: 1 addition & 0 deletions regtests/client/python/cli/options/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Parser(object):
Argument(Arguments.CLIENT_SECRET, str, hint='client secret for token-based authentication'),
Argument(Arguments.ACCESS_TOKEN, str, hint='access token for token-based authentication'),
Argument(Arguments.PROFILE, str, hint='profile for token-based authentication'),
Argument(Arguments.PROXY, str, hint='proxy URL'),
]

@staticmethod
Expand Down
23 changes: 11 additions & 12 deletions regtests/client/python/cli/polaris_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,21 @@ def _get_client_builder(options):
polaris_management_url = f'http://{host}:{port}/api/management/v1'
polaris_catalog_url = f'http://{host}:{port}/api/catalog/v1'

builder = None
config = Configuration(host=polaris_management_url)
config.proxy = options.proxy
if has_access_token:
builder = lambda: ApiClient(
Configuration(host=polaris_management_url, access_token=options.access_token),
)
config.access_token = options.access_token
elif has_client_secret:
builder = lambda: ApiClient(
Configuration(host=polaris_management_url, username=client_id, password=client_secret),
)
config.username = client_id
config.password = client_secret

if not has_access_token and not PolarisCli.DIRECT_AUTHENTICATION_ENABLED:
token = PolarisCli._get_token(builder(), polaris_catalog_url, client_id, client_secret)
builder = lambda: ApiClient(
Configuration(host=polaris_management_url, access_token=token),
)
return builder
token = PolarisCli._get_token(ApiClient(config), polaris_catalog_url, client_id, client_secret)
config.username = None
config.password = None
config.access_token = token

return lambda: ApiClient(config)


if __name__ == '__main__':
Expand Down