Merge pull request #419 from terraform-google-modules/jccb/factories-fix
Fix vpc subnet factory for yamls with different shapes.
This commit is contained in:
commit
390d653a40
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
|
||||
locals {
|
||||
_factory_data = var.data_folder == null ? {} : {
|
||||
_factory_data = var.data_folder == null ? tomap({}) : {
|
||||
for f in fileset(var.data_folder, "**/*.yaml") :
|
||||
trimsuffix(basename(f), ".yaml") => yamldecode(file("${var.data_folder}/${f}"))
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# Copyright 2022 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
region: europe-west4
|
||||
description: Sample description
|
||||
ip_cidr_range: 10.129.0.0/24
|
|
@ -35,12 +35,11 @@ _VAR_DATA_FOLDER = "data"
|
|||
def test_subnet_factory(plan_runner):
|
||||
"Test subnet factory."
|
||||
_, resources = plan_runner(FIXTURES_DIR, data_folder=_VAR_DATA_FOLDER)
|
||||
assert len(resources) == 3
|
||||
assert len(resources) == 5
|
||||
subnets = [r['values']
|
||||
for r in resources if r['type'] == 'google_compute_subnetwork']
|
||||
assert set(s['name'] for s in subnets) == set(
|
||||
['factory-subnet'])
|
||||
assert set(len(s['secondary_ip_range']) for s in subnets) == set([1])
|
||||
assert {s['name'] for s in subnets} == {'factory-subnet', 'factory-subnet2'}
|
||||
assert {len(s['secondary_ip_range']) for s in subnets} == {0, 1}
|
||||
|
||||
|
||||
def test_subnets_simple(plan_runner):
|
||||
|
@ -49,9 +48,8 @@ def test_subnets_simple(plan_runner):
|
|||
assert len(resources) == 4
|
||||
subnets = [r['values']
|
||||
for r in resources if r['type'] == 'google_compute_subnetwork']
|
||||
assert set(s['name'] for s in subnets) == set(
|
||||
['a', 'b', 'c'])
|
||||
assert set(len(s['secondary_ip_range']) for s in subnets) == set([0, 0, 2])
|
||||
assert {s['name'] for s in subnets} == {'a', 'b', 'c'}
|
||||
assert {len(s['secondary_ip_range']) for s in subnets} == {0, 0, 2}
|
||||
|
||||
|
||||
def test_subnet_log_configs(plan_runner):
|
||||
|
|
Loading…
Reference in New Issue