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

Commit 638496c

Browse files
alexk53Alexandr Sokolov
andauthored
0.3.10 (#78)
* network resource create_router ForceNew removed subnet resource connect_network_to_router ForceNew removed some fix in securitygroup resource to improve plan * ignore_creds_auth_error DefaultFunc fixed Co-authored-by: Alexandr Sokolov <[email protected]>
1 parent ff3ded1 commit 638496c

File tree

8 files changed

+71
-43
lines changed

8 files changed

+71
-43
lines changed

examples/resources/gcore_lblistener/resource.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ resource "gcore_loadbalancer" "lb" {
1010
region_id = 1
1111
name = "test"
1212
flavor = "lb1-1-2"
13-
listener {
14-
name = "test"
15-
protocol = "HTTP"
16-
protocol_port = 80
17-
}
1813

1914
listener {
2015
name = "test3"

gcore/provider.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ func Provider() *schema.Provider {
4949
Type: schema.TypeBool,
5050
Optional: true,
5151
Description: "Should be set to true when you are gonna to use storage resource with permanent API-token only.",
52-
DefaultFunc: schema.EnvDefaultFunc("GCORE_PERMANENT_TOKEN", false),
52+
DefaultFunc: func() (interface{}, error) {
53+
return os.Getenv("GCORE_PERMANENT_TOKEN") != "", nil
54+
},
5355
},
5456
"gcore_platform": {
5557
Type: schema.TypeString,
5658
Optional: true,
57-
Description: "Platform ulr is used for generate jwt",
59+
Description: "Platform url is used for generate jwt",
5860
DefaultFunc: schema.EnvDefaultFunc("GCORE_PLATFORM", "https://api.gcdn.co"),
5961
},
6062
"gcore_api": {

gcore/resource_gcore_network.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ func resourceNetwork() *schema.Resource {
9191
"create_router": &schema.Schema{
9292
Type: schema.TypeBool,
9393
Optional: true,
94-
ForceNew: true,
9594
Default: true,
9695
Description: "Create external router to the network, default true",
9796
},

gcore/resource_gcore_securitygroup.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,24 @@ func resourceSecurityGroup() *schema.Resource {
131131
"port_range_min": &schema.Schema{
132132
Type: schema.TypeInt,
133133
Optional: true,
134+
Default: 0,
134135
ValidateDiagFunc: validatePortRange,
135136
},
136137
"port_range_max": &schema.Schema{
137138
Type: schema.TypeInt,
138139
Optional: true,
140+
Default: 0,
139141
ValidateDiagFunc: validatePortRange,
140142
},
141143
"description": &schema.Schema{
142144
Type: schema.TypeString,
143145
Optional: true,
146+
Default: "",
144147
},
145148
"remote_ip_prefix": &schema.Schema{
146149
Type: schema.TypeString,
147150
Optional: true,
151+
Default: "",
148152
},
149153
"updated_at": &schema.Schema{
150154
Type: schema.TypeString,
@@ -266,6 +270,7 @@ func resourceSecurityGroupRead(ctx context.Context, d *schema.ResourceData, m in
266270

267271
newSgRules := make([]interface{}, len(sg.SecurityGroupRules))
268272
for i, sgr := range sg.SecurityGroupRules {
273+
log.Printf("rules: %+v", sgr)
269274
r := make(map[string]interface{})
270275
r["id"] = sgr.ID
271276
r["direction"] = sgr.Direction.String()
@@ -274,10 +279,9 @@ func resourceSecurityGroupRead(ctx context.Context, d *schema.ResourceData, m in
274279
r["ethertype"] = sgr.EtherType.String()
275280
}
276281

282+
r["protocol"] = types.ProtocolAny
277283
if sgr.Protocol != nil {
278284
r["protocol"] = sgr.Protocol.String()
279-
} else {
280-
r["protocol"] = types.ProtocolAny
281285
}
282286

283287
r["port_range_max"] = 0
@@ -296,7 +300,7 @@ func resourceSecurityGroupRead(ctx context.Context, d *schema.ResourceData, m in
296300

297301
r["remote_ip_prefix"] = ""
298302
if sgr.RemoteIPPrefix != nil {
299-
r["remote_ip_prefix"] = strings.TrimSuffix(*sgr.RemoteIPPrefix, "/32")
303+
r["remote_ip_prefix"] = *sgr.RemoteIPPrefix
300304
}
301305

302306
r["updated_at"] = sgr.UpdatedAt.String()

gcore/resource_gcore_subnet.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ func resourceSubnet() *schema.Resource {
9797
Description: "True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null. Default true.",
9898
Optional: true,
9999
Default: true,
100-
ForceNew: true,
101100
},
102101
"dns_nameservers": &schema.Schema{
103102
Type: schema.TypeList,

gcore/utils.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ func secGroupUniqueID(i interface{}) int {
582582
io.WriteString(h, strconv.Itoa(e["port_range_min"].(int)))
583583
io.WriteString(h, strconv.Itoa(e["port_range_max"].(int)))
584584
io.WriteString(h, e["description"].(string))
585-
io.WriteString(h, strings.TrimSuffix(e["remote_ip_prefix"].(string), "/32"))
585+
io.WriteString(h, e["remote_ip_prefix"].(string))
586586

587587
return int(binary.BigEndian.Uint64(h.Sum(nil)))
588588
}
@@ -609,10 +609,8 @@ func extractSecurityGroupRuleMap(r interface{}, gid string) securitygroups.Creat
609609
opts.PortRangeMax = &maxP
610610
}
611611

612-
descr := rule["description"].(string)
613-
if descr != "" {
614-
opts.Description = &descr
615-
}
612+
descr, _ := rule["description"].(string)
613+
opts.Description = &descr
616614

617615
remoteIPPrefix := rule["remote_ip_prefix"].(string)
618616
if remoteIPPrefix != "" {

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ require (
99
github.com/G-Core/gcorelabscloud-go v0.4.42
1010
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
1111
github.com/hashicorp/terraform-exec v0.15.0 // indirect
12-
github.com/hashicorp/terraform-plugin-docs v0.5.1 // indirect
13-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0
12+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1
1413
github.com/mattn/go-colorable v0.1.11 // indirect
1514
github.com/mitchellh/mapstructure v1.4.1
1615
github.com/zclconf/go-cty v1.10.0 // indirect

0 commit comments

Comments
 (0)