Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def default_env(self):
env = util.merge_dicts(os.environ, self._config.env)
env = util.merge_dicts(env, self._config.provisioner.env)
return env
def test_merge_dicts():
# example taken from python-anyconfig/anyconfig/__init__.py
a = {'b': [{'c': 0}, {'c': 2}], 'd': {'e': 'aaa', 'f': 3}}
b = {'a': 1, 'b': [{'c': 3}], 'd': {'e': 'bbb'}}
x = {'a': 1, 'b': [{'c': 3}], 'd': {'e': "bbb", 'f': 3}}
assert x == util.merge_dicts(a, b)
# NOTE(retr0h): Options provided here will be passed to
# Vagrant as "$provider_name.#{key} = #{value}".
'options': {
'memory': self._module.params['provider_memory'],
'cpus': self._module.params['provider_cpus'],
},
'raw_config_args': self._module.params['provider_raw_config_args'],
'override_args': self._module.params['provider_override_args'],
},
}
molecule.util.merge_dicts(
d['config']['options'], self._module.params['config_options']
)
molecule.util.merge_dicts(
d['provider']['options'], self._module.params['provider_options']
)
return d
def options(self):
o = self._config.config['dependency']['options']
# NOTE(retr0h): Remove verbose options added by the user while in
# debug.
if self._config.debug:
o = util.filter_verbose_permutation(o)
return util.merge_dicts(self.default_options, o)
def login_options(self, instance_name):
d = {'instance': instance_name}
return util.merge_dicts(d, self._get_instance_config(instance_name))
def default_env(self):
return util.merge_dicts(os.environ, self._config.env)
def _reget_config(self):
"""
Perform the same prioritized recursive merge from `get_config`, this
time, interpolating the ``keep_string`` left behind in the original
``get_config`` call. This is probably __very__ bad.
:return: dict
"""
env = util.merge_dicts(os.environ, self.env)
env = set_env_from_file(env, self.env_file)
return self._combine(env=env)
def login_options(self, instance_name):
if self.managed:
d = {'instance': instance_name}
return util.merge_dicts(d, self._get_instance_config(instance_name))
return {'instance': instance_name}
base_config = self.args.get('base_config')
if base_config and os.path.exists(base_config):
with util.open_file(base_config) as stream:
s = stream.read()
self._preflight(s)
interpolated_config = self._interpolate(s, env, keep_string)
defaults = util.merge_dicts(
defaults, util.safe_load(interpolated_config)
)
if self.molecule_file:
with util.open_file(self.molecule_file) as stream:
s = stream.read()
self._preflight(s)
interpolated_config = self._interpolate(s, env, keep_string)
defaults = util.merge_dicts(
defaults, util.safe_load(interpolated_config)
)
return defaults
def validate(c):
schema = base_schema
# Dependency
if c['dependency']['name'] == 'shell':
schema = util.merge_dicts(schema, dependency_command_nullable_schema)
# Driver
if c['driver']['name'] == 'docker':
schema = util.merge_dicts(schema, platforms_docker_schema)
elif c['driver']['name'] == 'podman':
schema = util.merge_dicts(schema, platforms_podman_schema)
# Verifier
schema = util.merge_dicts(schema, api.verifiers()[c['verifier']['name']].schema())
v = Validator(allow_unknown=True)
v.validate(c, schema)
return v.errors