Allow proxy_server use for chart tarball downloads
Currently the chart `source` schema allows for a proxy server to be specified, but it is only used for git repos. This patchset allows the `proxy_server` to also be used for tarball url sources. Change-Id: I6f90d056fa46f596b1fb248b6c596c58b6513d64
This commit is contained in:
parent
fd45cff385
commit
4e76d15eda
@ -122,6 +122,7 @@ class Armada(object):
|
|||||||
location = chart_source.get('location')
|
location = chart_source.get('location')
|
||||||
ct_type = chart_source.get('type')
|
ct_type = chart_source.get('type')
|
||||||
subpath = chart_source.get('subpath', '.')
|
subpath = chart_source.get('subpath', '.')
|
||||||
|
proxy_server = chart_source.get('proxy_server')
|
||||||
|
|
||||||
if ct_type == 'local':
|
if ct_type == 'local':
|
||||||
chart['source_dir'] = (location, subpath)
|
chart['source_dir'] = (location, subpath)
|
||||||
@ -129,15 +130,18 @@ class Armada(object):
|
|||||||
source_key = (ct_type, location)
|
source_key = (ct_type, location)
|
||||||
|
|
||||||
if source_key not in self.chart_cache:
|
if source_key not in self.chart_cache:
|
||||||
LOG.info('Downloading tarball from: %s', location)
|
LOG.info(
|
||||||
|
"Downloading tarball from: %s / proxy %s", location,
|
||||||
|
proxy_server or "not set")
|
||||||
|
|
||||||
if not CONF.certs:
|
if not CONF.certs:
|
||||||
LOG.warn(
|
LOG.warn(
|
||||||
'Disabling server validation certs to extract charts')
|
'Disabling server validation certs to extract charts')
|
||||||
tarball_dir = source.get_tarball(location, verify=False)
|
tarball_dir = source.get_tarball(
|
||||||
|
location, verify=False, proxy_server=proxy_server)
|
||||||
else:
|
else:
|
||||||
tarball_dir = source.get_tarball(
|
tarball_dir = source.get_tarball(
|
||||||
location, verify=CONF.certs)
|
location, verify=CONF.certs, proxy_server=proxy_server)
|
||||||
self.chart_cache[source_key] = tarball_dir
|
self.chart_cache[source_key] = tarball_dir
|
||||||
chart['source_dir'] = (self.chart_cache.get(source_key), subpath)
|
chart['source_dir'] = (self.chart_cache.get(source_key), subpath)
|
||||||
elif ct_type == 'git':
|
elif ct_type == 'git':
|
||||||
@ -146,7 +150,6 @@ class Armada(object):
|
|||||||
|
|
||||||
if source_key not in self.chart_cache:
|
if source_key not in self.chart_cache:
|
||||||
auth_method = chart_source.get('auth_method')
|
auth_method = chart_source.get('auth_method')
|
||||||
proxy_server = chart_source.get('proxy_server')
|
|
||||||
|
|
||||||
logstr = 'Cloning repo: {} from branch: {}'.format(
|
logstr = 'Cloning repo: {} from branch: {}'.format(
|
||||||
location, reference)
|
location, reference)
|
||||||
|
@ -113,21 +113,28 @@ def git_clone(repo_url, ref='master', proxy_server=None, auth_method=None):
|
|||||||
return temp_dir
|
return temp_dir
|
||||||
|
|
||||||
|
|
||||||
def get_tarball(tarball_url, verify=False):
|
def get_tarball(tarball_url, verify=False, proxy_server=None):
|
||||||
tarball_path = download_tarball(tarball_url, verify=verify)
|
tarball_path = download_tarball(
|
||||||
|
tarball_url, verify=verify, proxy_server=proxy_server)
|
||||||
return extract_tarball(tarball_path)
|
return extract_tarball(tarball_path)
|
||||||
|
|
||||||
|
|
||||||
def download_tarball(tarball_url, verify=False):
|
def download_tarball(tarball_url, verify=False, proxy_server=None):
|
||||||
'''
|
'''
|
||||||
Downloads a tarball to /tmp and returns the path
|
Downloads a tarball to /tmp and returns the path
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
if not verify:
|
if not verify:
|
||||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||||
|
kwargs = {}
|
||||||
|
if proxy_server:
|
||||||
|
kwargs['proxies'] = {
|
||||||
|
'http': proxy_server,
|
||||||
|
'https': proxy_server,
|
||||||
|
'ftp': proxy_server
|
||||||
|
}
|
||||||
tarball_filename = tempfile.mkstemp(prefix='armada')[1]
|
tarball_filename = tempfile.mkstemp(prefix='armada')[1]
|
||||||
response = requests.get(tarball_url, verify=verify)
|
response = requests.get(tarball_url, verify=verify, **kwargs)
|
||||||
|
|
||||||
with open(tarball_filename, 'wb') as f:
|
with open(tarball_filename, 'wb') as f:
|
||||||
f.write(response.content)
|
f.write(response.content)
|
||||||
|
@ -333,17 +333,19 @@ Delete
|
|||||||
Source
|
Source
|
||||||
^^^^^^
|
^^^^^^
|
||||||
|
|
||||||
+-------------+----------+-----------------------------------------------------------------------------------+
|
+-----------------+----------+-----------------------------------------------------------------------------------+
|
||||||
| keyword | type | action |
|
| keyword | type | action |
|
||||||
+=============+==========+===================================================================================+
|
+=================+==========+===================================================================================+
|
||||||
| type | string | source to build the chart: ``git``, ``local``, or ``tar`` |
|
| type | string | source to build the chart: ``git``, ``local``, or ``tar`` |
|
||||||
+-------------+----------+-----------------------------------------------------------------------------------+
|
+-----------------+----------+-----------------------------------------------------------------------------------+
|
||||||
| location | string | ``url`` or ``path`` to the chart's parent directory |
|
| location | string | ``url`` or ``path`` to the chart's parent directory |
|
||||||
+-------------+----------+-----------------------------------------------------------------------------------+
|
+-----------------+----------+-----------------------------------------------------------------------------------+
|
||||||
| subpath | string | (optional) relative path to target chart from parent (``.`` if not specified) |
|
| subpath | string | (optional) relative path to target chart from parent (``.`` if not specified) |
|
||||||
+-------------+----------+-----------------------------------------------------------------------------------+
|
+-----------------+----------+-----------------------------------------------------------------------------------+
|
||||||
| reference | string | (optional) branch, commit, or reference in the repo (``master`` if not specified) |
|
| reference | string | (optional) branch, commit, or reference in the repo (``master`` if not specified) |
|
||||||
+-------------+----------+-----------------------------------------------------------------------------------+
|
+-----------------+----------+-----------------------------------------------------------------------------------+
|
||||||
|
| proxy\_server | string | (optional) proxy server URL for downloading ``git`` or ``tar`` charts |
|
||||||
|
+-----------------+----------+-----------------------------------------------------------------------------------+
|
||||||
|
|
||||||
Source Example
|
Source Example
|
||||||
^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^
|
||||||
@ -420,6 +422,7 @@ Source Example
|
|||||||
location: https://localhost:8879/charts/chart-0.1.0.tgz
|
location: https://localhost:8879/charts/chart-0.1.0.tgz
|
||||||
subpath: mariadb
|
subpath: mariadb
|
||||||
reference: null
|
reference: null
|
||||||
|
proxy_server: http://my.proxy.server:8888
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -397,17 +397,19 @@ Delete
|
|||||||
Source
|
Source
|
||||||
^^^^^^
|
^^^^^^
|
||||||
|
|
||||||
+-------------+----------+-----------------------------------------------------------------------------------+
|
+-----------------+----------+-----------------------------------------------------------------------------------+
|
||||||
| keyword | type | action |
|
| keyword | type | action |
|
||||||
+=============+==========+===================================================================================+
|
+=================+==========+===================================================================================+
|
||||||
| type | string | source to build the chart: ``git``, ``local``, or ``tar`` |
|
| type | string | source to build the chart: ``git``, ``local``, or ``tar`` |
|
||||||
+-------------+----------+-----------------------------------------------------------------------------------+
|
+-----------------+----------+-----------------------------------------------------------------------------------+
|
||||||
| location | string | ``url`` or ``path`` to the chart's parent directory |
|
| location | string | ``url`` or ``path`` to the chart's parent directory |
|
||||||
+-------------+----------+-----------------------------------------------------------------------------------+
|
+-----------------+----------+-----------------------------------------------------------------------------------+
|
||||||
| subpath | string | (optional) relative path to target chart from parent (``.`` if not specified) |
|
| subpath | string | (optional) relative path to target chart from parent (``.`` if not specified) |
|
||||||
+-------------+----------+-----------------------------------------------------------------------------------+
|
+-----------------+----------+-----------------------------------------------------------------------------------+
|
||||||
| reference | string | (optional) branch, commit, or reference in the repo (``master`` if not specified) |
|
| reference | string | (optional) branch, commit, or reference in the repo (``master`` if not specified) |
|
||||||
+-------------+----------+-----------------------------------------------------------------------------------+
|
+-----------------+----------+-----------------------------------------------------------------------------------+
|
||||||
|
| proxy\_server | string | (optional) proxy server URL for downloading ``git`` or ``tar`` charts |
|
||||||
|
+-----------------+----------+-----------------------------------------------------------------------------------+
|
||||||
|
|
||||||
Source Example
|
Source Example
|
||||||
^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^
|
||||||
@ -430,6 +432,7 @@ Source Example
|
|||||||
source:
|
source:
|
||||||
type: git
|
type: git
|
||||||
location: https://github.com/namespace/repo
|
location: https://github.com/namespace/repo
|
||||||
|
proxy_server: http://my.proxy.server:8888
|
||||||
|
|
||||||
# type local
|
# type local
|
||||||
---
|
---
|
||||||
|
Loading…
Reference in New Issue
Block a user