diff --git a/cli/tests/integrations/test_marathon.py b/cli/tests/integrations/test_marathon.py index 3225d0d..d469b2b 100644 --- a/cli/tests/integrations/test_marathon.py +++ b/cli/tests/integrations/test_marathon.py @@ -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 `.\n'), env=missing_env) diff --git a/dcos/marathon.py b/dcos/marathon.py index 37f0270..e3bda5c 100644 --- a/dcos/marathon.py +++ b/dcos/marathon.py @@ -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 """ diff --git a/dcos/package.py b/dcos/package.py index c9f838d..3f610f7 100644 --- a/dcos/package.py +++ b/dcos/package.py @@ -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):