From 1f84772f79c1ff0c8adbc36c9f8fe6d58d2b5237 Mon Sep 17 00:00:00 2001 From: Alison <32000834+AlisonB319@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:51:44 -0800 Subject: [PATCH] fix: clean up AB linting errors (#3885) --- pkg/agent/bakerapi.go | 1 + pkg/agent/datamodel/mocks.go | 71 ------------------- pkg/vhdbuilder/datamodel/component_configs.go | 6 +- 3 files changed, 4 insertions(+), 74 deletions(-) diff --git a/pkg/agent/bakerapi.go b/pkg/agent/bakerapi.go index 231f2007d30..993c6c6090f 100644 --- a/pkg/agent/bakerapi.go +++ b/pkg/agent/bakerapi.go @@ -23,6 +23,7 @@ func NewAgentBaker() (AgentBaker, error) { type agentBakerImpl struct{} +//nolint:revive, nolintlint // ctx is not used, but may be in the future func (agentBaker *agentBakerImpl) GetNodeBootstrapping(ctx context.Context, config *datamodel.NodeBootstrappingConfiguration) (*datamodel.NodeBootstrapping, error) { // validate and fix input before passing config to the template generator. diff --git a/pkg/agent/datamodel/mocks.go b/pkg/agent/datamodel/mocks.go index 78cf4650311..73e2130bf72 100644 --- a/pkg/agent/datamodel/mocks.go +++ b/pkg/agent/datamodel/mocks.go @@ -3,77 +3,6 @@ package datamodel -import ( - "github.com/Azure/go-autorest/autorest/to" - "github.com/google/uuid" -) - -// CreateMockContainerService returns a mock container service for testing purposes. -func CreateMockContainerService(containerServiceName, orchestratorVersion string, masterCount, agentCount int, certs bool) *ContainerService { - cs := ContainerService{} - cs.ID = uuid.Must(uuid.NewRandom()).String() - cs.Location = "eastus" - cs.Name = containerServiceName - - cs.Properties = &Properties{} - - cs.Properties.AgentPoolProfiles = []*AgentPoolProfile{} - agentPool := &AgentPoolProfile{} - agentPool.Name = "agentpool1" - agentPool.VMSize = "Standard_D2_v2" - agentPool.AvailabilityProfile = "AvailabilitySet" - agentPool.StorageProfile = "StorageAccount" - - cs.Properties.AgentPoolProfiles = append(cs.Properties.AgentPoolProfiles, agentPool) - - cs.Properties.LinuxProfile = &LinuxProfile{ - AdminUsername: "azureuser", - SSH: struct { - PublicKeys []PublicKey `json:"publicKeys"` - }{}, - } - - cs.Properties.LinuxProfile.AdminUsername = "azureuser" - cs.Properties.LinuxProfile.SSH.PublicKeys = append( - cs.Properties.LinuxProfile.SSH.PublicKeys, PublicKey{KeyData: "test"}) - - cs.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{} - cs.Properties.ServicePrincipalProfile.ClientID = "DEC923E3-1EF1-4745-9516-37906D56DEC4" - cs.Properties.ServicePrincipalProfile.Secret = "DEC923E3-1EF1-4745-9516-37906D56DEC4" - - cs.Properties.OrchestratorProfile = &OrchestratorProfile{} - cs.Properties.OrchestratorProfile.OrchestratorType = Kubernetes - cs.Properties.OrchestratorProfile.OrchestratorVersion = orchestratorVersion - const gcLowThreshold = 80 - const gcHighThreshold = 85 - const maxPods = 30 - cs.Properties.OrchestratorProfile.KubernetesConfig = &KubernetesConfig{ - EnableSecureKubelet: to.BoolPtr(true), - EnableRbac: to.BoolPtr(true), - DockerBridgeSubnet: "172.17.0.1/16", - GCLowThreshold: gcLowThreshold, - GCHighThreshold: gcHighThreshold, - MaxPods: maxPods, - ClusterSubnet: "10.240.0.0/12", - ContainerRuntime: Docker, - NetworkPlugin: "kubenet", - LoadBalancerSku: "Basic", - ControllerManagerConfig: make(map[string]string), - } - - cs.Properties.CertificateProfile = &CertificateProfile{} - if certs { - cs.Properties.CertificateProfile.CaCertificate = "cacert" - cs.Properties.CertificateProfile.KubeConfigCertificate = "kubeconfigcert" - cs.Properties.CertificateProfile.KubeConfigPrivateKey = "kubeconfigkey" - cs.Properties.CertificateProfile.APIServerCertificate = "apiservercert" - cs.Properties.CertificateProfile.ClientCertificate = "clientcert" - cs.Properties.CertificateProfile.ClientPrivateKey = "clientkey" - } - - return &cs -} - // GetK8sDefaultProperties returns a struct of type Properties for testing purposes. func GetK8sDefaultProperties(hasWindows bool) *Properties { p := &Properties{ diff --git a/pkg/vhdbuilder/datamodel/component_configs.go b/pkg/vhdbuilder/datamodel/component_configs.go index 6777aede1ed..181d504409b 100644 --- a/pkg/vhdbuilder/datamodel/component_configs.go +++ b/pkg/vhdbuilder/datamodel/component_configs.go @@ -40,7 +40,7 @@ type DockerKubeProxyImages struct { ContainerImages []*ContainerImage `json:"ContainerImages"` } -func loadJsonFromFile(path string, v interface{}) error { +func loadJSONFromFile(path string, v interface{}) error { configFile, err := os.Open(path) if err != nil { return err @@ -71,7 +71,7 @@ func toImageList(downloadURL string, imageTagList []string) ([]string, error) { func NewComponentsFromFile(path string) (*Components, error) { ret := &Components{} - err := loadJsonFromFile(path, ret) + err := loadJSONFromFile(path, ret) if err != nil { return nil, err } @@ -115,7 +115,7 @@ The given file should be in JSON format. func NewKubeProxyImagesFromFile(path string) (*KubeProxyImages, error) { ret := &KubeProxyImages{} - err := loadJsonFromFile(path, ret) + err := loadJSONFromFile(path, ret) if err != nil { return nil, err }