Include auth credentials with release requests 23/16423/1 v0.25.3
authorEric Ball <eball@linuxfoundation.org>
Fri, 2 Aug 2019 21:08:06 +0000 (14:08 -0700)
committerEric Ball <eball@linuxfoundation.org>
Fri, 2 Aug 2019 21:08:06 +0000 (14:08 -0700)
Also includes a small logging improvement. During troubleshooting, I
found that it wasn't clear whether the credentials were being picked
up successfully from lftools.ini. Having some feedback during a
handled error will be much more helpful.

Change-Id: I2fa49f11ccb242296db9875e3018a8adf8b70f18
Signed-off-by: Eric Ball <eball@linuxfoundation.org>
lftools/nexus/cmd.py

index d43bc31..377bfed 100644 (file)
@@ -46,6 +46,8 @@ def get_credentials(settings_file, url=None):
             password = config.get_setting("nexus", "password")
         except (configparser.NoOptionError,
                 configparser.NoSectionError):
+            log.info("Failed to get nexus credentials; using empty username "
+                     "and password.")
             return {"nexus": url, "user": "", "password": ""}
         return {"nexus": url, "user": user, "password": password}
     log.error('Please define a settings.yaml file, or include a url if using '
@@ -314,7 +316,7 @@ def release_staging_repos(repos, nexus_url=""):
         log.debug("Sending data: {}".format(data))
         request_url = "{}/staging/bulk/promote".format(_nexus.baseurl)
         log.debug("Request URL: {}".format(request_url))
-        response = requests.post(request_url, json=data)
+        response = requests.post(request_url, json=data, auth=_nexus.auth)
 
         if response.status_code != 201:
             raise requests.HTTPError("Release failed with the following error:"
@@ -325,7 +327,7 @@ def release_staging_repos(repos, nexus_url=""):
 
         request_url = "{}/staging/bulk/drop".format(_nexus.baseurl)
         log.debug("Request URL: {}".format(request_url))
-        response = requests.post(request_url, json=data)
+        response = requests.post(request_url, json=data, auth=_nexus.auth)
 
         if response.status_code != 201:
             raise requests.HTTPError("Drop failed with the following error:"