Skip to content

fix: update go to 1.26 and run go fix#8010

Open
timmy-wright wants to merge 6 commits intomainfrom
timmy/update-go
Open

fix: update go to 1.26 and run go fix#8010
timmy-wright wants to merge 6 commits intomainfrom
timmy/update-go

Conversation

@timmy-wright
Copy link
Contributor

@timmy-wright timmy-wright commented Mar 4, 2026

What this PR does / why we need it:

Updates go to 1.26

Which issue(s) this PR fixes:

Fixes #

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 submodule go.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.Ptr usage 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.).

Comment on lines 51 to 64
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),
}
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(...).

Copilot uses AI. Check for mistakes.
for {
pager := config.Azure.VMSSVM.NewListPager(*s.Runtime.Cluster.Model.Properties.NodeResourceGroup, s.Runtime.VMSSName, &armcompute.VirtualMachineScaleSetVMsClientListOptions{
Expand: to.Ptr("instanceView"),
Expand: new("instanceView"),
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
Expand: new("instanceView"),
Expand: to.Ptr("instanceView"),

Copilot uses AI. Check for mistakes.
Comment on lines 550 to 552
if customKc.PodMaxPids != nil {
kubeletConfig.PodPidsLimit = to.Int64Ptr(int64(*customKc.PodMaxPids))
kubeletConfig.PodPidsLimit = new(int64(*customKc.PodMaxPids))
}
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 47 out of 47 changed files in this pull request and generated 6 comments.

Comment on lines +212 to +216
Mode: new(0o600),
Overwrite: new(true),
Contents: base0_5.Resource{
Source: to.StringPtr(dataURL),
Compression: to.StringPtr(encodingGZIP),
Source: new(dataURL),
Compression: new(encodingGZIP),
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 49 to 63
@@ -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))
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +43 to 46
func loadJSONFromFile(path string, v any) error {
//nolint: gosec
configFile, err := os.Open(path)
if err != nil {
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// 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.

Copilot uses AI. Check for mistakes.
type ServicePrincipalProfile struct {
ClientID string `json:"clientId"`
Secret string `json:"secret,omitempty" conform:"redact"`
Secret string `json:"secret,omitempty" conform:"redact"` //nolint: gosec
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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").

Copilot uses AI. Check for mistakes.
Comment on lines +53 to +59
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),
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
}
if customKc.PodMaxPids != nil {
kubeletConfig.PodPidsLimit = to.Int64Ptr(int64(*customKc.PodMaxPids))
kubeletConfig.PodPidsLimit = new(int64(*customKc.PodMaxPids))
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(...)).

Copilot uses AI. Check for mistakes.
@cameronmeissner
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants