Skip to content

Commit c0fbcce

Browse files
authored
Merge branch 'master' into feat/new_management_for_update_instance_rdb
2 parents 0b06704 + 9619b26 commit c0fbcce

File tree

383 files changed

+3613
-1268
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

383 files changed

+3613
-1268
lines changed

.github/workflows/nightly.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ jobs:
4848
# Checkout should always be before setup-go to ensure caching is working
4949
- name: Checkout
5050
uses: actions/checkout@v4
51+
- name: Install Terraform
52+
uses: hashicorp/setup-terraform@v3
5153
- name: Install Go
5254
uses: actions/setup-go@v5
5355
with:

.golangci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ linters:
1818
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: false, auto-fix: false]
1919
- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted. [fast: false, auto-fix: false]
2020
- errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. [fast: false, auto-fix: false]
21+
- exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. [auto-fix]
2122
- forbidigo # Forbids identifiers [fast: true, auto-fix: false]
2223
- gci # Gci controls golang package import order and makes it always deterministic. [fast: true, auto-fix: false]
2324
- gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. [fast: true, auto-fix: false]
@@ -48,6 +49,7 @@ linters:
4849
- musttag # enforce field tags in (un)marshaled structs [fast: false, auto-fix: false]
4950
- nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false]
5051
- nilerr # Finds the code that returns nil even if it checks that the error is not nil. [fast: false, auto-fix: false]
52+
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity [fast: true, auto-fix: true]
5153
- noctx # noctx finds sending http request without context.Context [fast: false, auto-fix: false]
5254
- nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false]
5355
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. [fast: true, auto-fix: false]
@@ -74,8 +76,10 @@ linters:
7476
- unconvert # Remove unnecessary type conversions [fast: false, auto-fix: false]
7577
- unused #(megacheck): Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
7678
- usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. [fast: true, auto-fix: false]
79+
- usetesting # Reports uses of functions with replacement inside the testing package. [auto-fix]
7780
- wastedassign # wastedassign finds wasted assignment statements. [fast: false, auto-fix: false]
7881
- whitespace # Tool for detection of leading and trailing whitespace [fast: true, auto-fix: true]
82+
- wsl # Whitespace Linter - Forces you to use empty lines! [fast: true, auto-fix: false]
7983
- zerologlint # Detects the wrong usage of `zerolog` that a user forgets to dispatch with `Send` or `Msg` [fast: false, auto-fix: false]
8084

8185
disable:
@@ -97,9 +101,7 @@ linters:
97101
- mnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false]
98102
- nestif # Reports deeply nested if statements [fast: true, auto-fix: false]
99103
- nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value. [fast: false, auto-fix: false]
100-
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity [fast: true, auto-fix: false]
101104
- varnamelen # checks that the length of a variable's name matches its scope [fast: false, auto-fix: false]
102-
- wsl # Whitespace Linter - Forces you to use empty lines! [fast: true, auto-fix: false]
103105

104106
linters-settings:
105107
goconst:

docs/resources/instance_server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ In addition to all arguments above, the following attributes are exported:
283283

284284
~> **Important:** Instance servers' IDs are [zoned](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111`
285285

286-
- `placement_group_policy_respected` - True when the placement group policy is respected.
286+
- `placement_group_policy_respected` - (Deprecated) Always false, use [instance_placement_group ressource](instance_placement_group.md) to known when the placement group policy is respected.
287287
- `root_volume`
288288
- `volume_id` - The volume ID of the root volume of the server.
289289
- `private_ip` - The Scaleway internal IP address of the server (Deprecated use [ipam_ip datasource](../data-sources/ipam_ip.md#instance-private-network-ip) instead).

docs/resources/redis_cluster.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ The `private_network` block supports :
149149
Keep in mind that in cluster mode you cannot edit your Private Network after its creation so if you want to be able to
150150
scale your cluster horizontally (adding nodes) later, you should provide more IPs than nodes.
151151
If not set, the IP network address within the private subnet is determined by the IP Address Management (IPAM) service.
152-
152+
~> **Important:** When IPAM is enabled, the IPs specified here will be ignored and should not be provided.
153+
153154
~> The `private_network` conflicts with `acl`. Only one should be specified.
154155

155156
~> **Important:** The way to use Private Networks differs whether you are using Redis™ in Standalone or cluster mode.

internal/acctest/acctest.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type TestTools struct {
2626

2727
func NewTestTools(t *testing.T) *TestTools {
2828
t.Helper()
29+
2930
ctx := context.Background()
3031

3132
folder, err := os.Getwd()
@@ -98,6 +99,7 @@ func extractGeneratedNamePrefix(name string) string {
9899
// ^
99100
dashIndex = strings.LastIndex(name, "-")
100101
name = name[:dashIndex]
102+
101103
return name
102104
}
103105

@@ -141,6 +143,7 @@ func compareJSONBodies(expected, actual map[string]interface{}) bool {
141143
// We do not want to generate new cassettes for each new features
142144
continue
143145
}
146+
144147
if !compareJSONFields(expectedValue, actual[key]) {
145148
return false
146149
}
@@ -155,6 +158,7 @@ func compareJSONBodies(expected, actual map[string]interface{}) bool {
155158
return false
156159
}
157160
}
161+
158162
return true
159163
}
160164

internal/acctest/checks.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ func CheckResourceIDChanged(resourceName string, resourceID *string) resource.Te
1818
if resourceID == nil || *resourceID == "" {
1919
return errors.New("resourceID was not set")
2020
}
21+
2122
rs, ok := s.RootModule().Resources[resourceName]
2223
if !ok {
2324
return fmt.Errorf("resource was not found: %s", resourceName)
2425
}
26+
2527
if *resourceID == rs.Primary.ID {
2628
return errors.New("resource ID persisted when it should have changed")
2729
}
30+
2831
*resourceID = rs.Primary.ID
32+
2933
return nil
3034
}
3135
}
@@ -38,10 +42,13 @@ func CheckResourceIDPersisted(resourceName string, resourceID *string) resource.
3842
if !ok {
3943
return fmt.Errorf("resource was not found: %s", resourceName)
4044
}
45+
4146
if *resourceID != "" && *resourceID != rs.Primary.ID {
4247
return errors.New("resource ID changed when it should have persisted")
4348
}
49+
4450
*resourceID = rs.Primary.ID
51+
4552
return nil
4653
}
4754
}
@@ -82,14 +89,17 @@ func CheckResourceAttrFunc(name string, key string, test func(string) error) res
8289
if !ok {
8390
return fmt.Errorf("resource not found: %s", name)
8491
}
92+
8593
value, ok := rs.Primary.Attributes[key]
8694
if !ok {
8795
return fmt.Errorf("key not found: %s", key)
8896
}
97+
8998
err := test(value)
9099
if err != nil {
91100
return fmt.Errorf("test for %s %s did not pass test: %s", name, key, err)
92101
}
102+
93103
return nil
94104
}
95105
}
@@ -100,6 +110,7 @@ func CheckResourceAttrIPv4(name string, key string) resource.TestCheckFunc {
100110
if ip.To4() == nil {
101111
return fmt.Errorf("%s is not a valid IPv4", value)
102112
}
113+
103114
return nil
104115
})
105116
}
@@ -110,6 +121,7 @@ func CheckResourceAttrIPv6(name string, key string) resource.TestCheckFunc {
110121
if ip.To16() == nil {
111122
return fmt.Errorf("%s is not a valid IPv6", value)
112123
}
124+
113125
return nil
114126
})
115127
}
@@ -120,6 +132,7 @@ func CheckResourceAttrIP(name string, key string) resource.TestCheckFunc {
120132
if ip == nil {
121133
return fmt.Errorf("%s is not a valid IP", value)
122134
}
135+
123136
return nil
124137
})
125138
}

