mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [mesos] andreaspeters commented on a change in pull request #383: Add mesos authentication to the mesos cli
Date Thu, 27 May 2021 06:34:11 GMT

andreaspeters commented on a change in pull request #383:

File path: src/python/cli_new/lib/cli/
@@ -19,70 +19,63 @@
 import json
-import urllib.request
-import urllib.error
-import urllib.parse
-import time
+from urllib.parse import urlencode
+import urllib3
 import cli
 from cli.exceptions import CLIException
-def read_endpoint(addr, endpoint, query=None):
+def read_endpoint(addr, endpoint, config, query=None):
     Read the specified endpoint and return the results.
         addr = cli.util.sanitize_address(addr)
     except Exception as exception:
         raise CLIException("Unable to sanitize address '{addr}': {error}"
                            .format(addr=addr, error=str(exception)))
         url = "{addr}/{endpoint}".format(addr=addr, endpoint=endpoint)
         if query is not None:
-            url += "?{query}".format(query=urllib.parse.urlencode(query))
-        http_response = urllib.request.urlopen(url).read().decode("utf-8")
+            url += "?{query}".format(query=urlencode(query))
+        if config.principal() is not None and config.secret() is not None:
+            headers = urllib3.make_headers(
+                basic_auth=config.principal() + ":" + config.secret()
+            )
+        else:
+            headers = None
+        http = urllib3.PoolManager()
+        http_response = http.request('GET', url, headers=headers, timeout=5)

Review comment:
       :+1: good idea. 
   Even if it's not easy to see that someone "want" have so many changes in the code, I feel
like the code is getting better and better. :-) The discuss about some points helping a lot.
So, thank's @cf-natali @asekretenko @kamaradclimber 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:

View raw message