Skip to content

Commit 118adc0

Browse files
authored
Merge branch 'master' into tags_fixup
2 parents b5da921 + 9f85bde commit 118adc0

14 files changed

+4549
-3208
lines changed

docs/resources/lb_backend.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The following arguments are supported:
4949
- `forward_protocol` - (Required) Backend protocol. Possible values are: `tcp` or `http`.
5050
- `name` - (Optional) The name of the load-balancer backend.
5151
- `forward_port` - (Required) User sessions will be forwarded to this port of backend servers.
52-
- `forward_port_algorithm` - (Default: `roundrobin`) Load balancing algorithm. Possible values are: `roundrobin` and `leastconn`.
52+
- `forward_port_algorithm` - (Default: `roundrobin`) Load balancing algorithm. Possible values are: `roundrobin`, `leastconn` and `first`.
5353
- `sticky_sessions` - (Default: `none`) Load balancing algorithm. Possible values are: `none`, `cookie` and `table`.
5454
- `sticky_sessions_cookie_name` - (Optional) Cookie name for for sticky sessions. Only applicable when sticky_sessions is set to `cookie`.
5555
- `server_ips` - (Optional) List of backend server IP addresses. Addresses can be either IPv4 or IPv6.

scaleway/data_source_account_ssh_key.go

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,25 @@ import (
1111
)
1212

1313
func dataSourceScalewayAccountSSHKey() *schema.Resource {
14+
dsSchema := datasourceSchemaFromResourceSchema(resourceScalewayAccountSSKKey().Schema)
15+
addOptionalFieldsToSchema(dsSchema, "name")
16+
17+
dsSchema["name"].ConflictsWith = []string{"ssh_key_id"}
18+
dsSchema["ssh_key_id"] = &schema.Schema{
19+
Type: schema.TypeString,
20+
Optional: true,
21+
Description: "The ID of the SSH key",
22+
ValidateFunc: validationUUID(),
23+
}
24+
1425
return &schema.Resource{
1526
ReadContext: dataSourceScalewayAccountSSHKeyRead,
16-
Schema: map[string]*schema.Schema{
17-
"name": {
18-
Type: schema.TypeString,
19-
Optional: true,
20-
Computed: true,
21-
Description: "The name of the SSH key",
22-
},
23-
"ssh_key_id": {
24-
Type: schema.TypeString,
25-
Optional: true,
26-
Computed: true,
27-
Description: "The ID of the SSH key",
28-
ValidateFunc: validationUUIDorUUIDWithLocality(),
29-
},
30-
"public_key": {
31-
Type: schema.TypeString,
32-
Computed: true,
33-
Description: "The public SSH key",
34-
},
35-
"organization_id": organizationIDSchema(),
36-
"project_id": projectIDSchema(),
37-
},
27+
Schema: dsSchema,
3828
}
3929
}
4030

41-
func dataSourceScalewayAccountSSHKeyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
42-
accountAPI := accountAPI(m)
31+
func dataSourceScalewayAccountSSHKeyRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
32+
accountAPI := accountAPI(meta)
4333

4434
var sshKey *account.SSHKey
4535
sshKeyID, ok := d.GetOk("ssh_key_id")
@@ -67,11 +57,7 @@ func dataSourceScalewayAccountSSHKeyRead(ctx context.Context, d *schema.Resource
6757
}
6858

6959
d.SetId(sshKey.ID)
70-
_ = d.Set("name", sshKey.Name)
7160
_ = d.Set("ssh_key_id", sshKey.ID)
72-
_ = d.Set("public_key", sshKey.PublicKey)
73-
_ = d.Set("organization_id", sshKey.OrganizationID)
74-
_ = d.Set("project_id", sshKey.ProjectID)
7561

76-
return nil
62+
return resourceScalewayAccountSSHKeyRead(ctx, d, meta)
7763
}

scaleway/resource_baremetal_server.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,5 +296,9 @@ func resourceScalewayBaremetalServerDelete(ctx context.Context, d *schema.Resour
296296
Timeout: scw.TimeDurationPtr(baremetalServerWaitForTimeout),
297297
})
298298

299-
return diag.FromErr(err)
299+
if err != nil && !is404Error(err) {
300+
return diag.FromErr(err)
301+
}
302+
303+
return nil
300304
}

scaleway/resource_k8s_cluster_test.go

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,64 @@ import (
1010
"github.com/scaleway/scaleway-sdk-go/scw"
1111
)
1212

13-
var (
14-
latestK8SVersion = "1.19.2"
15-
latestK8SVersionMinor = "1.19"
16-
previousK8SVersion = "1.18.9"
17-
previousK8SVersionMinor = "1.18"
18-
)
19-
2013
func init() {
2114
resource.AddTestSweepers("scaleway_k8s_cluster", &resource.Sweeper{
2215
Name: "scaleway_k8s_cluster",
2316
F: testSweepK8SCluster,
2417
})
2518
}
2619

27-
func testAccScalewayK8SClusterGetLatestVersion(tt *TestTools) {
20+
func testAccScalewayK8SClusterGetLatestK8SVersion(tt *TestTools) string {
21+
api := k8s.NewAPI(tt.Meta.scwClient)
22+
versions, err := api.ListVersions(&k8s.ListVersionsRequest{})
23+
if err != nil {
24+
tt.T.Fatalf("Could not get latestK8SVersion: %s", err)
25+
}
26+
if len(versions.Versions) > 1 {
27+
latestK8SVersion := versions.Versions[0].Name
28+
return latestK8SVersion
29+
}
30+
return ""
31+
}
32+
func testAccScalewayK8SClusterGetLatestK8SVersionMinor(tt *TestTools) string {
33+
api := k8s.NewAPI(tt.Meta.scwClient)
34+
versions, err := api.ListVersions(&k8s.ListVersionsRequest{})
35+
if err != nil {
36+
tt.T.Fatalf("Could not get latestK8SVersion: %s", err)
37+
}
38+
if len(versions.Versions) > 1 {
39+
latestK8SVersion := versions.Versions[0].Name
40+
latestK8SVersionMinor, _ := k8sGetMinorVersionFromFull(latestK8SVersion)
41+
return latestK8SVersionMinor
42+
}
43+
return ""
44+
}
45+
46+
func testAccScalewayK8SClusterGetPreviousK8SVersion(tt *TestTools) string {
47+
api := k8s.NewAPI(tt.Meta.scwClient)
48+
versions, err := api.ListVersions(&k8s.ListVersionsRequest{})
49+
if err != nil {
50+
tt.T.Fatalf("Could not get latestK8SVersion: %s", err)
51+
}
52+
if len(versions.Versions) > 1 {
53+
previousK8SVersion := versions.Versions[1].Name
54+
return previousK8SVersion
55+
}
56+
return ""
57+
}
58+
59+
func testAccScalewayK8SClusterGetPreviousK8SVersionMinor(tt *TestTools) string {
2860
api := k8s.NewAPI(tt.Meta.scwClient)
2961
versions, err := api.ListVersions(&k8s.ListVersionsRequest{})
3062
if err != nil {
3163
tt.T.Fatalf("Could not get latestK8SVersion: %s", err)
32-
return
3364
}
3465
if len(versions.Versions) > 1 {
35-
latestK8SVersion = versions.Versions[0].Name
36-
latestK8SVersionMinor, _ = k8sGetMinorVersionFromFull(latestK8SVersion)
37-
previousK8SVersion = versions.Versions[1].Name
38-
previousK8SVersionMinor, _ = k8sGetMinorVersionFromFull(previousK8SVersion)
66+
previousK8SVersion := versions.Versions[1].Name
67+
previousK8SVersionMinor, _ := k8sGetMinorVersionFromFull(previousK8SVersion)
68+
return previousK8SVersionMinor
3969
}
70+
return ""
4071
}
4172

4273
func testSweepK8SCluster(_ string) error {
@@ -65,9 +96,12 @@ func testSweepK8SCluster(_ string) error {
6596
func TestAccScalewayK8SCluster_Basic(t *testing.T) {
6697
tt := NewTestTools(t)
6798
defer tt.Cleanup()
99+
100+
latestK8SVersion := testAccScalewayK8SClusterGetLatestK8SVersion(tt)
101+
previousK8SVersion := testAccScalewayK8SClusterGetPreviousK8SVersion(tt)
102+
68103
resource.ParallelTest(t, resource.TestCase{
69104
PreCheck: func() {
70-
testAccScalewayK8SClusterGetLatestVersion(tt)
71105
testAccPreCheck(t)
72106
},
73107
ProviderFactories: tt.ProviderFactories,
@@ -116,9 +150,11 @@ func TestAccScalewayK8SCluster_Basic(t *testing.T) {
116150
func TestAccScalewayK8SCluster_IngressDashboard(t *testing.T) {
117151
tt := NewTestTools(t)
118152
defer tt.Cleanup()
153+
154+
latestK8SVersion := testAccScalewayK8SClusterGetLatestK8SVersion(tt)
155+
119156
resource.ParallelTest(t, resource.TestCase{
120157
PreCheck: func() {
121-
testAccScalewayK8SClusterGetLatestVersion(tt)
122158
testAccPreCheck(t)
123159
},
124160
ProviderFactories: tt.ProviderFactories,
@@ -191,9 +227,11 @@ func TestAccScalewayK8SCluster_IngressDashboard(t *testing.T) {
191227
func TestAccScalewayK8SCluster_Autoscaling(t *testing.T) {
192228
tt := NewTestTools(t)
193229
defer tt.Cleanup()
230+
231+
latestK8SVersion := testAccScalewayK8SClusterGetLatestK8SVersion(tt)
232+
194233
resource.ParallelTest(t, resource.TestCase{
195234
PreCheck: func() {
196-
testAccScalewayK8SClusterGetLatestVersion(tt)
197235
testAccPreCheck(t)
198236
},
199237
ProviderFactories: tt.ProviderFactories,
@@ -258,10 +296,15 @@ func TestAccScalewayK8SCluster_Autoscaling(t *testing.T) {
258296
func TestAccScalewayK8SCluster_AutoUpgrade(t *testing.T) {
259297
tt := NewTestTools(t)
260298
defer tt.Cleanup()
299+
300+
latestK8SVersion := testAccScalewayK8SClusterGetLatestK8SVersion(tt)
301+
latestK8SVersionMinor := testAccScalewayK8SClusterGetLatestK8SVersionMinor(tt)
302+
previousK8SVersion := testAccScalewayK8SClusterGetPreviousK8SVersion(tt)
303+
previousK8SVersionMinor := testAccScalewayK8SClusterGetPreviousK8SVersionMinor(tt)
304+
261305
resource.ParallelTest(t, resource.TestCase{
262306
PreCheck: func() {
263307
testAccPreCheck(t)
264-
testAccScalewayK8SClusterGetLatestVersion(tt)
265308
},
266309
ProviderFactories: tt.ProviderFactories,
267310
CheckDestroy: testAccCheckScalewayK8SClusterDestroy(tt),

scaleway/resource_k8s_pool_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import (
1212
func TestAccScalewayK8SCluster_PoolBasic(t *testing.T) {
1313
tt := NewTestTools(t)
1414
defer tt.Cleanup()
15+
16+
latestK8SVersion := testAccScalewayK8SClusterGetLatestK8SVersion(tt)
17+
1518
resource.ParallelTest(t, resource.TestCase{
1619
PreCheck: func() { testAccPreCheck(t) },
1720
ProviderFactories: tt.ProviderFactories,
@@ -63,6 +66,7 @@ func TestAccScalewayK8SCluster_PoolBasic(t *testing.T) {
6366
func TestAccScalewayK8SCluster_PoolWait(t *testing.T) {
6467
tt := NewTestTools(t)
6568
defer tt.Cleanup()
69+
latestK8SVersion := testAccScalewayK8SClusterGetLatestK8SVersion(tt)
6670
resource.ParallelTest(t, resource.TestCase{
6771
PreCheck: func() { testAccPreCheck(t) },
6872
ProviderFactories: tt.ProviderFactories,
@@ -135,6 +139,7 @@ func TestAccScalewayK8SCluster_PoolWait(t *testing.T) {
135139
func TestAccScalewayK8SCluster_PoolPlacementGroup(t *testing.T) {
136140
tt := NewTestTools(t)
137141
defer tt.Cleanup()
142+
latestK8SVersion := testAccScalewayK8SClusterGetLatestK8SVersion(tt)
138143
resource.ParallelTest(t, resource.TestCase{
139144
PreCheck: func() { testAccPreCheck(t) },
140145
ProviderFactories: tt.ProviderFactories,

scaleway/resource_lb_backend.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func resourceScalewayLbBackend() *schema.Resource {
5252
ValidateFunc: validation.StringInSlice([]string{
5353
lb.ForwardPortAlgorithmRoundrobin.String(),
5454
lb.ForwardPortAlgorithmLeastconn.String(),
55+
lb.ForwardPortAlgorithmFirst.String(),
5556
}, false),
5657
Default: lb.ForwardPortAlgorithmRoundrobin.String(),
5758
Optional: true,

0 commit comments

Comments
 (0)