This is an automated email from the ASF dual-hosted git repository.
dubeejw pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/incubator-openwhisk-package-kafka.git
The following commit(s) were added to refs/heads/master by this push:
new 40c2370 Fix for overriding api host (#286)
40c2370 is described below
commit 40c2370dd3e075c1cbaaf6968d44e49e22403f5a
Author: Adnan Baruni <[email protected]>
AuthorDate: Wed Sep 19 15:03:23 2018 -0500
Fix for overriding api host (#286)
* fix the way we are handling trigger urls when env var overrides api host.
also remove basic auth from trigger url
---
provider/consumer.py | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/provider/consumer.py b/provider/consumer.py
index 1b6bf6f..9b48a2d 100644
--- a/provider/consumer.py
+++ b/provider/consumer.py
@@ -213,18 +213,29 @@ class ConsumerProcess (Process):
return secondsSince(self.lastPoll())
def __triggerURL(self, originalURL):
+ parsed = urlparse(originalURL)
apiHost = os.getenv('API_HOST')
if apiHost is not None:
logging.info('[{}] Environment variable defined for API_HOST.
Overriding host value defined for trigger in DB with {}'.format(self.trigger,
apiHost))
- parsed = urlparse(originalURL)
- parts = parsed.netloc.split('@')
- auth = parts[0]
- newURL = parsed._replace(netloc='{}@{}'.format(auth, apiHost))
+ newURL = parsed._replace(netloc=apiHost)
return newURL.geturl()
else:
- return originalURL
+ # remove https://user:pass@host from url and replace it with just
https://host
+ # we do this because we no longer need the basic auth in the url
itself.
+ # we rely upon the HTTPBasicAuth handler or the IAMAuth handler
+ parts = parsed.netloc.split('@')
+
+ if len(parts) == 2:
+ host = parts[1]
+ else:
+ host = parts[0]
+
+ logging.info('[{}] Environment variable undefined for API_HOST.
Using value in DB of {}'.format(self.trigger, host))
+ newURL = parsed._replace(netloc=host)
+
+ return newURL.geturl()
def run(self):
try: