Skip to content

Commit

Permalink
Upgrade golangci-lint to v1.60.3 and fix linter issues
Browse files Browse the repository at this point in the history
Signed-off-by: Ferran Rodenas <ferran.rodenas@broadcom.com>
  • Loading branch information
frodenas committed Sep 10, 2024
1 parent 970bf3c commit 0750141
Show file tree
Hide file tree
Showing 22 changed files with 104 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.2
version: v1.60.3
args: --issues-exit-code=1
only-new-issues: true
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ linters:
enable:
- durationcheck
- errcheck
- exportloopref
- gofmt
- goimports
- gosimple
Expand Down
9 changes: 5 additions & 4 deletions vra/data_source_region_enumeration.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package vra

import (
"context"
"errors"
"fmt"
"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/vmware/vra-sdk-go/pkg/client"
"github.com/vmware/vra-sdk-go/pkg/client/cloud_account"
Expand Down Expand Up @@ -77,7 +78,7 @@ func dataSourceRegionEnumerationRead(ctx context.Context, d *schema.ResourceData
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: dataSourceRegionEnumerationReadRefreshFunc(*apiClient, *enumResp.Payload.ID),
Expand Down Expand Up @@ -106,7 +107,7 @@ func dataSourceRegionEnumerationRead(ctx context.Context, d *schema.ResourceData
return nil
}

func dataSourceRegionEnumerationReadRefreshFunc(apiClient client.API, id string) resource.StateRefreshFunc {
func dataSourceRegionEnumerationReadRefreshFunc(apiClient client.API, id string) retry.StateRefreshFunc {
return func() (interface{}, string, error) {
reqResp, err := apiClient.Request.GetRequestTracker(request.NewGetRequestTrackerParams().WithID(id))
if err != nil {
Expand All @@ -116,7 +117,7 @@ func dataSourceRegionEnumerationReadRefreshFunc(apiClient client.API, id string)
status := reqResp.Payload.Status
switch *status {
case models.RequestTrackerStatusFAILED:
return []string{""}, *status, fmt.Errorf(reqResp.Payload.Message)
return []string{""}, *status, errors.New(reqResp.Payload.Message)
case models.RequestTrackerStatusINPROGRESS:
return [...]string{id}, *status, nil
case models.RequestTrackerStatusFINISHED:
Expand Down
4 changes: 2 additions & 2 deletions vra/data_source_region_enumeration_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/vmware/vra-sdk-go/pkg/client/cloud_account"
"github.com/vmware/vra-sdk-go/pkg/models"
Expand Down Expand Up @@ -53,7 +53,7 @@ func dataSourceRegionEnumerationAWSRead(ctx context.Context, d *schema.ResourceD
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: dataSourceRegionEnumerationReadRefreshFunc(*apiClient, *enumResp.Payload.ID),
Expand Down
4 changes: 2 additions & 2 deletions vra/data_source_region_enumeration_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/vmware/vra-sdk-go/pkg/client/cloud_account"
"github.com/vmware/vra-sdk-go/pkg/models"
Expand Down Expand Up @@ -65,7 +65,7 @@ func dataSourceRegionEnumerationAzureRead(ctx context.Context, d *schema.Resourc
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: dataSourceRegionEnumerationReadRefreshFunc(*apiClient, *enumResp.Payload.ID),
Expand Down
4 changes: 2 additions & 2 deletions vra/data_source_region_enumeration_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/vmware/vra-sdk-go/pkg/client/cloud_account"
"github.com/vmware/vra-sdk-go/pkg/models"
Expand Down Expand Up @@ -65,7 +65,7 @@ func dataSourceRegionEnumerationGCPRead(ctx context.Context, d *schema.ResourceD
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: dataSourceRegionEnumerationReadRefreshFunc(*apiClient, *enumResp.Payload.ID),
Expand Down
4 changes: 2 additions & 2 deletions vra/data_source_region_enumeration_vmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/vmware/vra-sdk-go/pkg/client/cloud_account"
"github.com/vmware/vra-sdk-go/pkg/models"
Expand Down Expand Up @@ -90,7 +90,7 @@ func dataSourceRegionEnumerationVMCRead(ctx context.Context, d *schema.ResourceD
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: dataSourceRegionEnumerationReadRefreshFunc(*apiClient, *enumResp.Payload.ID),
Expand Down
4 changes: 2 additions & 2 deletions vra/data_source_region_enumeration_vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/vmware/vra-sdk-go/pkg/models"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -73,7 +73,7 @@ func dataSourceRegionEnumerationVsphereRead(ctx context.Context, d *schema.Resou
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: dataSourceRegionEnumerationReadRefreshFunc(*apiClient, *enumResp.Payload.ID),
Expand Down
13 changes: 7 additions & 6 deletions vra/resource_block_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package vra

import (
"context"
"errors"
"fmt"
"log"
"strings"
Expand All @@ -13,7 +14,7 @@ import (
"github.com/vmware/vra-sdk-go/pkg/models"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -202,7 +203,7 @@ func resourceBlockDeviceCreate(ctx context.Context, d *schema.ResourceData, m in
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: blockDeviceStateRefreshFunc(*apiClient, *createBlockDeviceCreated.Payload.ID),
Expand All @@ -225,7 +226,7 @@ func resourceBlockDeviceCreate(ctx context.Context, d *schema.ResourceData, m in
return resourceBlockDeviceRead(ctx, d, m)
}

func blockDeviceStateRefreshFunc(apiClient client.API, id string) resource.StateRefreshFunc {
func blockDeviceStateRefreshFunc(apiClient client.API, id string) retry.StateRefreshFunc {
return func() (interface{}, string, error) {
ret, err := apiClient.Request.GetRequestTracker(request.NewGetRequestTrackerParams().WithID(id))
if err != nil {
Expand All @@ -235,7 +236,7 @@ func blockDeviceStateRefreshFunc(apiClient client.API, id string) resource.State
status := ret.Payload.Status
switch *status {
case models.RequestTrackerStatusFAILED:
return []string{""}, *status, fmt.Errorf(ret.Payload.Message)
return []string{""}, *status, errors.New(ret.Payload.Message)
case models.RequestTrackerStatusINPROGRESS:
return [...]string{id}, *status, nil
case models.RequestTrackerStatusFINISHED:
Expand Down Expand Up @@ -337,7 +338,7 @@ func resizeDisk(ctx context.Context, d *schema.ResourceData, apiClient *client.A
return nil
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: blockDeviceStateRefreshFunc(*apiClient, *resizeBlockDeviceAccepted.Payload.ID),
Expand Down Expand Up @@ -386,7 +387,7 @@ func resourceBlockDeviceDelete(ctx context.Context, d *schema.ResourceData, m in
return nil
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: blockDeviceStateRefreshFunc(*apiClient, *deleteBlockDeviceAccepted.Payload.ID),
Expand Down
11 changes: 6 additions & 5 deletions vra/resource_block_device_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package vra

import (
"context"
"errors"
"fmt"
"log"
"time"
Expand All @@ -12,7 +13,7 @@ import (
"github.com/vmware/vra-sdk-go/pkg/models"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -87,7 +88,7 @@ func resourceBlockDeviceSnapshotCreate(ctx context.Context, d *schema.ResourceDa
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: BlockDeviceSnapshotStateRefreshFunc(*apiClient, *createDiskSnapshotCreated.Payload.ID),
Expand All @@ -112,7 +113,7 @@ func resourceBlockDeviceSnapshotCreate(ctx context.Context, d *schema.ResourceDa
return resourceBlockDeviceSnapshotRead(ctx, d, m)
}

func BlockDeviceSnapshotStateRefreshFunc(apiClient client.API, id string) resource.StateRefreshFunc {
func BlockDeviceSnapshotStateRefreshFunc(apiClient client.API, id string) retry.StateRefreshFunc {
return func() (interface{}, string, error) {
ret, err := apiClient.Request.GetRequestTracker(request.NewGetRequestTrackerParams().WithID(id))
if err != nil {
Expand All @@ -122,7 +123,7 @@ func BlockDeviceSnapshotStateRefreshFunc(apiClient client.API, id string) resour
status := ret.Payload.Status
switch *status {
case models.RequestTrackerStatusFAILED:
return []string{""}, *status, fmt.Errorf(ret.Payload.Message)
return []string{""}, *status, errors.New(ret.Payload.Message)
case models.RequestTrackerStatusINPROGRESS:
return [...]string{id}, *status, nil
case models.RequestTrackerStatusFINISHED:
Expand Down Expand Up @@ -220,7 +221,7 @@ func resourceBlockDeviceSnapshotDelete(ctx context.Context, d *schema.ResourceDa
return nil
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: BlockDeviceSnapshotStateRefreshFunc(*apiClient, *deleteDiskSnapshotAccepted.Payload.ID),
Expand Down
10 changes: 5 additions & 5 deletions vra/resource_cloud_account_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/vmware/vra-sdk-go/pkg/models"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -116,7 +116,7 @@ func resourceCloudAccountAWSCreate(ctx context.Context, d *schema.ResourceData,
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: resourceCloudAccountAWSStateRefreshFunc(*apiClient, *createResp.Payload.ID),
Expand Down Expand Up @@ -201,7 +201,7 @@ func resourceCloudAccountAWSUpdate(ctx context.Context, d *schema.ResourceData,
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: resourceCloudAccountAWSStateRefreshFunc(*apiClient, *updateResp.Payload.ID),
Expand Down Expand Up @@ -230,7 +230,7 @@ func resourceCloudAccountAWSDelete(_ context.Context, d *schema.ResourceData, m
return nil
}

func resourceCloudAccountAWSStateRefreshFunc(apiClient client.API, id string) resource.StateRefreshFunc {
func resourceCloudAccountAWSStateRefreshFunc(apiClient client.API, id string) retry.StateRefreshFunc {
return func() (interface{}, string, error) {
ret, err := apiClient.Request.GetRequestTracker(request.NewGetRequestTrackerParams().WithID(id))
if err != nil {
Expand All @@ -240,7 +240,7 @@ func resourceCloudAccountAWSStateRefreshFunc(apiClient client.API, id string) re
status := ret.Payload.Status
switch *status {
case models.RequestTrackerStatusFAILED:
return []string{""}, *status, fmt.Errorf(ret.Payload.Message)
return []string{""}, *status, errors.New(ret.Payload.Message)
case models.RequestTrackerStatusINPROGRESS:
return [...]string{id}, *status, nil
case models.RequestTrackerStatusFINISHED:
Expand Down
10 changes: 5 additions & 5 deletions vra/resource_cloud_account_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/vmware/vra-sdk-go/pkg/models"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -128,7 +128,7 @@ func resourceCloudAccountAzureCreate(ctx context.Context, d *schema.ResourceData
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: resourceCloudAccountAzureStateRefreshFunc(*apiClient, *createResp.Payload.ID),
Expand Down Expand Up @@ -215,7 +215,7 @@ func resourceCloudAccountAzureUpdate(ctx context.Context, d *schema.ResourceData
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: resourceCloudAccountAzureStateRefreshFunc(*apiClient, *updateResp.Payload.ID),
Expand Down Expand Up @@ -243,7 +243,7 @@ func resourceCloudAccountAzureDelete(_ context.Context, d *schema.ResourceData,
return nil
}

func resourceCloudAccountAzureStateRefreshFunc(apiClient client.API, id string) resource.StateRefreshFunc {
func resourceCloudAccountAzureStateRefreshFunc(apiClient client.API, id string) retry.StateRefreshFunc {
return func() (interface{}, string, error) {
ret, err := apiClient.Request.GetRequestTracker(request.NewGetRequestTrackerParams().WithID(id))
if err != nil {
Expand All @@ -253,7 +253,7 @@ func resourceCloudAccountAzureStateRefreshFunc(apiClient client.API, id string)
status := ret.Payload.Status
switch *status {
case models.RequestTrackerStatusFAILED:
return []string{""}, *status, fmt.Errorf(ret.Payload.Message)
return []string{""}, *status, errors.New(ret.Payload.Message)
case models.RequestTrackerStatusINPROGRESS:
return [...]string{id}, *status, nil
case models.RequestTrackerStatusFINISHED:
Expand Down
10 changes: 5 additions & 5 deletions vra/resource_cloud_account_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/vmware/vra-sdk-go/pkg/models"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -128,7 +128,7 @@ func resourceCloudAccountGCPCreate(ctx context.Context, d *schema.ResourceData,
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: resourceCloudAccountGCPStateRefreshFunc(*apiClient, *createResp.Payload.ID),
Expand Down Expand Up @@ -215,7 +215,7 @@ func resourceCloudAccountGCPUpdate(ctx context.Context, d *schema.ResourceData,
return diag.FromErr(err)
}

stateChangeFunc := resource.StateChangeConf{
stateChangeFunc := retry.StateChangeConf{
Delay: 5 * time.Second,
Pending: []string{models.RequestTrackerStatusINPROGRESS},
Refresh: resourceCloudAccountGCPStateRefreshFunc(*apiClient, *updateResp.Payload.ID),
Expand Down Expand Up @@ -243,7 +243,7 @@ func resourceCloudAccountGCPDelete(_ context.Context, d *schema.ResourceData, m
return nil
}

func resourceCloudAccountGCPStateRefreshFunc(apiClient client.API, id string) resource.StateRefreshFunc {
func resourceCloudAccountGCPStateRefreshFunc(apiClient client.API, id string) retry.StateRefreshFunc {
return func() (interface{}, string, error) {
ret, err := apiClient.Request.GetRequestTracker(request.NewGetRequestTrackerParams().WithID(id))
if err != nil {
Expand All @@ -253,7 +253,7 @@ func resourceCloudAccountGCPStateRefreshFunc(apiClient client.API, id string) re
status := ret.Payload.Status
switch *status {
case models.RequestTrackerStatusFAILED:
return []string{""}, *status, fmt.Errorf(ret.Payload.Message)
return []string{""}, *status, errors.New(ret.Payload.Message)
case models.RequestTrackerStatusINPROGRESS:
return [...]string{id}, *status, nil
case models.RequestTrackerStatusFINISHED:
Expand Down
Loading

0 comments on commit 0750141

Please sign in to comment.