Skip to content

Conversation

@tenthirtyam
Copy link
Collaborator

@tenthirtyam tenthirtyam commented May 21, 2025

Updates golangci-lint to v2 (latest).

  • Migrated the configuration.
  • Updates the golangci/golangci-lint-action to v7 for interoperability.
  • Addresses existing linting issues.
~/Downloads/packer-plugin-vsphere git:[main]
golangci-lint migrate
WARN The configuration comments are not migrated. 
WARN Details about the migration: https://golangci-lint.run/product/migration-guide/ 
╭───────────────────────────────────────────────────────────────────────────╮
│                                                                           │
│                               We need you!                                │
│                                                                           │
│ Donations help fund the ongoing development and maintenance of this tool. │
│  If golangci-lint has been useful to you, please consider contributing.   │
│                                                                           │
│                  Donate now: https://donate.golangci.org                  │
│                                                                           │
╰───────────────────────────────────────────────────────────────────────────╯
~/Downloads/packer-plugin-vsphere git:[main]
golangci-lint run
builder/vsphere/clone/builder.go:48:22: QF1008: could remove embedded field "CDConfig" from selector (staticcheck)
                        Files:   b.config.CDConfig.CDFiles,
                                          ^
builder/vsphere/clone/builder.go:49:22: QF1008: could remove embedded field "CDConfig" from selector (staticcheck)
                        Content: b.config.CDConfig.CDContent,
                                          ^
builder/vsphere/clone/builder.go:50:22: QF1008: could remove embedded field "CDConfig" from selector (staticcheck)
                        Label:   b.config.CDConfig.CDLabel,
                                          ^
builder/vsphere/clone/builder.go:60:23: QF1008: could remove embedded field "PackerConfig" from selector (staticcheck)
                        Force:    b.config.PackerConfig.PackerForce,
                                           ^
