Skip to content

Commit 0fa31d2

Browse files
authored
refactor: fix golangci-lint v1.52 checks (#1851)
* refactor: fix golangci-lint v1.52 checks * refactor: really fix the issues
1 parent 457d8b6 commit 0fa31d2

12 files changed

+25
-19
lines changed

scaleway/data_source_instance_servers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ func dataSourceScalewayInstanceServersRead(ctx context.Context, d *schema.Resour
181181
if err != nil {
182182
diags = append(diags, diag.FromErr(fmt.Errorf("failed to read ipv6 netmask: %w", err))...)
183183
continue
184-
} else {
185-
rawServer["ipv6_prefix_length"] = prefixLength
186184
}
185+
186+
rawServer["ipv6_prefix_length"] = prefixLength
187187
}
188188

189189
servers = append(servers, rawServer)

scaleway/helpers.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ func flattenMapStringStringPtr(m map[string]*string) interface{} {
684684
return flattenedMap
685685
}
686686

687-
func diffSuppressFuncDuration(k, oldValue, newValue string, d *schema.ResourceData) bool {
687+
func diffSuppressFuncDuration(_, oldValue, newValue string, _ *schema.ResourceData) bool {
688688
if oldValue == newValue {
689689
return true
690690
}
@@ -696,7 +696,7 @@ func diffSuppressFuncDuration(k, oldValue, newValue string, d *schema.ResourceDa
696696
return d1 == d2
697697
}
698698

699-
func diffSuppressFuncTimeRFC3339(k, oldValue, newValue string, d *schema.ResourceData) bool {
699+
func diffSuppressFuncTimeRFC3339(_, oldValue, newValue string, _ *schema.ResourceData) bool {
700700
if oldValue == newValue {
701701
return true
702702
}
@@ -708,17 +708,17 @@ func diffSuppressFuncTimeRFC3339(k, oldValue, newValue string, d *schema.Resourc
708708
return t1.Equal(t2)
709709
}
710710

711-
func diffSuppressFuncIgnoreCase(k, oldValue, newValue string, d *schema.ResourceData) bool {
711+
func diffSuppressFuncIgnoreCase(_, oldValue, newValue string, _ *schema.ResourceData) bool {
712712
return strings.EqualFold(oldValue, newValue)
713713
}
714714

715-
func diffSuppressFuncIgnoreCaseAndHyphen(k, oldValue, newValue string, d *schema.ResourceData) bool {
715+
func diffSuppressFuncIgnoreCaseAndHyphen(_, oldValue, newValue string, _ *schema.ResourceData) bool {
716716
return strings.ReplaceAll(strings.ToLower(oldValue), "-", "_") == strings.ReplaceAll(strings.ToLower(newValue), "-", "_")
717717
}
718718

719719
// diffSuppressFuncLocality is a SuppressDiffFunc to remove the locality from an ID when checking diff.
720720
// e.g. 2c1a1716-5570-4668-a50a-860c90beabf6 == fr-par-1/2c1a1716-5570-4668-a50a-860c90beabf6
721-
func diffSuppressFuncLocality(k, oldValue, newValue string, d *schema.ResourceData) bool {
721+
func diffSuppressFuncLocality(_, oldValue, newValue string, _ *schema.ResourceData) bool {
722722
return expandID(oldValue) == expandID(newValue)
723723
}
724724

scaleway/helpers_instance.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func validateLocalVolumeSizes(volumes map[string]*instance.VolumeServerTemplate,
244244
// On the api side, there are two possibles validation schemas for volumes and the validator will be chosen dynamically depending on the passed JSON request
245245
// - With an image (in that case the root volume can be skipped because it is taken from the image)
246246
// - Without an image (in that case, the root volume must be defined)
247-
func sanitizeVolumeMap(serverName string, volumes map[string]*instance.VolumeServerTemplate) map[string]*instance.VolumeServerTemplate {
247+
func sanitizeVolumeMap(volumes map[string]*instance.VolumeServerTemplate) map[string]*instance.VolumeServerTemplate {
248248
m := make(map[string]*instance.VolumeServerTemplate)
249249

250250
for index, v := range volumes {
@@ -315,7 +315,7 @@ type privateNICsHandler struct {
315315
zone scw.Zone
316316
}
317317

318-
func newPrivateNICHandler(ctx context.Context, api *instance.API, server string, zone scw.Zone) (*privateNICsHandler, error) {
318+
func newPrivateNICHandler(api *instance.API, server string, zone scw.Zone) (*privateNICsHandler, error) {
319319
handler := &privateNICsHandler{
320320
instanceAPI: api,
321321
serverID: server,

scaleway/helpers_lb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ func lbUpgradeV1SchemaType() cty.Type {
391391
}
392392

393393
// lbUpgradeV1UpgradeFunc allow upgrade the from regional to a zoned resource.
394-
func lbUpgradeV1SchemaUpgradeFunc(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
394+
func lbUpgradeV1SchemaUpgradeFunc(_ context.Context, rawState map[string]interface{}, _ interface{}) (map[string]interface{}, error) {
395395
var err error
396396
// element id: upgrade
397397
ID, exist := rawState["id"]

scaleway/helpers_object.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ func TransitionSCWStorageClassValues() []string {
496496
}
497497
}
498498

499-
func SuppressEquivalentPolicyDiffs(k, old, newP string, d *schema.ResourceData) bool {
499+
func SuppressEquivalentPolicyDiffs(k, old, newP string, _ *schema.ResourceData) bool {
500500
tflog.Debug(context.Background(),
501501
fmt.Sprintf("[DEBUG] suppress policy on key: %s, old: %s new: %s", k, old, newP))
502502
if strings.TrimSpace(old) == "" && strings.TrimSpace(newP) == "" {

scaleway/helpers_rdb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ func flattenReadReplicaEndpoints(endpoints []*rdb.Endpoint) (directAccess, priva
327327
}
328328

329329
// rdbPrivilegeV1SchemaUpgradeFunc allow upgrade the privilege ID on schema V1
330-
func rdbPrivilegeV1SchemaUpgradeFunc(ctx context.Context, rawState map[string]interface{}, m interface{}) (map[string]interface{}, error) {
330+
func rdbPrivilegeV1SchemaUpgradeFunc(_ context.Context, rawState map[string]interface{}, m interface{}) (map[string]interface{}, error) {
331331
idRaw, exist := rawState["id"]
332332
if !exist {
333333
return nil, fmt.Errorf("upgrade: id not exist")

scaleway/helpers_registry.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package scaleway
22

33
import (
44
"context"
5+
"fmt"
56
"time"
67

78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -72,6 +73,7 @@ func waitForRegistryNamespaceDelete(ctx context.Context, api *registry.API, regi
7273
registry.NamespaceStatusDeleting: {},
7374
}
7475

76+
start := time.Now()
7577
for {
7678
ns, err := api.GetNamespace(&registry.GetNamespaceRequest{
7779
Region: region,
@@ -85,6 +87,10 @@ func waitForRegistryNamespaceDelete(ctx context.Context, api *registry.API, regi
8587
return ns, nil
8688
}
8789

90+
if time.Since(start) > timeout {
91+
return nil, fmt.Errorf("timeout while waiting for namespace %s to be deleted", id)
92+
}
93+
8894
select {
8995
case <-ctx.Done():
9096
return nil, ctx.Err()

scaleway/logger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ func (l logger) Printf(format string, args ...interface{}) {
4141
}
4242

4343
// ShouldLog allow the SDK to log only in DEBUG or TRACE levels.
44-
func (l logger) ShouldLog(level sdkLogger.LogLevel) bool {
44+
func (l logger) ShouldLog(_ sdkLogger.LogLevel) bool {
4545
return logging.IsDebugOrHigher()
4646
}

scaleway/resource_instance_server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ func resourceScalewayInstanceServerCreate(ctx context.Context, d *schema.Resourc
410410
}
411411

412412
// Sanitize the volume map to respect API schemas
413-
req.Volumes = sanitizeVolumeMap(req.Name, req.Volumes)
413+
req.Volumes = sanitizeVolumeMap(req.Volumes)
414414

415415
res, err := instanceAPI.CreateServer(req, scw.WithContext(ctx))
416416
if err != nil {
@@ -646,7 +646,7 @@ func resourceScalewayInstanceServerRead(ctx context.Context, d *schema.ResourceD
646646
////
647647
// Read server private networks
648648
////
649-
ph, err := newPrivateNICHandler(ctx, instanceAPI, id, zone)
649+
ph, err := newPrivateNICHandler(instanceAPI, id, zone)
650650
if err != nil {
651651
return diag.FromErr(err)
652652
}
@@ -870,7 +870,7 @@ func resourceScalewayInstanceServerUpdate(ctx context.Context, d *schema.Resourc
870870
// Update server private network
871871
////
872872
if d.HasChanges("private_network") {
873-
ph, err := newPrivateNICHandler(ctx, instanceAPI, id, zone)
873+
ph, err := newPrivateNICHandler(instanceAPI, id, zone)
874874
if err != nil {
875875
diag.FromErr(err)
876876
}

scaleway/resource_instance_server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ func testAccCheckScalewayInstanceServerDestroy(tt *TestTools) resource.TestCheck
983983

984984
// testAccCheckScalewayInstanceServerHasNewVolume tests if volume name is generated by terraform
985985
// It is useful as volume should not be set in request when creating an instance from an image
986-
func testAccCheckScalewayInstanceServerHasNewVolume(tt *TestTools, n string) resource.TestCheckFunc {
986+
func testAccCheckScalewayInstanceServerHasNewVolume(_ *TestTools, n string) resource.TestCheckFunc {
987987
return func(s *terraform.State) error {
988988
rs, ok := s.RootModule().Resources[n]
989989
if !ok {

0 commit comments

Comments
 (0)