Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the repository’s Go version to 1.26.0 and applies go fix-style refactors across the AgentBaker codebase (agent templates/datamodel, VHD builder helpers, and e2e tooling).
Changes:
- Bump
go.mod(and submodulego.mods) from Go 1.24.12 to Go 1.26.0. - Apply Go modernizations (e.g.,
any,maps.Copy,slices.Contains, range-int loops,strings.SplitSeq,strings.Builder). - Refactor pointer creation in multiple places (replacing
to.*Ptr/to.Ptrusage in some files).
Reviewed changes
Copilot reviewed 44 out of 44 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| go.mod | Bumps root module Go version to 1.26.0. |
| hack/tools/go.mod | Bumps tools module Go version to 1.26.0. |
| aks-node-controller/go.mod | Bumps aks-node-controller module Go version to 1.26.0. |
| e2e/go.mod | Bumps e2e module Go version to 1.26.0. |
| vhdbuilder/prefetch/go.mod | Bumps prefetch module Go version to 1.26.0. |
| vhdbuilder/lister/go.mod | Bumps lister module Go version to 1.26.0. |
| pkg/vhdbuilder/datamodel/component_configs.go | Replaces interface{} with any. |
| pkg/agent/variables.go | Switches maps from map[string]interface{} to map[string]any. |
| pkg/agent/utils.go | Uses any, SplitSeq, strings.Builder, and other modernizations; refactors pointer creation. |
| pkg/agent/utils_test.go | Updates tests to match pointer creation/refactor patterns. |
| pkg/agent/baker.go | Updates template helpers to any; refactors pointer creation. |
| pkg/agent/bakerapi.go | Uses maps.Copy for map cloning. |
| pkg/agent/baker_test.go | Updates tests to match pointer creation/refactor patterns. |
| pkg/agent/datamodel/versions.go | Uses maps.Copy and slices.Contains. |
| pkg/agent/datamodel/versions_test.go | Removes now-unnecessary range variable capture for parallel subtests. |
| pkg/agent/datamodel/types.go | Uses maps.Copy/slices.Contains; adjusts some JSON tags. |
| pkg/agent/datamodel/types_test.go | Updates tests to match pointer creation/refactor patterns; removes range captures. |
| pkg/agent/datamodel/sig_config.go | Uses slices.Contains for distro membership checks. |
| pkg/agent/datamodel/helper.go | Uses range-int loop form for indentation. |
| pkg/agent/datamodel/helper_test.go | Removes now-unnecessary range variable captures. |
| pkg/agent/datamodel/azenvtypes.go | Adjusts JSON tags on struct fields. |
| e2e/* (multiple) | Refactors pointer creation and uses newer iteration helpers (SplitSeq, range-int loops, etc.). |
| customKc := &datamodel.CustomKubeletConfig{ | ||
| CPUManagerPolicy: "static", | ||
| CPUCfsQuota: to.BoolPtr(false), | ||
| CPUCfsQuota: new(false), | ||
| CPUCfsQuotaPeriod: "200ms", | ||
| ImageGcHighThreshold: to.Int32Ptr(90), | ||
| ImageGcLowThreshold: to.Int32Ptr(70), | ||
| TopologyManagerPolicy: "best-effort", | ||
| AllowedUnsafeSysctls: &[]string{"kernel.msg*", "net.ipv4.route.min_pmtu"}, | ||
| FailSwapOn: to.BoolPtr(false), | ||
| FailSwapOn: new(false), | ||
| ContainerLogMaxSizeMB: to.Int32Ptr(1000), | ||
| ContainerLogMaxFiles: to.Int32Ptr(99), | ||
| PodMaxPids: to.Int32Ptr(12345), | ||
| SeccompDefault: to.BoolPtr(true), | ||
| SeccompDefault: new(true), | ||
| } |
There was a problem hiding this comment.
new(false) / new(true) does not compile with the built-in new (it requires a type, e.g. new(bool)), and there is no package-level new helper in pkg/agent to make this valid. If the intent is to get pointers to literal values, please switch back to an explicit pointer helper (e.g. the existing to.BoolPtr / to.Int32Ptr) or introduce a clearly named helper function instead of relying on new(...).
| for { | ||
| pager := config.Azure.VMSSVM.NewListPager(*s.Runtime.Cluster.Model.Properties.NodeResourceGroup, s.Runtime.VMSSName, &armcompute.VirtualMachineScaleSetVMsClientListOptions{ | ||
| Expand: to.Ptr("instanceView"), | ||
| Expand: new("instanceView"), |
There was a problem hiding this comment.
Expand: new("instanceView") will not compile with the built-in new (it expects a type, not a value) and there is no local new helper in the e2e package. Use an explicit pointer helper (e.g. to.Ptr("instanceView"), consistent with nearby code) or add a properly named helper for pointer-to-literal if that's the migration goal.
| Expand: new("instanceView"), | |
| Expand: to.Ptr("instanceView"), |
| if customKc.PodMaxPids != nil { | ||
| kubeletConfig.PodPidsLimit = to.Int64Ptr(int64(*customKc.PodMaxPids)) | ||
| kubeletConfig.PodPidsLimit = new(int64(*customKc.PodMaxPids)) | ||
| } |
There was a problem hiding this comment.
kubeletConfig.PodPidsLimit = new(int64(*customKc.PodMaxPids)) relies on calling new with a value expression. There is no package-level new helper in pkg/agent, so this resolves to the built-in new, which normally requires a type and will not compile. If the goal is to take a pointer to the computed int64, please use an explicit pointer helper (consistent with existing to.Int64Ptr usage elsewhere) or add a clearly named helper that returns a pointer to a provided value.
| Mode: new(0o600), | ||
| Overwrite: new(true), | ||
| Contents: base0_5.Resource{ | ||
| Source: to.StringPtr(dataURL), | ||
| Compression: to.StringPtr(encodingGZIP), | ||
| Source: new(dataURL), | ||
| Compression: new(encodingGZIP), |
There was a problem hiding this comment.
These new(0o600) / new(true) / new(dataURL) calls will not compile with the built-in new (it takes a type, not a value). Replace with pointers created from values via a helper (e.g., ptrTo(0o600)), or use address-of on a variable.
| @@ -58,5 +59,6 @@ func (api *APIServer) GetNodeBootstrapData(w http.ResponseWriter, r *http.Reques | |||
| } | |||
|
|
|||
| w.WriteHeader(http.StatusOK) | |||
| //nolint: gosec | |||
| fmt.Fprint(w, string(result)) | |||
There was a problem hiding this comment.
Avoid broad // nolint: gosec here. fmt.Fprint(w, ...) returns an error that can be handled cheaply (e.g., log/return on write failure), which is preferable to suppressing gosec; similarly the log.Println line typically shouldn't need a gosec suppression. If a suppression is truly needed, use the narrow // #nosec <rule-id> form with a brief justification.
| func loadJSONFromFile(path string, v any) error { | ||
| //nolint: gosec | ||
| configFile, err := os.Open(path) | ||
| if err != nil { |
There was a problem hiding this comment.
// nolint: gosec on os.Open(path) is very broad. If the path is trusted (e.g., only internal config paths), prefer a narrow suppression with the specific rule id (commonly G304) and a short justification, or validate/clean the input path before opening.
| type ServicePrincipalProfile struct { | ||
| ClientID string `json:"clientId"` | ||
| Secret string `json:"secret,omitempty" conform:"redact"` | ||
| Secret string `json:"secret,omitempty" conform:"redact"` //nolint: gosec |
There was a problem hiding this comment.
Using // nolint: gosec on the Secret field is a broad suppression that can mask unrelated gosec findings on the same line in the future. Prefer a narrow suppression (// #nosec G101) with a brief justification (e.g., "field name contains 'Secret' but value is provided at runtime and redacted").
| CPUCfsQuota: new(false), | ||
| CPUCfsQuotaPeriod: "200ms", | ||
| ImageGcHighThreshold: to.Int32Ptr(90), | ||
| ImageGcLowThreshold: to.Int32Ptr(70), | ||
| TopologyManagerPolicy: "best-effort", | ||
| AllowedUnsafeSysctls: &[]string{"kernel.msg*", "net.ipv4.route.min_pmtu"}, | ||
| FailSwapOn: to.BoolPtr(false), | ||
| FailSwapOn: new(false), |
There was a problem hiding this comment.
new(false) / new("...") is not valid Go: the built-in new takes a type (e.g., new(bool)), not a value, so this will not compile. Use an explicit helper that returns a pointer to a value (e.g., ptrTo(false)), or keep using to.BoolPtr/to.StringPtr, or assign to a local variable and take its address.
| } | ||
| if customKc.PodMaxPids != nil { | ||
| kubeletConfig.PodPidsLimit = to.Int64Ptr(int64(*customKc.PodMaxPids)) | ||
| kubeletConfig.PodPidsLimit = new(int64(*customKc.PodMaxPids)) |
There was a problem hiding this comment.
This new(int64(*customKc.PodMaxPids)) call will not compile (built-in new takes a type, not a value). If the goal is to set PodPidsLimit to the converted value, create an int64 variable and take its address, or use a helper like ptrTo(int64(...)).
|
we were planning on making a PR to update AgentBakerService (internally) to go1.26 first, and then doing this, though now that I think about I believe that vendoring in this change via a new tag into AgentBakerService should automatically bump the go version anyways |
What this PR does / why we need it:
Updates go to 1.26
Which issue(s) this PR fixes:
Fixes #