File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -147,18 +147,27 @@ func ParseConfig(b io.Reader) (*Config, error) {
147
147
deploy .CloudInitPath = c .Common .CloudInitPath
148
148
}
149
149
150
+ if deploy .Vars == nil {
151
+ deploy .Vars = make (map [string ]string )
152
+ }
150
153
for k , v := range c .Common .Vars {
151
154
if _ , ok := deploy .Vars [k ]; ! ok {
152
155
deploy .Vars [k ] = v
153
156
}
154
157
}
155
158
159
+ if deploy .Labels == nil {
160
+ deploy .Labels = make (map [string ]string )
161
+ }
156
162
for k , v := range c .Common .Labels {
157
163
if _ , ok := deploy .Labels [k ]; ! ok {
158
164
deploy .Labels [k ] = v
159
165
}
160
166
}
161
167
168
+ if deploy .Metadata == nil {
169
+ deploy .Metadata = make (map [string ]string )
170
+ }
162
171
for k , v := range c .Common .Metadata {
163
172
if _ , ok := deploy .Metadata [k ]; ! ok {
164
173
deploy .Metadata [k ] = v
Original file line number Diff line number Diff line change @@ -181,6 +181,30 @@ deploys:
181
181
assert .Equal (t , "12" , c .Deploys [0 ].UpdatePolicy .MaxUnavailable )
182
182
}
183
183
184
+ func TestNilMaps (t * testing.T ) {
185
+ config := `
186
+ common:
187
+ vars:
188
+ var1: x
189
+ labels:
190
+ label1: x
191
+ metadata:
192
+ metadata1: x
193
+ tags:
194
+ - tag1
195
+
196
+ deploys:
197
+ - name: test
198
+ region: w
199
+ instance_group: x
200
+ instance_template_base: y
201
+ instance_template: z
202
+ `
203
+
204
+ _ , err := ParseConfig (strings .NewReader (config ))
205
+ require .NoError (t , err )
206
+ }
207
+
184
208
func TestExpandShellRe (t * testing.T ) {
185
209
in := `$foo $FOO ${foo} a${foo}b \$foo \${foo} a\${foo}b $foo-$foo $foo-${foo} $fo $f`
186
210
You can’t perform that action at this time.
0 commit comments