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

Commit 93e67fa

Browse files
author
Alexandr Sokolov
committed
external_dns_enabled added in k8s, routers interfaces fixed
1 parent 7eecd2b commit 93e67fa

File tree

5 files changed

+35
-37
lines changed

5 files changed

+35
-37
lines changed

gcore/resource_gcore_k8s.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ func resourceK8s() *schema.Resource {
100100
Type: schema.TypeBool,
101101
Optional: true,
102102
},
103-
//"external_dns_enabled": &schema.Schema{
104-
// Type: schema.TypeBool,
105-
// Optional: true,
106-
//},
103+
"external_dns_enabled": &schema.Schema{
104+
Type: schema.TypeBool,
105+
Optional: true,
106+
},
107107
"master_lb_floating_ip_enabled": &schema.Schema{
108108
Type: schema.TypeBool,
109109
Optional: true,
@@ -269,12 +269,12 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
269269
}
270270

271271
opts := clusters.CreateOpts{
272-
Name: d.Get("name").(string),
273-
FixedNetwork: d.Get("fixed_network").(string),
274-
FixedSubnet: d.Get("fixed_subnet").(string),
275-
KeyPair: d.Get("keypair").(string),
276-
AutoHealingEnabled: d.Get("auto_healing_enabled").(bool),
277-
//ExternalDNSEnabled: d.Get("external_dns_enabled").(bool),
272+
Name: d.Get("name").(string),
273+
FixedNetwork: d.Get("fixed_network").(string),
274+
FixedSubnet: d.Get("fixed_subnet").(string),
275+
KeyPair: d.Get("keypair").(string),
276+
AutoHealingEnabled: d.Get("auto_healing_enabled").(bool),
277+
ExternalDNSEnabled: d.Get("external_dns_enabled").(bool),
278278
MasterLBFloatingIPEnabled: d.Get("master_lb_floating_ip_enabled").(bool),
279279
}
280280

@@ -364,7 +364,7 @@ func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{})
364364
}
365365

366366
d.Set("name", cluster.Name)
367-
//d.Set("external_dns_enabled", cluster.ExternalDNSEnabled)
367+
d.Set("external_dns_enabled", cluster.ExternalDNSEnabled)
368368
d.Set("fixed_network", cluster.FixedNetwork)
369369
d.Set("fixed_subnet", cluster.FixedSubnet)
370370
d.Set("master_lb_floating_ip_enabled", cluster.FloatingIPEnabled)

