Skip to content

Commit d019ada

Browse files
jtherinMonitob
authored andcommitted
k8s: add type on cluster (scaleway#886)
1 parent 5e6743f commit d019ada

16 files changed

+5029
-7180
lines changed

docs/resources/k8s_cluster.md

+2
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ The following arguments are supported:
179179

180180
- `name` - (Required) The name for the Kubernetes cluster.
181181

182+
- `type` - (Optional) The type of Kubernetes cluster.
183+
182184
- `description` - (Optional) A description for the Kubernetes cluster.
183185

184186
- `version` - (Required) The version of the Kubernetes cluster.

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
99
github.com/hashicorp/go-retryablehttp v0.7.0
1010
github.com/hashicorp/terraform-plugin-sdk/v2 v2.8.0
11-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210804084528-d11825fe1059
11+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20211005125957-db499d89a262
1212
github.com/stretchr/testify v1.7.0
1313
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
1414

@@ -72,7 +72,7 @@ require (
7272
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
7373
google.golang.org/grpc v1.32.0 // indirect
7474
google.golang.org/protobuf v1.25.0 // indirect
75-
gopkg.in/yaml.v2 v2.3.0 // indirect
75+
gopkg.in/yaml.v2 v2.4.0 // indirect
7676
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
7777
)
7878

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
7878
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7979
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
8080
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
81-
github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E=
8281
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
8382
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
8483
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
@@ -285,8 +284,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
285284
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
286285
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
287286
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
288-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210804084528-d11825fe1059 h1:nwz2J8vqZJNN32yzUY9W8cPn4AwbMJdk/O/4nx+RLPM=
289-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210804084528-d11825fe1059/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
287+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20211005125957-db499d89a262 h1:ioN4zmp/4AoCJ/BbuwmkpH+bnSSntgWMUN1PkQ46/nI=
288+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20211005125957-db499d89a262/go.mod h1:NnxccdAsg2lS0ng/kfLVLemUQR50FCM/cdZv2gqKDhw=
290289
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
291290
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
292291
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
@@ -600,8 +599,9 @@ gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRN
600599
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
601600
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
602601
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
603-
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
604602
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
603+
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
604+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
605605
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
606606
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
607607
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

scaleway/resource_k8s_cluster.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ func resourceScalewayK8SCluster() *schema.Resource {
3232
Required: true,
3333
Description: "The name of the cluster",
3434
},
35+
"type": {
36+
Type: schema.TypeString,
37+
Optional: true,
38+
ForceNew: true,
39+
Computed: true,
40+
Description: "The type of cluster",
41+
},
3542
"description": {
3643
Type: schema.TypeString,
3744
Optional: true,
@@ -53,6 +60,7 @@ func resourceScalewayK8SCluster() *schema.Resource {
5360
k8s.CNICalico.String(),
5461
k8s.CNIFlannel.String(),
5562
k8s.CNIWeave.String(),
63+
k8s.CNIKilo.String(),
5664
}, false),
5765
},
5866
"tags": {
@@ -228,10 +236,16 @@ func resourceScalewayK8SClusterCreate(ctx context.Context, d *schema.ResourceDat
228236
description = ""
229237
}
230238

239+
clusterType, ok := d.GetOk("type")
240+
if !ok {
241+
clusterType = ""
242+
}
243+
231244
req := &k8s.CreateClusterRequest{
232245
Region: region,
233246
ProjectID: expandStringPtr(d.Get("project_id")),
234247
Name: expandOrGenerateString(d.Get("name"), "cluster"),
248+
Type: clusterType.(string),
235249
Description: description.(string),
236250
Cni: k8s.CNI(d.Get("cni").(string)),
237251
Tags: expandStrings(d.Get("tags")),
@@ -365,7 +379,7 @@ func resourceScalewayK8SClusterCreate(ctx context.Context, d *schema.ResourceDat
365379
return diag.FromErr(err)
366380
}
367381

368-
err = waitK8SCluster(ctx, k8sAPI, region, res.ID, k8s.ClusterStatusPoolRequired)
382+
err = waitK8SCluster(ctx, k8sAPI, region, res.ID, k8s.ClusterStatusReady, k8s.ClusterStatusPoolRequired)
369383
if err != nil {
370384
return diag.FromErr(err)
371385
}
@@ -398,6 +412,7 @@ func resourceScalewayK8SClusterRead(ctx context.Context, d *schema.ResourceData,
398412

399413
_ = d.Set("region", string(region))
400414
_ = d.Set("name", response.Name)
415+
_ = d.Set("type", response.Type)
401416
_ = d.Set("organization_id", response.OrganizationID)
402417
_ = d.Set("project_id", response.ProjectID)
403418
_ = d.Set("description", response.Description)

0 commit comments

Comments
 (0)