Few changes to 'address' function for ingress
* scheme can be added with with_scheme=True flag * ingress port will be added to the end of the address Change-Id: Iea6b885efdbf0d18268b181007a61dff36b904f0 Depends-On: I94efeea5a8a0acb67781d3e5a50b0c99601f7b4e
This commit is contained in:
parent
b5a0ec86b7
commit
4f96245635
|
@ -205,13 +205,16 @@ def get_ingress_host(ingress_name):
|
|||
ingress_name, VARIABLES['namespace'], VARIABLES['ingress']['domain']))
|
||||
|
||||
|
||||
def address(service, port=None, external=False):
|
||||
def address(service, port=None, external=False, with_scheme=False):
|
||||
addr = None
|
||||
scheme = 'http'
|
||||
if external:
|
||||
if not port:
|
||||
raise RuntimeError('Port config is required for external address')
|
||||
if VARIABLES['ingress']['enabled'] and port.get('ingress'):
|
||||
addr = get_ingress_host(port['ingress'])
|
||||
scheme = 'https'
|
||||
addr = "%s:%s" % (get_ingress_host(port['ingress']),
|
||||
VARIABLES['ingress']['port'])
|
||||
elif port.get('node'):
|
||||
addr = '%s:%s' % (VARIABLES['k8s_external_ip'], port['node'])
|
||||
|
||||
|
@ -220,6 +223,9 @@ def address(service, port=None, external=False):
|
|||
if port:
|
||||
addr = '%s:%s' % (addr, port['cont'])
|
||||
|
||||
if with_scheme:
|
||||
addr = "%s://%s" % (scheme, addr)
|
||||
|
||||
return addr
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue