Skip to content

Commit 3c28869

Browse files
authored
chore: add support for staticcheck (#2717)
* chore: add support for staticcheck * Fix ValidateDiagFunc * Fix retry * ignore some alerts * ignore deprecated errors * chore: add documentation and deprecation messages * chore: add deprecation warnings for PublicIP and PublicIPv6 * chore: add deprecation warnings for last_errors * Add deprecation warnings for instance * chore: add checks on send_proxy_v2 * chore: add deprecation warnings for certificate_id * chore: add deprecation warnings * Fix
1 parent 591cf5b commit 3c28869

File tree

133 files changed

+856
-766
lines changed

Some content is hidden

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

133 files changed

+856
-766
lines changed

.golangci.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ linters:
77
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers [fast: true, auto-fix: false]
88
- bidichk # Checks for dangerous unicode character sequences [fast: true, auto-fix: false]
99
- bodyclose # checks whether HTTP response body is closed successfully [fast: false, auto-fix: false]
10+
- canonicalheader # canonicalheader checks whether net/http.Header uses canonical header [fast: false, auto-fix: false]
1011
- containedctx # containedctx is a linter that detects struct contained context.Context field [fast: true, auto-fix: false]
1112
- contextcheck # check the function whether use a non-inherited context [fast: false, auto-fix: false]
1213
- copyloopvar # copyloopvar is a linter detects places where loop variables are copied [fast: true, auto-fix: false]
@@ -54,10 +55,12 @@ linters:
5455
- predeclared # find code that shadows one of Go's predeclared identifiers [fast: true, auto-fix: false]
5556
- promlinter # Check Prometheus metrics naming via promlint [fast: true, auto-fix: false]
5657
- protogetter # Reports direct reads from proto message fields when getters should be used [fast: false, auto-fix: true]
58+
- reassign # Checks that package variables are not reassigned [fast: false, auto-fix: false]
5759
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false]
5860
- rowserrcheck # checks whether Err of rows is checked successfully [fast: false, auto-fix: false]
5961
- sloglint # ensure consistent code style when using log/slog [fast: false, auto-fix: false]
6062
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. [fast: false, auto-fix: false]
63+
- staticcheck #(megacheck): Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false]
6164
- stylecheck # Stylecheck is a replacement for golint [fast: false, auto-fix: false]
6265
- tagliatelle # Checks the struct tags. [fast: true, auto-fix: false]
6366
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 [fast: false, auto-fix: false]
@@ -94,7 +97,6 @@ linters:
9497
- nestif # Reports deeply nested if statements [fast: true, auto-fix: false]
9598
- nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value. [fast: false, auto-fix: false]
9699
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity [fast: true, auto-fix: false]
97-
- staticcheck #(megacheck): Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false]
98100
- varnamelen # checks that the length of a variable's name matches its scope [fast: false, auto-fix: false]
99101
- wsl # Whitespace Linter - Forces you to use empty lines! [fast: true, auto-fix: false]
100102

docs/resources/instance_server.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ attached to the server. Updates to this field will trigger a stop/start of the s
211211
~> **Important:** If this field contains local volumes, you have to first detach them, in one apply, and then delete the volume in another apply.
212212

213213
- `enable_ipv6` - (Defaults to `false`) Determines if IPv6 is enabled for the server. Useful only with `routed_ip_enabled` as false, otherwise ipv6 is always supported.
214+
Deprecated: Please use a scaleway_instance_ip with a `routed_ipv6` type.
214215

215216
- `ip_id` - (Optional) The ID of the reserved IP that is attached to the server.
216217

