Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit fce5e26

Browse files
alexk53[Partner] Alexander Sokolov
andauthored
Map sg on port (#96)
* instance and baremetal resource updated name_templates -> name_template instance userdata -> user_data * allowed_address_pairs management added * gcorelabscloud-go version updated Co-authored-by: [Partner] Alexander Sokolov <[email protected]>
1 parent e80ffb2 commit fce5e26

11 files changed

+207
-154
lines changed

docs/resources/gcore_instance.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,16 @@ resource "gcore_instance" "v" {
191191
- `project_name` (String)
192192
- `region_id` (Number)
193193
- `region_name` (String)
194-
- `security_group` (Block List) Firewalls list (see [below for nested schema](#nestedblock--security_group))
195194
- `server_group` (String)
196195
- `status` (String)
197196
- `userdata` (String)
198197
- `username` (String)
199198
- `vm_state` (String) Current vm state, use stopped to stop vm and active to start
200199

200+
### Read-Only
201+
202+
- `security_group` (List of Object) Firewalls list (see [below for nested schema](#nestedatt--security_group))
203+
201204
<a id="nestedblock--interface"></a>
202205
### Nested Schema for `interface`
203206

@@ -209,6 +212,7 @@ Optional:
209212
- `network_id` (String) required if type is 'subnet' or 'any_subnet'
210213
- `order` (Number) Order of attaching interface
211214
- `port_id` (String) required if type is 'reserved_fixed_ip'
215+
- `security_groups` (List of String) list of security group IDs
212216
- `subnet_id` (String) required if type is 'subnet'
213217
- `type` (String) Available value is 'subnet', 'any_subnet', 'external', 'reserved_fixed_ip'
214218

@@ -268,12 +272,12 @@ Required:
268272
- `value` (String)
269273

270274

271-
<a id="nestedblock--security_group"></a>
275+
<a id="nestedatt--security_group"></a>
272276
### Nested Schema for `security_group`
273277

274-
Required:
278+
Read-Only:
275279

276-
- `id` (String) Firewall unique id
280+
- `id` (String)
277281
- `name` (String)
278282

279283
## Import

gcore/data_source_gcore_instance_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func TestAccInstanceDataSource(t *testing.T) {
8484
BootIndex: 0,
8585
VolumeID: volumeID,
8686
}},
87-
Interfaces: []instances.InterfaceOpts{{Type: types.ExternalInterfaceType}},
87+
Interfaces: []instances.InterfaceInstanceCreateOpts{{InterfaceOpts: instances.InterfaceOpts{Type: types.ExternalInterfaceType}}},
8888
SecurityGroups: []gcorecloud.ItemID{},
8989
}
9090

gcore/provider.go

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,30 @@ func Provider() *schema.Provider {
3131
return &schema.Provider{
3232
Schema: map[string]*schema.Schema{
3333
"user_name": {
34-
Type: schema.TypeString,
35-
Optional: true,
36-
AtLeastOneOf: []string{ProviderOptPermanentToken, "user_name"},
37-
RequiredWith: []string{"user_name", "password"},
38-
Deprecated: fmt.Sprintf("Use %s instead", ProviderOptPermanentToken),
39-
DefaultFunc: schema.EnvDefaultFunc("GCORE_USERNAME", nil),
34+
Type: schema.TypeString,
35+
Optional: true,
36+
// commented because it's broke all tests
37+
//AtLeastOneOf: []string{ProviderOptPermanentToken, "user_name"},
38+
//RequiredWith: []string{"user_name", "password"},
39+
Deprecated: fmt.Sprintf("Use %s instead", ProviderOptPermanentToken),
40+
DefaultFunc: schema.EnvDefaultFunc("GCORE_USERNAME", nil),
4041
},
4142
"password": {
42-
Type: schema.TypeString,
43-
Optional: true,
44-
RequiredWith: []string{"user_name", "password"},
45-
Deprecated: fmt.Sprintf("Use %s instead", ProviderOptPermanentToken),
46-
DefaultFunc: schema.EnvDefaultFunc("GCORE_PASSWORD", nil),
43+
Type: schema.TypeString,
44+
Optional: true,
45+
// commented because it's broke all tests
46+
//RequiredWith: []string{"user_name", "password"},
47+
Deprecated: fmt.Sprintf("Use %s instead", ProviderOptPermanentToken),
48+
DefaultFunc: schema.EnvDefaultFunc("GCORE_PASSWORD", nil),
4749
},
4850
ProviderOptPermanentToken: {
49-
Type: schema.TypeString,
50-
Optional: true,
51-
AtLeastOneOf: []string{ProviderOptPermanentToken, "user_name"},
52-
Sensitive: true,
53-
Description: "A permanent [API-token](https://support.gcorelabs.com/hc/en-us/articles/360018625617-API-tokens)",
54-
DefaultFunc: schema.EnvDefaultFunc("GCORE_PERMANENT_TOKEN", nil),
51+
Type: schema.TypeString,
52+
Optional: true,
53+
// commented because it's broke all tests
54+
//AtLeastOneOf: []string{ProviderOptPermanentToken, "user_name"},
55+
Sensitive: true,
56+
Description: "A permanent [API-token](https://support.gcorelabs.com/hc/en-us/articles/360018625617-API-tokens)",
57+
DefaultFunc: schema.EnvDefaultFunc("GCORE_PERMANENT_TOKEN", nil),
5558
},
5659
ProviderOptSingleApiEndpoint: {
5760
Type: schema.TypeString,

gcore/resource_gcore_baremetal.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ func resourceBmInstance() *schema.Resource {
9191
Type: schema.TypeString,
9292
Optional: true,
9393
Computed: true,
94-
ExactlyOneOf: []string{
95-
"name",
96-
"name_templates",
97-
},
9894
},
9995
"name_templates": &schema.Schema{
100-
Type: schema.TypeString,
101-
Optional: true,
102-
ExactlyOneOf: []string{
103-
"name",
104-
"name_templates",
105-
},
96+
Type: schema.TypeList,
97+
Optional: true,
98+
Deprecated: "Use name_template instead",
99+
ConflictsWith: []string{"name_template"},
100+
Elem: &schema.Schema{Type: schema.TypeString},
101+
},
102+
"name_template": &schema.Schema{
103+
Type: schema.TypeString,
104+
Optional: true,
105+
ConflictsWith: []string{"name_templates"},
106106
},
107107
"image_id": {
108108
Type: schema.TypeString,

0 commit comments

Comments
 (0)