builder/vsphere/clone/builder.go:100:24: QF1008: could remove embedded field "HTTPConfig" from selector (staticcheck)
                if addrs := b.config.HTTPConfig.HTTPAddress; addrs != "" && addrs != common.DefaultHttpBindAddress {
                                     ^
builder/vsphere/clone/builder.go:108:30: QF1008: could remove embedded field "HTTPConfig" from selector (staticcheck)
                } else if intf := b.config.HTTPConfig.HTTPInterface; intf != "" {
                                           ^
builder/vsphere/clone/builder.go:114:23: QF1008: could remove embedded field "BootConfig" from selector (staticcheck)
                                HTTPIP:  b.config.BootConfig.HTTPIP,
                                                  ^
builder/vsphere/clone/builder.go:115:23: QF1008: could remove embedded field "WaitIpConfig" from selector (staticcheck)
                                Network: b.config.WaitIpConfig.GetIPNet(),
                                                  ^
builder/vsphere/clone/config_test.go:34:10: QF1008: could remove embedded field "ShutdownConfig" from selector (staticcheck)
        if conf.ShutdownConfig.Timeout != 3*time.Minute {
                ^
builder/vsphere/clone/config_test.go:35:72: QF1008: could remove embedded field "ShutdownConfig" from selector (staticcheck)
                t.Fatalf("unexpected result: expected '3m', but returned '%v'", conf.ShutdownConfig.Timeout)
                                                                                     ^
builder/vsphere/driver/datastore.go:122:2: S1008: should use 'return !errors.As(err, &datastoreNoSuchDirectoryError)' instead of 'if errors.As(err, &datastoreNoSuchDirectoryError) { return false }; return true' (staticcheck)
        if errors.As(err, &datastoreNoSuchDirectoryError) {
        ^
builder/vsphere/iso/builder.go:86:23: QF1008: could remove embedded field "PackerConfig" from selector (staticcheck)
                        Force:    b.config.PackerConfig.PackerForce,
                                           ^
builder/vsphere/iso/builder.go:116:23: QF1008: could remove embedded field "HTTPConfig" from selector (staticcheck)
        if addrs := b.config.HTTPConfig.HTTPAddress; addrs != "" && addrs != common.DefaultHttpBindAddress {
                             ^
builder/vsphere/iso/builder.go:131:22: QF1008: could remove embedded field "BootConfig" from selector (staticcheck)
                        HTTPIP:  b.config.BootConfig.HTTPIP,
                                          ^
builder/vsphere/iso/builder.go:132:22: QF1008: could remove embedded field "WaitIpConfig" from selector (staticcheck)
                        Network: b.config.WaitIpConfig.GetIPNet(),
                                          ^
builder/vsphere/supervisor/builder.go:63:14: QF1008: could remove embedded field "ImportImageConfig" from selector (staticcheck)
        if b.config.ImportImageConfig.ImportSourceURL != "" {
                    ^
16 issues:
* staticcheck: 16

~/Downloads/packer-plugin-vsphere git:[main]
golangci-lint run --fix
builder/vsphere/driver/datastore.go:122:2: S1008: should use 'return !errors.As(err, &datastoreNoSuchDirectoryError)' instead of 'if errors.As(err, &datastoreNoSuchDirectoryError) { return false }; return true' (staticcheck)
        if errors.As(err, &datastoreNoSuchDirectoryError) {
        ^
1 issues:
* staticcheck: 1

~/Downloads/packer-plugin-vsphere git:[main]
golangci-lint run
0 issues.

~/Downloads/packer-plugin-vsphere git:[main]
go fmt ./...

~/Downloads/packer-plugin-vsphere git:[main]
make dev
packer plugins install --path packer-plugin-vsphere "github.com/hashicorp/vsphere"
Successfully installed plugin github.com/hashicorp/vsphere from /Users/johnsonryan/Downloads/packer-plugin-vsphere/packer-plugin-vsphere to /Users/johnsonryan/.packer.d/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.4.3-dev_x5.0_darwin_amd64

~/Downloads/packer-plugin-vsphere git:[main]
make build

~/Downloads/packer-plugin-vsphere git:[main]
make test
?       github.com/hashicorp/packer-plugin-vsphere      [no test files]
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone        1.709s
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common       4.467s
?       github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/testing       [no test files]
?       github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/utils [no test files]
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/driver       8.048s
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso  2.331s
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/supervisor   6.200s
?       github.com/hashicorp/packer-plugin-vsphere/examples/driver      [no test files]
ok      github.com/hashicorp/packer-plugin-vsphere/post-processor/vsphere       1.561s
ok      github.com/hashicorp/packer-plugin-vsphere/post-processor/vsphere-template      2.171s
?       github.com/hashicorp/packer-plugin-vsphere/version      [no test files]

@tenthirtyam tenthirtyam added this to the v2.0.0 milestone May 21, 2025
@tenthirtyam tenthirtyam requested a review from JenGoldstrich May 21, 2025 16:48
@tenthirtyam tenthirtyam self-assigned this May 21, 2025
@tenthirtyam tenthirtyam requested a review from a team as a code owner May 21, 2025 16:48
Updates `golangci-lint` to v2 (`latest`).

- Migrated the configuration.
- Updates the `golangci/golangci-lint-action` to v7 for interoperability.
- Addresses existing linting issues.

Signed-off-by: Ryan Johnson <[email protected]>
@tenthirtyam tenthirtyam force-pushed the chore/update-golangci-lint-to-v2 branch from b635e8c to f6f5183 Compare May 21, 2025 17:10
@tenthirtyam tenthirtyam merged commit 3c634b4 into main May 21, 2025
14 checks passed
@tenthirtyam tenthirtyam deleted the chore/update-golangci-lint-to-v2 branch May 21, 2025 17:53
tenthirtyam added a commit that referenced this pull request May 22, 2025
Updates `golangci-lint` to v2 (`latest`).

- Migrated the configuration.
- Updates the `golangci/golangci-lint-action` to v7 for interoperability.
- Addresses existing linting issues.

Signed-off-by: Ryan Johnson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants