def get_server(): config_file = os.path.join(config.get_config_dir(), 'ias_proxy.toml') LOGGER.info('Loading IAS Proxy config from: %s', config_file) # Lack of a config file is a fatal error, so let the exception percolate # up to caller with open(config_file) as fd: proxy_config = toml.loads(fd.read()) # Verify the integrity (as best we can) of the TOML configuration file valid_keys = set(['proxy_name', 'proxy_port', 'ias_url', 'spid_cert_file']) found_keys = set(proxy_config.keys()) invalid_keys = found_keys.difference(valid_keys) if invalid_keys: raise \ ValueError( 'IAS Proxy config file contains the following invalid ' 'keys: {}'.format( ', '.join(sorted(list(invalid_keys))))) missing_keys = valid_keys.difference(found_keys) if missing_keys: raise \ ValueError( 'IAS Proxy config file missing the following keys: ' '{}'.format( ', '.join(sorted(list(missing_keys))))) return IasProxyServer(proxy_config)
def load_rest_api_config(first_config): default_config = load_default_rest_api_config() config_dir = get_config_dir() conf_file = os.path.join(config_dir, 'rest_api.toml') toml_config = load_toml_rest_api_config(conf_file) return merge_rest_api_config( configs=[first_config, toml_config, default_config])
def load_rest_api_config(first_config): """Loads the config from the config file and merges it with the given configuration. """ default_config = load_default_rest_api_config() config_dir = get_config_dir() conf_file = os.path.join(config_dir, 'supplychain_rest_api.toml') toml_config = load_toml_rest_api_config(conf_file) return merge_rest_api_configs( configs=[first_config, toml_config, default_config])