From 7ebf6c60b3e90a2fcb1012ca2cdaa7bdf8f16d88 Mon Sep 17 00:00:00 2001 From: Alison Burgess Date: Thu, 30 Nov 2023 14:55:32 -0800 Subject: [PATCH 1/3] fix: clean up AB linting errors --- 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..7efb7a5447d 100644 --- a/pkg/agent/bakerapi.go +++ b/pkg/agent/bakerapi.go @@ -23,6 +23,7 @@ func NewAgentBaker() (AgentBaker, error) { type agentBakerImpl struct{} +//nolint:revive //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 } From 23f05dcdfcd0d3e70d5f1751cfa55a4d6503fbb5 Mon Sep 17 00:00:00 2001 From: Alison Burgess Date: Thu, 30 Nov 2023 15:01:57 -0800 Subject: [PATCH 2/3] fix: fix spacing --- pkg/agent/bakerapi.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/agent/bakerapi.go b/pkg/agent/bakerapi.go index 7efb7a5447d..f1a8de7651a 100644 --- a/pkg/agent/bakerapi.go +++ b/pkg/agent/bakerapi.go @@ -23,7 +23,7 @@ func NewAgentBaker() (AgentBaker, error) { type agentBakerImpl struct{} -//nolint:revive //ctx is not used, but may be in the future +//nolint:revive // 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. From e59525bdf9ede7df753590fa6256c3c1b3a6ec29 Mon Sep 17 00:00:00 2001 From: Alison Burgess Date: Thu, 30 Nov 2023 15:22:19 -0800 Subject: [PATCH 3/3] fix: adding nolintlint since golangci-lint has this known bug --- pkg/agent/bakerapi.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/agent/bakerapi.go b/pkg/agent/bakerapi.go index f1a8de7651a..993c6c6090f 100644 --- a/pkg/agent/bakerapi.go +++ b/pkg/agent/bakerapi.go @@ -23,7 +23,7 @@ func NewAgentBaker() (AgentBaker, error) { type agentBakerImpl struct{} -//nolint:revive // ctx is not used, but may be in the future +//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.