Skip to content

Commit

Permalink
Bump up github action versions and linter
Browse files Browse the repository at this point in the history
And adjust code to new linter settings

Signed-off-by: Anna Khmelnitsky <[email protected]>
  • Loading branch information
annakhm committed Oct 3, 2024
1 parent db61285 commit f14546d
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22
- uses: actions/checkout@v3
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci-ut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22
- uses: actions/checkout@v4
go-version-file: 'go.mod'
- name: Install dependencies
run: |
go get .
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,29 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.22
go-version-file: 'go.mod'
-
name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50
args: --issues-exit-code=1
version: v1.61
args: --issues-exit-code=1 --timeout=30m
skip-pkg-cache: true
skip-build-cache: true
-
name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY2 }}
passphrase: ${{ secrets.GPG_PASSPHRASE2 }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
Expand Down
6 changes: 3 additions & 3 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,8 +21,7 @@ linters:
- staticcheck
- gosec
- goimports
- vet
- revive
- 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)
}
1 change: 1 addition & 0 deletions nsxt/data_source_nsxt_policy_uplink_host_switch_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package nsxt

import (
"fmt"

"github.com/vmware/vsphere-automation-sdk-go/runtime/bindings"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down
4 changes: 3 additions & 1 deletion nsxt/data_source_nsxt_upgrade_prepare_ready.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
package nsxt

import (
"errors"
"fmt"

"github.com/vmware/terraform-provider-nsxt/nsxt/util"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -84,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 @@ -454,7 +455,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
4 changes: 4 additions & 0 deletions nsxt/resource_nsxt_upgrade_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ func prepareUpgrade(upgradeClientSet *upgradeClientSet, d *schema.ResourceData,
continue
}

//#nosec G601 Ignore implicit memory aliasing in for loop temporarily
status, err := getUpgradeStatus(upgradeClientSet.StatusClient, &component)
if err != nil {
return err
Expand All @@ -466,13 +467,15 @@ func prepareUpgrade(upgradeClientSet *upgradeClientSet, d *schema.ResourceData,
if status.Status == model.ComponentUpgradeStatus_STATUS_IN_PROGRESS {
upgradeClientSet.PlanClient.Pause()
}
//#nosec G601 Ignore implicit memory aliasing in for loop temporarily
err = waitUpgradeForStatus(upgradeClientSet, &component, inFlightComponentUpgradeStatus, staticComponentUpgradeStatus)
if err != nil {
return err
}

// Cache the group list before reset as group IDs change by reset operation. References for some types of groups
// could be affected here
//#nosec G601 Ignore implicit memory aliasing in for loop temporarily
preResetGroupList, err := upgradeClientSet.GroupClient.List(&component, nil, nil, nil, nil, nil, nil, nil)
if err != nil {
return err
Expand Down Expand Up @@ -820,6 +823,7 @@ func runUpgrade(upgradeClientSet *upgradeClientSet, partialUpgradeMap map[string
prevComponent = component
completeLog = fmt.Sprintf("[INFO] %s upgrade is partially completed.", component)
}
//#nosec G601 Ignore implicit memory aliasing in for loop temporarily
err = upgradeClientSet.PlanClient.Upgrade(&component)
if err != nil {
return err
Expand Down

0 comments on commit f14546d

Please sign in to comment.