Skip to content

Commit

Permalink
Adjust code to linter 1.61
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Khmelnitsky <[email protected]>
  • Loading branch information
annakhm committed Sep 26, 2024
1 parent ceba650 commit 9f8246c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ issues:
- SA1019
- G402
- G404
- G115
- GetOkExists

run:
deadline: 5m
deadline: 30m

linters:
disable-all: true
Expand All @@ -20,7 +21,7 @@ linters:
- staticcheck
- gosec
- goimports
- vet
- govet
- misspell
- gosimple
- staticcheck
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package nsxt

import (
"errors"
"fmt"
"log"
"time"
Expand Down Expand Up @@ -122,5 +123,5 @@ func getErrorFromState(state *model.TransportNodeCollectionState) error {
result += fmt.Sprintf("VCLM transition error: %v\n", *state.VlcmTransitionError)
}

return fmt.Errorf(result)
return errors.New(result)
}
3 changes: 2 additions & 1 deletion nsxt/data_source_nsxt_upgrade_prepare_ready.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package nsxt

import (
"errors"
"fmt"

"github.com/vmware/terraform-provider-nsxt/nsxt/util"
Expand Down Expand Up @@ -85,7 +86,7 @@ func dataSourceNsxtUpgradePrepareReadyRead(d *schema.ResourceData, m interface{}
errMessage += fmt.Sprintf("\nThere are unacknowledged warnings in prechecks:\n%s\nPlease address these errors from NSX or using nsxt_upgrade_precheck_acknowledge resource", preCheckText)
}
if len(errMessage) > 0 {
return fmt.Errorf(errMessage)
return errors.New(errMessage)
}
objID := util.GetVerifiableID(newUUID(), "nsxt_upgrade_prepare_ready")
d.SetId(objID)
Expand Down
3 changes: 2 additions & 1 deletion nsxt/policy_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package nsxt

import (
liberrors "errors"
"fmt"
"log"

Expand Down Expand Up @@ -104,7 +105,7 @@ func logVapiErrorData(message string, vapiMessages []std.LocalizableMessage, vap
}
}
log.Printf("[ERROR]: %s", details)
return fmt.Errorf(details)
return liberrors.New(details)
}

func logAPIError(message string, err error) error {
Expand Down
4 changes: 2 additions & 2 deletions nsxt/resource_nsxt_lb_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func setSnatTranslationInSchema(d *schema.ResourceData, snatTranslation *loadbal
if snatTranslation != nil {
if snatTranslation.Type_ == "LbSnatIpPool" {
elem["type"] = "SNAT_IP_POOL"
if snatTranslation.IpAddresses != nil && len(snatTranslation.IpAddresses) > 0 {
if len(snatTranslation.IpAddresses) > 0 {
elem["ip"] = snatTranslation.IpAddresses[0].IpAddress
}
} else {
Expand Down Expand Up @@ -421,7 +421,7 @@ func resourceNsxtLbPoolRead(d *schema.ResourceData, m interface{}) error {
d.Set("description", lbPool.Description)
d.Set("display_name", lbPool.DisplayName)
setTagsInSchema(d, lbPool.Tags)
if lbPool.ActiveMonitorIds != nil && len(lbPool.ActiveMonitorIds) > 0 {
if len(lbPool.ActiveMonitorIds) > 0 {
d.Set("active_monitor_id", lbPool.ActiveMonitorIds[0])
} else {
d.Set("active_monitor_id", "")
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_ipsec_vpn_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ func resourceNsxtPolicyIPSecVpnSessionRead(d *schema.ResourceData, m interface{}
}
var subnets []string
var prefixLength int64
if blockVPN.TunnelInterfaces != nil && len(blockVPN.TunnelInterfaces) > 0 {
if len(blockVPN.TunnelInterfaces) > 0 {
for _, tunnelInterface := range blockVPN.TunnelInterfaces {
ipSubnets := tunnelInterface.IpSubnets
for _, ipSubnet := range ipSubnets {
Expand Down
3 changes: 2 additions & 1 deletion nsxt/resource_nsxt_upgrade_prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package nsxt

import (
liberrors "errors"
"fmt"
"log"
"strings"
Expand Down Expand Up @@ -415,7 +416,7 @@ func waitForBundleUpload(m interface{}, bundleID string, timeout int) error {

log.Printf("[DEBUG] Current status for uploading bundle %s is %s", bundleID, *state.Status)
if *state.Status == nsxModel.UpgradeBundleUploadStatus_STATUS_FAILED {
return state, nsxModel.UpgradeBundleUploadStatus_STATUS_FAILED, fmt.Errorf(*state.DetailedStatus)
return state, nsxModel.UpgradeBundleUploadStatus_STATUS_FAILED, liberrors.New(*state.DetailedStatus)
}

return state, *state.Status, nil
Expand Down

0 comments on commit 9f8246c

Please sign in to comment.