Repository navigation
chore: reset golangci-lint config - #10150
Merged
Merged
Conversation
Replace the large, hand-tuned golangci-lint config with a short config based on default linters plus selected bug and security linters. Fix the findings in code, apply linter auto-fixes, and remove stale //nolint directives. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
Windows Unit Test Results 3 files 21 suites 1m 6s ⏱️ Results for commit 00c2fd9. ♻️ This comment has been updated with latest results. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the lint configuration simplification and accompanying Go updates.
No open issues 🎉
What changed in this PR
Simplifies AgentBaker’s Go lint configuration and updates the service, node controller, and tests to match, with the intent of preserving exported APIs and JSON wire formats.
Changes:
- Replaces extensive lint tuning with default linters, selected correctness/security checks, and focused exceptions.
- Modernizes Go code, removes stale suppressions, moves test-only helpers, and adds explicit JSON tags matching existing field names.
- Preserves context values during API shutdown and tightens newly created KVP pool files to mode
0644.
| File | Description |
|---|---|
pkg/vhdbuilder/datamodel/component_configs.go |
Uses any in the JSON loader. |
pkg/agent/variables.go |
Constructs cloud-init data without a type assertion. |
pkg/agent/variables_test.go |
Removes a stale lint suppression. |
pkg/agent/utils.go |
Modernizes helpers and moves test-only code out. |
pkg/agent/utils_test.go |
Modernizes tests and receives the script-encoding helper. |
pkg/agent/toggles/types.go |
Explicitly marks unused parameters. |
pkg/agent/script_minification_artifacts_test.go |
Uses a dedicated error assertion. |
pkg/agent/localdns_test.go |
Modernizes pointer creation and string iteration. |
pkg/agent/datamodel/versions.go |
Uses standard map-copy and slice-membership helpers. |
pkg/agent/datamodel/versions_test.go |
Removes redundant loop captures and suppressions. |
pkg/agent/datamodel/types.go |
Adds exact-name JSON tags and modernizes map copying. |
pkg/agent/datamodel/types_test.go |
Modernizes fixtures and receives test-only mock helpers. |
pkg/agent/datamodel/sig_config.go |
Adds exact-name JSON tags and simplifies membership checks. |
pkg/agent/datamodel/osimageconfig.go |
Removes a stale lint suppression. |
pkg/agent/datamodel/mocks.go |
Moves private test helpers into test files. |
pkg/agent/datamodel/helper.go |
Modernizes iteration and moves test-only URL helpers. |
pkg/agent/datamodel/helper_test.go |
Receives URL helpers and removes redundant loop captures. |
pkg/agent/datamodel/gpu_components.go |
Cleans up comments and stale suppressions. |
pkg/agent/bakerapi.go |
Uses map copying and documents API compatibility exceptions. |
pkg/agent/bakerapi_test.go |
Removes a stale lint suppression. |
pkg/agent/baker.go |
Checks template type assertions and modernizes helpers. |
pkg/agent/baker_test.go |
Modernizes assertions and receives the label-normalization helper. |
image-fetcher/image.go |
Adds spacing before a function comment. |
hotfix/render-nodecustomdata/main.go |
Uses any for variadic arguments. |
e2e/scenario/scenario_win.go |
Removes a suppression while retaining its explanatory comment. |
e2e/scenario/scenario_kubelet_disk.go |
Formats import groups. |
e2e/scenario/scenario_gpu_daemonset.go |
Formats import groups. |
e2e/scenario/scenario_cse_perf.go |
Formats import groups. |
cmd/starter/start.go |
Removes stale global-variable suppressions. |
apiserver/apiserver.go |
Preserves context values in uncancelled shutdown context. |
aks-node-controller/version.go |
Retains build-time documentation without the suppression. |
aks-node-controller/utils/sensitive_string.go |
Uses any in the YAML marshaler signature. |
aks-node-controller/repository_telemetry.go |
Explains ignored string-marshaling errors. |
aks-node-controller/repository_telemetry_test.go |
Uses dedicated substring assertions. |
aks-node-controller/repository_hotfix.go |
Uses typed error extraction. |
aks-node-controller/repository_hotfix_test.go |
Modernizes assertions and avoids fatal assertions in handlers. |
aks-node-controller/repository_hotfix_rpm.go |
Modernizes version splitting and text iteration. |
aks-node-controller/repository_hotfix_deb.go |
Uses iterator-based repository parsing loops. |
aks-node-controller/pkg/nodeconfigutils/validation.go |
Uses protobuf getters and iterator-based parsing. |
aks-node-controller/pkg/nodeconfigutils/validation_test.go |
Modernizes pointer creation. |
aks-node-controller/pkg/nodeconfigutils/utils_test.go |
Modernizes MIME-header iteration. |
aks-node-controller/pkg/nodeconfigutils/testutil.go |
Uses integer-range loops. |
aks-node-controller/pkg/gpu/skus.go |
Cleans up comments and stale suppressions. |
aks-node-controller/parser/parser.go |
Uses protobuf getters while preserving nil-sensitive VHD handling. |
aks-node-controller/parser/parser_test.go |
Modernizes pointers, assertions, and suppressions. |
aks-node-controller/parser/kubelet_config_test.go |
Modernizes tests while retaining byte-exact output checks. |
aks-node-controller/parser/helper.go |
Simplifies protobuf access and modernizes iteration. |
aks-node-controller/parser/helper_test.go |
Modernizes fixtures, map copying, and iteration. |
aks-node-controller/main.go |
Documents diagnostic log permissions and removes stale suppressions. |
aks-node-controller/hotfix.go |
Modernizes OS-release parsing. |
aks-node-controller/hotfix_test.go |
Uses dedicated empty-value assertions. |
aks-node-controller/goal_state.go |
Canonicalizes headers and creates KVP files with 0644. |
aks-node-controller/goal_state_test.go |
Matches canonical header spelling. |
aks-node-controller/embeddednodecustomdata.go |
Modernizes OS-release line iteration. |
aks-node-controller/const.go |
Retains path documentation without the suppression. |
aks-node-controller/checkhotfix.go |
Uses typed error extraction for fallback decisions. |
aks-node-controller/checkhotfix_test.go |
Uses a dedicated empty-value assertion. |
aks-node-controller/app.go |
Modernizes protobuf access, iteration, and error extraction. |
aks-node-controller/app_test.go |
Uses dedicated empty-value assertions. |
.golangci.yaml |
Resets lint policy with focused settings and exceptions. |
Review effort: Balanced
- exhaustive: proto enum switches must list every value. - unparam: remove always-constant params from addSecret and strKeyValToMapBool. - dupl: removed; its size threshold flags intentional similar code. - revive unexported-return: disabled; it reports NewAgentBaker on Go 1.26 but not on Go 1.27, so a //nolint was unused in CI. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Artur Khantimirov (r2k1)
enabled auto-merge (squash)
November 23, 2026 21:10
Contributor
Contributor
Contributor
|
Tim Wright (timmy-wright)
approved these changes
Nov 25, 2026
Artur Khantimirov (r2k1)
added a commit
that referenced
this pull request
Nov 26, 2026
Rebase onto dev after #10150. Use strings.SplitSeq, give gosec G302 directives a reason, drop gochecknoglobals directives, and ignore the darwin syscall.Sync error. AB#40892331 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Replaces the golangci-lint config with a short config that needs little tuning.
Before: a large hand-tuned config with many per-linter settings and about 82 stale
//nolintdirectives.After:
.golangci.yamlkeeps the default linters and adds selected bug and security linters: asasalint, asciicheck, bidichk, bodyclose, canonicalheader, containedctx, contextcheck, durationcheck, errchkjson, errorlint, exhaustive, exptostd, fatcontext, forcetypeassert, gocritic, gomoddirectives, goprintffuncname, gosec, makezero, modernize, musttag, nilerr, nilnil, noctx, nolintlint, protogetter, reassign, revive, testifylint, unparam, usetesting. govet also enablesnilnessandshadow.Settings are kept to a minimum. Each one has a reason in the config:
var-namingandexportedare off. They are naming style only, and renames break importers of exported names.unexported-returnis off. Changing the return type ofNewAgentBakerwould break importers. Also, it reports on Go 1.26 but not on Go 1.27, so a//nolintis unused in CI.omitzerois off, so json tags stay as written.//nolintdirectives.//nolint.gosec,noctx,protogetterandreviveare off.Code changes:
modernize:interface{}→any,new(x)instead ofto.Ptr(x),strings.SplitSeq,maps.Copy. Alsotestifylintandcanonicalheaderfixes.pkg/agent/datamodel: exact-name json tags such asjson:"ResourceGroup"for musttag. A temporary test showed byte-identical JSON before and after, and the decode/encode round trip matched. Embedded structs stay untagged.apiservershutdown usescontext.WithoutCancel(ctx).aks-node-controllercreates the KVP pool file with mode 0644 (was 0666)._test.gofiles.require.Equal.IsVhdkeeps a direct field read, because nil means VHD.unparam: removed parameters that always get the same value fromaddSecretandstrKeyValToMapBool.exhaustive:getStringFromLoadBalancerSkuTypelists theUNSPECIFIEDcase.No exported Go API changes and no JSON wire-format changes.
Validation:
golangci-lint run ./...(v2.15.0) in.,aks-node-controllerandaks-live-patching: 0 issues each, with Go 1.27.4 (GOOS=linux, as in CI) and with Go 1.26.go build ./...andgo vet ./...(alsoe2e): passed.go test ./pkg/... ./apiserver/...: passed.cd aks-node-controller && go test ./...: passed, exceptTestRunProvisionRemovesInputsAfterExecutionandTestRunProvisionReportsInputCleanupFailure. These fail the same way on the base branch on macOS (no/bin/true).Which issue(s) this PR fixes:
AB#40892308