@@ -273,13 +274,16 @@ In addition to all arguments above, the following attributes are exported:
273274
- `root_volume`
274275
- `volume_id` - The volume ID of the root volume of the server.
275276
- `private_ip` - The Scaleway internal IP address of the server.
276-
- `public_ip` - The public IP address of the server.
277+
- `public_ip` - The public IP address of the server (Deprecated use `public_ips` instead).
277278
- `public_ips` - The list of public IPs of the server.
278279
- `id` - The ID of the IP
279280
- `address` - The address of the IP
280281
- `ipv6_address` - The default ipv6 address routed to the server. ( Only set when enable_ipv6 is set to true )
282+
Deprecated: Please use a scaleway_instance_ip with a `routed_ipv6` type.
281283
- `ipv6_gateway` - The ipv6 gateway address. ( Only set when enable_ipv6 is set to true )
284+
Deprecated: Please use a scaleway_instance_ip with a `routed_ipv6` type.
282285
- `ipv6_prefix_length` - The prefix length of the ipv6 subnet routed to the server. ( Only set when enable_ipv6 is set to true )
286+
Deprecated: Please use a scaleway_instance_ip with a `routed_ipv6` type.
283287
- `boot_type` - The boot Type of the server. Possible values are: `local`, `bootscript` or `rescue`.
284288
- `organization_id` - The organization ID the server is associated with.
285289

docs/resources/k8s_pool.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ In addition to all arguments above, the following attributes are exported:
9999
- `status` - The status of the pool.
100100
- `nodes` - (List of) The nodes in the default pool.
101101
- `name` - The name of the node.
102-
- `public_ip` - The public IPv4.
103-
- `public_ip_v6` - The public IPv6.
102+
- `public_ip` - The public IPv4. (Deprecated, Please use the official Kubernetes provider and the kubernetes_nodes data source)
103+
- `public_ip_v6` - The public IPv6. (Deprecated, Please use the official Kubernetes provider and the kubernetes_nodes data source)
104104
- `status` - The status of the node.
105105
- `created_at` - The creation date of the pool.
106106
- `updated_at` - The last update date of the pool.

docs/resources/lb.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ resource "scaleway_lb" "main" {
244244

245245
- `ipam_ids` - (Optional) IPAM ID of a pre-reserved IP address to assign to the Load Balancer on this Private Network.
246246

247-
- `dhcp_config` - (Optional) Set to `true` if you want to let DHCP assign IP addresses. See below.
247+
- `dhcp_config` - (Deprecated) Please use `ipam_ids`. Set to `true` if you want to let DHCP assign IP addresses. See below.
248248

249249
- `static_config` - (Deprecated) Please use `ipam_ids`. Define a local ip address of your choice for the load balancer instance.
250250

docs/resources/lb_frontend.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ In addition to all arguments above, the following attributes are exported:
215215

216216
~> **Important:** Load Balancer frontend 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`
217217

218-
- `certificate_id` - (Deprecated) First certificate ID used by the frontend.
218+
- `certificate_id` - (Deprecated, use `certificate_ids` instead) First certificate ID used by the frontend.
219219

220220

221221
## Import

docs/resources/rdb_instance.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ In addition to all arguments above, the following attributes are exported:
218218
~> **Important** Database Instances' IDs are [regional](../guides/regions_and_zones.md#resource-ids), which means they
219219
are of the form `{region}/{id}`, e.g. `fr-par/11111111-1111-1111-1111-111111111111`
220220

221-
- `endpoint_ip` - (Deprecated) The IP of the Database Instance.
222-
- `endpoint_port` - (Deprecated) The port of the Database Instance.
221+
- `endpoint_ip` - (Deprecated) The IP of the Database Instance. Please use the private_network or the load_balancer attribute.
222+
- `endpoint_port` - (Deprecated) The port of the Database Instance. Please use the private_network or the load_balancer attribute.
223223
- `read_replicas` - List of read replicas of the Database Instance.
224224
- `ip` - IP of the replica.
225225
- `port` - Port of the replica.

docs/resources/tem_domain.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ In addition to all arguments above, the following attributes are exported:
119119

120120
- `revoked_at` - The date and time of the revocation of the domain (RFC 3339 format).
121121

122-
- `last_error` - The error message if the last check failed.
122+
- `last_error` - (Deprecated) The error message if the last check failed.
123123

124124
- `spf_config` - The snippet of the SPF record that should be registered in the DNS zone.
125125

internal/provider/provider.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,27 @@ func Provider(config *Config) plugin.ProviderFunc {
8585
Description: "The Scaleway access key.",
8686
},
8787
"secret_key": {
88-
Type: schema.TypeString,
89-
Optional: true, // To allow user to use deprecated `token`.
90-
Description: "The Scaleway secret Key.",
91-
ValidateFunc: verify.IsUUID(),
88+
Type: schema.TypeString,
89+
Optional: true, // To allow user to use deprecated `token`.
90+
Description: "The Scaleway secret Key.",
91+
ValidateDiagFunc: verify.IsUUID(),
9292
},
9393
"profile": {
9494
Type: schema.TypeString,
9595
Optional: true, // To allow user to use `access_key`, `secret_key`, `project_id`...
9696
Description: "The Scaleway profile to use.",
9797
},
9898
"project_id": {
99-
Type: schema.TypeString,
100-
Optional: true, // To allow user to use organization instead of project
101-
Description: "The Scaleway project ID.",
102-
ValidateFunc: verify.IsUUID(),
99+
Type: schema.TypeString,
100+
Optional: true, // To allow user to use organization instead of project
101+
Description: "The Scaleway project ID.",
102+
ValidateDiagFunc: verify.IsUUID(),
103103
},
104104
"organization_id": {
105-
Type: schema.TypeString,
106-
Optional: true,
107-
Description: "The Scaleway organization ID.",
108-
ValidateFunc: verify.IsUUID(),
105+
Type: schema.TypeString,
106+
Optional: true,
107+
Description: "The Scaleway organization ID.",
108+
ValidateDiagFunc: verify.IsUUID(),
109109
},
110110
"region": regional.Schema(),
111111
"zone": zonal.Schema(),

internal/services/account/project.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ func ResourceProject() *schema.Resource {
4545
Description: "The date and time of the last update of the Project (Format ISO 8601)",
4646
},
4747
"organization_id": {
48-
Type: schema.TypeString,
49-
Description: "The organization_id you want to attach the resource to",
50-
Optional: true,
51-
ForceNew: true,
52-
Computed: true,
53-
ValidateFunc: verify.IsUUID(),
48+
Type: schema.TypeString,
49+
Description: "The organization_id you want to attach the resource to",
50+
Optional: true,
51+
ForceNew: true,
52+
Computed: true,
53+
ValidateDiagFunc: verify.IsUUID(),
5454
},
5555
},
5656
}

internal/services/account/project_data_source.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ func DataSourceProject() *schema.Resource {
1919

2020
dsSchema["name"].ConflictsWith = []string{"project_id"}
2121
dsSchema["project_id"] = &schema.Schema{
22-
Type: schema.TypeString,
23-
Computed: true,
24-
Optional: true,
25-
Description: "The ID of the SSH key",
26-
ValidateFunc: verify.IsUUID(),
22+
Type: schema.TypeString,
23+
Computed: true,
24+
Optional: true,
25+
Description: "The ID of the SSH key",
26+
ValidateDiagFunc: verify.IsUUID(),
2727
}
2828

2929
return &schema.Resource{

internal/services/account/schemas.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ func OrganizationIDOptionalSchema() *schema.Schema {
2626
// ProjectIDSchema returns a standard schema for a project_id
2727
func ProjectIDSchema() *schema.Schema {
2828
return &schema.Schema{
29-
Type: schema.TypeString,
30-
Description: "The project_id you want to attach the resource to",
31-
Optional: true,
32-
ForceNew: true,
33-
Computed: true,
34-
ValidateFunc: verify.IsUUID(),
29+
Type: schema.TypeString,
30+
Description: "The project_id you want to attach the resource to",
31+
Optional: true,
32+
ForceNew: true,
33+
Computed: true,
34+
ValidateDiagFunc: verify.IsUUID(),
3535
}
3636
}

internal/services/baremetal/option_data_source.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ func DataSourceOption() *schema.Resource {
2424
ConflictsWith: []string{"option_id"},
2525
},
2626
"option_id": {
27-
Type: schema.TypeString,
28-
Optional: true,
29-
Description: "The ID of the option",
30-
ValidateFunc: verify.IsUUIDorUUIDWithLocality(),
31-
ConflictsWith: []string{"name"},
27+
Type: schema.TypeString,
28+
Optional: true,
29+
Description: "The ID of the option",
30+
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
31+
ConflictsWith: []string{"name"},
3232
},
3333
"manageable": {
3434
Type: schema.TypeBool,

internal/services/baremetal/os_data_source.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ func DataSourceOS() *schema.Resource {
3030
ConflictsWith: []string{"os_id"},
3131
},
3232
"os_id": {
33-
Type: schema.TypeString,
34-
Optional: true,
35-
Description: "The ID of the os",
36-
ValidateFunc: verify.IsUUIDorUUIDWithLocality(),
37-
ConflictsWith: []string{"name"},
33+
Type: schema.TypeString,
34+
Optional: true,
35+
Description: "The ID of the os",
36+
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
37+
ConflictsWith: []string{"name"},
3838
},
3939
"zone": zonal.Schema(),
4040
},

internal/services/baremetal/server.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func ResourceServer() *schema.Resource {
8181
Optional: true,
8282
Description: "The base image of the server",
8383
DiffSuppressFunc: dsf.Locality,
84-
ValidateFunc: verify.IsUUIDorUUIDWithLocality(),
84+
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
8585
},
8686
"os_name": {
8787
Type: schema.TypeString,
@@ -91,8 +91,8 @@ func ResourceServer() *schema.Resource {
9191
"ssh_key_ids": {
9292
Type: schema.TypeList,
9393
Elem: &schema.Schema{
94-
Type: schema.TypeString,
95-
ValidateFunc: verify.IsUUID(),
94+
Type: schema.TypeString,
95+
ValidateDiagFunc: verify.IsUUID(),
9696
},
9797
Optional: true,
9898
Description: `Array of SSH key IDs allowed to SSH to the server
@@ -212,10 +212,10 @@ If this behaviour is wanted, please set 'reinstall_on_ssh_key_changes' argument
212212
Elem: &schema.Resource{
213213
Schema: map[string]*schema.Schema{
214214
"id": {
215-
Type: schema.TypeString,
216-
Description: "The private network ID",
217-
Required: true,
218-
ValidateFunc: verify.IsUUIDorUUIDWithLocality(),
215+
Type: schema.TypeString,
216+
Description: "The private network ID",
217+
Required: true,
218+
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
219219
StateFunc: func(i interface{}) string {
220220
return locality.ExpandID(i.(string))
221221
},

internal/services/baremetal/server_data_source.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ func DataSourceServer() *schema.Resource {
2121

2222
dsSchema["name"].ConflictsWith = []string{"server_id"}
2323
dsSchema["server_id"] = &schema.Schema{
24-
Type: schema.TypeString,
25-
Optional: true,
26-
Description: "The ID of the server",
27-
ValidateFunc: verify.IsUUIDorUUIDWithLocality(),
28-
ConflictsWith: []string{"name"},
24+
Type: schema.TypeString,
25+
Optional: true,
26+
Description: "The ID of the server",
27+
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
28+
ConflictsWith: []string{"name"},
2929
}
3030

3131
return &schema.Resource{

internal/services/block/snapshot.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func ResourceSnapshot() *schema.Resource {
4242
"volume_id": {
4343
Type: schema.TypeString,
4444
Required: true,
45-
ValidateFunc: verify.IsUUIDorUUIDWithLocality(),
45+
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
4646
Description: "ID of the volume from which creates a snapshot",
4747
DiffSuppressFunc: dsf.Locality,
4848
},

internal/services/block/snapshot_data_source.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ func DataSourceSnapshot() *schema.Resource {
1818
datasource.AddOptionalFieldsToSchema(dsSchema, "name", "zone", "volume_id", "project_id")
1919

2020
dsSchema["snapshot_id"] = &schema.Schema{
21-
Type: schema.TypeString,
22-
Optional: true,
23-
Description: "The ID of the snapshot",
24-
ConflictsWith: []string{"name"},
25-
ValidateFunc: verify.IsUUIDorUUIDWithLocality(),
21+
Type: schema.TypeString,
22+
Optional: true,
23+
Description: "The ID of the snapshot",
24+
ConflictsWith: []string{"name"},
25+
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
2626
}
2727

2828
return &schema.Resource{

internal/services/block/volume_data_source.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ func DataSourceVolume() *schema.Resource {
1818
datasource.AddOptionalFieldsToSchema(dsSchema, "name", "zone", "project_id")
1919

2020
dsSchema["volume_id"] = &schema.Schema{
21-
Type: schema.TypeString,
22-
Optional: true,
23-
Description: "The ID of the volume",
24-
ConflictsWith: []string{"name"},
25-
ValidateFunc: verify.IsUUIDorUUIDWithLocality(),
21+
Type: schema.TypeString,
22+
Optional: true,
23+
Description: "The ID of the volume",
24+
ConflictsWith: []string{"name"},
25+
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
2626
}
2727

2828
return &schema.Resource{

internal/services/cockpit/alert_manager.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ func ResourceCockpitAlertManager() *schema.Resource {
3939
Elem: &schema.Resource{
4040
Schema: map[string]*schema.Schema{
4141
"email": {
42-
Type: schema.TypeString,
43-
Optional: true,
44-
ValidateFunc: verify.IsEmail(),
45-
Description: "Email addresses for the alert receivers",
42+
Type: schema.TypeString,
43+
Optional: true,
44+
ValidateDiagFunc: verify.IsEmail(),
45+
Description: "Email addresses for the alert receivers",
4646
},
4747
},
4848
},

internal/services/cockpit/cockpit_data_source.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ func DataSourceCockpit() *schema.Resource {
1717
dsSchema := datasource.SchemaFromResourceSchema(ResourceCockpit().Schema)
1818

1919
dsSchema["project_id"] = &schema.Schema{
20-
Type: schema.TypeString,
21-
Description: "The project_id you want to attach the resource to",
22-
Optional: true,
23-
ValidateFunc: verify.IsUUID(),
20+
Type: schema.TypeString,
21+
Description: "The project_id you want to attach the resource to",
22+
Optional: true,
23+
ValidateDiagFunc: verify.IsUUID(),
2424
}
2525
dsSchema["plan"] = &schema.Schema{
2626
Type: schema.TypeString,

internal/services/container/container_data_source.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@ func DataSourceContainer() *schema.Resource {
2121

2222
dsSchema["name"].ConflictsWith = []string{"container_id"}
2323
dsSchema["container_id"] = &schema.Schema{
24-
Type: schema.TypeString,
25-
Optional: true,
26-
Description: "The ID of the Container",
27-
ValidateFunc: verify.IsUUIDorUUIDWithLocality(),
28-
ConflictsWith: []string{"name"},
24+
Type: schema.TypeString,
25+
Optional: true,
26+
Description: "The ID of the Container",
27+
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
28+
ConflictsWith: []string{"name"},
2929
}
3030
dsSchema["namespace_id"] = &schema.Schema{
31-
Type: schema.TypeString,
32-
Required: true,
33-
Description: "The ID of the Container namespace",
34-
ValidateFunc: verify.IsUUIDorUUIDWithLocality(),
31+
Type: schema.TypeString,
32+
Required: true,
33+
Description: "The ID of the Container namespace",
34+
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
3535
}
3636
dsSchema["project_id"] = &schema.Schema{
37-
Type: schema.TypeString,
38-
Optional: true,
39-
Description: "The ID of the project to filter the Container",
40-
ValidateFunc: verify.IsUUID(),
37+
Type: schema.TypeString,
38+
Optional: true,
39+
Description: "The ID of the project to filter the Container",
40+
ValidateDiagFunc: verify.IsUUID(),
4141
}
4242

4343
return &schema.Resource{

0 commit comments

Comments
 (0)