File tree Expand file tree Collapse file tree 4 files changed +42
-49
lines changed
environments/skeleton/{{cookiecutter.environment}}/tofu Expand file tree Collapse file tree 4 files changed +42
-49
lines changed Original file line number Diff line number Diff line change @@ -36,4 +36,8 @@ module "compute" {
36
36
control_address = openstack_networking_port_v2. control [var . cluster_networks [0 ]. network ]. all_fixed_ips [0 ]
37
37
security_group_ids = [for o in data . openstack_networking_secgroup_v2 . nonlogin : o . id ]
38
38
baremetal_nodes = data. external . baremetal_nodes . result
39
+
40
+ # input dict validation:
41
+ group_name = each. key
42
+ group_keys = keys (each. value )
39
43
}
Original file line number Diff line number Diff line change @@ -39,4 +39,8 @@ module "login" {
39
39
control_address = openstack_networking_port_v2. control [var . cluster_networks [0 ]. network ]. all_fixed_ips [0 ]
40
40
security_group_ids = [for o in data . openstack_networking_secgroup_v2 . login : o . id ]
41
41
baremetal_nodes = data. external . baremetal_nodes . result
42
+
43
+ # input dict validation:
44
+ group_name = each. key
45
+ group_keys = keys (each. value )
42
46
}
Original file line number Diff line number Diff line change @@ -140,3 +140,36 @@ variable "nodename_template" {
140
140
type = string
141
141
default = " "
142
142
}
143
+
144
+ variable "group_name" {
145
+ type = string
146
+ }
147
+
148
+ variable "group_keys" {
149
+ type = list
150
+ validation {
151
+ condition = length (setsubtract (var. group_keys , var. allowed_keys )) == 0
152
+ error_message = " Compute group ${ var . group_name } in var.compute contains invalid key(s): ${
153
+ join (" , " , setsubtract (var. group_keys , var. allowed_keys ))} "
154
+ }
155
+ }
156
+
157
+ variable "allowed_keys" {
158
+ type = list
159
+ default = [
160
+ " nodes" ,
161
+ " flavor" ,
162
+ " image_id" ,
163
+ " extra_networks" ,
164
+ " vnic_types" ,
165
+ " compute_init_enable" ,
166
+ " ignore_image_changes" ,
167
+ " volume_backed_instances" ,
168
+ " root_volume_size" ,
169
+ " extra_volumes" ,
170
+ " match_ironic_node" ,
171
+ " availability_zone" ,
172
+ " gateway_ip" ,
173
+ " nodename_template"
174
+ ]
175
+ }
Original file line number Diff line number Diff line change @@ -101,55 +101,7 @@ variable "compute" {
101
101
nodename_template: Overrides variable cluster_nodename_template
102
102
EOF
103
103
default = {}
104
- type = any # can't do any better; TF type constraints can't cope with inhomogenous mappings
105
- # module call will fail if missing required values so only need to check for unexpected ones
106
- validation {
107
- condition = length (
108
- setsubtract (
109
- flatten ([for k , v in var . compute : keys (v)]),
110
- [
111
- " nodes" ,
112
- " flavor" ,
113
- " image_id" ,
114
- " extra_networks" ,
115
- " vnic_types" ,
116
- " compute_init_enable" ,
117
- " ignore_image_changes" ,
118
- " volume_backed_instances" ,
119
- " root_volume_size" ,
120
- " extra_volumes" ,
121
- " match_ironic_node" ,
122
- " availability_zone" ,
123
- " gateway_ip" ,
124
- " nodename_template"
125
- ]
126
- )
127
- ) == 0
128
- error_message = <<- EOT
129
- var.compute contains mappings with invalid keys: ${
130
- join (" , " , setsubtract (
131
- flatten ([for k , v in var . compute : keys (v)]),
132
- [
133
- " nodes" ,
134
- " flavor" ,
135
- " image_id" ,
136
- " extra_networks" ,
137
- " vnic_types" ,
138
- " compute_init_enable" ,
139
- " ignore_image_changes" ,
140
- " volume_backed_instances" ,
141
- " root_volume_size" ,
142
- " extra_volumes" ,
143
- " match_ironic_node" ,
144
- " availability_zone" ,
145
- " gateway_ip" ,
146
- " nodename_template"
147
- ]
148
- )
149
- )
150
- }
151
- EOT
152
- }
104
+ type = any # can't do any better; TF type constraints can't cope with inhomogenous inner mappings
153
105
}
154
106
155
107
variable "environment_root" {
You can’t perform that action at this time.
0 commit comments