update config access to use consistent error messaging
This commit is contained in:
@@ -145,8 +145,8 @@ def test_missing_config(missing_env):
|
||||
assert_command(
|
||||
['dcos', 'marathon', 'app', 'list'],
|
||||
returncode=1,
|
||||
stderr=(b"Marathon likely misconfigured. Please check your proxy or "
|
||||
b"Marathon URI settings. See dcos config --help. \n"),
|
||||
stderr=(b'Missing required config parameter: "core.dcos_url". '
|
||||
b'Please run `dcos config set core.dcos_url <value>`.\n'),
|
||||
env=missing_env)
|
||||
|
||||
|
||||
|
||||
@@ -37,11 +37,8 @@ def _get_marathon_uri(config):
|
||||
|
||||
marathon_uri = config.get('marathon.url')
|
||||
if marathon_uri is None:
|
||||
marathon_uri = config.get('core.dcos_url')
|
||||
if marathon_uri is None:
|
||||
raise DCOSException(_default_marathon_error())
|
||||
|
||||
marathon_uri = urllib.parse.urljoin(marathon_uri, 'marathon/')
|
||||
dcos_url = util.get_config_vals(config, ['core.dcos_url'])[0]
|
||||
marathon_uri = urllib.parse.urljoin(dcos_url, 'marathon/')
|
||||
|
||||
return marathon_uri
|
||||
|
||||
@@ -49,7 +46,7 @@ def _get_marathon_uri(config):
|
||||
def _to_error(response):
|
||||
"""
|
||||
:param response: HTTP response object or Error
|
||||
:type response: requests.Response or Error
|
||||
:type response: requests.Response | Error
|
||||
:returns: the error embedded in the response JSON
|
||||
:rtype: Error
|
||||
"""
|
||||
|
||||
@@ -589,10 +589,7 @@ def list_sources(config):
|
||||
:rtype: [Source]
|
||||
"""
|
||||
|
||||
source_uris = config.get('package.sources')
|
||||
|
||||
if source_uris is None:
|
||||
raise DCOSException('No configured value for [package.sources]')
|
||||
source_uris = util.get_config_vals(config, ['package.sources'])[0]
|
||||
|
||||
sources = [url_to_source(s) for s in source_uris]
|
||||
|
||||
@@ -660,10 +657,7 @@ def update_sources(config, validate=False):
|
||||
errors = []
|
||||
|
||||
# ensure the cache directory is properly configured
|
||||
cache_dir = config.get('package.cache')
|
||||
|
||||
if cache_dir is None:
|
||||
raise DCOSException('No configured value for [package.cache]')
|
||||
cache_dir = util.get_config_vals(config, ['package.cache'])[0]
|
||||
|
||||
# ensure the cache directory exists
|
||||
if not os.path.exists(cache_dir):
|
||||
@@ -759,10 +753,7 @@ class Source:
|
||||
:rtype: str or None
|
||||
"""
|
||||
|
||||
cache_dir = config.get('package.cache')
|
||||
if cache_dir is None:
|
||||
return None
|
||||
|
||||
cache_dir = util.get_config_vals(config, ['package.cache'])[0]
|
||||
return os.path.join(cache_dir, self.hash())
|
||||
|
||||
def copy_to_cache(self, target_dir):
|
||||
|
||||
Reference in New Issue
Block a user