This is an automated email from the ASF dual-hosted git repository.

emaynard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new 72b14cb3 Add proxy option for CLI (#1115)
72b14cb3 is described below

commit 72b14cb3e59ce87bcff56da98a9902954b1cec92
Author: MonkeyCanCode <[email protected]>
AuthorDate: Thu Mar 6 11:27:05 2025 -0600

    Add proxy option for CLI (#1115)
    
    * Add proxy option for CLI
    
    * Refactor
---
 regtests/client/python/cli/constants.py      |  1 +
 regtests/client/python/cli/options/parser.py |  1 +
 regtests/client/python/cli/polaris_cli.py    | 23 +++++++++++------------
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/regtests/client/python/cli/constants.py 
b/regtests/client/python/cli/constants.py
index 1fae549d..c29174a0 100644
--- a/regtests/client/python/cli/constants.py
+++ b/regtests/client/python/cli/constants.py
@@ -136,6 +136,7 @@ class Arguments:
     LOCATION = 'location'
     REGION = 'region'
     PROFILE = 'profile'
+    PROXY = 'proxy'
 
 
 class Hints:
diff --git a/regtests/client/python/cli/options/parser.py 
b/regtests/client/python/cli/options/parser.py
index 9b91e561..64130968 100644
--- a/regtests/client/python/cli/options/parser.py
+++ b/regtests/client/python/cli/options/parser.py
@@ -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
diff --git a/regtests/client/python/cli/polaris_cli.py 
b/regtests/client/python/cli/polaris_cli.py
index 2cc2f4e2..a19daed8 100644
--- a/regtests/client/python/cli/polaris_cli.py
+++ b/regtests/client/python/cli/polaris_cli.py
@@ -143,22 +143,21 @@ class PolarisCli:
             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__':

Reply via email to