internal/acctest/domain.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,18 @@ func init() {
3333

3434
// check if the test domain is not a Scaleway reserved domain
3535
isReserved := false
36+
3637
for _, reservedDomain := range reservedDomains {
3738
if reservedDomain.MatchString(TestDomain) {
3839
isReserved = true
40+
3941
break
4042
}
4143
}
4244

4345
if isReserved {
4446
logging.L.Warningf("TF_TEST_DOMAIN cannot be a Scaleway required domain. Please use another one.")
47+
4548
return
4649
}
4750

internal/acctest/fixtures.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func CreateFakeIAMManager(tt *TestTools) (*account.Project, *iam.APIKey, FakeSid
6464
iamPolicyName := sdkacctest.RandomWithPrefix("test-acc-scaleway-iam-policy")
6565

6666
projectAPI := account.NewProjectAPI(tt.Meta.ScwClient())
67+
6768
project, err := projectAPI.CreateProject(&account.ProjectAPICreateProjectRequest{
6869
Name: projectName,
6970
})
@@ -74,13 +75,15 @@ func CreateFakeIAMManager(tt *TestTools) (*account.Project, *iam.APIKey, FakeSid
7475

7576
return nil, nil, nil, err
7677
}
78+
7779
terminateFunctions = append(terminateFunctions, func() error {
7880
return projectAPI.DeleteProject(&account.ProjectAPIDeleteProjectRequest{
7981
ProjectID: project.ID,
8082
})
8183
})
8284

8385
iamAPI := iam.NewAPI(tt.Meta.ScwClient())
86+
8487
iamApplication, err := iamAPI.CreateApplication(&iam.CreateApplicationRequest{
8588
Name: iamApplicationName,
8689
})
@@ -91,6 +94,7 @@ func CreateFakeIAMManager(tt *TestTools) (*account.Project, *iam.APIKey, FakeSid
9194

9295
return nil, nil, nil, err
9396
}
97+
9498
terminateFunctions = append(terminateFunctions, func() error {
9599
return iamAPI.DeleteApplication(&iam.DeleteApplicationRequest{
96100
ApplicationID: iamApplication.ID,
@@ -114,6 +118,7 @@ func CreateFakeIAMManager(tt *TestTools) (*account.Project, *iam.APIKey, FakeSid
114118

115119
return nil, nil, nil, err
116120
}
121+
117122
terminateFunctions = append(terminateFunctions, func() error {
118123
return iamAPI.DeletePolicy(&iam.DeletePolicyRequest{
119124
PolicyID: iamPolicy.ID,
@@ -131,6 +136,7 @@ func CreateFakeIAMManager(tt *TestTools) (*account.Project, *iam.APIKey, FakeSid
131136

132137
return nil, nil, nil, err
133138
}
139+
134140
terminateFunctions = append(terminateFunctions, func() error {
135141
return iamAPI.DeleteAPIKey(&iam.DeleteAPIKeyRequest{
136142
AccessKey: iamAPIKey.AccessKey,
@@ -163,6 +169,7 @@ func CreateFakeSideProject(tt *TestTools) (*account.Project, *iam.APIKey, FakeSi
163169
iamPolicyName := sdkacctest.RandomWithPrefix("test-acc-scaleway-iam-policy")
164170

165171
projectAPI := account.NewProjectAPI(tt.Meta.ScwClient())
172+
166173
project, err := projectAPI.CreateProject(&account.ProjectAPICreateProjectRequest{
167174
Name: projectName,
168175
})
@@ -173,13 +180,15 @@ func CreateFakeSideProject(tt *TestTools) (*account.Project, *iam.APIKey, FakeSi
173180

174181
return nil, nil, nil, err
175182
}
183+
176184
terminateFunctions = append(terminateFunctions, func() error {
177185
return projectAPI.DeleteProject(&account.ProjectAPIDeleteProjectRequest{
178186
ProjectID: project.ID,
179187
})
180188
})
181189

182190
iamAPI := iam.NewAPI(tt.Meta.ScwClient())
191+
183192
iamApplication, err := iamAPI.CreateApplication(&iam.CreateApplicationRequest{
184193
Name: iamApplicationName,
185194
})
@@ -190,6 +199,7 @@ func CreateFakeSideProject(tt *TestTools) (*account.Project, *iam.APIKey, FakeSi
190199

191200
return nil, nil, nil, err
192201
}
202+
193203
terminateFunctions = append(terminateFunctions, func() error {
194204
return iamAPI.DeleteApplication(&iam.DeleteApplicationRequest{
195205
ApplicationID: iamApplication.ID,
@@ -213,6 +223,7 @@ func CreateFakeSideProject(tt *TestTools) (*account.Project, *iam.APIKey, FakeSi
213223

214224
return nil, nil, nil, err
215225
}
226+
216227
terminateFunctions = append(terminateFunctions, func() error {
217228
return iamAPI.DeletePolicy(&iam.DeletePolicyRequest{
218229
PolicyID: iamPolicy.ID,
@@ -230,6 +241,7 @@ func CreateFakeSideProject(tt *TestTools) (*account.Project, *iam.APIKey, FakeSi
230241

231242
return nil, nil, nil, err
232243
}
244+
233245
terminateFunctions = append(terminateFunctions, func() error {
234246
return iamAPI.DeleteAPIKey(&iam.DeleteAPIKeyRequest{
235247
AccessKey: iamAPIKey.AccessKey,

internal/acctest/sweepers.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import (
1010

1111
func Sweep(f func(scwClient *scw.Client) error) error {
1212
ctx := context.Background()
13+
1314
m, err := meta.NewMeta(ctx, &meta.Config{
1415
TerraformVersion: "terraform-tests",
1516
})
1617
if err != nil {
1718
return err
1819
}
20+
1921
return f(m.ScwClient())
2022
}
2123

@@ -25,11 +27,13 @@ func SweepZones(zones []scw.Zone, f func(scwClient *scw.Client, zone scw.Zone) e
2527
if err != nil {
2628
return err
2729
}
30+
2831
err = f(client, zone)
2932
if err != nil {
3033
logging.L.Warningf("error running sweepZones, ignoring: %s", err)
3134
}
3235
}
36+
3337
return nil
3438
}
3539

@@ -41,6 +45,7 @@ func SweepRegions(regions []scw.Region, f func(scwClient *scw.Client, region scw
4145

4246
return SweepZones(zones, func(scwClient *scw.Client, zone scw.Zone) error {
4347
r, _ := zone.Region()
48+
4449
return f(scwClient, r)
4550
})
4651
}
@@ -49,12 +54,14 @@ func SweepRegions(regions []scw.Region, f func(scwClient *scw.Client, region scw
4954
// functions for a given zone
5055
func sharedClientForZone(zone scw.Zone) (*scw.Client, error) {
5156
ctx := context.Background()
57+
5258
m, err := meta.NewMeta(ctx, &meta.Config{
5359
TerraformVersion: "terraform-tests",
5460
ForceZone: zone,
5561
})
5662
if err != nil {
5763
return nil, err
5864
}
65+
5966
return m.ScwClient(), nil
6067
}

internal/acctest/validate_cassettes_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ func exceptionsCassettesCases() map[string]struct{} {
3434
func getTestFiles() (map[string]struct{}, error) {
3535
filesMap := make(map[string]struct{})
3636
exceptions := exceptionsCassettesCases()
37+
3738
err := filepath.WalkDir("../services", func(path string, _ fs.DirEntry, _ error) error {
3839
isCassette := strings.Contains(path, "cassette")
3940
_, isException := exceptions[path]
41+
4042
if isCassette && !isException {
4143
filesMap[fileNameWithoutExtSuffix(path)] = struct{}{}
4244
}
45+
4346
return nil
4447
})
4548
if err != nil {
@@ -73,6 +76,7 @@ func checkErrorCode(c *cassette.Cassette) error {
7376

7477
func checkErrCodeExcept(i *cassette.Interaction, c *cassette.Cassette, codes ...int) bool {
7578
exceptions := exceptionsCassettesCases()
79+
7680
_, isException := exceptions[c.File]
7781
if isException {
7882
return isException
@@ -81,14 +85,17 @@ func checkErrCodeExcept(i *cassette.Interaction, c *cassette.Cassette, codes ...
8185
if strings.Contains(i.Response.Body, mnq.AWSErrNonExistentQueue) && i.Response.Code == 400 {
8286
return true
8387
}
88+
8489
if i.Response.Code >= 400 {
8590
for _, httpCode := range codes {
8691
if i.Response.Code == httpCode {
8792
return true
8893
}
8994
}
95+
9096
return false
9197
}
98+
9299
return true
93100
}
94101

0 commit comments

Comments
 (0)