@@ -36,14 +36,15 @@ func TestExtraSpecsFromBootstrapData(t *testing.T) {
36
36
{
37
37
name : "valid bootstrap data" ,
38
38
input : params.BootstrapInstance {
39
- ExtraSpecs : json .RawMessage (`{"subnet_id": "subnet-0a0a0a0a0a0a0a0a0", "ssh_key_name": "ssh_key_name", "disable_updates": true, "enable_boot_debug": true, "extra_packages": ["package1", "package2"], "runner_install_template": "IyEvYmluL2Jhc2gKZWNobyBJbnN0YWxsaW5nIHJ1bm5lci4uLg==", "pre_install_scripts": {"setup.sh": "IyEvYmluL2Jhc2gKZWNobyBTZXR1cCBzY3JpcHQuLi4="}, "extra_context": {"key": "value"}}` ),
39
+ ExtraSpecs : json .RawMessage (`{"subnet_id": "subnet-0a0a0a0a0a0a0a0a0", "ssh_key_name": "ssh_key_name", "security_group_ids": ["sg-018c35963edfb1cce", "sg-018c35963edfb1cee"], " disable_updates": true, "enable_boot_debug": true, "extra_packages": ["package1", "package2"], "runner_install_template": "IyEvYmluL2Jhc2gKZWNobyBJbnN0YWxsaW5nIHJ1bm5lci4uLg==", "pre_install_scripts": {"setup.sh": "IyEvYmluL2Jhc2gKZWNobyBTZXR1cCBzY3JpcHQuLi4="}, "extra_context": {"key": "value"}}` ),
40
40
},
41
41
expectedOutput : & extraSpecs {
42
- SubnetID : aws .String ("subnet-0a0a0a0a0a0a0a0a0" ),
43
- SSHKeyName : aws .String ("ssh_key_name" ),
44
- DisableUpdates : aws .Bool (true ),
45
- EnableBootDebug : aws .Bool (true ),
46
- ExtraPackages : []string {"package1" , "package2" },
42
+ SubnetID : aws .String ("subnet-0a0a0a0a0a0a0a0a0" ),
43
+ SSHKeyName : aws .String ("ssh_key_name" ),
44
+ SecurityGroupIds : []string {"sg-018c35963edfb1cce" , "sg-018c35963edfb1cee" },
45
+ DisableUpdates : aws .Bool (true ),
46
+ EnableBootDebug : aws .Bool (true ),
47
+ ExtraPackages : []string {"package1" , "package2" },
47
48
CloudConfigSpec : cloudconfig.CloudConfigSpec {
48
49
RunnerInstallTemplate : []byte ("#!/bin/bash\n echo Installing runner..." ),
49
50
PreInstallScripts : map [string ][]byte {
@@ -74,6 +75,15 @@ func TestExtraSpecsFromBootstrapData(t *testing.T) {
74
75
},
75
76
errString : "" ,
76
77
},
78
+ {
79
+ name : "specs just with security_group_ids" ,
80
+ input : params.BootstrapInstance {
81
+ ExtraSpecs : json .RawMessage (`{"security_group_ids": ["sg-018c35963edfb1cce", "sg-018c35963edfb1cee"]}` ),
82
+ },
83
+ expectedOutput : & extraSpecs {
84
+ SecurityGroupIds : []string {"sg-018c35963edfb1cce" , "sg-018c35963edfb1cee" },
85
+ },
86
+ },
77
87
{
78
88
name : "specs just with disable_updates" ,
79
89
input : params.BootstrapInstance {
@@ -174,6 +184,14 @@ func TestExtraSpecsFromBootstrapData(t *testing.T) {
174
184
expectedOutput : nil ,
175
185
errString : "ssh_key_name: Invalid type. Expected: string, given: integer" ,
176
186
},
187
+ {
188
+ name : "invalid type for security_group_ids" ,
189
+ input : params.BootstrapInstance {
190
+ ExtraSpecs : json .RawMessage (`{"security_group_ids": "sg-018c35963edfb1cce"}` ),
191
+ },
192
+ expectedOutput : nil ,
193
+ errString : "security_group_ids: Invalid type. Expected: array, given: string" ,
194
+ },
177
195
{
178
196
name : "invalid type for disable_updates" ,
179
197
input : params.BootstrapInstance {
@@ -267,7 +285,7 @@ func TestGetRunnerSpecFromBootstrapParams(t *testing.T) {
267
285
268
286
data := params.BootstrapInstance {
269
287
Name : "mock-name" ,
270
- ExtraSpecs : json .RawMessage (`{"subnet_id": "subnet-0a0a0a0a0a0a0a0a0", "ssh_key_name": "ssh_key_name", "disable_updates": true, "enable_boot_debug": true, "extra_packages": ["package1", "package2"], "runner_install_template": "IyEvYmluL2Jhc2gKZWNobyBJbnN0YWxsaW5nIHJ1bm5lci4uLg==", "pre_install_scripts": {"setup.sh": "IyEvYmluL2Jhc2gKZWNobyBTZXR1cCBzY3JpcHQuLi4="}, "extra_context": {"key": "value"}}` ),
288
+ ExtraSpecs : json .RawMessage (`{"subnet_id": "subnet-0a0a0a0a0a0a0a0a0", "ssh_key_name": "ssh_key_name", "security_group_ids": ["sg-018c35963edfb1cce", "sg-018c35963edfb1cee"], " disable_updates": true, "enable_boot_debug": true, "extra_packages": ["package1", "package2"], "runner_install_template": "IyEvYmluL2Jhc2gKZWNobyBJbnN0YWxsaW5nIHJ1bm5lci4uLg==", "pre_install_scripts": {"setup.sh": "IyEvYmluL2Jhc2gKZWNobyBTZXR1cCBzY3JpcHQuLi4="}, "extra_context": {"key": "value"}}` ),
271
289
}
272
290
273
291
config := & config.Config {
@@ -283,15 +301,16 @@ func TestGetRunnerSpecFromBootstrapParams(t *testing.T) {
283
301
Region : "region" ,
284
302
}
285
303
expectedRunnerSpec := & RunnerSpec {
286
- Region : "region" ,
287
- DisableUpdates : true ,
288
- ExtraPackages : []string {"package1" , "package2" },
289
- EnableBootDebug : true ,
290
- SubnetID : "subnet-0a0a0a0a0a0a0a0a0" ,
291
- Tools : Mocktools ,
292
- ControllerID : "controller_id" ,
293
- BootstrapParams : data ,
294
- SSHKeyName : aws .String ("ssh_key_name" ),
304
+ Region : "region" ,
305
+ DisableUpdates : true ,
306
+ ExtraPackages : []string {"package1" , "package2" },
307
+ EnableBootDebug : true ,
308
+ SubnetID : "subnet-0a0a0a0a0a0a0a0a0" ,
309
+ Tools : Mocktools ,
310
+ ControllerID : "controller_id" ,
311
+ BootstrapParams : data ,
312
+ SSHKeyName : aws .String ("ssh_key_name" ),
313
+ SecurityGroupIds : []string {"sg-018c35963edfb1cce" , "sg-018c35963edfb1cee" },
295
314
}
296
315
297
316
runnerSpec , err := GetRunnerSpecFromBootstrapParams (config , data , "controller_id" )
0 commit comments