def test_parse_configurations_module_resources_with_source(self, *args): obj = TerraformParser('somefile', parse_it=False) obj.raw['configuration'] = { 'root_module': { 'module_calls': { 'a_module': { 'source': 'source_of_a', 'module': { 'resources': [{ 'address': 'something' }] } }, 'b_module': { 'source': 'source_of_b', 'module': { 'resources': [{ 'address': 'something' }] } } } } } obj._parse_configurations() self.assertEqual( obj.configuration['resources']['module.a_module.something'], { 'address': 'module.a_module.something', 'source': 'source_of_a' })
def test_parse_configurations_providers(self, *args): obj = TerraformParser('somefile', parse_it=False) obj.raw['configuration'] = { 'provider_config': { 'some_provider': 'some_provider_data' } } obj._parse_configurations() self.assertEqual(obj.configuration['providers'], {'some_provider': 'some_provider_data'})
def test_parse_configurations_resources(self, *args): obj = TerraformParser('somefile', parse_it=False) obj.raw['configuration'] = { 'root_module': { 'resources': [{ 'address': 'something' }] } } obj._parse_configurations() self.assertEqual(obj.configuration['resources']['something'], {'address': 'something'})
def test_parse_configurations_variables(self, *args): obj = TerraformParser('somefile', parse_it=False) obj.raw['configuration'] = { 'root_module': { 'variables': [ { 'variable_key': 'variable_value' } ] } } obj._parse_configurations() self.assertEqual(obj.configuration['variables'], [{'variable_key': 'variable_value'}])
def test_parse_configurations_ignore_nested_resources(self, *args): obj = TerraformParser('somefile', parse_it=False) obj.raw['configuration'] = { 'root_module': { 'module_calls': { 'a_module': { 'expressions': { 'cluster_role_rules': { 'constant_values': [{ "resources": ["namespaces", "pods"] }] } } } }, 'resources': [{ 'address': 'something' }] } } obj._parse_configurations() self.assertEqual(obj.configuration['resources']['something'], {'address': 'something'})