diff --git a/.github/workflows/check-coverage.yml b/.github/workflows/check-coverage.yml index f577d55c5c9..4ba072500fe 100644 --- a/.github/workflows/check-coverage.yml +++ b/.github/workflows/check-coverage.yml @@ -14,7 +14,7 @@ jobs: if: success() uses: actions/setup-go@v6 with: - go-version: '1.24' + go-version: '1.26' - name: Checkout code uses: actions/checkout@v6 - name: Run unit tests diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index d34b70dbbff..a9dfb291498 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -30,7 +30,7 @@ jobs: - uses: actions/setup-go@v6 with: - go-version: '1.24' + go-version: '1.26' - run: | set -ex diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index 28fda49471d..7a0bef69472 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -8,7 +8,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: - go-version: '1.24' + go-version: '1.26' - run: | set -ex make test diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 88b91ce5249..10f45795b35 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -22,13 +22,13 @@ jobs: steps: - uses: actions/setup-go@v6 with: - go-version: '1.24' + go-version: '1.26' - uses: actions/checkout@v6 - name: golangci-lint uses: golangci/golangci-lint-action@v9 with: # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v2.8.0 + version: v2.10.1 working-directory: ${{ matrix.dirs }} # Optional: working directory, useful for monorepos diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index f20c43e935c..d1357a41ef5 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -8,7 +8,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: - go-version: '1.24' + go-version: '1.26' - run: | make validate-shell name: Lint shell/bash scripts with ShellCheck diff --git a/.github/workflows/shellspec.yaml b/.github/workflows/shellspec.yaml index 851a020ca67..e3fd34799d2 100644 --- a/.github/workflows/shellspec.yaml +++ b/.github/workflows/shellspec.yaml @@ -8,7 +8,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: - go-version: '1.24' + go-version: '1.26' - run: | make shellspec-ci name: Run shell/bash script unit tests with shellspec diff --git a/.github/workflows/validate-components.yml b/.github/workflows/validate-components.yml index 5a6be9dc683..726345e5dbf 100644 --- a/.github/workflows/validate-components.yml +++ b/.github/workflows/validate-components.yml @@ -9,7 +9,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: - go-version: '1.24' + go-version: '1.26' - name: Install cue run: | go version @@ -46,7 +46,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: - go-version: '1.24' + go-version: '1.26' - name: Run GPU managed components version consistency test working-directory: ./e2e run: | diff --git a/aks-node-controller/go.mod b/aks-node-controller/go.mod index 7daefb5c643..f54a54056ae 100644 --- a/aks-node-controller/go.mod +++ b/aks-node-controller/go.mod @@ -1,6 +1,6 @@ module github.com/Azure/agentbaker/aks-node-controller -go 1.24.12 +go 1.26.0 require ( github.com/Azure/agentbaker v0.20240503.0 diff --git a/aks-node-controller/parser/helper.go b/aks-node-controller/parser/helper.go index f5644dcda02..184271e0f9f 100644 --- a/aks-node-controller/parser/helper.go +++ b/aks-node-controller/parser/helper.go @@ -478,7 +478,7 @@ func createSortedKeyValuePairs[T any](m map[string]T, delimiter string) string { // we are sorting the keys for deterministic output for readability and testing. sort.Strings(keys) - var buf bytes.Buffer + buf := &bytes.Buffer{} i := 0 for _, key := range keys { i++ @@ -486,7 +486,7 @@ func createSortedKeyValuePairs[T any](m map[string]T, delimiter string) string { if i == len(keys) { delimiter = "" } - buf.WriteString(fmt.Sprintf("%s=%v%s", key, m[key], delimiter)) + fmt.Fprintf(buf, "%s=%v%s", key, m[key], delimiter) } return buf.String() } diff --git a/apiserver/getnodebootstrapdata.go b/apiserver/getnodebootstrapdata.go index 328fe9ddbd5..e21f1e7331e 100644 --- a/apiserver/getnodebootstrapdata.go +++ b/apiserver/getnodebootstrapdata.go @@ -46,6 +46,7 @@ func (api *APIServer) GetNodeBootstrapData(w http.ResponseWriter, r *http.Reques nodeBootStrapping, err := agentBaker.GetNodeBootstrapping(ctx, &config) if err != nil { + //nolint: gosec log.Println(err.Error()) http.Error(w, err.Error(), http.StatusBadRequest) return @@ -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)) } diff --git a/e2e/aks_model.go b/e2e/aks_model.go index 7498d92c0d1..b07b7bddb2b 100644 --- a/e2e/aks_model.go +++ b/e2e/aks_model.go @@ -78,7 +78,7 @@ func getLatestKubernetesVersionClusterModel(ctx context.Context, name, location, return nil, fmt.Errorf("failed to get latest GA Kubernetes version: %w", err) } model := getBaseClusterModel(name, location, k8sSystemPoolSKU) - model.Properties.KubernetesVersion = to.Ptr(version) + model.Properties.KubernetesVersion = new(version) return model, nil } @@ -104,15 +104,15 @@ func getAzureOverlayNetworkDualStackClusterModel(name, location, k8sSystemPoolSK } networkProfile := model.Properties.NetworkProfile - networkProfile.PodCidr = to.Ptr("10.244.0.0/16") + networkProfile.PodCidr = new("10.244.0.0/16") networkProfile.PodCidrs = []*string{ networkProfile.PodCidr, - to.Ptr("fd12:3456:789a::/64 "), + new("fd12:3456:789a::/64 "), } - networkProfile.ServiceCidr = to.Ptr("10.0.0.0/16") + networkProfile.ServiceCidr = new("10.0.0.0/16") networkProfile.ServiceCidrs = []*string{ networkProfile.ServiceCidr, - to.Ptr("fd12:3456:789a:1::/108"), + new("fd12:3456:789a:1::/108"), } networkProfile.PodCidr = nil @@ -148,15 +148,15 @@ func getCiliumNetworkClusterModel(name, location, k8sSystemPoolSKU string) *armc func getBaseClusterModel(clusterName, location, k8sSystemPoolSKU string) *armcontainerservice.ManagedCluster { return &armcontainerservice.ManagedCluster{ - Name: to.Ptr(clusterName), - Location: to.Ptr(location), + Name: new(clusterName), + Location: new(location), Properties: &armcontainerservice.ManagedClusterProperties{ - DNSPrefix: to.Ptr(clusterName), + DNSPrefix: new(clusterName), AgentPoolProfiles: []*armcontainerservice.ManagedClusterAgentPoolProfile{ { - Name: to.Ptr("nodepool1"), + Name: new("nodepool1"), Count: to.Ptr[int32](1), - VMSize: to.Ptr(k8sSystemPoolSKU), + VMSize: new(k8sSystemPoolSKU), MaxPods: to.Ptr[int32](110), OSType: to.Ptr(armcontainerservice.OSTypeLinux), Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets), @@ -173,15 +173,15 @@ func getBaseClusterModel(clusterName, location, k8sSystemPoolSKU string) *armcon }, AddonProfiles: map[string]*armcontainerservice.ManagedClusterAddonProfile{ "omsagent": { - Enabled: to.Ptr(false), + Enabled: new(false), }, }, LinuxProfile: &armcontainerservice.LinuxProfile{ - AdminUsername: to.Ptr("azureuser"), + AdminUsername: new("azureuser"), SSH: &armcontainerservice.SSHConfiguration{ PublicKeys: []*armcontainerservice.SSHPublicKey{ { - KeyData: to.Ptr(string(config.SysSSHPublicKey)), + KeyData: new(string(config.SysSSHPublicKey)), }, }, }, @@ -201,8 +201,8 @@ func getFirewall(ctx context.Context, location, firewallSubnetID, publicIPID str // Application rule for AKS FQDN tags aksAppRule := armnetwork.AzureFirewallApplicationRule{ - Name: to.Ptr("aks-fqdn"), - SourceAddresses: []*string{to.Ptr("*")}, + Name: new("aks-fqdn"), + SourceAddresses: []*string{new("*")}, Protocols: []*armnetwork.AzureFirewallApplicationRuleProtocol{ { ProtocolType: to.Ptr(armnetwork.AzureFirewallApplicationRuleProtocolTypeHTTP), @@ -213,55 +213,55 @@ func getFirewall(ctx context.Context, location, firewallSubnetID, publicIPID str Port: to.Ptr[int32](443), }, }, - FqdnTags: []*string{to.Ptr("AzureKubernetesService")}, + FqdnTags: []*string{new("AzureKubernetesService")}, } // needed for scriptless e2e hack blobStorageFqdn := config.Config.BlobStorageAccount() + ".blob.core.windows.net" blobStorageAppRule := armnetwork.AzureFirewallApplicationRule{ - Name: to.Ptr("blob-storage-fqdn"), - SourceAddresses: []*string{to.Ptr("*")}, + Name: new("blob-storage-fqdn"), + SourceAddresses: []*string{new("*")}, Protocols: []*armnetwork.AzureFirewallApplicationRuleProtocol{ { ProtocolType: to.Ptr(armnetwork.AzureFirewallApplicationRuleProtocolTypeHTTPS), Port: to.Ptr[int32](443), }, }, - TargetFqdns: []*string{to.Ptr(blobStorageFqdn)}, + TargetFqdns: []*string{new(blobStorageFqdn)}, } // needed for Mock Azure China Cloud tests mooncakeMAR := "mcr.azure.cn" mooncakeMARData := "*.data.mcr.azure.cn" mooncakeMARRule := armnetwork.AzureFirewallApplicationRule{ - Name: to.Ptr("mooncake-mar-fqdn"), - SourceAddresses: []*string{to.Ptr("*")}, + Name: new("mooncake-mar-fqdn"), + SourceAddresses: []*string{new("*")}, Protocols: []*armnetwork.AzureFirewallApplicationRuleProtocol{ { ProtocolType: to.Ptr(armnetwork.AzureFirewallApplicationRuleProtocolTypeHTTPS), Port: to.Ptr[int32](443), }, }, - TargetFqdns: []*string{to.Ptr(mooncakeMAR), to.Ptr(mooncakeMARData)}, + TargetFqdns: []*string{new(mooncakeMAR), new(mooncakeMARData)}, } // Needed for access to download.microsoft.com // This is currently only needed by the Supernova (MA35D) SKU GPU tests // Driver install code in setupAmdAma() depends on this dmcRule := armnetwork.AzureFirewallApplicationRule{ - Name: to.Ptr("dmc-fqdn"), - SourceAddresses: []*string{to.Ptr("*")}, + Name: new("dmc-fqdn"), + SourceAddresses: []*string{new("*")}, Protocols: []*armnetwork.AzureFirewallApplicationRuleProtocol{ { ProtocolType: to.Ptr(armnetwork.AzureFirewallApplicationRuleProtocolTypeHTTPS), Port: to.Ptr[int32](443), }, }, - TargetFqdns: []*string{to.Ptr("download.microsoft.com")}, + TargetFqdns: []*string{new("download.microsoft.com")}, } appRuleCollection := armnetwork.AzureFirewallApplicationRuleCollection{ - Name: to.Ptr("aksfwar"), + Name: new("aksfwar"), Properties: &armnetwork.AzureFirewallApplicationRuleCollectionPropertiesFormat{ Priority: to.Ptr[int32](100), Action: &armnetwork.AzureFirewallRCAction{ @@ -273,13 +273,13 @@ func getFirewall(ctx context.Context, location, firewallSubnetID, publicIPID str ipConfigurations := []*armnetwork.AzureFirewallIPConfiguration{ { - Name: to.Ptr("firewall-ip-config"), + Name: new("firewall-ip-config"), Properties: &armnetwork.AzureFirewallIPConfigurationPropertiesFormat{ Subnet: &armnetwork.SubResource{ - ID: to.Ptr(firewallSubnetID), + ID: new(firewallSubnetID), }, PublicIPAddress: &armnetwork.SubResource{ - ID: to.Ptr(publicIPID), + ID: new(publicIPID), }, }, }, @@ -287,7 +287,7 @@ func getFirewall(ctx context.Context, location, firewallSubnetID, publicIPID str toolkit.Logf(ctx, "Firewall rules configured successfully") return &armnetwork.AzureFirewall{ - Location: to.Ptr(location), + Location: new(location), Properties: &armnetwork.AzureFirewallPropertiesFormat{ ApplicationRuleCollections: []*armnetwork.AzureFirewallApplicationRuleCollection{&appRuleCollection}, NetworkRuleCollections: netRuleCollections, @@ -323,7 +323,7 @@ func addFirewallRules( firewallSubnetName := "AzureFirewallSubnet" firewallSubnetParams := armnetwork.Subnet{ Properties: &armnetwork.SubnetPropertiesFormat{ - AddressPrefix: to.Ptr("10.225.0.0/24"), // Use a different CIDR that doesn't overlap with 10.224.0.0/16 + AddressPrefix: new("10.225.0.0/24"), // Use a different CIDR that doesn't overlap with 10.224.0.0/16 }, } @@ -351,7 +351,7 @@ func addFirewallRules( // Create public IP for the firewall publicIPName := "abe2e-fw-pip" publicIPParams := armnetwork.PublicIPAddress{ - Location: to.Ptr(location), + Location: new(location), SKU: &armnetwork.PublicIPAddressSKU{ Name: to.Ptr(armnetwork.PublicIPAddressSKUNameStandard), }, @@ -405,28 +405,28 @@ func addFirewallRules( } routeTableParams := armnetwork.RouteTable{ - Location: to.Ptr(location), + Location: new(location), Properties: &armnetwork.RouteTablePropertiesFormat{ Routes: []*armnetwork.Route{ // Allow internal VNet traffic to bypass the firewall { - Name: to.Ptr("vnet-local"), + Name: new("vnet-local"), Properties: &armnetwork.RoutePropertiesFormat{ - AddressPrefix: to.Ptr("10.224.0.0/16"), // AKS subnet CIDR + AddressPrefix: new("10.224.0.0/16"), // AKS subnet CIDR NextHopType: to.Ptr(armnetwork.RouteNextHopTypeVnetLocal), }, }, // Route all other traffic (internet-bound) through the firewall { - Name: to.Ptr("default-route-to-firewall"), + Name: new("default-route-to-firewall"), Properties: &armnetwork.RoutePropertiesFormat{ - AddressPrefix: to.Ptr("0.0.0.0/0"), + AddressPrefix: new("0.0.0.0/0"), NextHopType: to.Ptr(armnetwork.RouteNextHopTypeVirtualAppliance), - NextHopIPAddress: to.Ptr(firewallPrivateIP), + NextHopIPAddress: new(firewallPrivateIP), }, }, }, - DisableBgpRoutePropagation: to.Ptr(true), + DisableBgpRoutePropagation: new(true), }, } @@ -534,9 +534,9 @@ func addNetworkIsolatedSettings(ctx context.Context, clusterModel *armcontainers } subnetParameters := armnetwork.Subnet{ - ID: to.Ptr(subnetId), + ID: new(subnetId), Properties: &armnetwork.SubnetPropertiesFormat{ - AddressPrefix: to.Ptr("10.224.0.0/16"), + AddressPrefix: new("10.224.0.0/16"), NetworkSecurityGroup: &armnetwork.SecurityGroup{ ID: nsg.ID, }, @@ -557,29 +557,29 @@ func networkIsolatedSecurityGroup(location, clusterFQDN string) (armnetwork.Secu } allowVnet := &armnetwork.SecurityRule{ - Name: to.Ptr("AllowVnetOutBound"), + Name: new("AllowVnetOutBound"), Properties: &armnetwork.SecurityRulePropertiesFormat{ Protocol: to.Ptr(armnetwork.SecurityRuleProtocolAsterisk), Access: to.Ptr(armnetwork.SecurityRuleAccessAllow), Direction: to.Ptr(armnetwork.SecurityRuleDirectionOutbound), - SourceAddressPrefix: to.Ptr("VirtualNetwork"), - SourcePortRange: to.Ptr("*"), - DestinationAddressPrefix: to.Ptr("VirtualNetwork"), - DestinationPortRange: to.Ptr("*"), + SourceAddressPrefix: new("VirtualNetwork"), + SourcePortRange: new("*"), + DestinationAddressPrefix: new("VirtualNetwork"), + DestinationPortRange: new("*"), Priority: to.Ptr[int32](2000), }, } blockOutbound := &armnetwork.SecurityRule{ - Name: to.Ptr("block-all-outbound"), + Name: new("block-all-outbound"), Properties: &armnetwork.SecurityRulePropertiesFormat{ Protocol: to.Ptr(armnetwork.SecurityRuleProtocolAsterisk), Access: to.Ptr(armnetwork.SecurityRuleAccessDeny), Direction: to.Ptr(armnetwork.SecurityRuleDirectionOutbound), - SourceAddressPrefix: to.Ptr("*"), - SourcePortRange: to.Ptr("*"), - DestinationAddressPrefix: to.Ptr("*"), - DestinationPortRange: to.Ptr("*"), + SourceAddressPrefix: new("*"), + SourcePortRange: new("*"), + DestinationAddressPrefix: new("*"), + DestinationPortRange: new("*"), Priority: to.Ptr[int32](2001), }, } @@ -677,13 +677,13 @@ func createPrivateAzureContainerRegistry(ctx context.Context, cluster *armcontai toolkit.Logf(ctx, "ACR does not exist, creating...") createParams := armcontainerregistry.Registry{ - Location: to.Ptr(*cluster.Location), + Location: new(*cluster.Location), SKU: &armcontainerregistry.SKU{ Name: to.Ptr(armcontainerregistry.SKUNamePremium), }, Properties: &armcontainerregistry.RegistryProperties{ - AdminUserEnabled: to.Ptr(isNonAnonymousPull), // if non-anonymous pull is enabled, admin user must be enabled to be able to set credentials for the debug pods - AnonymousPullEnabled: to.Ptr(!isNonAnonymousPull), // required to pull images from the private ACR without authentication + AdminUserEnabled: new(isNonAnonymousPull), // if non-anonymous pull is enabled, admin user must be enabled to be able to set credentials for the debug pods + AnonymousPullEnabled: new(!isNonAnonymousPull), // required to pull images from the private ACR without authentication }, } pollerResp, err := config.Azure.RegistriesClient.BeginCreate( @@ -782,8 +782,8 @@ func addCacheRulesToPrivateAzureContainerRegistry(ctx context.Context, resourceG cacheParams := armcontainerregistry.CacheRule{ Properties: &armcontainerregistry.CacheRuleProperties{ - SourceRepository: to.Ptr("mcr.microsoft.com/*"), - TargetRepository: to.Ptr(config.Config.AzureContainerRegistrytargetRepository), + SourceRepository: new("mcr.microsoft.com/*"), + TargetRepository: new(config.Config.AzureContainerRegistrytargetRepository), }, } cacheCreateResp, err := config.Azure.CacheRulesClient.BeginCreate( @@ -819,17 +819,17 @@ func createPrivateEndpoint(ctx context.Context, nodeResourceGroup, privateEndpoi acrID := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerRegistry/registries/%s", config.Config.SubscriptionID, config.ResourceGroupName(location), privateACRName) peParams := armnetwork.PrivateEndpoint{ - Location: to.Ptr(location), + Location: new(location), Properties: &armnetwork.PrivateEndpointProperties{ Subnet: &armnetwork.Subnet{ - ID: to.Ptr(vnet.subnetId), + ID: new(vnet.subnetId), }, PrivateLinkServiceConnections: []*armnetwork.PrivateLinkServiceConnection{ { - Name: to.Ptr(privateEndpointName), + Name: new(privateEndpointName), Properties: &armnetwork.PrivateLinkServiceConnectionProperties{ - PrivateLinkServiceID: to.Ptr(acrID), - GroupIDs: []*string{to.Ptr("registry")}, + PrivateLinkServiceID: new(acrID), + GroupIDs: []*string{new("registry")}, }, }, }, @@ -866,7 +866,7 @@ func createPrivateZone(ctx context.Context, nodeResourceGroup, privateZoneName s return &pzResp.PrivateZone, nil } dnsZoneParams := armprivatedns.PrivateZone{ - Location: to.Ptr("global"), + Location: new("global"), } poller, err := config.Azure.PrivateZonesClient.BeginCreateOrUpdate( ctx, @@ -907,12 +907,12 @@ func createPrivateDNSLink(ctx context.Context, vnet VNet, nodeResourceGroup, pri return fmt.Errorf("failed to get vnet: %w", err) } linkParams := armprivatedns.VirtualNetworkLink{ - Location: to.Ptr("global"), + Location: new("global"), Properties: &armprivatedns.VirtualNetworkLinkProperties{ VirtualNetwork: &armprivatedns.SubResource{ ID: vnetForId.ID, }, - RegistrationEnabled: to.Ptr(false), + RegistrationEnabled: new(false), }, } poller, err := config.Azure.VirutalNetworkLinksClient.BeginCreateOrUpdate( @@ -982,10 +982,10 @@ func addDNSZoneGroup(ctx context.Context, privateZone *armprivatedns.PrivateZone return nil } dnsZonegroup := armnetwork.PrivateDNSZoneGroup{ - Name: to.Ptr(fmt.Sprintf("%s/default", privateZoneName)), + Name: new(fmt.Sprintf("%s/default", privateZoneName)), Properties: &armnetwork.PrivateDNSZoneGroupPropertiesFormat{ PrivateDNSZoneConfigs: []*armnetwork.PrivateDNSZoneConfig{{ - Name: to.Ptr(groupName), + Name: new(groupName), Properties: &armnetwork.PrivateDNSZonePropertiesFormat{ PrivateDNSZoneID: privateZone.ID, }, @@ -1034,16 +1034,16 @@ func getRequiredSecurityRules(clusterFQDN string) ([]*armnetwork.SecurityRule, e func getSecurityRule(name, destinationAddressPrefix string, priority int32) *armnetwork.SecurityRule { return &armnetwork.SecurityRule{ - Name: to.Ptr(name), + Name: new(name), Properties: &armnetwork.SecurityRulePropertiesFormat{ Protocol: to.Ptr(armnetwork.SecurityRuleProtocolAsterisk), Access: to.Ptr(armnetwork.SecurityRuleAccessAllow), Direction: to.Ptr(armnetwork.SecurityRuleDirectionOutbound), - SourceAddressPrefix: to.Ptr("*"), - SourcePortRange: to.Ptr("*"), - DestinationAddressPrefix: to.Ptr(destinationAddressPrefix), - DestinationPortRange: to.Ptr("*"), - Priority: to.Ptr(priority), + SourceAddressPrefix: new("*"), + SourcePortRange: new("*"), + DestinationAddressPrefix: new(destinationAddressPrefix), + DestinationPortRange: new("*"), + Priority: new(priority), }, } } diff --git a/e2e/cache.go b/e2e/cache.go index cfa45122af7..4cba0db1d60 100644 --- a/e2e/cache.go +++ b/e2e/cache.go @@ -60,9 +60,9 @@ func createGallery(ctx context.Context, request CreateGalleryRequest) (armcomput } // If the gallery does not exist, create it. poller, err := config.Azure.Galleries.BeginCreateOrUpdate(ctx, request.ResourceGroup, galleryName, armcompute.Gallery{ - Location: to.Ptr(request.Location), + Location: new(request.Location), Properties: &armcompute.GalleryProperties{ - Description: to.Ptr("E2E test gallery for two-stage kubelet configuration"), + Description: new("E2E test gallery for two-stage kubelet configuration"), }, }, nil) if err != nil { @@ -102,7 +102,7 @@ func createGalleryImage(ctx context.Context, request CreateGalleryImageRequest) return armcompute.GalleryImage{}, fmt.Errorf("failed to get gallery image: %w", err) } poller, err := config.Azure.GalleryImages.BeginCreateOrUpdate(ctx, request.ResourceGroup, request.GalleryName, imageName, armcompute.GalleryImage{ - Location: to.Ptr(request.Location), + Location: new(request.Location), Properties: &armcompute.GalleryImageProperties{ Architecture: func() *armcompute.Architecture { if request.Arch == "arm64" { @@ -119,9 +119,9 @@ func createGalleryImage(ctx context.Context, request CreateGalleryImageRequest) OSState: to.Ptr(armcompute.OperatingSystemStateTypesGeneralized), Identifier: &armcompute.GalleryImageIdentifier{ // Combination of these 3 fields must be unique for each image - Publisher: to.Ptr("akse2e"), - Offer: to.Ptr("akse2e"), - SKU: to.Ptr(imageName), + Publisher: new("akse2e"), + Offer: new("akse2e"), + SKU: new(imageName), }, HyperVGeneration: request.HyperVGeneration, // IMPORTANT, INCORRECT VALUE CAUSES VM PROVISIONING TO FAIL WITHOUT CLEAR ERROR MESSAGE }, diff --git a/e2e/cluster.go b/e2e/cluster.go index 589371e2d2b..1aa3e0e3db3 100644 --- a/e2e/cluster.go +++ b/e2e/cluster.go @@ -63,7 +63,7 @@ func prepareCluster(ctx context.Context, cluster *armcontainerservice.ManagedClu defer toolkit.LogStepCtx(ctx, "preparing cluster")() ctx, cancel := context.WithTimeout(ctx, config.Config.TestTimeoutCluster) defer cancel() - cluster.Name = to.Ptr(fmt.Sprintf("%s-%s", *cluster.Name, hash(cluster))) + cluster.Name = new(fmt.Sprintf("%s-%s", *cluster.Name, hash(cluster))) cluster, err := getOrCreateCluster(ctx, cluster) if err != nil { return nil, fmt.Errorf("get or create cluster: %w", err) @@ -179,9 +179,9 @@ func assignACRPullToIdentity(ctx context.Context, privateACRName, principalID st uid := uuid.New().String() _, err := config.Azure.RoleAssignments.Create(ctx, scope, uid, armauthorization.RoleAssignmentCreateParameters{ Properties: &armauthorization.RoleAssignmentProperties{ - PrincipalID: to.Ptr(principalID), + PrincipalID: new(principalID), // ACR-Pull role definition ID - RoleDefinitionID: to.Ptr("/providers/Microsoft.Authorization/roleDefinitions/7f951dda-4ed3-4680-a7ca-43fe172d538d"), + RoleDefinitionID: new("/providers/Microsoft.Authorization/roleDefinitions/7f951dda-4ed3-4680-a7ca-43fe172d538d"), PrincipalType: to.Ptr(armauthorization.PrincipalTypeServicePrincipal), }, }, nil) @@ -392,7 +392,7 @@ func createNewAKSClusterWithRetry(ctx context.Context, cluster *armcontainerserv maxRetries := 10 retryInterval := 30 * time.Second var lastErr error - for attempt := 0; attempt < maxRetries; attempt++ { + for attempt := range maxRetries { if attempt > 0 { toolkit.Logf(ctx, "Attempt %d: creating or updating cluster %s in region %s and rg %s", attempt+1, *cluster.Name, *cluster.Location, config.ResourceGroupName(*cluster.Location)) } @@ -442,12 +442,12 @@ func createNewMaintenanceConfiguration(ctx context.Context, cluster *armcontaine MaintenanceWindow: &armcontainerservice.MaintenanceWindow{ NotAllowedDates: []*armcontainerservice.DateSpan{ // no maintenance till 2100 { - End: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2100-01-01"); return t }()), - Start: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2000-01-01"); return t }()), + End: new(func() time.Time { t, _ := time.Parse("2006-01-02", "2100-01-01"); return t }()), + Start: new(func() time.Time { t, _ := time.Parse("2006-01-02", "2000-01-01"); return t }()), }}, DurationHours: to.Ptr[int32](4), - StartTime: to.Ptr("00:00"), //PST - UTCOffset: to.Ptr("+08:00"), //PST + StartTime: new("00:00"), //PST + UTCOffset: new("+08:00"), //PST Schedule: &armcontainerservice.Schedule{ Weekly: &armcontainerservice.WeeklySchedule{ DayOfWeek: to.Ptr(armcontainerservice.WeekDayMonday), @@ -514,7 +514,7 @@ func createNewBastion(ctx context.Context, cluster *armcontainerservice.ManagedC toolkit.Logf(ctx, "creating subnet %s in VNet %s (rg %s)", bastionSubnetName, vnet.name, nodeRG) subnetParams := armnetwork.Subnet{ Properties: &armnetwork.SubnetPropertiesFormat{ - AddressPrefix: to.Ptr(bastionSubnetPrefix), + AddressPrefix: new(bastionSubnetPrefix), }, } subnetPoller, err := config.Azure.Subnet.BeginCreateOrUpdate(ctx, nodeRG, vnet.name, bastionSubnetName, subnetParams, nil) @@ -532,7 +532,7 @@ func createNewBastion(ctx context.Context, cluster *armcontainerservice.ManagedC // Public IP for Bastion pipParams := armnetwork.PublicIPAddress{ - Location: to.Ptr(location), + Location: new(location), SKU: &armnetwork.PublicIPAddressSKU{ Name: to.Ptr(armnetwork.PublicIPAddressSKUNameStandard), }, @@ -555,19 +555,19 @@ func createNewBastion(ctx context.Context, cluster *armcontainerservice.ManagedC } bastionHost := armnetwork.BastionHost{ - Location: to.Ptr(location), + Location: new(location), SKU: &armnetwork.SKU{ Name: to.Ptr(armnetwork.BastionHostSKUNameStandard), }, Properties: &armnetwork.BastionHostPropertiesFormat{ // Native client support is enabled via tunneling. - EnableTunneling: to.Ptr(true), + EnableTunneling: new(true), IPConfigurations: []*armnetwork.BastionHostIPConfiguration{ { - Name: to.Ptr("bastion-ipcfg"), + Name: new("bastion-ipcfg"), Properties: &armnetwork.BastionHostIPConfigurationPropertiesFormat{ Subnet: &armnetwork.SubResource{ - ID: to.Ptr(bastionSubnetID), + ID: new(bastionSubnetID), }, PublicIPAddress: &armnetwork.SubResource{ ID: pipResp.ID, @@ -719,7 +719,7 @@ func collectGarbageVMSS(ctx context.Context, cluster *armcontainerservice.Manage } _, err := config.Azure.VMSS.BeginDelete(ctx, rg, *vmss.Name, &armcompute.VirtualMachineScaleSetsClientBeginDeleteOptions{ - ForceDeletion: to.Ptr(true), + ForceDeletion: new(true), }) if err != nil { toolkit.Logf(ctx, "failed to delete vmss %q: %s", *vmss.Name, err) @@ -738,8 +738,8 @@ func ensureResourceGroup(ctx context.Context, location string) (armresources.Res ctx, resourceGroupName, armresources.ResourceGroup{ - Location: to.Ptr(location), - Name: to.Ptr(resourceGroupName), + Location: new(location), + Name: new(resourceGroupName), }, nil) diff --git a/e2e/config/azure.go b/e2e/config/azure.go index e003a87754c..4d9030553aa 100644 --- a/e2e/config/azure.go +++ b/e2e/config/azure.go @@ -366,8 +366,8 @@ func (a *AzureClient) UploadAndGetSignedLink(ctx context.Context, blobName strin } udc, err := a.Blob.ServiceClient().GetUserDelegationCredential(ctx, service.KeyInfo{ - Expiry: to.Ptr(time.Now().Add(time.Hour).UTC().Format(sas.TimeFormat)), - Start: to.Ptr(time.Now().UTC().Format(sas.TimeFormat)), + Expiry: new(time.Now().Add(time.Hour).UTC().Format(sas.TimeFormat)), + Start: new(time.Now().UTC().Format(sas.TimeFormat)), }, nil) if err != nil { return "", fmt.Errorf("get user delegation credential: %w", err) @@ -376,7 +376,7 @@ func (a *AzureClient) UploadAndGetSignedLink(ctx context.Context, blobName strin sig, err := sas.BlobSignatureValues{ Protocol: sas.ProtocolHTTPS, ExpiryTime: time.Now().Add(time.Hour).UTC(), - Permissions: to.Ptr(sas.BlobPermissions{Read: true}).String(), + Permissions: new(sas.BlobPermissions{Read: true}).String(), ContainerName: Config.BlobContainer, BlobName: blobName, }.SignWithUserDelegation(udc) @@ -389,7 +389,7 @@ func (a *AzureClient) UploadAndGetSignedLink(ctx context.Context, blobName strin func (a *AzureClient) CreateVMManagedIdentity(ctx context.Context, identityLocation string) (string, error) { identity, err := a.UserAssignedIdentities.CreateOrUpdate(ctx, ResourceGroupName(identityLocation), VMIdentityName, armmsi.Identity{ - Location: to.Ptr(identityLocation), + Location: new(identityLocation), }, nil) if err != nil { return "", fmt.Errorf("create managed identity: %w", err) @@ -415,13 +415,13 @@ func (a *AzureClient) CreateVMManagedIdentity(ctx context.Context, identityLocat func (a *AzureClient) createBlobStorageAccount(ctx context.Context) error { poller, err := a.StorageAccounts.BeginCreate(ctx, ResourceGroupName(Config.DefaultLocation), Config.BlobStorageAccount(), armstorage.AccountCreateParameters{ Kind: to.Ptr(armstorage.KindStorageV2), - Location: to.Ptr(Config.DefaultLocation), + Location: new(Config.DefaultLocation), SKU: &armstorage.SKU{ Name: to.Ptr(armstorage.SKUNameStandardLRS), }, Properties: &armstorage.AccountPropertiesCreateParameters{ - AllowBlobPublicAccess: to.Ptr(false), - AllowSharedKeyAccess: to.Ptr(false), + AllowBlobPublicAccess: new(false), + AllowSharedKeyAccess: new(false), }, }, nil) if err != nil { @@ -451,7 +451,7 @@ func (a *AzureClient) assignRolesToVMIdentity(ctx context.Context, principalID * PrincipalID: principalID, // built-in "Storage Blob Data Contributor" role // https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles - RoleDefinitionID: to.Ptr("/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe"), + RoleDefinitionID: new("/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe"), }, }, nil) var respError *azcore.ResponseError diff --git a/e2e/config/config.go b/e2e/config/config.go index 02cf274cdc9..5b042d4103b 100644 --- a/e2e/config/config.go +++ b/e2e/config/config.go @@ -114,7 +114,7 @@ func (c *Configuration) GalleryResourceID() string { func (c *Configuration) String() string { data := make([]string, 0) v := reflect.ValueOf(c) - if v.Kind() == reflect.Ptr { + if v.Kind() == reflect.Pointer { v = v.Elem() } t := v.Type() @@ -179,7 +179,7 @@ func mustGetNewRSAKeyPair() ([]byte, []byte, string) { privateKeyFileName, err := writePrivateKeyToTempFile(privatePEMBytes) if err != nil { - panic(fmt.Sprintf("failed to write private key to temp file: %w", err)) + panic(fmt.Errorf("failed to write private key to temp file: %w", err).Error()) } return privatePEMBytes, publicKeyBytes, privateKeyFileName diff --git a/e2e/exec.go b/e2e/exec.go index 5e5254ea4ff..7af8ed26394 100644 --- a/e2e/exec.go +++ b/e2e/exec.go @@ -195,7 +195,7 @@ func execOnPod(ctx context.Context, kube *Kubeclient, namespace, podName string, maxRetries := 3 retryDelay := 1 * time.Second - for attempt := 0; attempt < maxRetries; attempt++ { + for attempt := range maxRetries { result, err := attemptExecOnPod(ctx, kube, namespace, podName, command) if err == nil { return result, nil diff --git a/e2e/go.mod b/e2e/go.mod index 14844009b7a..b4a0d0e4b79 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -1,6 +1,6 @@ module github.com/Azure/agentbaker/e2e -go 1.24.12 +go 1.26.0 require ( github.com/Azure/agentbaker v0.20240503.0 diff --git a/e2e/kube.go b/e2e/kube.go index 3b551f6f370..48e351c3f15 100644 --- a/e2e/kube.go +++ b/e2e/kube.go @@ -11,7 +11,6 @@ import ( "github.com/Azure/agentbaker/e2e/config" "github.com/Azure/agentbaker/e2e/toolkit" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -110,7 +109,7 @@ func (k *Kubeclient) WaitUntilPodRunningWithRetry(ctx context.Context, namespace if maxRetries <= 0 { return false, sandboxErr } - k.Typed.CoreV1().Pods(pod.Namespace).Delete(ctx, pod.Name, metav1.DeleteOptions{GracePeriodSeconds: to.Ptr(int64(0))}) + k.Typed.CoreV1().Pods(pod.Namespace).Delete(ctx, pod.Name, metav1.DeleteOptions{GracePeriodSeconds: new(int64(0))}) return false, nil // Keep polling } } @@ -209,7 +208,7 @@ func logPodDebugInfo(ctx context.Context, kube *Kubeclient, pod *corev1.Pod) { if pod == nil { return } - logs, _ := kube.Typed.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &corev1.PodLogOptions{TailLines: to.Ptr(int64(5))}).DoRaw(ctx) + logs, _ := kube.Typed.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &corev1.PodLogOptions{TailLines: new(int64(5))}).DoRaw(ctx) type Condition struct { Reason string Message string @@ -328,7 +327,7 @@ func (k *Kubeclient) createKubernetesSecret(ctx context.Context, namespace, secr return fmt.Errorf("create Kubernetes client: %w", err) } - auth := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", username, password))) + auth := base64.StdEncoding.EncodeToString(fmt.Appendf(nil, "%s:%s", username, password)) dockerConfigJSON := fmt.Sprintf(`{ "auths": { "%s.azurecr.io": { @@ -413,7 +412,7 @@ func daemonsetDebug(ctx context.Context, deploymentName, targetNodeLabel, privat Name: "mariner", Command: []string{"sleep", "infinity"}, SecurityContext: &corev1.SecurityContext{ - Privileged: to.Ptr(true), + Privileged: new(true), Capabilities: &corev1.Capabilities{ Add: []corev1.Capability{"SYS_PTRACE", "SYS_RAWIO"}, }, diff --git a/e2e/node_config.go b/e2e/node_config.go index e70e95e19e5..c7d25451716 100644 --- a/e2e/node_config.go +++ b/e2e/node_config.go @@ -62,18 +62,18 @@ func baseKubeletConfig() *aksnodeconfigv1.KubeletConfig { Authorization: &aksnodeconfigv1.KubeletAuthorization{ Mode: "Webhook", }, - EventRecordQps: to.Ptr(int32(0)), + EventRecordQps: new(int32(0)), ClusterDomain: "cluster.local", ClusterDns: []string{ "10.0.0.10", }, StreamingConnectionIdleTimeout: "4h", NodeStatusUpdateFrequency: "10s", - ImageGcHighThresholdPercent: to.Ptr(int32(85)), - ImageGcLowThresholdPercent: to.Ptr(int32(80)), - CgroupsPerQos: to.Ptr(true), - MaxPods: to.Ptr(int32(110)), - PodPidsLimit: to.Ptr(int32(-1)), + ImageGcHighThresholdPercent: new(int32(85)), + ImageGcLowThresholdPercent: new(int32(80)), + CgroupsPerQos: new(true), + MaxPods: new(int32(110)), + PodPidsLimit: new(int32(-1)), ResolvConf: "/run/systemd/resolve/resolv.conf", EvictionHard: map[string]string{ "memory.available": "750Mi", @@ -82,7 +82,7 @@ func baseKubeletConfig() *aksnodeconfigv1.KubeletConfig { }, ProtectKernelDefaults: true, FeatureGates: map[string]bool{}, - FailSwapOn: to.Ptr(false), + FailSwapOn: new(false), KubeReserved: map[string]string{ "cpu": "100m", "memory": "1638Mi", @@ -150,10 +150,10 @@ func nbcToAKSNodeConfigV1(nbc *datamodel.NodeBootstrappingConfiguration) *aksnod bootstrappingConfig := &aksnodeconfigv1.BootstrappingConfig{ TlsBootstrappingToken: nbc.KubeletClientTLSBootstrapToken, - SecureTlsBootstrappingDeadline: to.Ptr(nbc.SecureTLSBootstrappingConfig.GetDeadline()), - SecureTlsBootstrappingAadResource: to.Ptr(nbc.SecureTLSBootstrappingConfig.GetAADResource()), - SecureTlsBootstrappingUserAssignedIdentityId: to.Ptr(nbc.SecureTLSBootstrappingConfig.GetUserAssignedIdentityID()), - SecureTlsBootstrappingCustomClientDownloadUrl: to.Ptr(nbc.SecureTLSBootstrappingConfig.GetCustomClientDownloadURL()), + SecureTlsBootstrappingDeadline: new(nbc.SecureTLSBootstrappingConfig.GetDeadline()), + SecureTlsBootstrappingAadResource: new(nbc.SecureTLSBootstrappingConfig.GetAADResource()), + SecureTlsBootstrappingUserAssignedIdentityId: new(nbc.SecureTLSBootstrappingConfig.GetUserAssignedIdentityID()), + SecureTlsBootstrappingCustomClientDownloadUrl: new(nbc.SecureTLSBootstrappingConfig.GetCustomClientDownloadURL()), } if nbc.SecureTLSBootstrappingConfig.GetEnabled() { bootstrappingConfig.BootstrappingAuthMethod = aksnodeconfigv1.BootstrappingAuthMethod_BOOTSTRAPPING_AUTH_METHOD_SECURE_TLS_BOOTSTRAPPING @@ -214,17 +214,17 @@ func nbcToAKSNodeConfigV1(nbc *datamodel.NodeBootstrappingConfiguration) *aksnod }, LocalDnsProfile: &aksnodeconfigv1.LocalDnsProfile{ EnableLocalDns: true, - CpuLimitInMilliCores: to.Ptr(int32(2008)), - MemoryLimitInMb: to.Ptr(int32(256)), + CpuLimitInMilliCores: new(int32(2008)), + MemoryLimitInMb: new(int32(256)), VnetDnsOverrides: map[string]*aksnodeconfigv1.LocalDnsOverrides{ ".": { QueryLogging: "Log", Protocol: "PreferUDP", ForwardDestination: "VnetDNS", ForwardPolicy: "Sequential", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Immediate", }, "cluster.local": { @@ -232,9 +232,9 @@ func nbcToAKSNodeConfigV1(nbc *datamodel.NodeBootstrappingConfiguration) *aksnod Protocol: "ForceTCP", ForwardDestination: "ClusterCoreDNS", ForwardPolicy: "RoundRobin", - MaxConcurrent: to.Ptr(int32(3000)), - CacheDurationInSeconds: to.Ptr(int32(7200)), - ServeStaleDurationInSeconds: to.Ptr(int32(4500)), + MaxConcurrent: new(int32(3000)), + CacheDurationInSeconds: new(int32(7200)), + ServeStaleDurationInSeconds: new(int32(4500)), ServeStale: "Disable", }, "testdomain456.com": { @@ -242,9 +242,9 @@ func nbcToAKSNodeConfigV1(nbc *datamodel.NodeBootstrappingConfiguration) *aksnod Protocol: "PreferUDP", ForwardDestination: "VnetDNS", ForwardPolicy: "Random", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Verify", }, }, @@ -254,9 +254,9 @@ func nbcToAKSNodeConfigV1(nbc *datamodel.NodeBootstrappingConfiguration) *aksnod Protocol: "PreferUDP", ForwardDestination: "ClusterCoreDNS", ForwardPolicy: "Sequential", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Verify", }, "cluster.local": { @@ -264,9 +264,9 @@ func nbcToAKSNodeConfigV1(nbc *datamodel.NodeBootstrappingConfiguration) *aksnod Protocol: "ForceTCP", ForwardDestination: "ClusterCoreDNS", ForwardPolicy: "RoundRobin", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Disable", }, "testdomain567.com": { @@ -274,14 +274,14 @@ func nbcToAKSNodeConfigV1(nbc *datamodel.NodeBootstrappingConfiguration) *aksnod Protocol: "PreferUDP", ForwardDestination: "VnetDNS", ForwardPolicy: "Random", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Immediate", }, }, }, - NeedsCgroupv2: to.Ptr(true), + NeedsCgroupv2: new(true), // Before scriptless, absvc combined kubelet configs from multiple sources such as nbc.AgentPoolProfile.CustomKubeletConfig, nbc.KubeletConfig and more. // Now in scriptless, we don't have absvc to process nbc and nbc is no longer a dependency. // Therefore, we require client (e.g. AKS-RP) to provide the final kubelet config that is ready to be written to the final kubelet config file on a node. @@ -331,7 +331,7 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st WindowsNodeBinariesURL: "", WindowsContainerdURL: "", WindowsSdnPluginURL: "", - UseInstanceMetadata: to.Ptr(true), + UseInstanceMetadata: new(true), EnableRbac: nil, EnableSecureKubelet: nil, PrivateCluster: nil, @@ -343,17 +343,17 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st ControllerManagerConfig: map[string]string(nil), SchedulerConfig: map[string]string(nil), CloudProviderBackoffMode: "v2", - CloudProviderBackoff: to.Ptr(true), + CloudProviderBackoff: new(true), CloudProviderBackoffRetries: 6, CloudProviderBackoffJitter: 0.0, CloudProviderBackoffDuration: 5, CloudProviderBackoffExponent: 0.0, - CloudProviderRateLimit: to.Ptr(true), + CloudProviderRateLimit: new(true), CloudProviderRateLimitQPS: 10.0, CloudProviderRateLimitQPSWrite: 10.0, CloudProviderRateLimitBucket: 100, CloudProviderRateLimitBucketWrite: 100, - CloudProviderDisableOutboundSNAT: to.Ptr(false), + CloudProviderDisableOutboundSNAT: new(false), NodeStatusUpdateFrequency: "", LoadBalancerSku: "Standard", ExcludeMasterFromStandardLB: nil, @@ -449,17 +449,17 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st AgentPoolWindowsProfile: nil, LocalDNSProfile: &datamodel.LocalDNSProfile{ EnableLocalDNS: true, - CPULimitInMilliCores: to.Ptr(int32(2008)), - MemoryLimitInMB: to.Ptr(int32(128)), + CPULimitInMilliCores: new(int32(2008)), + MemoryLimitInMB: new(int32(128)), VnetDNSOverrides: map[string]*datamodel.LocalDNSOverrides{ ".": { QueryLogging: "Log", Protocol: "PreferUDP", ForwardDestination: "VnetDNS", ForwardPolicy: "Sequential", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Verify", }, "cluster.local": { @@ -467,9 +467,9 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st Protocol: "ForceTCP", ForwardDestination: "ClusterCoreDNS", ForwardPolicy: "Sequential", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Disable", }, "testdomain456.com": { @@ -477,9 +477,9 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st Protocol: "PreferUDP", ForwardDestination: "ClusterCoreDNS", ForwardPolicy: "Sequential", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Verify", }, }, @@ -489,9 +489,9 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st Protocol: "PreferUDP", ForwardDestination: "ClusterCoreDNS", ForwardPolicy: "Sequential", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Verify", }, "cluster.local": { @@ -499,9 +499,9 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st Protocol: "ForceTCP", ForwardDestination: "ClusterCoreDNS", ForwardPolicy: "RoundRobin", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Disable", }, "testdomain567.com": { @@ -509,9 +509,9 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st Protocol: "PreferUDP", ForwardDestination: "VnetDNS", ForwardPolicy: "Random", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Immediate", }, }, @@ -598,17 +598,17 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st }, LocalDNSProfile: &datamodel.LocalDNSProfile{ EnableLocalDNS: true, - CPULimitInMilliCores: to.Ptr(int32(2008)), - MemoryLimitInMB: to.Ptr(int32(128)), + CPULimitInMilliCores: new(int32(2008)), + MemoryLimitInMB: new(int32(128)), VnetDNSOverrides: map[string]*datamodel.LocalDNSOverrides{ ".": { QueryLogging: "Log", Protocol: "PreferUDP", ForwardDestination: "VnetDNS", ForwardPolicy: "Sequential", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Verify", }, "cluster.local": { @@ -616,9 +616,9 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st Protocol: "ForceTCP", ForwardDestination: "ClusterCoreDNS", ForwardPolicy: "Sequential", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Disable", }, "testdomain456.com": { @@ -626,9 +626,9 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st Protocol: "PreferUDP", ForwardDestination: "ClusterCoreDNS", ForwardPolicy: "Sequential", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Verify", }, }, @@ -638,9 +638,9 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st Protocol: "PreferUDP", ForwardDestination: "ClusterCoreDNS", ForwardPolicy: "Sequential", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Verify", }, "cluster.local": { @@ -648,9 +648,9 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st Protocol: "ForceTCP", ForwardDestination: "ClusterCoreDNS", ForwardPolicy: "RoundRobin", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Disable", }, "testdomain567.com": { @@ -658,9 +658,9 @@ func baseTemplateLinux(t testing.TB, location string, k8sVersion string, arch st Protocol: "PreferUDP", ForwardDestination: "VnetDNS", ForwardPolicy: "Random", - MaxConcurrent: to.Ptr(int32(1000)), - CacheDurationInSeconds: to.Ptr(int32(3600)), - ServeStaleDurationInSeconds: to.Ptr(int32(3600)), + MaxConcurrent: new(int32(1000)), + CacheDurationInSeconds: new(int32(3600)), + ServeStaleDurationInSeconds: new(int32(3600)), ServeStale: "Immediate", }, }, @@ -789,7 +789,7 @@ func baseTemplateWindows(t testing.TB, location string) *datamodel.NodeBootstrap NetworkPlugin: "azure", NetworkPluginMode: "overlay", ServiceCIDR: "10.0.0.0/16", - UseInstanceMetadata: to.Ptr(true), + UseInstanceMetadata: new(true), UseManagedIdentity: false, WindowsContainerdURL: "https://packages.aks.azure.com/containerd/windows/", }, @@ -822,13 +822,13 @@ func baseTemplateWindows(t testing.TB, location string) *datamodel.NodeBootstrap EnableWinDSR: true, }, WindowsProfile: &datamodel.WindowsProfile{ - AlwaysPullWindowsPauseImage: to.Ptr(false), + AlwaysPullWindowsPauseImage: new(false), CSIProxyURL: "https://packages.aks.azure.com/csi-proxy/v1.1.2-hotfix.20230807/binaries/csi-proxy-v1.1.2-hotfix.20230807.tar.gz", - EnableAutomaticUpdates: to.Ptr(false), - EnableCSIProxy: to.Ptr(true), + EnableAutomaticUpdates: new(false), + EnableCSIProxy: new(true), HnsRemediatorIntervalInMinutes: to.Ptr[uint32](1), ImageVersion: "", - SSHEnabled: to.Ptr(true), + SSHEnabled: new(true), WindowsDockerVersion: "", WindowsImageSourceURL: "", WindowsOffer: "aks-windows", @@ -902,7 +902,7 @@ DXRqvV7TWO2hndliQq3BW385ZkiephlrmpUVM= r2k1@arturs-mbp.lan`, ContainerRuntime: "containerd", CloudProviderBackoffMode: "", }, - NotRebootWindowsNode: to.Ptr(true), + NotRebootWindowsNode: new(true), }, PrimaryScaleSetName: "akswin30", //ConfigGPUDriverIfNeeded: configGpuDriverIfNeeded, diff --git a/e2e/scenario_gpu_managed_experience_test.go b/e2e/scenario_gpu_managed_experience_test.go index 80cefed3e51..752027a0e84 100644 --- a/e2e/scenario_gpu_managed_experience_test.go +++ b/e2e/scenario_gpu_managed_experience_test.go @@ -10,7 +10,6 @@ import ( "github.com/Azure/agentbaker/e2e/components" "github.com/Azure/agentbaker/e2e/config" "github.com/Azure/agentbaker/pkg/agent/datamodel" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7" "github.com/stretchr/testify/require" ) @@ -186,7 +185,6 @@ func Test_DCGM_Exporter_Compatibility(t *testing.T) { } for _, tc := range testCases { - tc := tc // capture range variable for parallel execution t.Run(tc.name, func(t *testing.T) { RunScenario(t, &Scenario{ Description: tc.description, @@ -252,11 +250,11 @@ func Test_Ubuntu2404_NvidiaDevicePluginRunning(t *testing.T) { nbc.ManagedGPUExperienceAFECEnabled = true }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_NV6ads_A10_v5") + vmss.SKU.Name = new("Standard_NV6ads_A10_v5") if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["EnableManagedGPUExperience"] = to.Ptr("true") + vmss.Tags["EnableManagedGPUExperience"] = new("true") // Enable the AKS VM extension for GPU nodes extension, err := createVMExtensionLinuxAKSNode(vmss.Location) @@ -327,11 +325,11 @@ func Test_Ubuntu2204_NvidiaDevicePluginRunning(t *testing.T) { nbc.ManagedGPUExperienceAFECEnabled = true }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_NV6ads_A10_v5") + vmss.SKU.Name = new("Standard_NV6ads_A10_v5") if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["EnableManagedGPUExperience"] = to.Ptr("true") + vmss.Tags["EnableManagedGPUExperience"] = new("true") // Enable the AKS VM extension for GPU nodes extension, err := createVMExtensionLinuxAKSNode(vmss.Location) @@ -401,11 +399,11 @@ func Test_AzureLinux3_NvidiaDevicePluginRunning(t *testing.T) { nbc.ManagedGPUExperienceAFECEnabled = true }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_NC6s_v3") + vmss.SKU.Name = new("Standard_NC6s_v3") if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["EnableManagedGPUExperience"] = to.Ptr("true") + vmss.Tags["EnableManagedGPUExperience"] = new("true") // Enable the AKS VM extension for GPU nodes extension, err := createVMExtensionLinuxAKSNode(vmss.Location) @@ -475,7 +473,7 @@ func Test_Ubuntu2404_NvidiaDevicePluginRunning_MIG(t *testing.T) { nbc.MigStrategy = "Single" }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_NC24ads_A100_v4") + vmss.SKU.Name = new("Standard_NC24ads_A100_v4") // Enable the AKS VM extension for GPU nodes extension, err := createVMExtensionLinuxAKSNode(vmss.Location) @@ -550,7 +548,7 @@ func Test_Ubuntu2204_NvidiaDevicePluginRunning_WithoutVMSSTag(t *testing.T) { nbc.EnableManagedGPU = true }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_NV6ads_A10_v5") + vmss.SKU.Name = new("Standard_NV6ads_A10_v5") // Explicitly DO NOT set the EnableManagedGPUExperience VMSS tag // to test that NBC EnableManagedGPU field works independently diff --git a/e2e/scenario_test.go b/e2e/scenario_test.go index 1d70a0742f9..d20ffe51a1e 100644 --- a/e2e/scenario_test.go +++ b/e2e/scenario_test.go @@ -100,7 +100,7 @@ func Test_Flatcar_ARM64(t *testing.T) { Validator: func(ctx context.Context, s *Scenario) { }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_D2pds_V5") + vmss.SKU.Name = new("Standard_D2pds_V5") }, }, }) @@ -347,7 +347,7 @@ func Test_Ubuntu2204FIPS(t *testing.T) { }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { vmss.Properties.AdditionalCapabilities = &armcompute.AdditionalCapabilities{ - EnableFips1403Encryption: to.Ptr(true), + EnableFips1403Encryption: new(true), } settings := vmss.Properties.VirtualMachineProfile.ExtensionProfile.Extensions[0].Properties.ProtectedSettings vmss.Properties.VirtualMachineProfile.ExtensionProfile.Extensions[0].Properties.Settings = settings @@ -375,7 +375,7 @@ func Test_Ubuntu2204Gen2FIPS(t *testing.T) { }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { vmss.Properties.AdditionalCapabilities = &armcompute.AdditionalCapabilities{ - EnableFips1403Encryption: to.Ptr(true), + EnableFips1403Encryption: new(true), } settings := vmss.Properties.VirtualMachineProfile.ExtensionProfile.Extensions[0].Properties.ProtectedSettings vmss.Properties.VirtualMachineProfile.ExtensionProfile.Extensions[0].Properties.Settings = settings @@ -404,7 +404,7 @@ func Test_Ubuntu2204Gen2FIPSTL(t *testing.T) { VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { vmss.Properties = addTrustedLaunchToVMSS(vmss.Properties) vmss.Properties.AdditionalCapabilities = &armcompute.AdditionalCapabilities{ - EnableFips1403Encryption: to.Ptr(true), + EnableFips1403Encryption: new(true), } settings := vmss.Properties.VirtualMachineProfile.ExtensionProfile.Extensions[0].Properties.ProtectedSettings vmss.Properties.VirtualMachineProfile.ExtensionProfile.Extensions[0].Properties.Settings = settings @@ -451,7 +451,7 @@ func Test_Ubuntu2204_EntraIDSSH_Scriptless(t *testing.T) { Cluster: ClusterKubenet, VHD: config.VHDUbuntu2204Gen2Containerd, AKSNodeConfigMutator: func(config *aksnodeconfigv1.Configuration) { - config.DisablePubkeyAuth = to.Ptr(true) + config.DisablePubkeyAuth = new(true) }, SkipSSHConnectivityValidation: true, // Skip SSH connectivity validation since Entra ID SSH disables private key authentication SkipDefaultValidation: true, // Skip default validation since it requires SSH connectivity @@ -590,7 +590,7 @@ func Test_AzureLinuxV3_NetworkIsolated_Package_Install(t *testing.T) { if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["ShouldEnforceKubePMCInstall"] = to.Ptr("true") + vmss.Tags["ShouldEnforceKubePMCInstall"] = new("true") }, Validator: func(ctx context.Context, s *Scenario) { ValidateDirectoryContent(ctx, s, "/run", []string{"outbound-check-skipped"}) @@ -741,7 +741,7 @@ func Test_Ubuntu2204Gen2_Containerd_NetworkIsolatedCluster_NonAnonymousNoneCache if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["ShouldEnforceKubePMCInstall"] = to.Ptr("true") + vmss.Tags["ShouldEnforceKubePMCInstall"] = new("true") }, Validator: func(ctx context.Context, s *Scenario) { ValidateDirectoryContent(ctx, s, "/opt/azure", []string{"outbound-check-skipped"}) @@ -761,7 +761,7 @@ func Test_Ubuntu2204ARM64(t *testing.T) { nbc.IsARM64 = true }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_D2pds_V5") + vmss.SKU.Name = new("Standard_D2pds_V5") }, }, }) @@ -921,10 +921,10 @@ func Test_Ubuntu2204_CustomSysctls(t *testing.T) { BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) { customLinuxConfig := &datamodel.CustomLinuxOSConfig{ Sysctls: &datamodel.SysctlConfig{ - NetNetfilterNfConntrackMax: to.Ptr(toolkit.StrToInt32(customSysctls["net.netfilter.nf_conntrack_max"])), - NetNetfilterNfConntrackBuckets: to.Ptr(toolkit.StrToInt32(customSysctls["net.netfilter.nf_conntrack_buckets"])), + NetNetfilterNfConntrackMax: new(toolkit.StrToInt32(customSysctls["net.netfilter.nf_conntrack_max"])), + NetNetfilterNfConntrackBuckets: new(toolkit.StrToInt32(customSysctls["net.netfilter.nf_conntrack_buckets"])), NetIpv4IpLocalPortRange: customSysctls["net.ipv4.ip_local_port_range"], - NetIpv4TcpkeepaliveIntvl: to.Ptr(toolkit.StrToInt32(customSysctls["net.ipv4.tcp_keepalive_intvl"])), + NetIpv4TcpkeepaliveIntvl: new(toolkit.StrToInt32(customSysctls["net.ipv4.tcp_keepalive_intvl"])), }, UlimitConfig: &datamodel.UlimitConfig{ MaxLockedMemory: "75000", @@ -961,14 +961,14 @@ func Test_Ubuntu2204_CustomSysctls_Scriptless(t *testing.T) { AKSNodeConfigMutator: func(config *aksnodeconfigv1.Configuration) { customLinuxOsConfig := &aksnodeconfigv1.CustomLinuxOsConfig{ SysctlConfig: &aksnodeconfigv1.SysctlConfig{ - NetNetfilterNfConntrackMax: to.Ptr(toolkit.StrToInt32(customSysctls["net.netfilter.nf_conntrack_max"])), - NetNetfilterNfConntrackBuckets: to.Ptr(toolkit.StrToInt32(customSysctls["net.netfilter.nf_conntrack_buckets"])), - NetIpv4IpLocalPortRange: to.Ptr(customSysctls["net.ipv4.ip_local_port_range"]), - NetIpv4TcpkeepaliveIntvl: to.Ptr(toolkit.StrToInt32(customSysctls["net.ipv4.tcp_keepalive_intvl"])), + NetNetfilterNfConntrackMax: new(toolkit.StrToInt32(customSysctls["net.netfilter.nf_conntrack_max"])), + NetNetfilterNfConntrackBuckets: new(toolkit.StrToInt32(customSysctls["net.netfilter.nf_conntrack_buckets"])), + NetIpv4IpLocalPortRange: new(customSysctls["net.ipv4.ip_local_port_range"]), + NetIpv4TcpkeepaliveIntvl: new(toolkit.StrToInt32(customSysctls["net.ipv4.tcp_keepalive_intvl"])), }, UlimitConfig: &aksnodeconfigv1.UlimitConfig{ - MaxLockedMemory: to.Ptr(customContainerdUlimits["LimitMEMLOCK"]), - NoFile: to.Ptr(customContainerdUlimits["LimitNOFILE"]), + MaxLockedMemory: new(customContainerdUlimits["LimitMEMLOCK"]), + NoFile: new(customContainerdUlimits["LimitNOFILE"]), }, } config.CustomLinuxOsConfig = customLinuxOsConfig @@ -1010,7 +1010,7 @@ func runScenarioUbuntu2204GPU(t *testing.T, vmSize string) { nbc.EnableNvidia = true }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr(vmSize) + vmss.SKU.Name = new(vmSize) }, Validator: func(ctx context.Context, s *Scenario) { // Ensure nvidia-modprobe install does not restart kubelet and temporarily cause node to be unschedulable @@ -1038,7 +1038,7 @@ func runScenarioUbuntuGRID(t *testing.T, vmSize string) { nbc.EnableNvidia = true }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr(vmSize) + vmss.SKU.Name = new(vmSize) }, Validator: func(ctx context.Context, s *Scenario) { // Ensure nvidia-modprobe install does not restart kubelet and temporarily cause node to be unschedulable @@ -1062,7 +1062,7 @@ func Test_Ubuntu2204_GPUA10_Scriptless(t *testing.T) { Cluster: ClusterKubenet, VHD: config.VHDUbuntu2204Gen2Containerd, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_NV6ads_A10_v5") + vmss.SKU.Name = new("Standard_NV6ads_A10_v5") }, Validator: func(ctx context.Context, s *Scenario) { // Ensure nvidia-modprobe install does not restart kubelet and temporarily cause node to be unschedulable @@ -1074,7 +1074,7 @@ func Test_Ubuntu2204_GPUA10_Scriptless(t *testing.T) { config.VmSize = "Standard_NV6ads_A10_v5" config.GpuConfig.ConfigGpuDriver = true config.GpuConfig.GpuDevicePlugin = false - config.GpuConfig.EnableNvidia = to.Ptr(true) + config.GpuConfig.EnableNvidia = new(true) }, }, }) @@ -1096,7 +1096,7 @@ func Test_Ubuntu2204_GPUGridDriver(t *testing.T) { nbc.EnableNvidia = true }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_NV6ads_A10_v5") + vmss.SKU.Name = new("Standard_NV6ads_A10_v5") }, Validator: func(ctx context.Context, s *Scenario) { ValidateNvidiaModProbeInstalled(ctx, s) @@ -1125,9 +1125,9 @@ func Test_Ubuntu2204_GPUNoDriver(t *testing.T) { VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { vmss.Tags = map[string]*string{ // deliberately case mismatched to agentbaker logic to check case insensitivity - "SkipGPUDriverInstall": to.Ptr("true"), + "SkipGPUDriverInstall": new("true"), } - vmss.SKU.Name = to.Ptr("Standard_NC6s_v3") + vmss.SKU.Name = new("Standard_NC6s_v3") }, Validator: func(ctx context.Context, s *Scenario) { ValidateNvidiaSMINotInstalled(ctx, s) @@ -1149,15 +1149,15 @@ func Test_Ubuntu2204_GPUNoDriver_Scriptless(t *testing.T) { config.VmSize = "Standard_NC6s_v3" config.GpuConfig.ConfigGpuDriver = true config.GpuConfig.GpuDevicePlugin = false - config.GpuConfig.EnableNvidia = to.Ptr(true) + config.GpuConfig.EnableNvidia = new(true) }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { // this vmss tag is needed since there is a logic in cse_main.sh otherwise the test will fail vmss.Tags = map[string]*string{ // deliberately case mismatched to agentbaker logic to check case insensitivity - "SkipGPUDriverInstall": to.Ptr("true"), + "SkipGPUDriverInstall": new("true"), } - vmss.SKU.Name = to.Ptr("Standard_NC6s_v3") + vmss.SKU.Name = new("Standard_NC6s_v3") }, Validator: func(ctx context.Context, s *Scenario) { ValidateNvidiaSMINotInstalled(ctx, s) @@ -1254,7 +1254,7 @@ func Test_AzureLinux_Skip_Binary_Cleanup(t *testing.T) { if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["SkipBinaryCleanup"] = to.Ptr("true") + vmss.Tags["SkipBinaryCleanup"] = new("true") }, Validator: func(ctx context.Context, s *Scenario) { ValidateMultipleKubeProxyVersionsExist(ctx, s) @@ -1274,7 +1274,7 @@ func Test_Ubuntu2204_DisableKubeletServingCertificateRotationWithTags(t *testing if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = to.Ptr("true") + vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = new("true") }, }, }) @@ -1289,7 +1289,7 @@ func Test_Ubuntu2204_DisableKubeletServingCertificateRotationWithTags_CustomKube BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) { // to force kubelet config file customKubeletConfig := &datamodel.CustomKubeletConfig{ - FailSwapOn: to.Ptr(true), + FailSwapOn: new(true), AllowedUnsafeSysctls: &[]string{"kernel.msg*", "net.ipv4.route.min_pmtu"}, } nbc.AgentPoolProfile.CustomKubeletConfig = customKubeletConfig @@ -1298,7 +1298,7 @@ func Test_Ubuntu2204_DisableKubeletServingCertificateRotationWithTags_CustomKube if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = to.Ptr("true") + vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = new("true") }, }, }) @@ -1312,7 +1312,7 @@ func Test_Ubuntu2204_DisableKubeletServingCertificateRotationWithTags_CustomKube VHD: config.VHDUbuntu2204Gen2Containerd, AKSNodeConfigMutator: func(config *aksnodeconfigv1.Configuration) { config.KubeletConfig.EnableKubeletConfigFile = true - config.KubeletConfig.KubeletConfigFileConfig.FailSwapOn = to.Ptr(true) + config.KubeletConfig.KubeletConfigFileConfig.FailSwapOn = new(true) config.KubeletConfig.KubeletConfigFileConfig.AllowedUnsafeSysctls = []string{"kernel.msg*", "net.ipv4.route.min_pmtu"} config.KubeletConfig.KubeletConfigFileConfig.ServerTlsBootstrap = true config.KubeletConfig.KubeletConfigFileConfig.FeatureGates = map[string]bool{"RotateKubeletServerCertificate": true} @@ -1322,7 +1322,7 @@ func Test_Ubuntu2204_DisableKubeletServingCertificateRotationWithTags_CustomKube if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = to.Ptr("true") + vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = new("true") }, }, }) @@ -1340,7 +1340,7 @@ func Test_Ubuntu2204_DisableKubeletServingCertificateRotationWithTags_AlreadyDis if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = to.Ptr("true") + vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = new("true") }, }, }) @@ -1355,7 +1355,7 @@ func Test_Ubuntu2204_DisableKubeletServingCertificateRotationWithTags_AlreadyDis BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) { // to force kubelet config file customKubeletConfig := &datamodel.CustomKubeletConfig{ - FailSwapOn: to.Ptr(true), + FailSwapOn: new(true), AllowedUnsafeSysctls: &[]string{"kernel.msg*", "net.ipv4.route.min_pmtu"}, } nbc.AgentPoolProfile.CustomKubeletConfig = customKubeletConfig @@ -1364,7 +1364,7 @@ func Test_Ubuntu2204_DisableKubeletServingCertificateRotationWithTags_AlreadyDis if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = to.Ptr("true") + vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = new("true") }, }, }) @@ -1432,7 +1432,7 @@ func Test_AzureLinuxV3_MA35D(t *testing.T) { nbc.AgentPoolProfile.VMSize = "Standard_NM16ads_MA35D" }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_NM16ads_MA35D") + vmss.SKU.Name = new("Standard_NM16ads_MA35D") vmss.Properties.VirtualMachineProfile.StorageProfile.OSDisk.DiffDiskSettings.Placement = to.Ptr(armcompute.DiffDiskPlacementCacheDisk) }, Validator: func(ctx context.Context, s *Scenario) { @@ -1461,7 +1461,7 @@ func Test_AzureLinuxV3_MA35D_Scriptless(t *testing.T) { config.VmSize = "Standard_NM16ads_MA35D" }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_NM16ads_MA35D") + vmss.SKU.Name = new("Standard_NM16ads_MA35D") vmss.Properties.VirtualMachineProfile.StorageProfile.OSDisk.DiffDiskSettings.Placement = to.Ptr(armcompute.DiffDiskPlacementCacheDisk) }, Validator: func(ctx context.Context, s *Scenario) { @@ -1517,10 +1517,10 @@ func Test_AzureLinuxV3_CustomSysctls(t *testing.T) { BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) { customLinuxConfig := &datamodel.CustomLinuxOSConfig{ Sysctls: &datamodel.SysctlConfig{ - NetNetfilterNfConntrackMax: to.Ptr(toolkit.StrToInt32(customSysctls["net.netfilter.nf_conntrack_max"])), - NetNetfilterNfConntrackBuckets: to.Ptr(toolkit.StrToInt32(customSysctls["net.netfilter.nf_conntrack_buckets"])), + NetNetfilterNfConntrackMax: new(toolkit.StrToInt32(customSysctls["net.netfilter.nf_conntrack_max"])), + NetNetfilterNfConntrackBuckets: new(toolkit.StrToInt32(customSysctls["net.netfilter.nf_conntrack_buckets"])), NetIpv4IpLocalPortRange: customSysctls["net.ipv4.ip_local_port_range"], - NetIpv4TcpkeepaliveIntvl: to.Ptr(toolkit.StrToInt32(customSysctls["net.ipv4.tcp_keepalive_intvl"])), + NetIpv4TcpkeepaliveIntvl: new(toolkit.StrToInt32(customSysctls["net.ipv4.tcp_keepalive_intvl"])), }, UlimitConfig: &datamodel.UlimitConfig{ MaxLockedMemory: customContainerdUlimits["LimitMEMLOCK"], @@ -1550,7 +1550,7 @@ func Test_Ubuntu2204_KubeletCustomConfig(t *testing.T) { nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-ubuntu-containerd-22.04-gen2" nbc.AgentPoolProfile.Distro = "aks-ubuntu-containerd-22.04-gen2" customKubeletConfig := &datamodel.CustomKubeletConfig{ - SeccompDefault: to.Ptr(true), + SeccompDefault: new(true), } nbc.AgentPoolProfile.CustomKubeletConfig = customKubeletConfig nbc.ContainerService.Properties.AgentPoolProfiles[0].CustomKubeletConfig = customKubeletConfig @@ -1577,7 +1577,7 @@ func Test_AzureLinuxV3_KubeletCustomConfig(t *testing.T) { nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-azurelinux-v3-gen2" nbc.AgentPoolProfile.Distro = "aks-azurelinux-v3-gen2" customKubeletConfig := &datamodel.CustomKubeletConfig{ - SeccompDefault: to.Ptr(true), + SeccompDefault: new(true), } nbc.AgentPoolProfile.CustomKubeletConfig = customKubeletConfig nbc.ContainerService.Properties.AgentPoolProfiles[0].CustomKubeletConfig = customKubeletConfig @@ -1630,7 +1630,7 @@ func Test_AzureLinuxV3_GPU(t *testing.T) { nbc.EnableNvidia = true }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_NC6s_v3") + vmss.SKU.Name = new("Standard_NC6s_v3") }, Validator: func(ctx context.Context, s *Scenario) { }, @@ -1656,7 +1656,7 @@ func Test_AzureLinuxV3_GPUAzureCNI(t *testing.T) { nbc.EnableNvidia = true }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_NC6s_v3") + vmss.SKU.Name = new("Standard_NC6s_v3") }, Validator: func(ctx context.Context, s *Scenario) { }, @@ -1678,10 +1678,10 @@ func Test_AzureLinuxV3_GPUAzureCNI_Scriptless(t *testing.T) { config.VmSize = "Standard_NC6s_v3" config.GpuConfig.ConfigGpuDriver = true config.GpuConfig.GpuDevicePlugin = false - config.GpuConfig.EnableNvidia = to.Ptr(true) + config.GpuConfig.EnableNvidia = new(true) }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_NC6s_v3") + vmss.SKU.Name = new("Standard_NC6s_v3") }, Validator: func(ctx context.Context, s *Scenario) { }, @@ -1705,13 +1705,13 @@ func Test_Ubuntu2204ARM64_KubeletCustomConfig(t *testing.T) { nbc.AgentPoolProfile.VMSize = "Standard_D2pds_V5" customKubeletConfig := &datamodel.CustomKubeletConfig{ - SeccompDefault: to.Ptr(true), + SeccompDefault: new(true), } nbc.AgentPoolProfile.CustomKubeletConfig = customKubeletConfig nbc.ContainerService.Properties.AgentPoolProfiles[0].CustomKubeletConfig = customKubeletConfig }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_D2pds_V5") + vmss.SKU.Name = new("Standard_D2pds_V5") }, Validator: func(ctx context.Context, s *Scenario) { @@ -1762,7 +1762,7 @@ func Test_Ubuntu2404Gen2_McrChinaCloud_Scriptless(t *testing.T) { if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["E2EMockAzureChinaCloud"] = to.Ptr("true") + vmss.Tags["E2EMockAzureChinaCloud"] = new("true") }, Validator: func(ctx context.Context, s *Scenario) { ValidateDirectoryContent(ctx, s, "/etc/containerd/certs.d/mcr.azk8s.cn", []string{"hosts.toml"}) @@ -1786,7 +1786,7 @@ func Test_Ubuntu2404Gen2_McrChinaCloud(t *testing.T) { if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["E2EMockAzureChinaCloud"] = to.Ptr("true") + vmss.Tags["E2EMockAzureChinaCloud"] = new("true") }, Validator: func(ctx context.Context, s *Scenario) { containerdVersions := components.GetExpectedPackageVersions("containerd", "ubuntu", "r2404") @@ -1859,9 +1859,9 @@ func Test_Ubuntu2404Gen2_GPUNoDriver(t *testing.T) { VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { vmss.Tags = map[string]*string{ // deliberately case mismatched to agentbaker logic to check case insensitivity - "SkipGPUDriverInstall": to.Ptr("true"), + "SkipGPUDriverInstall": new("true"), } - vmss.SKU.Name = to.Ptr("Standard_NC6s_v3") + vmss.SKU.Name = new("Standard_NC6s_v3") }, Validator: func(ctx context.Context, s *Scenario) { containerdVersions := components.GetExpectedPackageVersions("containerd", "ubuntu", "r2404") @@ -1902,7 +1902,7 @@ func Test_Ubuntu2404ARM(t *testing.T) { BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) { }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr("Standard_D2pds_V5") + vmss.SKU.Name = new("Standard_D2pds_V5") }, Validator: func(ctx context.Context, s *Scenario) { containerdVersions := components.GetExpectedPackageVersions("containerd", "ubuntu", "r2404") @@ -1942,7 +1942,7 @@ func runScenarioUbuntu2404GRID(t *testing.T, vmSize string) { nbc.EnableNvidia = true }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr(vmSize) + vmss.SKU.Name = new(vmSize) }, Validator: func(ctx context.Context, s *Scenario) { // Ensure nvidia-modprobe install does not restart kubelet and temporarily cause node to be unschedulable @@ -2003,7 +2003,7 @@ func Test_AzureLinux3_PMC_Install(t *testing.T) { if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["ShouldEnforceKubePMCInstall"] = to.Ptr("true") + vmss.Tags["ShouldEnforceKubePMCInstall"] = new("true") }, Validator: func(ctx context.Context, s *Scenario) { }, @@ -2029,7 +2029,7 @@ func Test_Ubuntu2204_PMC_Install(t *testing.T) { if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["ShouldEnforceKubePMCInstall"] = to.Ptr("true") + vmss.Tags["ShouldEnforceKubePMCInstall"] = new("true") }, Validator: func(ctx context.Context, s *Scenario) { ValidateInstalledPackageVersion(ctx, s, "moby-containerd", components.GetExpectedPackageVersions("containerd", "ubuntu", "r2204")[0]) @@ -2055,7 +2055,7 @@ func Test_AzureLinux3OSGuard_PMC_Install(t *testing.T) { if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["ShouldEnforceKubePMCInstall"] = to.Ptr("true") + vmss.Tags["ShouldEnforceKubePMCInstall"] = new("true") }, }, }) diff --git a/e2e/scenario_win_test.go b/e2e/scenario_win_test.go index fd0e4063705..d7c99a6d4a5 100644 --- a/e2e/scenario_win_test.go +++ b/e2e/scenario_win_test.go @@ -41,9 +41,9 @@ func DualStackVMConfigMutator(set *armcompute.VirtualMachineScaleSet) { ip4Config := set.Properties.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].Properties.IPConfigurations[0] ip6Config := &armcompute.VirtualMachineScaleSetIPConfiguration{ - Name: to.Ptr(fmt.Sprintf("%s_1", *ip4Config.Name)), + Name: new(fmt.Sprintf("%s_1", *ip4Config.Name)), Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{ - Primary: to.Ptr(false), + Primary: new(false), PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv6), Subnet: &armcompute.APIEntityReference{ ID: ip4Config.Properties.Subnet.ID, @@ -388,7 +388,7 @@ func Test_Windows2022_DisableKubeletServingCertificateRotationWithTags(t *testin if vmss.Tags == nil { vmss.Tags = map[string]*string{} } - vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = to.Ptr("true") + vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = new("true") }, Validator: func(ctx context.Context, s *Scenario) { ValidateWindowsVersionFromWindowsSettings(ctx, s, "2022-containerd-gen2") @@ -483,8 +483,8 @@ func Test_Windows23H2Gen2_WindowsCiliumNetworking(t *testing.T) { if configuration.AgentPoolProfile.AgentPoolWindowsProfile == nil { configuration.AgentPoolProfile.AgentPoolWindowsProfile = &datamodel.AgentPoolWindowsProfile{} } - configuration.AgentPoolProfile.AgentPoolWindowsProfile.NextGenNetworkingEnabled = to.Ptr(true) - configuration.AgentPoolProfile.AgentPoolWindowsProfile.NextGenNetworkingConfig = to.Ptr("") + configuration.AgentPoolProfile.AgentPoolWindowsProfile.NextGenNetworkingEnabled = new(true) + configuration.AgentPoolProfile.AgentPoolWindowsProfile.NextGenNetworkingConfig = new("") }, Validator: func(ctx context.Context, s *Scenario) { ValidateWindowsCiliumIsRunning(ctx, s) diff --git a/e2e/test_helpers.go b/e2e/test_helpers.go index 5e74742c0ed..8d557acf5ca 100644 --- a/e2e/test_helpers.go +++ b/e2e/test_helpers.go @@ -516,8 +516,8 @@ func addTrustedLaunchToVMSS(properties *armcompute.VirtualMachineScaleSetPropert if properties.VirtualMachineProfile.SecurityProfile.UefiSettings == nil { properties.VirtualMachineProfile.SecurityProfile.UefiSettings = &armcompute.UefiSettings{} } - properties.VirtualMachineProfile.SecurityProfile.UefiSettings.SecureBootEnabled = to.Ptr(true) - properties.VirtualMachineProfile.SecurityProfile.UefiSettings.VTpmEnabled = to.Ptr(true) + properties.VirtualMachineProfile.SecurityProfile.UefiSettings.SecureBootEnabled = new(true) + properties.VirtualMachineProfile.SecurityProfile.UefiSettings.VTpmEnabled = new(true) return properties } @@ -539,11 +539,11 @@ func createVMExtensionLinuxAKSNode(_ *string) (*armcompute.VirtualMachineScaleSe // } return &armcompute.VirtualMachineScaleSetExtension{ - Name: to.Ptr(extensionName), + Name: new(extensionName), Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{ - Publisher: to.Ptr(publisher), - Type: to.Ptr(extensionName), - TypeHandlerVersion: to.Ptr(extensionVersion), + Publisher: new(publisher), + Type: new(extensionName), + TypeHandlerVersion: new(extensionVersion), }, }, nil } @@ -562,11 +562,11 @@ func RunCommand(ctx context.Context, s *Scenario, command string) (armcompute.Ru runPoller, err := config.Azure.VMSSVM.BeginRunCommand(ctx, *s.Runtime.Cluster.Model.Properties.NodeResourceGroup, s.Runtime.VMSSName, *s.Runtime.VM.VM.InstanceID, armcompute.RunCommandInput{ CommandID: func() *string { if s.IsWindows() { - return to.Ptr("RunPowerShellScript") + return new("RunPowerShellScript") } - return to.Ptr("RunShellScript") + return new("RunShellScript") }(), - Script: []*string{to.Ptr(command)}, + Script: []*string{new(command)}, }, nil) if err != nil { return armcompute.RunCommandResult{}, fmt.Errorf("failed to run command on Windows VM for image creation: %w", err) @@ -640,12 +640,12 @@ func CreateSIGImageVersionFromDisk(ctx context.Context, s *Scenario, version str // Create the image version directly from the disk s.T.Logf("Creating gallery image version: %s in %s", version, *image.ID) createVersionOp, err := config.Azure.GalleryImageVersions.BeginCreateOrUpdate(ctx, rg, *gallery.Name, *image.Name, version, armcompute.GalleryImageVersion{ - Location: to.Ptr(s.Location), + Location: new(s.Location), Properties: &armcompute.GalleryImageVersionProperties{ StorageProfile: &armcompute.GalleryImageVersionStorageProfile{ OSDiskImage: &armcompute.GalleryOSDiskImage{ Source: &armcompute.GalleryDiskImageSource{ - ID: to.Ptr(diskResourceID), + ID: new(diskResourceID), }, }, }, @@ -653,7 +653,7 @@ func CreateSIGImageVersionFromDisk(ctx context.Context, s *Scenario, version str ReplicationMode: to.Ptr(armcompute.ReplicationModeShallow), TargetRegions: []*armcompute.TargetRegion{ { - Name: to.Ptr(s.Location), + Name: new(s.Location), RegionalReplicaCount: to.Ptr[int32](1), StorageAccountType: to.Ptr(armcompute.StorageAccountTypePremiumLRS), }, @@ -793,7 +793,7 @@ func runScenarioGPUNPD(t *testing.T, vmSize, location, k8sSystemPoolSKU string) nbc.EnableNvidia = true }, VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) { - vmss.SKU.Name = to.Ptr(vmSize) + vmss.SKU.Name = new(vmSize) extension, err := createVMExtensionLinuxAKSNode(vmss.Location) require.NoError(t, err, "creating AKS VM extension") diff --git a/e2e/types.go b/e2e/types.go index 795e3722d09..f6ae7d21e7d 100644 --- a/e2e/types.go +++ b/e2e/types.go @@ -15,7 +15,6 @@ import ( aksnodeconfigv1 "github.com/Azure/agentbaker/aks-node-controller/pkg/gen/aksnodeconfig/v1" "github.com/Azure/agentbaker/e2e/config" "github.com/Azure/agentbaker/pkg/agent/datamodel" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7" "github.com/stretchr/testify/require" "golang.org/x/crypto/ssh" @@ -60,9 +59,9 @@ func (t Tags) matchFilters(filters string, all bool) (bool, error) { } v := reflect.ValueOf(t) - filterPairs := strings.Split(filters, ",") + filterPairs := strings.SplitSeq(filters, ",") - for _, pair := range filterPairs { + for pair := range filterPairs { kv := strings.SplitN(pair, "=", 2) if len(kv) != 2 { return false, fmt.Errorf("invalid filter format: %s", pair) @@ -220,14 +219,14 @@ func (s *Scenario) PrepareVMSSModel(ctx context.Context, t testing.TB, vmss *arm vmss.Properties.VirtualMachineProfile.StorageProfile = &armcompute.VirtualMachineScaleSetStorageProfile{} } vmss.Properties.VirtualMachineProfile.StorageProfile.ImageReference = &armcompute.ImageReference{ - ID: to.Ptr(string(resourceID)), + ID: new(string(resourceID)), } // Override OS disk size if the VHD requires a non-default size. if s.VHD.OSDiskSizeGB > 0 { osDisk := vmss.Properties.VirtualMachineProfile.StorageProfile.OSDisk if osDisk != nil { - osDisk.DiskSizeGB = to.Ptr(s.VHD.OSDiskSizeGB) + osDisk.DiskSizeGB = new(s.VHD.OSDiskSizeGB) } } @@ -334,7 +333,7 @@ func (s *Scenario) updateTags(ctx context.Context, vmss *armcompute.VirtualMachi // don't clean up VMSS in other tests if config.Config.KeepVMSS { - vmss.Tags["KEEP_VMSS"] = to.Ptr("true") + vmss.Tags["KEEP_VMSS"] = new("true") } if config.Config.BuildID != "" { @@ -348,7 +347,7 @@ func (s *Scenario) updateTags(ctx context.Context, vmss *armcompute.VirtualMachi owner = "unknown" } } - vmss.Tags["owner"] = to.Ptr(owner) + vmss.Tags["owner"] = new(owner) } func getLoggedInAzUser() (string, error) { diff --git a/e2e/validation.go b/e2e/validation.go index 367c2796656..863b081ce61 100644 --- a/e2e/validation.go +++ b/e2e/validation.go @@ -8,7 +8,6 @@ import ( "time" "github.com/Azure/agentbaker/e2e/toolkit" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" @@ -129,7 +128,7 @@ func validatePodRunning(ctx context.Context, s *Scenario, pod *corev1.Pod) error defer func() { ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second) defer cancel() - err := kube.Typed.CoreV1().Pods(pod.Namespace).Delete(ctx, pod.Name, v1.DeleteOptions{GracePeriodSeconds: to.Ptr(int64(0))}) + err := kube.Typed.CoreV1().Pods(pod.Namespace).Delete(ctx, pod.Name, v1.DeleteOptions{GracePeriodSeconds: new(int64(0))}) if err != nil { s.T.Logf("couldn't not delete pod %s: %v", pod.Name, err) } diff --git a/e2e/validators.go b/e2e/validators.go index 2647fccb699..19ea6b6e03f 100644 --- a/e2e/validators.go +++ b/e2e/validators.go @@ -16,7 +16,6 @@ import ( "testing" "time" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7" "github.com/blang/semver" "github.com/samber/lo" @@ -817,7 +816,7 @@ func ValidateInstalledPackageVersion(ctx context.Context, s *Scenario, component } }() execResult := execScriptOnVMForScenarioValidateExitCode(ctx, s, installedCommand, 0, "could not get package list") - for _, line := range strings.Split(execResult.stdout, "\n") { + for line := range strings.SplitSeq(execResult.stdout, "\n") { if strings.Contains(line, component) && strings.Contains(line, version) { s.T.Logf("found %s %s in the installed packages", component, version) return @@ -862,7 +861,7 @@ func ValidateMultipleKubeProxyVersionsExist(ctx context.Context, s *Scenario) { versions := bytes.NewBufferString(strings.TrimSpace(execResult.stdout)) versionMap := make(map[string]struct{}) - for _, version := range strings.Split(versions.String(), "\n") { + for version := range strings.SplitSeq(versions.String(), "\n") { if version != "" { versionMap[version] = struct{}{} } @@ -1568,8 +1567,8 @@ func ValidateSSHServiceDisabled(ctx context.Context, s *Scenario) { // Use VMSS RunCommand to check SSH service status directly on the node // Ubuntu uses 'ssh' as service name, while AzureLinux and Mariner use 'sshd' runPoller, err := config.Azure.VMSSVM.BeginRunCommand(ctx, *s.Runtime.Cluster.Model.Properties.NodeResourceGroup, s.Runtime.VMSSName, *s.Runtime.VM.VM.InstanceID, armcompute.RunCommandInput{ - CommandID: to.Ptr("RunShellScript"), - Script: []*string{to.Ptr(`#!/bin/bash + CommandID: new("RunShellScript"), + Script: []*string{new(`#!/bin/bash # Determine the correct SSH service name based on the distro # Ubuntu uses 'ssh', AzureLinux and Mariner use 'sshd' if [ -f /etc/os-release ]; then @@ -1923,7 +1922,7 @@ func ValidateKernelLogs(ctx context.Context, s *Scenario) { var summary strings.Builder summary.WriteString("Critical kernel issues detected:\n") for category, issues := range issuesFound { - summary.WriteString(fmt.Sprintf("\n[%s]:\n%s\n", category, issues)) + fmt.Fprintf(&summary, "\n[%s]:\n%s\n", category, issues) } s.T.Fatalf("%s", summary.String()) } diff --git a/e2e/vmss.go b/e2e/vmss.go index 7bd589e854b..d9acb28e583 100644 --- a/e2e/vmss.go +++ b/e2e/vmss.go @@ -388,7 +388,7 @@ func waitForVMSSVM(ctx context.Context, s *Scenario) (*armcompute.VirtualMachine var lastErr error for { pager := config.Azure.VMSSVM.NewListPager(*s.Runtime.Cluster.Model.Properties.NodeResourceGroup, s.Runtime.VMSSName, &armcompute.VirtualMachineScaleSetVMsClientListOptions{ - Expand: to.Ptr("instanceView"), + Expand: new("instanceView"), }) if pager.More() { @@ -688,23 +688,23 @@ func extractLogsFromVMWindows(ctx context.Context, s *Scenario) { "RunPowerShellScript", armcompute.VirtualMachineRunCommand{ Properties: &armcompute.VirtualMachineRunCommandProperties{ - TimeoutInSeconds: to.Ptr(runCommandTimeout), // 20 minutes should be enough + TimeoutInSeconds: new(runCommandTimeout), // 20 minutes should be enough Source: &armcompute.VirtualMachineRunCommandScriptSource{ //CommandID: to.Ptr("RunPowerShellScript"), - Script: to.Ptr(uploadLogsPowershellScript), + Script: new(uploadLogsPowershellScript), }, Parameters: []*armcompute.RunCommandInputParameter{ { - Name: to.Ptr("arg1"), - Value: to.Ptr(blobUrl), + Name: new("arg1"), + Value: new(blobUrl), }, { - Name: to.Ptr("arg2"), - Value: to.Ptr(s.Runtime.VMSSName), + Name: new("arg2"), + Value: new(s.Runtime.VMSSName), }, { - Name: to.Ptr("arg3"), - Value: to.Ptr(config.Config.VMIdentityResourceID(s.Location)), + Name: new("arg3"), + Value: new(config.Config.VMIdentityResourceID(s.Location)), }, }, }, @@ -764,7 +764,7 @@ func deleteVMSS(ctx context.Context, s *Scenario) { return } _, err := config.Azure.VMSS.BeginDelete(ctx, *s.Runtime.Cluster.Model.Properties.NodeResourceGroup, s.Runtime.VMSSName, &armcompute.VirtualMachineScaleSetsClientBeginDeleteOptions{ - ForceDeletion: to.Ptr(true), + ForceDeletion: new(true), }) if err != nil { s.T.Logf("failed to delete vmss %q: %s", s.Runtime.VMSSName, err) @@ -785,10 +785,10 @@ func addPodIPConfigsForAzureCNI(vmss *armcompute.VirtualMachineScaleSet, vmssNam var podIPConfigs []*armcompute.VirtualMachineScaleSetIPConfiguration for i := 1; i <= maxPodsPerNode; i++ { ipConfig := &armcompute.VirtualMachineScaleSetIPConfiguration{ - Name: to.Ptr(fmt.Sprintf("%s%d", vmssName, i)), + Name: new(fmt.Sprintf("%s%d", vmssName, i)), Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{ Subnet: &armcompute.APIEntityReference{ - ID: to.Ptr(cluster.SubnetID), + ID: new(cluster.SubnetID), }, }, } @@ -830,32 +830,32 @@ func generateVMSSName(s *Scenario) string { func getBaseVMSSModel(s *Scenario, customData, cseCmd string) armcompute.VirtualMachineScaleSet { model := armcompute.VirtualMachineScaleSet{ - Location: to.Ptr(s.Location), + Location: new(s.Location), SKU: &armcompute.SKU{ - Name: to.Ptr(config.Config.DefaultVMSKU), + Name: new(config.Config.DefaultVMSKU), Capacity: to.Ptr[int64](1), }, Properties: &armcompute.VirtualMachineScaleSetProperties{ - Overprovision: to.Ptr(false), + Overprovision: new(false), UpgradePolicy: &armcompute.UpgradePolicy{ Mode: to.Ptr(armcompute.UpgradeModeAutomatic), }, VirtualMachineProfile: &armcompute.VirtualMachineScaleSetVMProfile{ DiagnosticsProfile: &armcompute.DiagnosticsProfile{ BootDiagnostics: &armcompute.BootDiagnostics{ - Enabled: to.Ptr(true), + Enabled: new(true), }, }, OSProfile: &armcompute.VirtualMachineScaleSetOSProfile{ - ComputerNamePrefix: to.Ptr(s.Runtime.VMSSName), - AdminUsername: to.Ptr("azureuser"), + ComputerNamePrefix: new(s.Runtime.VMSSName), + AdminUsername: new("azureuser"), CustomData: &customData, LinuxConfiguration: &armcompute.LinuxConfiguration{ SSH: &armcompute.SSHConfiguration{ PublicKeys: []*armcompute.SSHPublicKey{ { - KeyData: to.Ptr(string(config.VMSSHPublicKey)), - Path: to.Ptr("/home/azureuser/.ssh/authorized_keys"), + KeyData: new(string(config.VMSSHPublicKey)), + Path: new("/home/azureuser/.ssh/authorized_keys"), }, }, }, @@ -864,7 +864,7 @@ func getBaseVMSSModel(s *Scenario, customData, cseCmd string) armcompute.Virtual StorageProfile: &armcompute.VirtualMachineScaleSetStorageProfile{ OSDisk: &armcompute.VirtualMachineScaleSetOSDisk{ CreateOption: to.Ptr(armcompute.DiskCreateOptionTypesFromImage), - DiskSizeGB: to.Ptr(int32(50)), + DiskSizeGB: new(int32(50)), OSType: to.Ptr(armcompute.OperatingSystemTypesLinux), Caching: to.Ptr(armcompute.CachingTypesReadOnly), DiffDiskSettings: &armcompute.DiffDiskSettings{ @@ -876,19 +876,19 @@ func getBaseVMSSModel(s *Scenario, customData, cseCmd string) armcompute.Virtual NetworkProfile: &armcompute.VirtualMachineScaleSetNetworkProfile{ NetworkInterfaceConfigurations: []*armcompute.VirtualMachineScaleSetNetworkConfiguration{ { - Name: to.Ptr(s.Runtime.VMSSName), + Name: new(s.Runtime.VMSSName), Properties: &armcompute.VirtualMachineScaleSetNetworkConfigurationProperties{ - Primary: to.Ptr(true), - EnableIPForwarding: to.Ptr(true), + Primary: new(true), + EnableIPForwarding: new(true), IPConfigurations: []*armcompute.VirtualMachineScaleSetIPConfiguration{ { - Name: to.Ptr(fmt.Sprintf("%s0", s.Runtime.VMSSName)), + Name: new(fmt.Sprintf("%s0", s.Runtime.VMSSName)), Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{ - Primary: to.Ptr(true), + Primary: new(true), PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv4), LoadBalancerBackendAddressPools: []*armcompute.SubResource{ { - ID: to.Ptr( + ID: new( fmt.Sprintf( loadBalancerBackendAddressPoolIDTemplate, config.Config.SubscriptionID, @@ -898,7 +898,7 @@ func getBaseVMSSModel(s *Scenario, customData, cseCmd string) armcompute.Virtual }, }, Subnet: &armcompute.APIEntityReference{ - ID: to.Ptr(s.Runtime.Cluster.SubnetID), + ID: new(s.Runtime.Cluster.SubnetID), }, }, }, @@ -915,14 +915,14 @@ func getBaseVMSSModel(s *Scenario, customData, cseCmd string) armcompute.Virtual model.Properties.VirtualMachineProfile.ExtensionProfile = &armcompute.VirtualMachineScaleSetExtensionProfile{ Extensions: []*armcompute.VirtualMachineScaleSetExtension{ { - Name: to.Ptr("vmssCSE"), + Name: new("vmssCSE"), Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{ - Publisher: to.Ptr("Microsoft.Azure.Extensions"), - Type: to.Ptr("CustomScript"), - TypeHandlerVersion: to.Ptr("2.1"), - AutoUpgradeMinorVersion: to.Ptr(true), - Settings: map[string]interface{}{}, - ProtectedSettings: map[string]interface{}{ + Publisher: new("Microsoft.Azure.Extensions"), + Type: new("CustomScript"), + TypeHandlerVersion: new("2.1"), + AutoUpgradeMinorVersion: new(true), + Settings: map[string]any{}, + ProtectedSettings: map[string]any{ "commandToExecute": cseCmd, }, }, @@ -939,11 +939,11 @@ func getBaseVMSSModel(s *Scenario, customData, cseCmd string) armcompute.Virtual } model.Properties.VirtualMachineProfile.StorageProfile.OSDisk.OSType = to.Ptr(armcompute.OperatingSystemTypesWindows) model.Properties.VirtualMachineProfile.OSProfile.LinuxConfiguration = nil - model.Properties.VirtualMachineProfile.ExtensionProfile.Extensions[0].Properties.Publisher = to.Ptr("Microsoft.Compute") - model.Properties.VirtualMachineProfile.ExtensionProfile.Extensions[0].Properties.Type = to.Ptr("CustomScriptExtension") - model.Properties.VirtualMachineProfile.ExtensionProfile.Extensions[0].Properties.TypeHandlerVersion = to.Ptr("1.10") - model.Properties.VirtualMachineProfile.OSProfile.AdminUsername = to.Ptr("azureuser") - model.Properties.VirtualMachineProfile.OSProfile.AdminPassword = to.Ptr(generateWindowsPassword()) + model.Properties.VirtualMachineProfile.ExtensionProfile.Extensions[0].Properties.Publisher = new("Microsoft.Compute") + model.Properties.VirtualMachineProfile.ExtensionProfile.Extensions[0].Properties.Type = new("CustomScriptExtension") + model.Properties.VirtualMachineProfile.ExtensionProfile.Extensions[0].Properties.TypeHandlerVersion = new("1.10") + model.Properties.VirtualMachineProfile.OSProfile.AdminUsername = new("azureuser") + model.Properties.VirtualMachineProfile.OSProfile.AdminPassword = new(generateWindowsPassword()) } return model } diff --git a/go.mod b/go.mod index 1741906a57b..3b916a9134b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Azure/agentbaker -go 1.24.12 +go 1.26.0 require ( github.com/Azure/go-autorest/autorest/to v0.4.1 diff --git a/hack/tools/go.mod b/hack/tools/go.mod index 4352389ff03..f11b7054d1b 100644 --- a/hack/tools/go.mod +++ b/hack/tools/go.mod @@ -1,6 +1,6 @@ module github.com/Azure/agentbaker/hack/tools -go 1.24.12 +go 1.26.0 require github.com/onsi/ginkgo v1.16.4 diff --git a/pkg/agent/baker.go b/pkg/agent/baker.go index 881215b60aa..4a68fc2be67 100644 --- a/pkg/agent/baker.go +++ b/pkg/agent/baker.go @@ -209,11 +209,11 @@ func cloudInitToButane(customData cloudInit) flatcar1_1.Config { tarFile := base0_5.File{ Path: ignitionFilesTarPath, - Mode: to.IntPtr(0o600), - Overwrite: to.BoolPtr(true), + Mode: new(0o600), + Overwrite: new(true), Contents: base0_5.Resource{ - Source: to.StringPtr(dataURL), - Compression: to.StringPtr(encodingGZIP), + Source: new(dataURL), + Compression: new(encodingGZIP), }, } butaneconfig.Storage.Files = append(butaneconfig.Storage.Files, tarFile) @@ -341,7 +341,7 @@ func (t *TemplateGenerator) getWindowsNodeCSECommand(config *datamodel.NodeBoots } // getSingleLineForTemplate returns the file as a single line for embedding in an arm template. -func (t *TemplateGenerator) getSingleLineForTemplate(textFilename string, profile interface{}, funcMap template.FuncMap, isLinux bool) (string, error) { +func (t *TemplateGenerator) getSingleLineForTemplate(textFilename string, profile any, funcMap template.FuncMap, isLinux bool) (string, error) { expandedTemplate, err := t.getSingleLine(textFilename, profile, funcMap, isLinux) if err != nil { return "", err @@ -353,7 +353,7 @@ func (t *TemplateGenerator) getSingleLineForTemplate(textFilename string, profil } // getSingleLine returns the file as a single line. -func (t *TemplateGenerator) getSingleLine(textFilename string, profile interface{}, funcMap template.FuncMap, isLinux bool) (string, error) { +func (t *TemplateGenerator) getSingleLine(textFilename string, profile any, funcMap template.FuncMap, isLinux bool) (string, error) { b, err := parts.Templates.ReadFile(textFilename) if err != nil { return "", fmt.Errorf("yaml file %s does not exist", textFilename) @@ -381,7 +381,7 @@ func (t *TemplateGenerator) getSingleLine(textFilename string, profile interface func getBakerFuncMap(config *datamodel.NodeBootstrappingConfiguration, params paramsMap, variables paramsMap) template.FuncMap { funcMap := getContainerServiceFuncMap(config) - funcMap["GetParameter"] = func(s string) interface{} { + funcMap["GetParameter"] = func(s string) any { if v, ok := params[s].(paramsMap); ok && v != nil { if v["value"] == nil { // return empty string so we don't get from go template @@ -393,7 +393,7 @@ func getBakerFuncMap(config *datamodel.NodeBootstrappingConfiguration, params pa } // TODO: GetParameterPropertyLower - funcMap["GetParameterProperty"] = func(s, p string) interface{} { + funcMap["GetParameterProperty"] = func(s, p string) any { if v, ok := params[s].(paramsMap); ok && v != nil { //nolint:errcheck // this code been writen before linter was added param := v["value"].(paramsMap)[p] @@ -406,7 +406,7 @@ func getBakerFuncMap(config *datamodel.NodeBootstrappingConfiguration, params pa return "" } - funcMap["GetVariable"] = func(s string) interface{} { + funcMap["GetVariable"] = func(s string) any { if variables[s] == nil { // return empty string so we don't get from go template return "" @@ -414,7 +414,7 @@ func getBakerFuncMap(config *datamodel.NodeBootstrappingConfiguration, params pa return variables[s] } - funcMap["GetVariableProperty"] = func(v, p string) interface{} { + funcMap["GetVariableProperty"] = func(v, p string) any { if v, ok := variables[v].(paramsMap); ok && v != nil { if v[p] == nil { // return empty string so we don't get from go template @@ -627,7 +627,7 @@ func getContainerServiceFuncMap(config *datamodel.NodeBootstrappingConfiguration "ShouldConfigCustomSysctl": func() bool { return profile.CustomLinuxOSConfig != nil && profile.CustomLinuxOSConfig.Sysctls != nil }, - "GetCustomSysctlConfigByName": func(fn string) interface{} { + "GetCustomSysctlConfigByName": func(fn string) any { if profile.CustomLinuxOSConfig != nil && profile.CustomLinuxOSConfig.Sysctls != nil { v := reflect.ValueOf(*profile.CustomLinuxOSConfig.Sysctls) return v.FieldByName(fn).Interface() @@ -672,13 +672,13 @@ func getContainerServiceFuncMap(config *datamodel.NodeBootstrappingConfiguration var sb strings.Builder sb.WriteString("[Service]\n") if ulimitConfig.MaxLockedMemory != "" { - sb.WriteString(fmt.Sprintf("LimitMEMLOCK=%s\n", ulimitConfig.MaxLockedMemory)) + fmt.Fprintf(&sb, "LimitMEMLOCK=%s\n", ulimitConfig.MaxLockedMemory) } if ulimitConfig.NoFile != "" { // ulimit is removed in containerd 2.0+, which is available only in ubuntu2404 distro // https://github.com/containerd/containerd/blob/main/docs/containerd-2.0.md#limitnofile-configuration-has-been-removed if !profile.Is2404VHDDistro() { - sb.WriteString(fmt.Sprintf("LimitNOFILE=%s\n", ulimitConfig.NoFile)) + fmt.Fprintf(&sb, "LimitNOFILE=%s\n", ulimitConfig.NoFile) } } return sb.String() diff --git a/pkg/agent/baker_test.go b/pkg/agent/baker_test.go index ef6f8f08b64..c3e7585d072 100644 --- a/pkg/agent/baker_test.go +++ b/pkg/agent/baker_test.go @@ -968,7 +968,7 @@ testdomain567.com:53 { config.KubeletConfig["--rotate-server-certificates"] = "false" config.ContainerService.Properties.AgentPoolProfiles[0].CustomKubeletConfig = &datamodel.CustomKubeletConfig{ CPUManagerPolicy: "static", - CPUCfsQuota: to.BoolPtr(false), + CPUCfsQuota: new(false), CPUCfsQuotaPeriod: "200ms", ImageGcHighThreshold: to.Int32Ptr(90), ImageGcLowThreshold: to.Int32Ptr(70), @@ -994,7 +994,7 @@ testdomain567.com:53 { config.KubeletConfig["--rotate-server-certificates"] = "true" config.ContainerService.Properties.AgentPoolProfiles[0].CustomKubeletConfig = &datamodel.CustomKubeletConfig{ CPUManagerPolicy: "static", - CPUCfsQuota: to.BoolPtr(false), + CPUCfsQuota: new(false), CPUCfsQuotaPeriod: "200ms", ImageGcHighThreshold: to.Int32Ptr(90), ImageGcLowThreshold: to.Int32Ptr(70), @@ -1655,7 +1655,7 @@ oom_score = -999 var netCoreSomaxconn int32 = 1638499 config.ContainerService.Properties.AgentPoolProfiles[0].CustomKubeletConfig = &datamodel.CustomKubeletConfig{ CPUManagerPolicy: "static", - CPUCfsQuota: to.BoolPtr(false), + CPUCfsQuota: new(false), CPUCfsQuotaPeriod: "200ms", ImageGcHighThreshold: to.Int32Ptr(90), ImageGcLowThreshold: to.Int32Ptr(70), @@ -1665,7 +1665,7 @@ oom_score = -999 ContainerLogMaxSizeMB: to.Int32Ptr(1000), ContainerLogMaxFiles: to.Int32Ptr(99), PodMaxPids: to.Int32Ptr(12345), - SeccompDefault: to.BoolPtr(true), + SeccompDefault: new(true), } config.ContainerService.Properties.AgentPoolProfiles[0].CustomLinuxOSConfig = &datamodel.CustomLinuxOSConfig{ Sysctls: &datamodel.SysctlConfig{ @@ -1691,7 +1691,7 @@ oom_score = -999 var kubeletConfigFile datamodel.AKSKubeletConfiguration err = json.Unmarshal([]byte(kubeletConfigFileContent), &kubeletConfigFile) Expect(err).To(BeNil()) - Expect(kubeletConfigFile.SeccompDefault).To(Equal(to.BoolPtr(true))) + Expect(kubeletConfigFile.SeccompDefault).To(Equal(new(true))) sysctlContent, err := getBase64DecodedValue([]byte(o.vars["SYSCTL_CONTENT"])) Expect(err).To(BeNil()) @@ -1716,7 +1716,7 @@ oom_score = -999 config.KubeletConfig["--serialize-image-pulls"] = "false" config.ContainerService.Properties.AgentPoolProfiles[0].CustomKubeletConfig = &datamodel.CustomKubeletConfig{ CPUManagerPolicy: "static", - CPUCfsQuota: to.BoolPtr(false), + CPUCfsQuota: new(false), CPUCfsQuotaPeriod: "200ms", ImageGcHighThreshold: to.Int32Ptr(90), ImageGcLowThreshold: to.Int32Ptr(70), @@ -1890,9 +1890,9 @@ var _ = Describe("Assert generated customData and cseCmd for Windows", func() { NetworkPlugin: "azure", DockerBridgeSubnet: "172.17.0.1/16", ServiceCIDR: "10.0.0.0/16", - EnableRbac: to.BoolPtr(true), - EnableSecureKubelet: to.BoolPtr(true), - UseInstanceMetadata: to.BoolPtr(true), + EnableRbac: new(true), + EnableSecureKubelet: new(true), + UseInstanceMetadata: new(true), DNSServiceIP: "10.0.0.10", }, }, @@ -2095,7 +2095,7 @@ var _ = Describe("Assert generated customData and cseCmd for Windows", func() { }), Entry("AKSWindows2019 with k8s version 1.19 + CSI", "AKSWindows2019+K8S119+CSI", "1.19.0", func(config *datamodel.NodeBootstrappingConfiguration) { config.ContainerService.Properties.WindowsProfile.CSIProxyURL = "https://acs-mirror.azureedge.net/csi-proxy/v0.1.0/binaries/csi-proxy.tar.gz" - config.ContainerService.Properties.WindowsProfile.EnableCSIProxy = to.BoolPtr(true) + config.ContainerService.Properties.WindowsProfile.EnableCSIProxy = new(true) }), Entry("AKSWindows2019 with CustomVnet", "AKSWindows2019+CustomVnet", "1.19.0", func(config *datamodel.NodeBootstrappingConfiguration) { config.ContainerService.Properties.OrchestratorProfile.KubernetesConfig.ClusterSubnet = "172.17.0.0/24" @@ -2110,7 +2110,7 @@ var _ = Describe("Assert generated customData and cseCmd for Windows", func() { config.ContainerService.Properties.OrchestratorProfile.KubernetesConfig.UserAssignedID = "/subscriptions/359833f5/resourceGroups/MC_rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/k8s-agentpool" //nolint:lll }), Entry("AKSWindows2019 with custom cloud", "AKSWindows2019+CustomCloud", "1.19.0", func(config *datamodel.NodeBootstrappingConfiguration) { - config.ContainerService.Properties.WindowsProfile.AlwaysPullWindowsPauseImage = to.BoolPtr(true) + config.ContainerService.Properties.WindowsProfile.AlwaysPullWindowsPauseImage = new(true) config.ContainerService.Properties.CustomCloudEnv = &datamodel.CustomCloudEnv{ Name: "akscustom", McrURL: "mcr.microsoft.fakecustomcloud", @@ -2149,14 +2149,14 @@ var _ = Describe("Assert generated customData and cseCmd for Windows", func() { func(config *datamodel.NodeBootstrappingConfiguration) { cs := config.ContainerService if cs.Properties.OrchestratorProfile.KubernetesConfig.PrivateCluster == nil { - cs.Properties.OrchestratorProfile.KubernetesConfig.PrivateCluster = &datamodel.PrivateCluster{EnableHostsConfigAgent: to.BoolPtr(true)} + cs.Properties.OrchestratorProfile.KubernetesConfig.PrivateCluster = &datamodel.PrivateCluster{EnableHostsConfigAgent: new(true)} } else { - cs.Properties.OrchestratorProfile.KubernetesConfig.PrivateCluster.EnableHostsConfigAgent = to.BoolPtr(true) + cs.Properties.OrchestratorProfile.KubernetesConfig.PrivateCluster.EnableHostsConfigAgent = new(true) } }), Entry("AKSWindows2019 with kubelet client TLS bootstrapping enabled", "AKSWindows2019+KubeletClientTLSBootstrapping", "1.19.0", func(config *datamodel.NodeBootstrappingConfiguration) { - config.KubeletClientTLSBootstrapToken = to.StringPtr("07401b.f395accd246ae52d") + config.KubeletClientTLSBootstrapToken = new("07401b.f395accd246ae52d") }), Entry("AKSWindows2019 with kubelet serving certificate rotation enabled", "AKSWindows2019+KubeletServingCertificateRotation", "1.29.7", func(config *datamodel.NodeBootstrappingConfiguration) { @@ -2176,13 +2176,13 @@ var _ = Describe("Assert generated customData and cseCmd for Windows", func() { } }), Entry("AKSWindows2019 with out of tree credential provider", "AKSWindows2019+ootcredentialprovider", "1.29.0", func(config *datamodel.NodeBootstrappingConfiguration) { - config.ContainerService.Properties.WindowsProfile.AlwaysPullWindowsPauseImage = to.BoolPtr(true) + config.ContainerService.Properties.WindowsProfile.AlwaysPullWindowsPauseImage = new(true) config.KubeletConfig["--image-credential-provider-config"] = "c:\\var\\lib\\kubelet\\credential-provider-config.yaml" config.KubeletConfig["--image-credential-provider-bin-dir"] = "c:\\var\\lib\\kubelet\\credential-provider" }), Entry("AKSWindows2019 with custom cloud and out of tree credential provider", "AKSWindows2019+CustomCloud+ootcredentialprovider", "1.29.0", func(config *datamodel.NodeBootstrappingConfiguration) { - config.ContainerService.Properties.WindowsProfile.AlwaysPullWindowsPauseImage = to.BoolPtr(true) + config.ContainerService.Properties.WindowsProfile.AlwaysPullWindowsPauseImage = new(true) config.ContainerService.Properties.CustomCloudEnv = &datamodel.CustomCloudEnv{ Name: "akscustom", McrURL: "mcr.microsoft.fakecustomcloud", @@ -2222,22 +2222,22 @@ var _ = Describe("Assert generated customData and cseCmd for Windows", func() { Entry("AKSWindows23H2Gen2 with NextGenNetworking", "AKSWindows23H2Gen2+NextGenNetworking", "1.29.0", func(config *datamodel.NodeBootstrappingConfiguration) { config.AgentPoolProfile.AgentPoolWindowsProfile = &datamodel.AgentPoolWindowsProfile{ - NextGenNetworkingEnabled: to.BoolPtr(true), - NextGenNetworkingConfig: to.StringPtr("{}"), + NextGenNetworkingEnabled: new(true), + NextGenNetworkingConfig: new("{}"), } }), Entry("AKSWindows23H2Gen2 with NextGenNetworking enabled but no config", "AKSWindows23H2Gen2+NextGenNetworkingNoConfig", "1.29.0", func(config *datamodel.NodeBootstrappingConfiguration) { config.AgentPoolProfile.AgentPoolWindowsProfile = &datamodel.AgentPoolWindowsProfile{ - NextGenNetworkingEnabled: to.BoolPtr(true), + NextGenNetworkingEnabled: new(true), NextGenNetworkingConfig: nil, } }), Entry("AKSWindows23H2Gen2 with NextGenNetworking disabled", "AKSWindows23H2Gen2+NextGenNetworkingDisabled", "1.29.0", func(config *datamodel.NodeBootstrappingConfiguration) { config.AgentPoolProfile.AgentPoolWindowsProfile = &datamodel.AgentPoolWindowsProfile{ - NextGenNetworkingEnabled: to.BoolPtr(false), - NextGenNetworkingConfig: to.StringPtr("{}"), + NextGenNetworkingEnabled: new(false), + NextGenNetworkingConfig: new("{}"), } }), ) @@ -2284,7 +2284,7 @@ func writeInnerCustomData(outputname, customData string) error { return os.WriteFile(outputname, ignitionIndented, 0644) } - ignitionMap := map[string]interface{}{} + ignitionMap := map[string]any{} if err := json.Unmarshal(ignition, &ignitionMap); err != nil { return err } @@ -2292,27 +2292,27 @@ func writeInnerCustomData(outputname, customData string) error { if err != nil { return err } - files := []map[string]interface{}{} + files := []map[string]any{} decodedFiles, err := decodeTarFiles(contents) if err != nil { return err } for _, entry := range decodedFiles { gzippedContents := getGzippedBufferFromBytes([]byte(entry.value)) - files = append(files, map[string]interface{}{ + files = append(files, map[string]any{ "path": entry.path, "overwrite": true, "mode": entry.mode, - "contents": map[string]interface{}{ + "contents": map[string]any{ "compression": encodingGZIP, "source": "data:;base64," + base64.StdEncoding.EncodeToString(gzippedContents), }, }) } - storage, ok := ignitionMap["storage"].(map[string]interface{}) + storage, ok := ignitionMap["storage"].(map[string]any) if !ok { - storage = map[string]interface{}{} + storage = map[string]any{} ignitionMap["storage"] = storage } storage["files"] = files @@ -2454,14 +2454,14 @@ var _ = Describe("Test normalizeResourceGroupNameForLabel", func() { Expect(normalizeResourceGroupNameForLabel("hel(lo")).To(Equal("hel-lo")) Expect(normalizeResourceGroupNameForLabel("hel)lo")).To(Equal("hel-lo")) var s string - for i := 0; i < 63; i++ { + for range 63 { s += "0" } Expect(normalizeResourceGroupNameForLabel(s)).To(Equal(s)) Expect(normalizeResourceGroupNameForLabel(s + "1")).To(Equal(s)) s = "" - for i := 0; i < 62; i++ { + for range 62 { s += "0" } Expect(normalizeResourceGroupNameForLabel(s + "(")).To(Equal(s + "z")) @@ -2476,7 +2476,7 @@ var _ = Describe("Test normalizeResourceGroupNameForLabel", func() { Expect(normalizeResourceGroupNameForLabel("-")).To(Equal("-z")) s = "" - for i := 0; i < 61; i++ { + for range 61 { s += "0" } Expect(normalizeResourceGroupNameForLabel(s + "-")).To(Equal(s + "-z")) @@ -2667,7 +2667,7 @@ var _ = Describe("getLinuxNodeCSECommand", func() { }) It("should handle TLS bootstrapping configuration", func() { - baseConfig.KubeletClientTLSBootstrapToken = to.StringPtr("07401b.f395accd246ae52d") + baseConfig.KubeletClientTLSBootstrapToken = new("07401b.f395accd246ae52d") cseCmd := templateGenerator.getLinuxNodeCSECommand(baseConfig) diff --git a/pkg/agent/bakerapi.go b/pkg/agent/bakerapi.go index 9cf7a2eb233..4f11e9157c7 100644 --- a/pkg/agent/bakerapi.go +++ b/pkg/agent/bakerapi.go @@ -6,6 +6,7 @@ package agent import ( "context" "fmt" + "maps" "github.com/Azure/agentbaker/pkg/agent/datamodel" "github.com/Azure/agentbaker/pkg/agent/toggles" @@ -120,9 +121,7 @@ func (agentBaker *agentBakerImpl) GetDistroSigImageConfig( e := toggles.NewEntityFromEnvironmentInfo(envInfo) allDistros := map[datamodel.Distro]datamodel.SigImageConfig{} - for distro, sigConfig := range allAzureSigConfig.SigWindowsImageConfig { - allDistros[distro] = sigConfig - } + maps.Copy(allDistros, allAzureSigConfig.SigWindowsImageConfig) for distro, sigConfig := range allAzureSigConfig.SigCBLMarinerImageConfig { imageVersion := agentBaker.toggles.GetLinuxNodeImageVersion(e, distro) diff --git a/pkg/agent/datamodel/azenvtypes.go b/pkg/agent/datamodel/azenvtypes.go index 597071a336f..0374f4f0e36 100644 --- a/pkg/agent/datamodel/azenvtypes.go +++ b/pkg/agent/datamodel/azenvtypes.go @@ -6,8 +6,8 @@ package datamodel // AzureEnvironmentSpecConfig is the overall configuration differences in different cloud environments. type AzureEnvironmentSpecConfig struct { CloudName string `json:"cloudName,omitempty"` - KubernetesSpecConfig KubernetesSpecConfig `json:"kubernetesSpecConfig,omitempty"` - EndpointConfig AzureEndpointConfig `json:"endpointConfig,omitempty"` + KubernetesSpecConfig KubernetesSpecConfig `json:"kubernetesSpecConfig"` + EndpointConfig AzureEndpointConfig `json:"endpointConfig"` OSImageConfig map[Distro]AzureOSImageConfig `json:"osImageConfig,omitempty"` } diff --git a/pkg/agent/datamodel/helper.go b/pkg/agent/datamodel/helper.go index c96137ff60f..0665f6af573 100644 --- a/pkg/agent/datamodel/helper.go +++ b/pkg/agent/datamodel/helper.go @@ -66,7 +66,7 @@ func GetOrderedEscapedKeyValsString(config map[string]string) string { sort.Strings(keys) var buf bytes.Buffer for _, key := range keys { - buf.WriteString(fmt.Sprintf("\"%s=%s\", ", key, config[key])) + fmt.Fprintf(&buf, "\"%s=%s\", ", key, config[key]) } return strings.TrimSuffix(buf.String(), ", ") } @@ -86,7 +86,7 @@ func IndentString(original string, spaces int) string { out := bytes.NewBuffer(nil) scanner := bufio.NewScanner(strings.NewReader(original)) for scanner.Scan() { - for i := 0; i < spaces; i++ { + for range spaces { out.WriteString(" ") } out.WriteString(scanner.Text()) diff --git a/pkg/agent/datamodel/helper_test.go b/pkg/agent/datamodel/helper_test.go index 8ed1a993fdf..d877191cf48 100644 --- a/pkg/agent/datamodel/helper_test.go +++ b/pkg/agent/datamodel/helper_test.go @@ -54,7 +54,6 @@ func TestValidateDNSPrefix(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() err := ValidateDNSPrefix(c.dnsPrefix) @@ -153,7 +152,6 @@ func TestIsSGXEnabledSKU(t *testing.T) { cases := getCSeriesVMCasesForTesting() for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() ret := IsSgxEnabledSKU(c.VMSKU) @@ -195,7 +193,6 @@ func TestGetOrderedEscapedKeyValsString(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() ret := GetOrderedEscapedKeyValsString(c.input) @@ -266,7 +263,6 @@ func TestSliceIntIsNonEmpty(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() ret := SliceIntIsNonEmpty(c.input) @@ -296,7 +292,6 @@ func TestWrapAsVerbatim(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() ret := WrapAsVerbatim(test.s) @@ -335,7 +330,6 @@ func TestIndentString(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() got := IndentString(test.input, test.count) @@ -369,7 +363,6 @@ func TestGetContainerImageNameFromURL(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() got, err := getContainerImageNameFromURL(test.downloadURL) @@ -408,7 +401,6 @@ func TestGetComponentNameFromURL(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() got, err := getComponentNameFromURL(test.downloadURL) diff --git a/pkg/agent/datamodel/mocks.go b/pkg/agent/datamodel/mocks.go index 96f27ae4184..79791ca7ef2 100644 --- a/pkg/agent/datamodel/mocks.go +++ b/pkg/agent/datamodel/mocks.go @@ -46,7 +46,7 @@ func GetK8sDefaultProperties(hasWindows bool) *Properties { func getMockProperitesWithCustomClouEnv() Properties { properties := Properties{ - CustomCloudEnv: &CustomCloudEnv{ + CustomCloudEnv: &CustomCloudEnv{ //nolint: gosec Name: "akscustom", McrURL: "mcr.microsoft.fakecustomcloud", RepoDepotEndpoint: "https://repodepot.azure.microsoft.fakecustomcloud/ubuntu", diff --git a/pkg/agent/datamodel/sig_config.go b/pkg/agent/datamodel/sig_config.go index 27e1af49755..b5fc17d6ba6 100644 --- a/pkg/agent/datamodel/sig_config.go +++ b/pkg/agent/datamodel/sig_config.go @@ -4,6 +4,7 @@ import ( _ "embed" "encoding/json" "fmt" + "slices" "strings" ) @@ -264,37 +265,17 @@ var AvailableFlatcarDistros = []Distro{ // IsContainerdSKU returns true if distro type is containerd-enabled. func (d Distro) IsContainerdDistro() bool { - for _, distro := range AvailableContainerdDistros { - if d == distro { - return true - } - } - return false + return slices.Contains(AvailableContainerdDistros, d) } func (d Distro) IsGen2Distro() bool { - for _, distro := range AvailableGen2Distros { - if d == distro { - return true - } - } - return false + return slices.Contains(AvailableGen2Distros, d) } func (d Distro) IsAzureLinuxDistro() bool { - for _, distro := range AvailableAzureLinuxDistros { - if d == distro { - return true - } - } - return false + return slices.Contains(AvailableAzureLinuxDistros, d) } func (d Distro) IsWindowsSIGDistro() bool { - for _, distro := range AvailableWindowsSIGDistros { - if d == distro { - return true - } - } - return false + return slices.Contains(AvailableWindowsSIGDistros, d) } func (d Distro) IsWindowsDistro() bool { diff --git a/pkg/agent/datamodel/types.go b/pkg/agent/datamodel/types.go index 117174f34c2..684126ad1ae 100644 --- a/pkg/agent/datamodel/types.go +++ b/pkg/agent/datamodel/types.go @@ -8,8 +8,10 @@ import ( "encoding/json" "fmt" "hash/fnv" + "maps" "math/rand" neturl "net/url" + "slices" "sort" "strings" "sync" @@ -282,40 +284,20 @@ const ( ) func (d Distro) IsVHDDistro() bool { - for _, distro := range AKSDistrosAvailableOnVHD { - if d == distro { - return true - } - } - return false + return slices.Contains(AKSDistrosAvailableOnVHD, d) } func (d Distro) Is2204VHDDistro() bool { - for _, distro := range AvailableUbuntu2204Distros { - if d == distro { - return true - } - } - return false + return slices.Contains(AvailableUbuntu2204Distros, d) } // This function will later be consumed by CSE to determine cgroupv2 usage. func (d Distro) Is2404VHDDistro() bool { - for _, distro := range AvailableUbuntu2404Distros { - if d == distro { - return true - } - } - return false + return slices.Contains(AvailableUbuntu2404Distros, d) } func (d Distro) IsAzureLinuxCgroupV2VHDDistro() bool { - for _, distro := range AvailableAzureLinuxCgroupV2Distros { - if d == distro { - return true - } - } - return false + return slices.Contains(AvailableAzureLinuxCgroupV2Distros, d) } func (d Distro) IsKataDistro() bool { @@ -323,21 +305,11 @@ func (d Distro) IsKataDistro() bool { } func (d Distro) IsFlatcarDistro() bool { - for _, distro := range AvailableFlatcarDistros { - if d == distro { - return true - } - } - return false + return slices.Contains(AvailableFlatcarDistros, d) } func (d Distro) IsAzureLinuxOSGuardDistro() bool { - for _, distro := range AvailableAzureLinuxOSGuardDistros { - if d == distro { - return true - } - } - return false + return slices.Contains(AvailableAzureLinuxOSGuardDistros, d) } /* @@ -408,7 +380,7 @@ type CustomCloudEnv struct { ContainerRegistryDNSSuffix string `json:"containerRegistryDNSSuffix,omitempty"` CosmosDBDNSSuffix string `json:"cosmosDBDNSSuffix,omitempty"` TokenAudience string `json:"tokenAudience,omitempty"` - ResourceIdentifiers ResourceIdentifiers `json:"resourceIdentifiers,omitempty"` + ResourceIdentifiers ResourceIdentifiers `json:"resourceIdentifiers"` } // FeatureFlags defines feature-flag restricted functionality. @@ -494,7 +466,7 @@ type CertificateProfile struct { // ServicePrincipalProfile contains the client and secret used by the cluster for Azure Resource CRUD. type ServicePrincipalProfile struct { ClientID string `json:"clientId"` - Secret string `json:"secret,omitempty" conform:"redact"` + Secret string `json:"secret,omitempty" conform:"redact"` //nolint: gosec ObjectID string `json:"objectId,omitempty"` KeyvaultSecretRef *KeyvaultSecretRef `json:"keyvaultSecretRef,omitempty"` } @@ -1169,7 +1141,7 @@ func (p *Properties) GetKubeProxyFeatureGatesWindowsArguments() string { sort.Strings(keys) var buf bytes.Buffer for _, key := range keys { - buf.WriteString(fmt.Sprintf("\"%s=%t\", ", key, featureGates[key])) + fmt.Fprintf(&buf, "\"%s=%t\", ", key, featureGates[key]) } return strings.TrimSuffix(buf.String(), ", ") } @@ -1231,8 +1203,8 @@ func (a *AgentPoolProfile) IsAvailabilitySets() bool { // GetKubernetesLabels returns a k8s API-compliant labels string for nodes in this profile. func (a *AgentPoolProfile) GetKubernetesLabels() string { var buf bytes.Buffer - buf.WriteString(fmt.Sprintf("agentpool=%s", a.Name)) - buf.WriteString(fmt.Sprintf(",kubernetes.azure.com/agentpool=%s", a.Name)) + fmt.Fprintf(&buf, "agentpool=%s", a.Name) + fmt.Fprintf(&buf, ",kubernetes.azure.com/agentpool=%s", a.Name) keys := []string{} for key := range a.CustomNodeLabels { @@ -1240,7 +1212,7 @@ func (a *AgentPoolProfile) GetKubernetesLabels() string { } sort.Strings(keys) for _, key := range keys { - buf.WriteString(fmt.Sprintf(",%s=%s", key, a.CustomNodeLabels[key])) + fmt.Fprintf(&buf, ",%s=%s", key, a.CustomNodeLabels[key]) } return buf.String() } @@ -1570,9 +1542,7 @@ func (config *NodeBootstrappingConfiguration) GetOrderedKubeletConfigStringForPo kubeletCustomConfiguration := config.ContainerService.Properties.GetComponentWindowsKubernetesConfiguration(Componentkubelet) if kubeletCustomConfiguration != nil { config := kubeletCustomConfiguration.Config - for k, v := range config { - kubeletConfig[k] = v - } + maps.Copy(kubeletConfig, config) } } @@ -1594,7 +1564,7 @@ func (config *NodeBootstrappingConfiguration) GetOrderedKubeletConfigStringForPo sort.Strings(keys) var buf bytes.Buffer for _, key := range keys { - buf.WriteString(fmt.Sprintf("\"%s=%s\", ", key, kubeletConfig[key])) + fmt.Fprintf(&buf, "\"%s=%s\", ", key, kubeletConfig[key]) } return strings.TrimSuffix(buf.String(), ", ") } @@ -1624,9 +1594,7 @@ func (config *NodeBootstrappingConfiguration) GetOrderedKubeproxyConfigStringFor kubeProxyCustomConfiguration := config.ContainerService.Properties.GetComponentWindowsKubernetesConfiguration(ComponentkubeProxy) if kubeProxyCustomConfiguration != nil { customConfig := kubeProxyCustomConfiguration.Config - for k, v := range customConfig { - kubeproxyConfig[k] = v - } + maps.Copy(kubeproxyConfig, customConfig) } keys := []string{} for key := range kubeproxyConfig { @@ -1635,7 +1603,7 @@ func (config *NodeBootstrappingConfiguration) GetOrderedKubeproxyConfigStringFor sort.Strings(keys) var buf bytes.Buffer for _, key := range keys { - buf.WriteString(fmt.Sprintf("\"%s=%s\", ", key, kubeproxyConfig[key])) + fmt.Fprintf(&buf, "\"%s=%s\", ", key, kubeproxyConfig[key]) } return strings.TrimSuffix(buf.String(), ", ") } diff --git a/pkg/agent/datamodel/types_test.go b/pkg/agent/datamodel/types_test.go index 0cc6c1d876e..a5df054a6a0 100644 --- a/pkg/agent/datamodel/types_test.go +++ b/pkg/agent/datamodel/types_test.go @@ -104,7 +104,7 @@ func TestPropertiesIsIPMasqAgentDisabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: "coredns", - Enabled: to.BoolPtr(true), + Enabled: new(true), }, }, }, @@ -120,7 +120,7 @@ func TestPropertiesIsIPMasqAgentDisabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: IPMASQAgentAddonName, - Enabled: to.BoolPtr(false), + Enabled: new(false), }, }, }, @@ -151,7 +151,7 @@ func TestPropertiesIsIPMasqAgentDisabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: IPMASQAgentAddonName, - Enabled: to.BoolPtr(true), + Enabled: new(true), }, }, }, @@ -162,7 +162,6 @@ func TestPropertiesIsIPMasqAgentDisabled(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() if c.p.IsIPMasqAgentDisabled() != c.expectedDisabled { @@ -264,7 +263,7 @@ func TestIsIPMasqAgentEnabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: IPMASQAgentAddonName, - Enabled: to.BoolPtr(false), + Enabled: new(false), Containers: []KubernetesContainerSpec{ { Name: IPMASQAgentAddonName, @@ -286,7 +285,7 @@ func TestIsIPMasqAgentEnabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: IPMASQAgentAddonName, - Enabled: to.BoolPtr(false), + Enabled: new(false), Containers: []KubernetesContainerSpec{ { Name: IPMASQAgentAddonName, @@ -311,7 +310,7 @@ func TestIsIPMasqAgentEnabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: IPMASQAgentAddonName, - Enabled: to.BoolPtr(true), + Enabled: new(true), Containers: []KubernetesContainerSpec{ { Name: IPMASQAgentAddonName, @@ -336,7 +335,7 @@ func TestIsIPMasqAgentEnabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: IPMASQAgentAddonName, - Enabled: to.BoolPtr(true), + Enabled: new(true), Containers: []KubernetesContainerSpec{ { Name: IPMASQAgentAddonName, @@ -401,7 +400,6 @@ func TestGenerateClusterID(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() actual := test.properties.GetClusterID() @@ -648,7 +646,6 @@ func TestGetSubnetName(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() actual := test.properties.GetSubnetName() @@ -669,14 +666,14 @@ func TestIsNextGenNetworkingEnabled(t *testing.T) { { name: "NextGenNetworkingEnabled is true", profile: &AgentPoolWindowsProfile{ - NextGenNetworkingEnabled: to.BoolPtr(true), + NextGenNetworkingEnabled: new(true), }, expected: true, }, { name: "NextGenNetworkingEnabled is false", profile: &AgentPoolWindowsProfile{ - NextGenNetworkingEnabled: to.BoolPtr(false), + NextGenNetworkingEnabled: new(false), }, expected: false, }, @@ -688,7 +685,6 @@ func TestIsNextGenNetworkingEnabled(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() actual := test.profile.IsNextGenNetworkingEnabled() @@ -709,7 +705,7 @@ func TestGetNextGenNetworkingConfig(t *testing.T) { { name: "NextGenNetworkingConfig is set", profile: &AgentPoolWindowsProfile{ - NextGenNetworkingConfig: to.StringPtr("config"), + NextGenNetworkingConfig: new("config"), }, expected: "config", }, @@ -721,7 +717,6 @@ func TestGetNextGenNetworkingConfig(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() actual := test.profile.GetNextGenNetworkingConfig() @@ -816,7 +811,6 @@ func TestProperties_GetVirtualNetworkName(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() actual := test.properties.GetVirtualNetworkName() @@ -914,7 +908,6 @@ func TestAgentPoolProfileIsVHDDistro(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() if c.expected != c.ap.IsVHDDistro() { @@ -961,7 +954,6 @@ func TestAgentPoolProfileIs2204VHDDistro(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() if c.expected != c.ap.Is2204VHDDistro() { @@ -1015,7 +1007,6 @@ func TestAgentPoolProfileIs2404VHDDistro(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() if c.expected != c.ap.Is2404VHDDistro() { @@ -1174,7 +1165,6 @@ func TestAgentPoolProfileIsAzureLinuxCgroupV2VHDDistro(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() if c.expected != c.ap.IsAzureLinuxCgroupV2VHDDistro() { @@ -1214,7 +1204,6 @@ func TestAgentPoolProfileIsFlatcarVHDDistro(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() isFlatcar := c.ap.IsFlatcar() @@ -1272,7 +1261,6 @@ func TestFlatcarAndCustomDistro(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() if c.nbc.AgentPoolProfile.Distro != c.nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro { @@ -1347,7 +1335,6 @@ func TestAgentPoolProfileGetKubernetesLabels(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() if c.expected != c.ap.GetKubernetesLabels() { @@ -1475,7 +1462,7 @@ func TestHasStorageProfile(t *testing.T) { OrchestratorType: Kubernetes, KubernetesConfig: &KubernetesConfig{ PrivateCluster: &PrivateCluster{ - Enabled: to.BoolPtr(true), + Enabled: new(true), JumpboxProfile: &PrivateJumpboxProfile{ StorageProfile: ManagedDisks, }, @@ -1502,7 +1489,7 @@ func TestHasStorageProfile(t *testing.T) { OrchestratorType: Kubernetes, KubernetesConfig: &KubernetesConfig{ PrivateCluster: &PrivateCluster{ - Enabled: to.BoolPtr(true), + Enabled: new(true), JumpboxProfile: &PrivateJumpboxProfile{ StorageProfile: StorageAccount, }, @@ -1571,7 +1558,6 @@ func TestHasStorageProfile(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() if c.p.OrchestratorProfile != nil && c.p.OrchestratorProfile.KubernetesConfig.PrivateJumpboxProvision() != c.expectedPrivateJB { @@ -1664,10 +1650,10 @@ func TestWindowsProfile(t *testing.T) { }, }, WindowsImageSourceURL: "testCustomImage", - IsCredentialAutoGenerated: to.BoolPtr(true), - EnableAHUB: to.BoolPtr(true), - EnableCSIProxy: to.BoolPtr(true), - AlwaysPullWindowsPauseImage: to.BoolPtr(true), + IsCredentialAutoGenerated: new(true), + EnableAHUB: new(true), + EnableCSIProxy: new(true), + AlwaysPullWindowsPauseImage: new(true), } if !w.HasSecrets() || !w.HasCustomImage() { @@ -1688,8 +1674,8 @@ func TestWindowsProfile(t *testing.T) { WindowsDockerVersion: "18.03.1-ee-3", WindowsSku: "Datacenter-Core-1809-with-Containers-smalldisk", SSHEnabled: &trueVar, - IsCredentialAutoGenerated: to.BoolPtr(false), - EnableAHUB: to.BoolPtr(false), + IsCredentialAutoGenerated: new(false), + EnableAHUB: new(false), ContainerdWindowsRuntimes: &ContainerdWindowsRuntimes{ DefaultSandboxIsolation: "hyperv", RuntimeHandlers: []RuntimeHandlers{ @@ -1698,7 +1684,7 @@ func TestWindowsProfile(t *testing.T) { }, }, WindowsGmsaPackageUrl: "windows-gmsa-package-url", - WindowsSecureTlsEnabled: to.BoolPtr(false), + WindowsSecureTlsEnabled: new(false), } dv = w.GetWindowsDockerVersion() @@ -1828,7 +1814,6 @@ func TestWindowsProfileCustomOS(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() if c.w.HasCustomImage() != c.expectedURL { @@ -1986,7 +1971,6 @@ func TestIsFeatureEnabled(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() actual := test.flags.IsFeatureEnabled(test.feature) @@ -2122,7 +2106,6 @@ func TestGetKubeProxyFeatureGatesWindowsArguments(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() actual := test.properties.GetKubeProxyFeatureGatesWindowsArguments() @@ -2160,7 +2143,7 @@ func TestKubernetesConfigIsAddonEnabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: "foo", - Enabled: to.BoolPtr(false), + Enabled: new(false), }, }, }, @@ -2172,7 +2155,7 @@ func TestKubernetesConfigIsAddonEnabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: "foo", - Enabled: to.BoolPtr(true), + Enabled: new(true), }, }, }, @@ -2184,7 +2167,7 @@ func TestKubernetesConfigIsAddonEnabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: "bar", - Enabled: to.BoolPtr(true), + Enabled: new(true), }, }, }, @@ -2229,7 +2212,7 @@ func TestKubernetesConfigIsIPMasqAgentDisabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: IPMASQAgentAddonName, - Enabled: to.BoolPtr(false), + Enabled: new(false), }, }, }, @@ -2241,7 +2224,7 @@ func TestKubernetesConfigIsIPMasqAgentDisabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: IPMASQAgentAddonName, - Enabled: to.BoolPtr(true), + Enabled: new(true), }, }, }, @@ -2250,7 +2233,6 @@ func TestKubernetesConfigIsIPMasqAgentDisabled(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() if c.k.IsIPMasqAgentDisabled() != c.expectedDisabled { @@ -2355,7 +2337,7 @@ func TestKubernetesConfigIsAddonDisabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: "foo", - Enabled: to.BoolPtr(false), + Enabled: new(false), }, }, }, @@ -2367,7 +2349,7 @@ func TestKubernetesConfigIsAddonDisabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: "foo", - Enabled: to.BoolPtr(true), + Enabled: new(true), }, }, }, @@ -2379,7 +2361,7 @@ func TestKubernetesConfigIsAddonDisabled(t *testing.T) { Addons: []KubernetesAddon{ { Name: "bar", - Enabled: to.BoolPtr(true), + Enabled: new(true), }, }, }, @@ -2465,7 +2447,6 @@ func TestKubernetesConfigGetOrderedKubeletConfigString(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() if c.expectedForPowershell != c.config.GetOrderedKubeletConfigStringForPowershell(c.CustomKubeletConfig) { @@ -2487,13 +2468,13 @@ func TestKubernetesAddonIsEnabled(t *testing.T) { }, { a: &KubernetesAddon{ - Enabled: to.BoolPtr(false), + Enabled: new(false), }, expected: false, }, { a: &KubernetesAddon{ - Enabled: to.BoolPtr(true), + Enabled: new(true), }, expected: true, }, @@ -2517,13 +2498,13 @@ func TestKubernetesAddonIsDisabled(t *testing.T) { }, { a: &KubernetesAddon{ - Enabled: to.BoolPtr(false), + Enabled: new(false), }, expected: true, }, { a: &KubernetesAddon{ - Enabled: to.BoolPtr(true), + Enabled: new(true), }, expected: false, }, @@ -2650,7 +2631,6 @@ func TestGetOrderedKubeproxyConfigStringForPowershell(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() actual := c.config.GetOrderedKubeproxyConfigStringForPowershell() @@ -2760,7 +2740,6 @@ func TestGetOrderedKubeletConfigStringForPowershell(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() actual := c.config.GetOrderedKubeletConfigStringForPowershell(c.CustomKubeletConfig) @@ -2801,7 +2780,6 @@ func TestSecurityProfileGetProxyAddress(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() actual := c.securityProfile.GetProxyAddress() @@ -2842,7 +2820,6 @@ func TestSecurityProfileGetPrivateEgressContainerRegistryServer(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() actual := c.securityProfile.GetPrivateEgressContainerRegistryServer() @@ -2907,7 +2884,7 @@ func TestLocalDNSProfileMethods(t *testing.T) { tests := []struct { name string agentPoolProfile *AgentPoolProfile - expectedData interface{} + expectedData any expectedError bool }{ { diff --git a/pkg/agent/datamodel/versions.go b/pkg/agent/datamodel/versions.go index 41ef1189d81..c236aad3c7e 100644 --- a/pkg/agent/datamodel/versions.go +++ b/pkg/agent/datamodel/versions.go @@ -5,6 +5,8 @@ package datamodel import ( "fmt" + "maps" + "slices" "sort" "strings" @@ -347,9 +349,7 @@ func getSortedSemverVersions(versions []string, preRelease bool) []semver.Versio func getAllKubernetesWindowsSupportedVersionsMap() map[string]bool { ret := make(map[string]bool) - for k, v := range AllKubernetesSupportedVersions { - ret[k] = v - } + maps.Copy(ret, AllKubernetesSupportedVersions) for _, version := range []string{ "1.6.6", "1.6.9", @@ -527,10 +527,5 @@ func GetLatestPatchVersion(majorMinor string, versionsList []string) string { // IsSupportedKubernetesVersion return true if the provided Kubernetes version is supported. func IsSupportedKubernetesVersion(version string, isUpdate, hasWindows bool) bool { - for _, ver := range GetAllSupportedKubernetesVersions(isUpdate, hasWindows) { - if ver == version { - return true - } - } - return false + return slices.Contains(GetAllSupportedKubernetesVersions(isUpdate, hasWindows), version) } diff --git a/pkg/agent/datamodel/versions_test.go b/pkg/agent/datamodel/versions_test.go index a6bdada3704..f5bb81e8378 100644 --- a/pkg/agent/datamodel/versions_test.go +++ b/pkg/agent/datamodel/versions_test.go @@ -156,7 +156,6 @@ func TestIsKubernetesVersionGe(t *testing.T) { }, } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() if c.expectedResult != IsKubernetesVersionGe(c.actualVersion, c.version) { @@ -471,7 +470,6 @@ func TestGetMinMaxVersion(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() minVersion := GetMinVersion(c.versions, c.preRelease) diff --git a/pkg/agent/utils.go b/pkg/agent/utils.go index 8315bc5c9d3..c9145367f13 100644 --- a/pkg/agent/utils.go +++ b/pkg/agent/utils.go @@ -19,7 +19,6 @@ import ( "github.com/Azure/agentbaker/parts" "github.com/Azure/agentbaker/pkg/agent/datamodel" - "github.com/Azure/go-autorest/autorest/to" "github.com/blang/semver" ) @@ -71,11 +70,11 @@ var TranslatedKubeletConfigFlags = map[string]bool{ "--serialize-image-pulls": true, } -type paramsMap map[string]interface{} +type paramsMap map[string]any const numInPair = 2 -func addValue(m paramsMap, k string, v interface{}) { +func addValue(m paramsMap, k string, v any) { m[k] = paramsMap{ "value": v, } @@ -94,7 +93,7 @@ func addKeyvaultReference(m paramsMap, k string, vaultID, secretName, secretVers } //nolint:unparam,nolintlint -func addSecret(m paramsMap, k string, v interface{}, encode bool) { +func addSecret(m paramsMap, k string, v any, encode bool) { str, ok := v.(string) if !ok { addValue(m, k, v) @@ -202,8 +201,8 @@ func getBase64EncodedGzippedCustomScript(csFilename string, config *datamodel.No // This is "best-effort" - removes MOST of the comments with obvious formats, to lower the space required by CustomData component. func removeComments(b []byte) []byte { var contentWithoutComments []string - lines := strings.Split(string(b), "\n") - for _, line := range lines { + lines := strings.SplitSeq(string(b), "\n") + for line := range lines { lineNoWhitespace := strings.TrimSpace(line) if lineStartsWithComment(lineNoWhitespace) { // ignore entire line that is a comment @@ -297,17 +296,17 @@ func getExtensionURL(rootURL, extensionName, version, fileName, query string) st } func getSSHPublicKeysPowerShell(linuxProfile *datamodel.LinuxProfile) string { - str := "" + var str strings.Builder if linuxProfile != nil { lastItem := len(linuxProfile.SSH.PublicKeys) - 1 for i, publicKey := range linuxProfile.SSH.PublicKeys { - str += `"` + strings.TrimSpace(publicKey.KeyData) + `"` + str.WriteString(`"` + strings.TrimSpace(publicKey.KeyData) + `"`) if i < lastItem { - str += ", " + str.WriteString(", ") } } } - return str + return str.String() } // IsSgxEnabledSKU determines if an VM SKU has SGX driver support. @@ -389,7 +388,7 @@ func GetOrderedKubeletConfigFlagString(config *datamodel.NodeBootstrappingConfig sort.Strings(keys) var buf bytes.Buffer for _, key := range keys { - buf.WriteString(fmt.Sprintf("%s=%s ", key, k[key])) + fmt.Fprintf(&buf, "%s=%s ", key, k[key]) } return buf.String() } @@ -414,7 +413,7 @@ func getOrderedKubeletConfigFlagWithCustomConfigurationString(customConfig, defa sort.Strings(keys) var buf bytes.Buffer for _, key := range keys { - buf.WriteString(fmt.Sprintf("%s=%s ", key, config[key])) + fmt.Fprintf(&buf, "%s=%s ", key, config[key]) } return buf.String() } @@ -549,7 +548,7 @@ func setCustomKubeletConfig(customKc *datamodel.CustomKubeletConfig, kubeletConfig.ContainerLogMaxFiles = customKc.ContainerLogMaxFiles } if customKc.PodMaxPids != nil { - kubeletConfig.PodPidsLimit = to.Int64Ptr(int64(*customKc.PodMaxPids)) + kubeletConfig.PodPidsLimit = new(int64(*customKc.PodMaxPids)) } if customKc.SeccompDefault != nil { kubeletConfig.SeccompDefault = customKc.SeccompDefault @@ -649,8 +648,8 @@ func strToInt64Ptr(str string) *int64 { func strKeyValToMap(str string, strDelim string, pairDelim string) map[string]string { m := make(map[string]string) - pairs := strings.Split(str, strDelim) - for _, pairRaw := range pairs { + pairs := strings.SplitSeq(str, strDelim) + for pairRaw := range pairs { pair := strings.Split(pairRaw, pairDelim) if len(pair) == numInPair { key := strings.TrimSpace(pair[0]) @@ -663,8 +662,8 @@ func strKeyValToMap(str string, strDelim string, pairDelim string) map[string]st func strKeyValToMapBool(str string, strDelim string, pairDelim string) map[string]bool { m := make(map[string]bool) - pairs := strings.Split(str, strDelim) - for _, pairRaw := range pairs { + pairs := strings.SplitSeq(str, strDelim) + for pairRaw := range pairs { pair := strings.Split(pairRaw, pairDelim) if len(pair) == numInPair { key := strings.TrimSpace(pair[0]) diff --git a/pkg/agent/utils_test.go b/pkg/agent/utils_test.go index a05706f65ff..c2e74452278 100644 --- a/pkg/agent/utils_test.go +++ b/pkg/agent/utils_test.go @@ -50,17 +50,17 @@ func TestGetKubeletConfigFileFromFlags(t *testing.T) { } 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), } configFileStr := GetKubeletConfigFileContent(kc, customKc) diff := cmp.Diff(expectedKubeletJSON, configFileStr) @@ -446,13 +446,13 @@ func TestGetKubeletConfigFileFlagsWithNodeStatusReportFrequency(t *testing.T) { kc := getExampleKcWithNodeStatusReportFrequency() 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), PodMaxPids: to.Int32Ptr(12345), } configFileStr := GetKubeletConfigFileContent(kc, customKc) @@ -466,13 +466,13 @@ func TestGetKubeletConfigFileFromFlagsWithContainerLogMaxSize(t *testing.T) { kc := getExampleKcWithContainerLogMaxSize() 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), ContainerLogMaxFiles: to.Int32Ptr(99), PodMaxPids: to.Int32Ptr(12345), } @@ -487,17 +487,17 @@ func TestGetKubeletConfigFileCustomKCShouldOverrideValuesPassedInKc(t *testing.T kc := getExampleKcWithContainerLogMaxSize() 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), ContainerLogMaxFiles: to.Int32Ptr(99), ContainerLogMaxSizeMB: to.Int32Ptr(1000), PodMaxPids: to.Int32Ptr(12345), - SeccompDefault: to.BoolPtr(true), + SeccompDefault: new(true), } configFileStr := GetKubeletConfigFileContent(kc, customKc) diff := cmp.Diff(expectedKubeletJSON, configFileStr) @@ -518,7 +518,7 @@ func TestIsTLSBootstrappingEnabledWithHardCodedToken(t *testing.T) { reason: "agent pool TLS bootstrap token not set", }, { - tlsBootstrapToken: to.StringPtr("foobar.foobar"), + tlsBootstrapToken: new("foobar.foobar"), expected: true, reason: "supported", }, @@ -542,7 +542,7 @@ func TestGetTLSBootstrapTokenForKubeConfig(t *testing.T) { expected: "", }, { - token: to.StringPtr("foo.bar"), + token: new("foo.bar"), expected: "foo.bar", }, } @@ -664,7 +664,7 @@ var _ = Describe("Test GetOrderedKubeletConfigFlagString", func() { EnableKubeletConfigFile: true, AgentPoolProfile: &datamodel.AgentPoolProfile{ CustomKubeletConfig: &datamodel.CustomKubeletConfig{ - SeccompDefault: to.BoolPtr(false), + SeccompDefault: new(false), }, }, } diff --git a/pkg/agent/variables.go b/pkg/agent/variables.go index 015546fcdb9..f1559346433 100644 --- a/pkg/agent/variables.go +++ b/pkg/agent/variables.go @@ -14,7 +14,7 @@ import ( // getCustomDataVariables returns cloudinit data used by Linux. func getCustomDataVariables(config *datamodel.NodeBootstrappingConfiguration) paramsMap { cs := config.ContainerService - cloudInitFiles := map[string]interface{}{ + cloudInitFiles := map[string]any{ "cloudInitData": paramsMap{ "provisionStartScript": getBase64EncodedGzippedCustomScript(kubernetesCSEStartScript, config), "provisionScript": getBase64EncodedGzippedCustomScript(kubernetesCSEMainScript, config), @@ -115,7 +115,7 @@ func getCSECommandVariables(config *datamodel.NodeBootstrappingConfiguration) pa agentPoolProfileWindows = &datamodel.AgentPoolWindowsProfile{} } - return map[string]interface{}{ + return map[string]any{ "tenantID": config.TenantID, "subscriptionId": config.SubscriptionID, "resourceGroup": config.ResourceGroupName, diff --git a/pkg/vhdbuilder/datamodel/component_configs.go b/pkg/vhdbuilder/datamodel/component_configs.go index daae12a25e7..192c5f39bb5 100644 --- a/pkg/vhdbuilder/datamodel/component_configs.go +++ b/pkg/vhdbuilder/datamodel/component_configs.go @@ -40,7 +40,8 @@ type DockerKubeProxyImages struct { ContainerImages []*ContainerImage `json:"ContainerImages"` } -func loadJSONFromFile(path string, v interface{}) error { +func loadJSONFromFile(path string, v any) error { + //nolint: gosec configFile, err := os.Open(path) if err != nil { return err diff --git a/vhdbuilder/lister/go.mod b/vhdbuilder/lister/go.mod index fd36cf06d12..89311c1acd7 100644 --- a/vhdbuilder/lister/go.mod +++ b/vhdbuilder/lister/go.mod @@ -1,6 +1,6 @@ module github.com/Azure/agentbaker/vhdbuilder/lister -go 1.24.12 +go 1.26.0 require ( github.com/containerd/containerd v1.7.29 diff --git a/vhdbuilder/prefetch/go.mod b/vhdbuilder/prefetch/go.mod index 2a084221817..762c48edb8d 100644 --- a/vhdbuilder/prefetch/go.mod +++ b/vhdbuilder/prefetch/go.mod @@ -1,6 +1,6 @@ module github.com/Azure/agentbaker/vhdbuilder/prefetch -go 1.24.12 +go 1.26.0 require github.com/stretchr/testify v1.9.0