gcore/resource_gcore_router.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ func resourceRouter() *schema.Resource {
9898
"network_id": {
9999
Type: schema.TypeString,
100100
Description: "Id of the external network",
101-
Required: true,
101+
Optional: true,
102+
Computed: true,
102103
},
103104
"external_fixed_ips": {
104105
Type: schema.TypeList,
@@ -120,8 +121,9 @@ func resourceRouter() *schema.Resource {
120121
},
121122
},
122123
"interfaces": &schema.Schema{
123-
Type: schema.TypeList,
124+
Type: schema.TypeSet,
124125
Optional: true,
126+
Set: routerInterfaceUniqueID,
125127
Elem: &schema.Resource{
126128
Schema: map[string]*schema.Schema{
127129
"type": {
@@ -187,9 +189,9 @@ func resourceRouterCreate(ctx context.Context, d *schema.ResourceData, m interfa
187189
createOpts.ExternalGatewayInfo = gws
188190
}
189191

190-
ifs := d.Get("interfaces")
191-
if len(ifs.([]interface{})) > 0 {
192-
ifaces, err := extractInterfacesMap(ifs.([]interface{}))
192+
ifs := d.Get("interfaces").(*schema.Set)
193+
if ifs.Len() > 0 {
194+
ifaces, err := extractInterfacesMap(ifs.List())
193195
if err != nil {
194196
return diag.FromErr(err)
195197
}
@@ -285,14 +287,16 @@ func resourceRouterRead(ctx context.Context, d *schema.ResourceData, m interface
285287
d.Set("external_gateway_info", egilst)
286288
}
287289

288-
ifs := make([]map[string]string, len(router.Interfaces))
290+
ifs := make([]interface{}, len(router.Interfaces))
289291
for i, iface := range router.Interfaces {
290-
smap := make(map[string]string, 2)
292+
smap := make(map[string]interface{}, 2)
291293
smap["type"] = "subnet"
292294
smap["subnet_id"] = iface.IPAssignments[0].SubnetID
293295
ifs[i] = smap
294296
}
295-
d.Set("interfaces", ifs)
297+
if err := d.Set("interfaces", schema.NewSet(routerInterfaceUniqueID, ifs)); err != nil {
298+
299+
}
296300

297301
rs := make([]map[string]string, len(router.Routes))
298302
for i, r := range router.Routes {
@@ -340,11 +344,11 @@ func resourceRouterUpdate(ctx context.Context, d *schema.ResourceData, m interfa
340344

341345
if d.HasChange("interfaces") {
342346
oldValue, newValue := d.GetChange("interfaces")
343-
oifs, err := extractInterfacesMap(oldValue.([]interface{}))
347+
oifs, err := extractInterfacesMap(oldValue.(*schema.Set).List())
344348
if err != nil {
345349
return diag.FromErr(err)
346350
}
347-
nifs, err := extractInterfacesMap(newValue.([]interface{}))
351+
nifs, err := extractInterfacesMap(newValue.(*schema.Set).List())
348352
if err != nil {
349353
return diag.FromErr(err)
350354
}

gcore/utils.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,13 @@ func interfaceUniqueID(i interface{}) int {
572572
return int(binary.BigEndian.Uint64(h.Sum(nil)))
573573
}
574574

575+
func routerInterfaceUniqueID(i interface{}) int {
576+
e := i.(map[string]interface{})
577+
h := md5.New()
578+
io.WriteString(h, e["subnet_id"].(string))
579+
return int(binary.BigEndian.Uint64(h.Sum(nil)))
580+
}
581+
575582
func volumeUniqueID(i interface{}) int {
576583
e := i.(map[string]interface{})
577584
h := md5.New()

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ require (
66
github.com/G-Core/g-dns-sdk-go v0.1.2
77
github.com/G-Core/gcorelabs-storage-sdk-go v0.0.9
88
github.com/G-Core/gcorelabscdn-go v0.1.2
9-
github.com/G-Core/gcorelabscloud-go v0.4.37
9+
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
1312
github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0
1413
github.com/mattn/go-colorable v0.1.11 // indirect
1514
github.com/mitchellh/mapstructure v1.4.1

go.sum

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,10 @@ github.com/G-Core/gcorelabs-storage-sdk-go v0.0.9 h1:6uyKbknI8Q2pIJApPBf6JA0CN5O
4747
github.com/G-Core/gcorelabs-storage-sdk-go v0.0.9/go.mod h1:BZef79y4G28n8ic3x6iQWbW+mtpHPSUyJRfIRSkeAJw=
4848
github.com/G-Core/gcorelabscdn-go v0.1.2 h1:AiwZY3oIHL4wMJNmIlLgxw4eQmSqtQmkTzrkGpa7ckc=
4949
github.com/G-Core/gcorelabscdn-go v0.1.2/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE=
50-
github.com/G-Core/gcorelabscloud-go v0.4.37 h1:Ae2EhrtMbTTd6MFyyrDAPnX9AIbQG696Jwn97hp6gek=
51-
github.com/G-Core/gcorelabscloud-go v0.4.37/go.mod h1:Z1MF80mWagEUrxygtYkvW/MJEYNmIUPsIEYBB3cKjOM=
52-
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
50+
github.com/G-Core/gcorelabscloud-go v0.4.42 h1:LBH4GnH82eQ5L/Lfnzm8KJovbIHPzt2KMitVN1V9kDQ=
51+
github.com/G-Core/gcorelabscloud-go v0.4.42/go.mod h1:Z1MF80mWagEUrxygtYkvW/MJEYNmIUPsIEYBB3cKjOM=
5352
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
54-
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
5553
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
56-
github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60=
5754
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
5855
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
5956
github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk=
@@ -86,7 +83,6 @@ github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/
8683
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
8784
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
8885
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
89-
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to=
9086
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
9187
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
9288
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
@@ -102,7 +98,6 @@ github.com/aws/aws-sdk-go v1.34.28 h1:sscPpn/Ns3i0F4HPEWAVcwdIRaZZCuL7llJ2/60yPI
10298
github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48=
10399
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas=
104100
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
105-
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
106101
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
107102
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
108103
github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
@@ -391,8 +386,6 @@ github.com/hashicorp/terraform-exec v0.15.0/go.mod h1:H4IG8ZxanU+NW0ZpDRNsvh9f0u
391386
github.com/hashicorp/terraform-json v0.12.0/go.mod h1:pmbq9o4EuL43db5+0ogX10Yofv1nozM+wskr/bGFJpI=
392387
github.com/hashicorp/terraform-json v0.13.0 h1:Li9L+lKD1FO5RVFRM1mMMIBDoUHslOniyEi5CM+FWGY=
393388
github.com/hashicorp/terraform-json v0.13.0/go.mod h1:y5OdLBCT+rxbwnpxZs9kGL7R9ExU76+cpdY8zHwoazk=
394-
github.com/hashicorp/terraform-plugin-docs v0.5.1 h1:WwrUcamix9x0TqfTw/WGHMRqoTe1QPZKaeWJPuFb4lQ=
395-
github.com/hashicorp/terraform-plugin-docs v0.5.1/go.mod h1:SQwEgy0/B0UPQ07rNEG1Wpt6E3jvRcCwkVHPNybGgc0=
396389
github.com/hashicorp/terraform-plugin-go v0.3.0 h1:AJqYzP52JFYl9NABRI7smXI1pNjgR5Q/y2WyVJ/BOZA=
397390
github.com/hashicorp/terraform-plugin-go v0.3.0/go.mod h1:dFHsQMaTLpON2gWhVWT96fvtlc/MF1vSy3OdMhWBzdM=
398391
github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0 h1:SuI59MqNjYDrL7EfqHX9V6P/24isgqYx/FdglwVs9bg=
@@ -401,7 +394,6 @@ github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKe
401394
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
402395
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
403396
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
404-
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
405397
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
406398
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
407399
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
@@ -484,7 +476,6 @@ github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9
484476
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
485477
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
486478
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
487-
github.com/mitchellh/cli v1.1.2 h1:PvH+lL2B7IQ101xQL63Of8yFS2y+aDlsFcsqNc+u/Kw=
488479
github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4=
489480
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
490481
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
@@ -541,14 +532,11 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
541532
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
542533
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
543534
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
544-
github.com/posener/complete v1.1.1 h1:ccV59UEOTzVDnDUEFdT95ZzHVZ+5+158q8+SJb2QV5w=
545535
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
546536
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
547537
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
548538
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
549539
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
550-
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
551-
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
552540
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
553541
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
554542
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=

0 commit comments

Comments
 (0)