diff --git a/cmd/eksctl-anywhere/cmd/deprecated_importimages.go b/cmd/eksctl-anywhere/cmd/deprecated_importimages.go index ac975bcc27a8..4a8a14e97fc5 100644 --- a/cmd/eksctl-anywhere/cmd/deprecated_importimages.go +++ b/cmd/eksctl-anywhere/cmd/deprecated_importimages.go @@ -112,7 +112,7 @@ func importImages(ctx context.Context, clusterSpecPath string) error { return importCharts(ctx, helmExecutable, bundle.Charts(), endpoint, registryUsername, registryPassword) } -func importImage(ctx context.Context, docker *executables.Docker, image string, endpoint string) error { +func importImage(ctx context.Context, docker *executables.Docker, image, endpoint string) error { if err := docker.PullImage(ctx, image); err != nil { return err } diff --git a/cmd/eksctl-anywhere/cmd/internal/commands/artifacts/download.go b/cmd/eksctl-anywhere/cmd/internal/commands/artifacts/download.go index e5c386b52c08..6047f50efbab 100644 --- a/cmd/eksctl-anywhere/cmd/internal/commands/artifacts/download.go +++ b/cmd/eksctl-anywhere/cmd/internal/commands/artifacts/download.go @@ -31,7 +31,7 @@ type ManifestDownloader interface { } type Packager interface { - Package(folder string, dstFile string) error + Package(folder, dstFile string) error } type Download struct { diff --git a/internal/pkg/api/cluster.go b/internal/pkg/api/cluster.go index 835d8b4cfb66..3294aa02c82a 100644 --- a/internal/pkg/api/cluster.go +++ b/internal/pkg/api/cluster.go @@ -40,7 +40,7 @@ func WithKubernetesVersion(v anywherev1.KubernetesVersion) ClusterFiller { } // WithBundlesRef sets BundlesRef with the provided name to use. -func WithBundlesRef(name string, namespace string, apiVersion string) ClusterFiller { +func WithBundlesRef(name, namespace, apiVersion string) ClusterFiller { return func(c *anywherev1.Cluster) { c.Spec.BundlesRef = &anywherev1.BundlesRef{Name: name, Namespace: namespace, APIVersion: apiVersion} } @@ -117,7 +117,7 @@ func WithControlPlaneTaints(taints []corev1.Taint) ClusterFiller { } } -func WithControlPlaneLabel(key string, val string) ClusterFiller { +func WithControlPlaneLabel(key, val string) ClusterFiller { return func(c *anywherev1.Cluster) { if c.Spec.ControlPlaneConfiguration.Labels == nil { c.Spec.ControlPlaneConfiguration.Labels = map[string]string{} @@ -176,7 +176,7 @@ func WithWorkerNodeCount(r int) ClusterFiller { } // WithWorkerNodeAutoScalingConfig adds an autoscaling configuration with a given min and max count. -func WithWorkerNodeAutoScalingConfig(min int, max int) ClusterFiller { +func WithWorkerNodeAutoScalingConfig(min, max int) ClusterFiller { return func(c *anywherev1.Cluster) { if len(c.Spec.WorkerNodeGroupConfigurations) == 0 { c.Spec.WorkerNodeGroupConfigurations = []anywherev1.WorkerNodeGroupConfiguration{{Count: ptr.Int(min)}} @@ -251,7 +251,7 @@ func WithProxyConfig(httpProxy, httpsProxy string, noProxy []string) ClusterFill } // WithRegistryMirror adds a registry mirror configuration. -func WithRegistryMirror(endpoint, port string, caCert string, authenticate bool, insecureSkipVerify bool) ClusterFiller { +func WithRegistryMirror(endpoint, port, caCert string, authenticate, insecureSkipVerify bool) ClusterFiller { return func(c *anywherev1.Cluster) { if c.Spec.RegistryMirrorConfiguration == nil { c.Spec.RegistryMirrorConfiguration = &anywherev1.RegistryMirrorConfiguration{} diff --git a/internal/pkg/api/vsphere.go b/internal/pkg/api/vsphere.go index 54023bb404ee..eff0c4ed2a41 100644 --- a/internal/pkg/api/vsphere.go +++ b/internal/pkg/api/vsphere.go @@ -99,7 +99,7 @@ func WithTemplateForAllMachines(value string) VSphereFiller { } // WithMachineTemplate configs template in machine config. -func WithMachineTemplate(machineConfigName string, template string) VSphereFiller { +func WithMachineTemplate(machineConfigName, template string) VSphereFiller { return func(config VSphereConfig) { config.machineConfigs[machineConfigName].Spec.Template = template } diff --git a/internal/pkg/ec2/list.go b/internal/pkg/ec2/list.go index afba3807eaa6..5c18ac6f4910 100644 --- a/internal/pkg/ec2/list.go +++ b/internal/pkg/ec2/list.go @@ -11,7 +11,7 @@ import ( "github.com/aws/eks-anywhere/pkg/logger" ) -func ListInstances(session *session.Session, key string, value string, maxAge float64) ([]*string, error) { +func ListInstances(session *session.Session, key, value string, maxAge float64) ([]*string, error) { service := ec2.New(session) var instanceList []*string diff --git a/internal/test/cleanup/cleanup.go b/internal/test/cleanup/cleanup.go index fb2a42db833d..d61722a3a0fe 100644 --- a/internal/test/cleanup/cleanup.go +++ b/internal/test/cleanup/cleanup.go @@ -26,7 +26,7 @@ const ( retryBackoff = 10 * time.Second ) -func CleanUpAwsTestResources(storageBucket string, maxAge string, tag string) error { +func CleanUpAwsTestResources(storageBucket, maxAge, tag string) error { session, err := session.NewSession() if err != nil { return fmt.Errorf("creating session: %v", err) diff --git a/internal/test/e2e/github.go b/internal/test/e2e/github.go index 2ea22c571f74..795341f47099 100644 --- a/internal/test/e2e/github.go +++ b/internal/test/e2e/github.go @@ -10,7 +10,7 @@ import ( "github.com/aws/eks-anywhere/pkg/git/providers/github" ) -func (e *E2ESession) TestGithubClient(ctx context.Context, githubToken string, owner string, repository string, personal bool) (git.ProviderClient, error) { +func (e *E2ESession) TestGithubClient(ctx context.Context, githubToken, owner, repository string, personal bool) (git.ProviderClient, error) { auth := git.TokenAuth{Token: githubToken, Username: owner} gogithubOpts := gogithub.Options{Auth: auth} githubProviderClient := gogithub.New(ctx, gogithubOpts) diff --git a/internal/test/e2e/registryMirror.go b/internal/test/e2e/registryMirror.go index cc8c7fdf49fc..3cfbde878e6a 100644 --- a/internal/test/e2e/registryMirror.go +++ b/internal/test/e2e/registryMirror.go @@ -74,7 +74,7 @@ func (e *E2ESession) setupRegistryMirrorEnv(testRegex string) error { return nil } -func (e *E2ESession) mountRegistryCert(cert string, endpoint string) error { +func (e *E2ESession) mountRegistryCert(cert, endpoint string) error { command := fmt.Sprintf("sudo mkdir -p /etc/docker/certs.d/%s", endpoint) if err := ssm.Run(e.session, logr.Discard(), e.instanceId, command, ssmTimeout); err != nil { diff --git a/internal/test/e2e/snow.go b/internal/test/e2e/snow.go index d793d499e39c..ee26495150ee 100644 --- a/internal/test/e2e/snow.go +++ b/internal/test/e2e/snow.go @@ -72,7 +72,7 @@ func (e *E2ESession) setupSnowEnv(testRegex string) error { return nil } -func sendFileViaS3(e *E2ESession, s3Path string, filename string) error { +func sendFileViaS3(e *E2ESession, s3Path, filename string) error { if err := s3.DownloadToDisk(e.session, s3Path, e.storageBucket, "bin/"+filename); err != nil { return err } diff --git a/pkg/api/v1alpha1/awsiamconfig.go b/pkg/api/v1alpha1/awsiamconfig.go index c8b1b6353781..7c01e375d3cc 100644 --- a/pkg/api/v1alpha1/awsiamconfig.go +++ b/pkg/api/v1alpha1/awsiamconfig.go @@ -14,7 +14,7 @@ const ( DefaultAWSIamConfigPartition = "aws" ) -func GetAndValidateAWSIamConfig(fileName string, refName string, clusterConfig *Cluster) (*AWSIamConfig, error) { +func GetAndValidateAWSIamConfig(fileName, refName string, clusterConfig *Cluster) (*AWSIamConfig, error) { config, err := getAWSIamConfig(fileName) if err != nil { return nil, err diff --git a/pkg/api/v1alpha1/cloudstackmachineconfig_types.go b/pkg/api/v1alpha1/cloudstackmachineconfig_types.go index 367f4fd0fbd5..2a80c7244697 100644 --- a/pkg/api/v1alpha1/cloudstackmachineconfig_types.go +++ b/pkg/api/v1alpha1/cloudstackmachineconfig_types.go @@ -115,7 +115,7 @@ func (r *CloudStackResourceDiskOffering) IsEmpty() bool { r.Filesystem == "" && r.MountPath == "" && r.CustomSize == 0 } -func (r *CloudStackResourceDiskOffering) Validate() (err error, field string, value string) { +func (r *CloudStackResourceDiskOffering) Validate() (err error, field, value string) { if r != nil && (len(r.Id) > 0 || len(r.Name) > 0) { if len(r.MountPath) < 2 || !strings.HasPrefix(r.MountPath, "/") { return errors.New("must be non-empty and start with /"), "mountPath", r.MountPath @@ -137,7 +137,7 @@ func (r *CloudStackResourceDiskOffering) Validate() (err error, field string, va return nil, "", "" } -func (r SymlinkMaps) Validate() (err error, field string, value string) { +func (r SymlinkMaps) Validate() (err error, field, value string) { isPortableFileNameSet := regexp.MustCompile(`^[a-zA-Z0-9\.\-\_\/]+$`) for key, value := range r { if !strings.HasPrefix(key, "/") || strings.HasSuffix(key, "/") { diff --git a/pkg/api/v1alpha1/cluster.go b/pkg/api/v1alpha1/cluster.go index 551165bd4292..fccca6748137 100644 --- a/pkg/api/v1alpha1/cluster.go +++ b/pkg/api/v1alpha1/cluster.go @@ -103,7 +103,7 @@ func WithClusterEndpoint() ClusterGenerateOpt { } // WithCPUpgradeRolloutStrategy allows add UpgradeRolloutStrategy option to cluster config under ControlPlaneConfiguration. -func WithCPUpgradeRolloutStrategy(maxSurge int, maxUnavailable int) ClusterGenerateOpt { +func WithCPUpgradeRolloutStrategy(maxSurge, maxUnavailable int) ClusterGenerateOpt { return func(c *ClusterGenerate) { c.Spec.ControlPlaneConfiguration.UpgradeRolloutStrategy = &ControlPlaneUpgradeRolloutStrategy{Type: "RollingUpdate", RollingUpdate: ControlPlaneRollingUpdateParams{MaxSurge: maxSurge}} } @@ -150,7 +150,7 @@ func WithWorkerMachineGroupRef(ref ProviderRefAccessor) ClusterGenerateOpt { } // WithWorkerMachineUpgradeRolloutStrategy allows add UpgradeRolloutStrategy option to cluster config under WorkerNodeGroupConfiguration. -func WithWorkerMachineUpgradeRolloutStrategy(maxSurge int, maxUnavailable int) ClusterGenerateOpt { +func WithWorkerMachineUpgradeRolloutStrategy(maxSurge, maxUnavailable int) ClusterGenerateOpt { return func(c *ClusterGenerate) { c.Spec.WorkerNodeGroupConfigurations[0].UpgradeRolloutStrategy = &WorkerNodesUpgradeRolloutStrategy{ Type: "RollingUpdate", diff --git a/pkg/api/v1alpha1/cluster_types.go b/pkg/api/v1alpha1/cluster_types.go index fa0b107b42d8..4ed82115242c 100644 --- a/pkg/api/v1alpha1/cluster_types.go +++ b/pkg/api/v1alpha1/cluster_types.go @@ -397,7 +397,7 @@ func (n *Endpoint) CloudStackEqual(o *Endpoint) bool { } // GetControlPlaneHostPort retrieves the ControlPlaneConfiguration host and port split defined in the cluster.Spec. -func GetControlPlaneHostPort(pHost string, defaultPort string) (string, string, error) { +func GetControlPlaneHostPort(pHost, defaultPort string) (string, string, error) { host, port, err := net.SplitHostPort(pHost) if err != nil { if strings.Contains(err.Error(), "missing port") { @@ -650,7 +650,7 @@ func UsersSliceEqual(a, b []UserConfiguration) bool { return true } -func CNIPluginSame(n ClusterNetwork, o ClusterNetwork) bool { +func CNIPluginSame(n, o ClusterNetwork) bool { if n.CNI != "" { /*This shouldn't be required since we set CNIConfig and unset CNI as part of cluster_defaults. However, while upgrading an existing cluster, the eks-a controller does not set any defaults (no mutating webhook), so it gets stuck in an error loop. Adding these checks to avoid that. We can remove it when removing the CNI field diff --git a/pkg/api/v1alpha1/machine_types.go b/pkg/api/v1alpha1/machine_types.go index 6883128abfcd..247de1c76725 100644 --- a/pkg/api/v1alpha1/machine_types.go +++ b/pkg/api/v1alpha1/machine_types.go @@ -30,7 +30,7 @@ func defaultMachineConfigUsers(defaultUsername string, users []UserConfiguration return users } -func validateMachineConfigUsers(machineConfigName string, machineConfigKind string, users []UserConfiguration) error { +func validateMachineConfigUsers(machineConfigName, machineConfigKind string, users []UserConfiguration) error { if len(users) == 0 { return fmt.Errorf("users is not set for %s %s, please provide a user", machineConfigKind, machineConfigName) } diff --git a/pkg/api/v1alpha1/nutanixmachineconfig.go b/pkg/api/v1alpha1/nutanixmachineconfig.go index 66b59aaca465..5140a1286d01 100644 --- a/pkg/api/v1alpha1/nutanixmachineconfig.go +++ b/pkg/api/v1alpha1/nutanixmachineconfig.go @@ -217,7 +217,7 @@ func validateNutanixReferences(c *NutanixMachineConfig) error { return nil } -func validateNutanixResourceReference(i *NutanixResourceIdentifier, resource string, mcName string) error { +func validateNutanixResourceReference(i *NutanixResourceIdentifier, resource, mcName string) error { if i.Type != NutanixIdentifierName && i.Type != NutanixIdentifierUUID { return fmt.Errorf("NutanixMachineConfig: invalid identifier type for %s: %s", resource, i.Type) } diff --git a/pkg/api/v1alpha1/nutanixmachineconfig_webhook_test.go b/pkg/api/v1alpha1/nutanixmachineconfig_webhook_test.go index d68a41dc82fb..449a26febb9b 100644 --- a/pkg/api/v1alpha1/nutanixmachineconfig_webhook_test.go +++ b/pkg/api/v1alpha1/nutanixmachineconfig_webhook_test.go @@ -222,17 +222,17 @@ func TestValidateUpdate_Invalid(t *testing.T) { g := NewWithT(t) tests := []struct { name string - fn func(new *v1alpha1.NutanixMachineConfig, old *v1alpha1.NutanixMachineConfig) + fn func(new, old *v1alpha1.NutanixMachineConfig) }{ { name: "different os family", - fn: func(new *v1alpha1.NutanixMachineConfig, old *v1alpha1.NutanixMachineConfig) { + fn: func(new, old *v1alpha1.NutanixMachineConfig) { new.Spec.OSFamily = v1alpha1.Bottlerocket }, }, { name: "different cluster", - fn: func(new *v1alpha1.NutanixMachineConfig, old *v1alpha1.NutanixMachineConfig) { + fn: func(new, old *v1alpha1.NutanixMachineConfig) { new.Spec.Cluster = v1alpha1.NutanixResourceIdentifier{ Type: v1alpha1.NutanixIdentifierName, Name: ptr.String("cluster-2"), @@ -241,7 +241,7 @@ func TestValidateUpdate_Invalid(t *testing.T) { }, { name: "different subnet", - fn: func(new *v1alpha1.NutanixMachineConfig, old *v1alpha1.NutanixMachineConfig) { + fn: func(new, old *v1alpha1.NutanixMachineConfig) { new.Spec.Subnet = v1alpha1.NutanixResourceIdentifier{ Type: v1alpha1.NutanixIdentifierName, Name: ptr.String("subnet-2"), @@ -250,42 +250,42 @@ func TestValidateUpdate_Invalid(t *testing.T) { }, { name: "old cluster is managed", - fn: func(new *v1alpha1.NutanixMachineConfig, old *v1alpha1.NutanixMachineConfig) { + fn: func(new, old *v1alpha1.NutanixMachineConfig) { new.Spec.OSFamily = v1alpha1.Bottlerocket old.SetManagedBy("test") }, }, { name: "mismatch vcpu sockets on control plane cluster", - fn: func(new *v1alpha1.NutanixMachineConfig, old *v1alpha1.NutanixMachineConfig) { + fn: func(new, old *v1alpha1.NutanixMachineConfig) { old.SetControlPlane() new.Spec.VCPUSockets++ }, }, { name: "mismatch vcpu per socket on control plane cluster", - fn: func(new *v1alpha1.NutanixMachineConfig, old *v1alpha1.NutanixMachineConfig) { + fn: func(new, old *v1alpha1.NutanixMachineConfig) { old.SetControlPlane() new.Spec.VCPUsPerSocket++ }, }, { name: "mismatch memory size on control plane cluster", - fn: func(new *v1alpha1.NutanixMachineConfig, old *v1alpha1.NutanixMachineConfig) { + fn: func(new, old *v1alpha1.NutanixMachineConfig) { old.SetControlPlane() new.Spec.MemorySize.Add(resource.MustParse("1Gi")) }, }, { name: "mismatch system disk size on control plane cluster", - fn: func(new *v1alpha1.NutanixMachineConfig, old *v1alpha1.NutanixMachineConfig) { + fn: func(new, old *v1alpha1.NutanixMachineConfig) { old.SetControlPlane() new.Spec.SystemDiskSize.Add(resource.MustParse("1Gi")) }, }, { name: "mismatch users on control plane cluster", - fn: func(new *v1alpha1.NutanixMachineConfig, old *v1alpha1.NutanixMachineConfig) { + fn: func(new, old *v1alpha1.NutanixMachineConfig) { old.SetControlPlane() new.Spec.Users = append(new.Spec.Users, v1alpha1.UserConfiguration{ Name: "another-user", @@ -294,7 +294,7 @@ func TestValidateUpdate_Invalid(t *testing.T) { }, { name: "invalid vcpus per socket", - fn: func(new *v1alpha1.NutanixMachineConfig, old *v1alpha1.NutanixMachineConfig) { + fn: func(new, old *v1alpha1.NutanixMachineConfig) { new.Spec.VCPUsPerSocket = 0 }, }, diff --git a/pkg/api/v1alpha1/oidcconfig.go b/pkg/api/v1alpha1/oidcconfig.go index 729afdbca923..46f83ca02e72 100644 --- a/pkg/api/v1alpha1/oidcconfig.go +++ b/pkg/api/v1alpha1/oidcconfig.go @@ -10,7 +10,7 @@ import ( const OIDCConfigKind = "OIDCConfig" -func GetAndValidateOIDCConfig(fileName string, refName string, clusterConfig *Cluster) (*OIDCConfig, error) { +func GetAndValidateOIDCConfig(fileName, refName string, clusterConfig *Cluster) (*OIDCConfig, error) { config, err := getOIDCConfig(fileName) if err != nil { return nil, err diff --git a/pkg/api/v1alpha1/tinkerbelltemplateconfig_defaults.go b/pkg/api/v1alpha1/tinkerbelltemplateconfig_defaults.go index a1ca06f4deb8..0a33673a5912 100644 --- a/pkg/api/v1alpha1/tinkerbelltemplateconfig_defaults.go +++ b/pkg/api/v1alpha1/tinkerbelltemplateconfig_defaults.go @@ -171,7 +171,7 @@ func withDisableCloudInitNetworkCapabilities(b v1alpha1.VersionsBundle, disk str } } -func withTinkCloudInitAction(b v1alpha1.VersionsBundle, disk string, metadataURLs string) ActionOpt { +func withTinkCloudInitAction(b v1alpha1.VersionsBundle, disk, metadataURLs string) ActionOpt { return func(a *[]tinkerbell.Action) { *a = append(*a, tinkerbell.Action{ Name: "add-tink-cloud-init-config", @@ -244,7 +244,7 @@ func withBottlerocketBootconfigAction(b v1alpha1.VersionsBundle, disk string) Ac } } -func withBottlerocketUserDataAction(b v1alpha1.VersionsBundle, disk string, metadataURLs string) ActionOpt { +func withBottlerocketUserDataAction(b v1alpha1.VersionsBundle, disk, metadataURLs string) ActionOpt { return func(a *[]tinkerbell.Action) { *a = append(*a, tinkerbell.Action{ Name: "write-user-data", diff --git a/pkg/api/v1alpha1/vspheredatacenterconfig.go b/pkg/api/v1alpha1/vspheredatacenterconfig.go index eec92170dbc4..c79605030039 100644 --- a/pkg/api/v1alpha1/vspheredatacenterconfig.go +++ b/pkg/api/v1alpha1/vspheredatacenterconfig.go @@ -53,7 +53,7 @@ func GetVSphereDatacenterConfig(fileName string) (*VSphereDatacenterConfig, erro return &clusterConfig, nil } -func generateFullVCenterPath(foldType folderType, folderPath string, datacenter string) string { +func generateFullVCenterPath(foldType folderType, folderPath, datacenter string) string { if folderPath == "" { return folderPath } @@ -69,7 +69,7 @@ func generateFullVCenterPath(foldType folderType, folderPath string, datacenter return modPath } -func validatePath(foldType folderType, folderPath string, datacenter string) error { +func validatePath(foldType folderType, folderPath, datacenter string) error { prefix := filepath.Join(fmt.Sprintf("/%s", datacenter), string(foldType)) if !strings.HasPrefix(folderPath, prefix) { return fmt.Errorf("invalid path, expected path [%s] to be under [%s]", folderPath, prefix) diff --git a/pkg/aws/snow.go b/pkg/aws/snow.go index 35adbc35fd0c..484d586d0daf 100644 --- a/pkg/aws/snow.go +++ b/pkg/aws/snow.go @@ -78,7 +78,7 @@ func WithCustomCABundleFile(certsFile string) AwsConfigOpt { // WithSnowEndpointAccess gathers all the config's LoadOptions for snow, // which includes snowball ec2 endpoint, snow credentials for a specific profile, // and CA bundles for accessing the https endpoint. -func WithSnowEndpointAccess(deviceIP string, certsFile, credsFile string) AwsConfigOpt { +func WithSnowEndpointAccess(deviceIP, certsFile, credsFile string) AwsConfigOpt { return AwsConfigOptSet( WithCustomCABundleFile(certsFile), config.WithSharedCredentialsFiles([]string{credsFile}), diff --git a/pkg/awsiamauth/client.go b/pkg/awsiamauth/client.go index 3500e3919d98..aeb80982afa2 100644 --- a/pkg/awsiamauth/client.go +++ b/pkg/awsiamauth/client.go @@ -18,7 +18,7 @@ import ( type Client interface { ApplyKubeSpecFromBytes(ctx context.Context, cluster *types.Cluster, data []byte) error GetApiServerUrl(ctx context.Context, cluster *types.Cluster) (string, error) - GetObject(ctx context.Context, resourceType string, name string, namespace string, kubeconfig string, obj runtime.Object) error + GetObject(ctx context.Context, resourceType, name, namespace, kubeconfig string, obj runtime.Object) error } // RetrierClient wraps basic kubernetes API operations around a retrier. diff --git a/pkg/bootstrapper/client.go b/pkg/bootstrapper/client.go index 872baca7af70..3d56753051a6 100644 --- a/pkg/bootstrapper/client.go +++ b/pkg/bootstrapper/client.go @@ -25,7 +25,7 @@ type KubernetesClient interface { ApplyKubeSpecFromBytes(ctx context.Context, cluster *types.Cluster, data []byte) error GetClusters(ctx context.Context, cluster *types.Cluster) ([]types.CAPICluster, error) ValidateClustersCRD(ctx context.Context, cluster *types.Cluster) error - CreateNamespaceIfNotPresent(ctx context.Context, kubeconfig string, namespace string) error + CreateNamespaceIfNotPresent(ctx context.Context, kubeconfig, namespace string) error } // RetrierClientOpt allows to customize a RetrierClient diff --git a/pkg/clustermanager/client.go b/pkg/clustermanager/client.go index 644b2bf474ca..bd182e672a33 100644 --- a/pkg/clustermanager/client.go +++ b/pkg/clustermanager/client.go @@ -16,7 +16,7 @@ type KubernetesClient interface { ApplyKubeSpecFromBytes(ctx context.Context, cluster *types.Cluster, data []byte) error ApplyKubeSpecFromBytesWithNamespace(ctx context.Context, cluster *types.Cluster, data []byte, namespace string) error ApplyKubeSpecFromBytesForce(ctx context.Context, cluster *types.Cluster, data []byte) error - WaitForDeployment(ctx context.Context, cluster *types.Cluster, timeout string, condition string, target string, namespace string) error + WaitForDeployment(ctx context.Context, cluster *types.Cluster, timeout, condition, target, namespace string) error UpdateAnnotationInNamespace(ctx context.Context, resourceType, objectName string, annotations map[string]string, cluster *types.Cluster, namespace string) error RemoveAnnotationInNamespace(ctx context.Context, resourceType, objectName, key string, cluster *types.Cluster, namespace string) error } diff --git a/pkg/clustermanager/cluster_manager.go b/pkg/clustermanager/cluster_manager.go index a2f0ccb10144..77ae750e4efe 100644 --- a/pkg/clustermanager/cluster_manager.go +++ b/pkg/clustermanager/cluster_manager.go @@ -108,17 +108,17 @@ type ClusterClient interface { KubernetesClient BackupManagement(ctx context.Context, cluster *types.Cluster, managementStatePath, clusterName string) error MoveManagement(ctx context.Context, from, target *types.Cluster, clusterName string) error - WaitForClusterReady(ctx context.Context, cluster *types.Cluster, timeout string, clusterName string) error - WaitForControlPlaneAvailable(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error - WaitForControlPlaneReady(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error - WaitForControlPlaneNotReady(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error - WaitForManagedExternalEtcdReady(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error - WaitForManagedExternalEtcdNotReady(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error + WaitForClusterReady(ctx context.Context, cluster *types.Cluster, timeout, clusterName string) error + WaitForControlPlaneAvailable(ctx context.Context, cluster *types.Cluster, timeout, newClusterName string) error + WaitForControlPlaneReady(ctx context.Context, cluster *types.Cluster, timeout, newClusterName string) error + WaitForControlPlaneNotReady(ctx context.Context, cluster *types.Cluster, timeout, newClusterName string) error + WaitForManagedExternalEtcdReady(ctx context.Context, cluster *types.Cluster, timeout, newClusterName string) error + WaitForManagedExternalEtcdNotReady(ctx context.Context, cluster *types.Cluster, timeout, newClusterName string) error GetWorkloadKubeconfig(ctx context.Context, clusterName string, cluster *types.Cluster) ([]byte, error) - GetEksaGitOpsConfig(ctx context.Context, gitOpsConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.GitOpsConfig, error) - GetEksaFluxConfig(ctx context.Context, fluxConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.FluxConfig, error) - GetEksaOIDCConfig(ctx context.Context, oidcConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.OIDCConfig, error) - GetEksaAWSIamConfig(ctx context.Context, awsIamConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.AWSIamConfig, error) + GetEksaGitOpsConfig(ctx context.Context, gitOpsConfigName, kubeconfigFile, namespace string) (*v1alpha1.GitOpsConfig, error) + GetEksaFluxConfig(ctx context.Context, fluxConfigName, kubeconfigFile, namespace string) (*v1alpha1.FluxConfig, error) + GetEksaOIDCConfig(ctx context.Context, oidcConfigName, kubeconfigFile, namespace string) (*v1alpha1.OIDCConfig, error) + GetEksaAWSIamConfig(ctx context.Context, awsIamConfigName, kubeconfigFile, namespace string) (*v1alpha1.AWSIamConfig, error) DeleteCluster(ctx context.Context, managementCluster, clusterToDelete *types.Cluster) error DeleteGitOpsConfig(ctx context.Context, managementCluster *types.Cluster, gitOpsName, namespace string) error DeleteOIDCConfig(ctx context.Context, managementCluster *types.Cluster, oidcConfigName, oidcConfigNamespace string) error @@ -126,25 +126,25 @@ type ClusterClient interface { DeleteEKSACluster(ctx context.Context, managementCluster *types.Cluster, eksaClusterName, eksaClusterNamespace string) error DeletePackageResources(ctx context.Context, managementCluster *types.Cluster, clusterName string) error InitInfrastructure(ctx context.Context, clusterSpec *cluster.Spec, cluster *types.Cluster, provider providers.Provider) error - WaitForDeployment(ctx context.Context, cluster *types.Cluster, timeout string, condition string, target string, namespace string) error + WaitForDeployment(ctx context.Context, cluster *types.Cluster, timeout, condition, target, namespace string) error SaveLog(ctx context.Context, cluster *types.Cluster, deployment *types.Deployment, fileName string, writer filewriter.FileWriter) error GetMachines(ctx context.Context, cluster *types.Cluster, clusterName string) ([]types.Machine, error) GetClusters(ctx context.Context, cluster *types.Cluster) ([]types.CAPICluster, error) PauseCAPICluster(ctx context.Context, cluster, kubeconfig string) error ResumeCAPICluster(ctx context.Context, cluster, kubeconfig string) error GetEksaCluster(ctx context.Context, cluster *types.Cluster, clusterName string) (*v1alpha1.Cluster, error) - GetEksaVSphereDatacenterConfig(ctx context.Context, VSphereDatacenterName string, kubeconfigFile string, namespace string) (*v1alpha1.VSphereDatacenterConfig, error) + GetEksaVSphereDatacenterConfig(ctx context.Context, VSphereDatacenterName, kubeconfigFile, namespace string) (*v1alpha1.VSphereDatacenterConfig, error) UpdateEnvironmentVariablesInNamespace(ctx context.Context, resourceType, resourceName string, envMap map[string]string, cluster *types.Cluster, namespace string) error - GetEksaVSphereMachineConfig(ctx context.Context, VSphereDatacenterName string, kubeconfigFile string, namespace string) (*v1alpha1.VSphereMachineConfig, error) - GetEksaCloudStackMachineConfig(ctx context.Context, cloudstackMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.CloudStackMachineConfig, error) + GetEksaVSphereMachineConfig(ctx context.Context, VSphereDatacenterName, kubeconfigFile, namespace string) (*v1alpha1.VSphereMachineConfig, error) + GetEksaCloudStackMachineConfig(ctx context.Context, cloudstackMachineConfigName, kubeconfigFile, namespace string) (*v1alpha1.CloudStackMachineConfig, error) SetEksaControllerEnvVar(ctx context.Context, envVar, envVarVal, kubeconfig string) error - CreateNamespaceIfNotPresent(ctx context.Context, kubeconfig string, namespace string) error + CreateNamespaceIfNotPresent(ctx context.Context, kubeconfig, namespace string) error ValidateControlPlaneNodes(ctx context.Context, cluster *types.Cluster, clusterName string) error - ValidateWorkerNodes(ctx context.Context, clusterName string, kubeconfigFile string) error - CountMachineDeploymentReplicasReady(ctx context.Context, clusterName string, kubeconfigFile string) (int, int, error) + ValidateWorkerNodes(ctx context.Context, clusterName, kubeconfigFile string) error + CountMachineDeploymentReplicasReady(ctx context.Context, clusterName, kubeconfigFile string) (int, int, error) GetBundles(ctx context.Context, kubeconfigFile, name, namespace string) (*releasev1alpha1.Bundles, error) GetApiServerUrl(ctx context.Context, cluster *types.Cluster) (string, error) - KubeconfigSecretAvailable(ctx context.Context, kubeconfig string, clusterName string, namespace string) (bool, error) + KubeconfigSecretAvailable(ctx context.Context, kubeconfig, clusterName, namespace string) (bool, error) DeleteOldWorkerNodeGroup(ctx context.Context, machineDeployment *clusterv1.MachineDeployment, kubeconfig string) error GetKubeadmControlPlane(ctx context.Context, cluster *types.Cluster, clusterName string, opts ...executables.KubectlOpt) (*controlplanev1.KubeadmControlPlane, error) GetMachineDeploymentsForCluster(ctx context.Context, clusterName string, opts ...executables.KubectlOpt) ([]clusterv1.MachineDeployment, error) diff --git a/pkg/clustermanager/retrier_client.go b/pkg/clustermanager/retrier_client.go index 2414a4dea7f9..444443aeb234 100644 --- a/pkg/clustermanager/retrier_client.go +++ b/pkg/clustermanager/retrier_client.go @@ -110,7 +110,7 @@ func (c *RetrierClient) ListObjects(ctx context.Context, resourceType, namespace } // DeleteGitOpsConfig deletes a GitOpsConfigObject from the cluster. -func (c *RetrierClient) DeleteGitOpsConfig(ctx context.Context, cluster *types.Cluster, name string, namespace string) error { +func (c *RetrierClient) DeleteGitOpsConfig(ctx context.Context, cluster *types.Cluster, name, namespace string) error { return c.retrier.Retry( func() error { return c.ClusterClient.DeleteGitOpsConfig(ctx, cluster, name, namespace) @@ -119,7 +119,7 @@ func (c *RetrierClient) DeleteGitOpsConfig(ctx context.Context, cluster *types.C } // DeleteEKSACluster deletes an EKSA Cluster object from the cluster. -func (c *RetrierClient) DeleteEKSACluster(ctx context.Context, cluster *types.Cluster, name string, namespace string) error { +func (c *RetrierClient) DeleteEKSACluster(ctx context.Context, cluster *types.Cluster, name, namespace string) error { return c.retrier.Retry( func() error { return c.ClusterClient.DeleteEKSACluster(ctx, cluster, name, namespace) @@ -128,7 +128,7 @@ func (c *RetrierClient) DeleteEKSACluster(ctx context.Context, cluster *types.Cl } // DeleteAWSIamConfig deletes an AWSIamConfig object from the cluster. -func (c *RetrierClient) DeleteAWSIamConfig(ctx context.Context, cluster *types.Cluster, name string, namespace string) error { +func (c *RetrierClient) DeleteAWSIamConfig(ctx context.Context, cluster *types.Cluster, name, namespace string) error { return c.retrier.Retry( func() error { return c.ClusterClient.DeleteAWSIamConfig(ctx, cluster, name, namespace) @@ -137,7 +137,7 @@ func (c *RetrierClient) DeleteAWSIamConfig(ctx context.Context, cluster *types.C } // DeleteOIDCConfig deletes a OIDCConfig object from the cluster. -func (c *RetrierClient) DeleteOIDCConfig(ctx context.Context, cluster *types.Cluster, name string, namespace string) error { +func (c *RetrierClient) DeleteOIDCConfig(ctx context.Context, cluster *types.Cluster, name, namespace string) error { return c.retrier.Retry( func() error { return c.ClusterClient.DeleteOIDCConfig(ctx, cluster, name, namespace) diff --git a/pkg/controller/clusters/management_test.go b/pkg/controller/clusters/management_test.go index 8907a21525b2..bf2062767e9b 100644 --- a/pkg/controller/clusters/management_test.go +++ b/pkg/controller/clusters/management_test.go @@ -84,7 +84,7 @@ func newFetchManagementTest(t *testing.T) *fetchManagementTest { } } -func createClustersForTest() (managementCluster *anywherev1.Cluster, workloadCluster *anywherev1.Cluster) { +func createClustersForTest() (managementCluster, workloadCluster *anywherev1.Cluster) { managementCluster = &anywherev1.Cluster{ TypeMeta: metav1.TypeMeta{ Kind: "Cluster", diff --git a/pkg/curatedpackages/bundle.go b/pkg/curatedpackages/bundle.go index e3bebe43fbd6..37456af7ff46 100644 --- a/pkg/curatedpackages/bundle.go +++ b/pkg/curatedpackages/bundle.go @@ -35,7 +35,7 @@ type BundleReader struct { registry BundleRegistry } -func NewBundleReader(kubeConfig string, clusterName string, k KubectlRunner, bm Manager, reg BundleRegistry) *BundleReader { +func NewBundleReader(kubeConfig, clusterName string, k KubectlRunner, bm Manager, reg BundleRegistry) *BundleReader { return &BundleReader{ kubeConfig: kubeConfig, clusterName: clusterName, diff --git a/pkg/curatedpackages/bundlemanager.go b/pkg/curatedpackages/bundlemanager.go index 928991f253db..93a4db90e2b6 100644 --- a/pkg/curatedpackages/bundlemanager.go +++ b/pkg/curatedpackages/bundlemanager.go @@ -7,5 +7,5 @@ import ( ) type Manager interface { - LatestBundle(ctx context.Context, baseRef string, kubeMajor string, kubeMinor string, clusterName string) (*packagesv1.PackageBundle, error) + LatestBundle(ctx context.Context, baseRef, kubeMajor, kubeMinor, clusterName string) (*packagesv1.PackageBundle, error) } diff --git a/pkg/curatedpackages/discovery.go b/pkg/curatedpackages/discovery.go index 8e33fcc33001..d6304bf73910 100644 --- a/pkg/curatedpackages/discovery.go +++ b/pkg/curatedpackages/discovery.go @@ -23,7 +23,7 @@ func NewDiscovery(kubeVersion *KubeVersion) *Discovery { } } -func NewKubeVersion(major string, minor string) *KubeVersion { +func NewKubeVersion(major, minor string) *KubeVersion { return &KubeVersion{ major: major, minor: minor, diff --git a/pkg/curatedpackages/kubectlrunner.go b/pkg/curatedpackages/kubectlrunner.go index 09e3f6402c81..cfb0d80a0f78 100644 --- a/pkg/curatedpackages/kubectlrunner.go +++ b/pkg/curatedpackages/kubectlrunner.go @@ -15,5 +15,5 @@ type KubectlRunner interface { // If the object is not found, it returns an error implementing apimachinery errors.APIStatus GetObject(ctx context.Context, resourceType, name, namespece, kubeconfig string, obj runtime.Object) error // HasResource is true if the resource can be retrieved from the API and has length > 0. - HasResource(ctx context.Context, resourceType string, name string, kubeconfig string, namespace string) (bool, error) + HasResource(ctx context.Context, resourceType, name, kubeconfig, namespace string) (bool, error) } diff --git a/pkg/curatedpackages/oras/download.go b/pkg/curatedpackages/oras/download.go index 712dc4f928ee..7d60bdb23cd1 100644 --- a/pkg/curatedpackages/oras/download.go +++ b/pkg/curatedpackages/oras/download.go @@ -59,7 +59,7 @@ func UniqueCharts(charts []string) []string { return list } -func writeToFile(dir string, packageName string, content []byte) error { +func writeToFile(dir, packageName string, content []byte) error { file := filepath.Join(dir, packageName) + ".yaml" if err := os.WriteFile(file, content, 0o640); err != nil { return fmt.Errorf("unable to write to the file: %s %v", file, err) diff --git a/pkg/curatedpackages/packageclient.go b/pkg/curatedpackages/packageclient.go index a781b671fb72..c839e3a56d97 100644 --- a/pkg/curatedpackages/packageclient.go +++ b/pkg/curatedpackages/packageclient.go @@ -117,7 +117,7 @@ func (pc *PackageClient) packageMap() map[string]packagesv1.BundlePackage { return pMap } -func (pc *PackageClient) InstallPackage(ctx context.Context, bp *packagesv1.BundlePackage, customName string, clusterName string, kubeConfig string) error { +func (pc *PackageClient) InstallPackage(ctx context.Context, bp *packagesv1.BundlePackage, customName, clusterName, kubeConfig string) error { configString, err := pc.getInstallConfigurations() if err != nil { return err @@ -146,7 +146,7 @@ func (pc *PackageClient) getInstallConfigurations() (string, error) { return GenerateAllValidConfigurations(installConfigs) } -func (pc *PackageClient) ApplyPackages(ctx context.Context, fileName string, kubeConfig string) error { +func (pc *PackageClient) ApplyPackages(ctx context.Context, fileName, kubeConfig string) error { params := []string{"apply", "-f", fileName, "--kubeconfig", kubeConfig} stdOut, err := pc.kubectl.ExecuteCommand(ctx, params...) if err != nil { @@ -157,7 +157,7 @@ func (pc *PackageClient) ApplyPackages(ctx context.Context, fileName string, kub return nil } -func (pc *PackageClient) CreatePackages(ctx context.Context, fileName string, kubeConfig string) error { +func (pc *PackageClient) CreatePackages(ctx context.Context, fileName, kubeConfig string) error { params := []string{"create", "-f", fileName, "--kubeconfig", kubeConfig} stdOut, err := pc.kubectl.ExecuteCommand(ctx, params...) if err != nil { @@ -168,7 +168,7 @@ func (pc *PackageClient) CreatePackages(ctx context.Context, fileName string, ku return nil } -func (pc *PackageClient) DeletePackages(ctx context.Context, packages []string, kubeConfig string, clusterName string) error { +func (pc *PackageClient) DeletePackages(ctx context.Context, packages []string, kubeConfig, clusterName string) error { params := []string{"delete", "packages", "--kubeconfig", kubeConfig, "--namespace", constants.EksaPackagesName + "-" + clusterName} params = append(params, packages...) stdOut, err := pc.kubectl.ExecuteCommand(ctx, params...) @@ -180,7 +180,7 @@ func (pc *PackageClient) DeletePackages(ctx context.Context, packages []string, return nil } -func (pc *PackageClient) DescribePackages(ctx context.Context, packages []string, kubeConfig string, clusterName string) error { +func (pc *PackageClient) DescribePackages(ctx context.Context, packages []string, kubeConfig, clusterName string) error { params := []string{"describe", "packages", "--kubeconfig", kubeConfig, "--namespace", constants.EksaPackagesName + "-" + clusterName} params = append(params, packages...) stdOut, err := pc.kubectl.ExecuteCommand(ctx, params...) @@ -195,7 +195,7 @@ func (pc *PackageClient) DescribePackages(ctx context.Context, packages []string return nil } -func convertBundlePackageToPackage(bp packagesv1.BundlePackage, name string, clusterName string, apiVersion string, config string) packagesv1.Package { +func convertBundlePackageToPackage(bp packagesv1.BundlePackage, name, clusterName, apiVersion, config string) packagesv1.Package { p := packagesv1.Package{ ObjectMeta: metav1.ObjectMeta{ Name: name, diff --git a/pkg/curatedpackages/packageinstaller.go b/pkg/curatedpackages/packageinstaller.go index ba473be21c43..e14dab9c9d6c 100644 --- a/pkg/curatedpackages/packageinstaller.go +++ b/pkg/curatedpackages/packageinstaller.go @@ -15,7 +15,7 @@ type PackageController interface { } type PackageHandler interface { - CreatePackages(ctx context.Context, fileName string, kubeConfig string) error + CreatePackages(ctx context.Context, fileName, kubeConfig string) error } type Installer struct { diff --git a/pkg/curatedpackages/validations.go b/pkg/curatedpackages/validations.go index 5fa9c98b7f3a..fda5ab98f408 100644 --- a/pkg/curatedpackages/validations.go +++ b/pkg/curatedpackages/validations.go @@ -5,7 +5,7 @@ import ( "strings" ) -func ValidateKubeVersion(kubeVersion string, clusterName string) error { +func ValidateKubeVersion(kubeVersion, clusterName string) error { if len(clusterName) > 0 { if len(kubeVersion) > 0 { return fmt.Errorf("please specify either kube-version or cluster name not both") diff --git a/pkg/diagnostics/diagnostic_bundle.go b/pkg/diagnostics/diagnostic_bundle.go index 07772c0c1b7e..d6c1cc69ecdb 100644 --- a/pkg/diagnostics/diagnostic_bundle.go +++ b/pkg/diagnostics/diagnostic_bundle.go @@ -149,7 +149,7 @@ func newDiagnosticBundleDefault(af AnalyzerFactory, cf CollectorFactory) *EksaDi WithManagementCluster(true) } -func newDiagnosticBundleCustom(af AnalyzerFactory, cf CollectorFactory, client BundleClient, kubectl *executables.Kubectl, bundlePath string, kubeconfig string, writer filewriter.FileWriter) *EksaDiagnosticBundle { +func newDiagnosticBundleCustom(af AnalyzerFactory, cf CollectorFactory, client BundleClient, kubectl *executables.Kubectl, bundlePath, kubeconfig string, writer filewriter.FileWriter) *EksaDiagnosticBundle { return &EksaDiagnosticBundle{ bundlePath: bundlePath, analyzerFactory: af, @@ -380,7 +380,7 @@ func ParseTimeFromDuration(since string) (*time.Time, error) { return &sinceTimeValue, nil } -func ParseTimeOptions(since string, sinceTime string) (*time.Time, error) { +func ParseTimeOptions(since, sinceTime string) (*time.Time, error) { var sinceTimeValue time.Time var err error if sinceTime == "" && since == "" { diff --git a/pkg/diagnostics/factory.go b/pkg/diagnostics/factory.go index ed5d60c0924e..0fbcf10bee99 100644 --- a/pkg/diagnostics/factory.go +++ b/pkg/diagnostics/factory.go @@ -35,7 +35,7 @@ func NewFactory(opts EksaDiagnosticBundleFactoryOpts) *eksaDiagnosticBundleFacto } } -func (f *eksaDiagnosticBundleFactory) DiagnosticBundle(spec *cluster.Spec, provider providers.Provider, kubeconfig string, bundlePath string) (DiagnosticBundle, error) { +func (f *eksaDiagnosticBundleFactory) DiagnosticBundle(spec *cluster.Spec, provider providers.Provider, kubeconfig, bundlePath string) (DiagnosticBundle, error) { if bundlePath == "" && spec != nil { b, err := f.DiagnosticBundleWorkloadCluster(spec, provider, kubeconfig) return b, err @@ -55,6 +55,6 @@ func (f *eksaDiagnosticBundleFactory) DiagnosticBundleDefault() DiagnosticBundle return newDiagnosticBundleDefault(f.analyzerFactory, f.collectorFactory) } -func (f *eksaDiagnosticBundleFactory) DiagnosticBundleCustom(kubeconfig string, bundlePath string) DiagnosticBundle { +func (f *eksaDiagnosticBundleFactory) DiagnosticBundleCustom(kubeconfig, bundlePath string) DiagnosticBundle { return newDiagnosticBundleCustom(f.analyzerFactory, f.collectorFactory, f.client, f.kubectl, bundlePath, kubeconfig, f.writer) } diff --git a/pkg/diagnostics/interfaces.go b/pkg/diagnostics/interfaces.go index 6d706db330e2..c668425e40a3 100644 --- a/pkg/diagnostics/interfaces.go +++ b/pkg/diagnostics/interfaces.go @@ -12,15 +12,15 @@ import ( type BundleClient interface { Collect(ctx context.Context, bundlePath string, sinceTime *time.Time, kubeconfig string) (archivePath string, err error) - Analyze(ctx context.Context, bundleSpecPath string, archivePath string) ([]*executables.SupportBundleAnalysis, error) + Analyze(ctx context.Context, bundleSpecPath, archivePath string) ([]*executables.SupportBundleAnalysis, error) } type DiagnosticBundleFactory interface { - DiagnosticBundle(spec *cluster.Spec, provider providers.Provider, kubeconfig string, bundlePath string) (DiagnosticBundle, error) + DiagnosticBundle(spec *cluster.Spec, provider providers.Provider, kubeconfig, bundlePath string) (DiagnosticBundle, error) DiagnosticBundleWorkloadCluster(spec *cluster.Spec, provider providers.Provider, kubeconfig string) (DiagnosticBundle, error) DiagnosticBundleManagementCluster(spec *cluster.Spec, kubeconfig string) (DiagnosticBundle, error) DiagnosticBundleDefault() DiagnosticBundle - DiagnosticBundleCustom(kubeconfig string, bundlePath string) DiagnosticBundle + DiagnosticBundleCustom(kubeconfig, bundlePath string) DiagnosticBundle } type DiagnosticBundle interface { diff --git a/pkg/docker/mover.go b/pkg/docker/mover.go index 8f2bd2f4dbe3..a5cabec6e61a 100644 --- a/pkg/docker/mover.go +++ b/pkg/docker/mover.go @@ -17,8 +17,8 @@ type ImageDiskWriter interface { } type ImageTaggerPusher interface { - PushImage(ctx context.Context, image string, endpoint string) error - TagImage(ctx context.Context, image string, endpoint string) error + PushImage(ctx context.Context, image, endpoint string) error + TagImage(ctx context.Context, image, endpoint string) error } type ImagePuller interface { diff --git a/pkg/executables/cmk.go b/pkg/executables/cmk.go index 1cb4cc67bf83..b4371c804f57 100644 --- a/pkg/executables/cmk.go +++ b/pkg/executables/cmk.go @@ -44,7 +44,7 @@ func (c *Cmk) Close(ctx context.Context) error { return nil } -func (c *Cmk) ValidateTemplatePresent(ctx context.Context, profile string, domainId string, zoneId string, account string, template v1alpha1.CloudStackResourceIdentifier) error { +func (c *Cmk) ValidateTemplatePresent(ctx context.Context, profile, domainId, zoneId, account string, template v1alpha1.CloudStackResourceIdentifier) error { command := newCmkCommand("list templates") applyCmkArgs(&command, appendArgs("templatefilter=all"), appendArgs("listall=true")) if len(template.Id) > 0 { @@ -112,7 +112,7 @@ func (c *Cmk) SearchTemplate(ctx context.Context, profile string, template v1alp return templates[0].Name, nil } -func (c *Cmk) ValidateServiceOfferingPresent(ctx context.Context, profile string, zoneId string, serviceOffering v1alpha1.CloudStackResourceIdentifier) error { +func (c *Cmk) ValidateServiceOfferingPresent(ctx context.Context, profile, zoneId string, serviceOffering v1alpha1.CloudStackResourceIdentifier) error { command := newCmkCommand("list serviceofferings") if len(serviceOffering.Id) > 0 { applyCmkArgs(&command, withCloudStackId(serviceOffering.Id)) @@ -144,7 +144,7 @@ func (c *Cmk) ValidateServiceOfferingPresent(ctx context.Context, profile string return nil } -func (c *Cmk) ValidateDiskOfferingPresent(ctx context.Context, profile string, zoneId string, diskOffering v1alpha1.CloudStackResourceDiskOffering) error { +func (c *Cmk) ValidateDiskOfferingPresent(ctx context.Context, profile, zoneId string, diskOffering v1alpha1.CloudStackResourceDiskOffering) error { command := newCmkCommand("list diskofferings") if len(diskOffering.Id) > 0 { applyCmkArgs(&command, withCloudStackId(diskOffering.Id)) @@ -182,7 +182,7 @@ func (c *Cmk) ValidateDiskOfferingPresent(ctx context.Context, profile string, z return nil } -func (c *Cmk) ValidateAffinityGroupsPresent(ctx context.Context, profile string, domainId string, account string, affinityGroupIds []string) error { +func (c *Cmk) ValidateAffinityGroupsPresent(ctx context.Context, profile, domainId, account string, affinityGroupIds []string) error { for _, affinityGroupId := range affinityGroupIds { command := newCmkCommand("list affinitygroups") applyCmkArgs(&command, withCloudStackId(affinityGroupId)) @@ -249,7 +249,7 @@ func (c *Cmk) ValidateZoneAndGetId(ctx context.Context, profile string, zone v1a return cmkZones[0].Id, nil } -func (c *Cmk) ValidateDomainAndGetId(ctx context.Context, profile string, domain string) (string, error) { +func (c *Cmk) ValidateDomainAndGetId(ctx context.Context, profile, domain string) (string, error) { domainId := "" command := newCmkCommand("list domains") // "list domains" API does not support querying by domain path, so here we extract the domain name which is the last part of the input domain @@ -291,7 +291,7 @@ func (c *Cmk) ValidateDomainAndGetId(ctx context.Context, profile string, domain return domainId, nil } -func (c *Cmk) ValidateNetworkPresent(ctx context.Context, profile string, domainId string, network v1alpha1.CloudStackResourceIdentifier, zoneId string, account string) error { +func (c *Cmk) ValidateNetworkPresent(ctx context.Context, profile, domainId string, network v1alpha1.CloudStackResourceIdentifier, zoneId, account string) error { command := newCmkCommand("list networks") // account must be specified within a domainId // domainId can be specified without account @@ -339,7 +339,7 @@ func (c *Cmk) ValidateNetworkPresent(ctx context.Context, profile string, domain return nil } -func (c *Cmk) ValidateAccountPresent(ctx context.Context, profile string, account string, domainId string) error { +func (c *Cmk) ValidateAccountPresent(ctx context.Context, profile, account, domainId string) error { // If account is not specified then no need to check its presence if len(account) == 0 { return nil @@ -395,7 +395,7 @@ func (c *Cmk) GetManagementApiEndpoint(profile string) (string, error) { return "", fmt.Errorf("profile %s does not exist", profile) } -func (c *Cmk) CleanupVms(ctx context.Context, profile string, clusterName string, dryRun bool) error { +func (c *Cmk) CleanupVms(ctx context.Context, profile, clusterName string, dryRun bool) error { command := newCmkCommand("list virtualmachines") applyCmkArgs(&command, withCloudStackKeyword(clusterName), appendArgs("listall=true")) result, err := c.exec(ctx, profile, command...) diff --git a/pkg/executables/docker.go b/pkg/executables/docker.go index b29b7070bf2b..bc51e4fd8942 100644 --- a/pkg/executables/docker.go +++ b/pkg/executables/docker.go @@ -69,7 +69,7 @@ func (d *Docker) AllocatedMemory(ctx context.Context) (uint64, error) { return strconv.ParseUint(totalMemory, 10, 64) } -func (d *Docker) TagImage(ctx context.Context, image string, endpoint string) error { +func (d *Docker) TagImage(ctx context.Context, image, endpoint string) error { replacer := strings.NewReplacer(defaultRegistry, endpoint, packageProdDomain, endpoint, packageDevDomain, endpoint) localImage := replacer.Replace(image) logger.Info("Tagging image", "image", image, "local image", localImage) @@ -79,7 +79,7 @@ func (d *Docker) TagImage(ctx context.Context, image string, endpoint string) er return nil } -func (d *Docker) PushImage(ctx context.Context, image string, endpoint string) error { +func (d *Docker) PushImage(ctx context.Context, image, endpoint string) error { replacer := strings.NewReplacer(defaultRegistry, endpoint, packageProdDomain, endpoint, packageDevDomain, endpoint) localImage := replacer.Replace(image) logger.Info("Pushing", "image", localImage) @@ -116,7 +116,7 @@ func (d *Docker) SaveToFile(ctx context.Context, filepath string, images ...stri return nil } -func (d *Docker) Run(ctx context.Context, image string, name string, cmd []string, flags ...string) error { +func (d *Docker) Run(ctx context.Context, image, name string, cmd []string, flags ...string) error { params := []string{"run", "-d", "-i"} params = append(params, flags...) params = append(params, "--name", name, image) diff --git a/pkg/executables/dockerlinux.go b/pkg/executables/dockerlinux.go index 58e4920d5d0b..69f623e9ac70 100644 --- a/pkg/executables/dockerlinux.go +++ b/pkg/executables/dockerlinux.go @@ -15,7 +15,7 @@ type linuxDockerExecutable struct { // This currently returns a linuxDockerExecutable, but if we support other types of docker executables we can change // the name of this constructor. -func NewDockerExecutable(cli string, containerName string) Executable { +func NewDockerExecutable(cli, containerName string) Executable { return &linuxDockerExecutable{ cli: cli, containerName: containerName, diff --git a/pkg/executables/export_test.go b/pkg/executables/export_test.go index e4fd9ae5a98d..70b037c3dff0 100644 --- a/pkg/executables/export_test.go +++ b/pkg/executables/export_test.go @@ -9,6 +9,6 @@ func KubectlWaitRetryPolicy(k *Kubectl, totalRetries int, err error) (retry bool return k.kubectlWaitRetryPolicy(totalRetries, err) } -func CallKubectlPrivateWait(k *Kubectl, ctx context.Context, kubeconfig string, timeoutTime time.Time, forCondition string, property string, namespace string) error { +func CallKubectlPrivateWait(k *Kubectl, ctx context.Context, kubeconfig string, timeoutTime time.Time, forCondition, property, namespace string) error { return k.wait(ctx, kubeconfig, timeoutTime, forCondition, property, namespace) } diff --git a/pkg/executables/govc.go b/pkg/executables/govc.go index 6f3c653ae224..b264bf2a1e0c 100644 --- a/pkg/executables/govc.go +++ b/pkg/executables/govc.go @@ -857,7 +857,7 @@ func (g *Govc) ValidateVCenterSetupMachineConfig(ctx context.Context, datacenter return nil } -func prependPath(folderType FolderType, folderPath string, datacenter string) (string, error) { +func prependPath(folderType FolderType, folderPath, datacenter string) (string, error) { prefix := fmt.Sprintf("/%s", datacenter) modPath := folderPath if !strings.HasPrefix(folderPath, prefix) { @@ -1031,7 +1031,7 @@ func getDeployOptions(network string) ([]byte, error) { } // CreateUser creates a user. -func (g *Govc) CreateUser(ctx context.Context, username string, password string) error { +func (g *Govc) CreateUser(ctx context.Context, username, password string) error { params := []string{ "sso.user.create", "-p", password, username, } @@ -1086,7 +1086,7 @@ func (g *Govc) GroupExists(ctx context.Context, name string) (bool, error) { } // AddUserToGroup adds a user to a group. -func (g *Govc) AddUserToGroup(ctx context.Context, name string, username string) error { +func (g *Govc) AddUserToGroup(ctx context.Context, name, username string) error { params := []string{ "sso.group.update", "-a", username, @@ -1128,7 +1128,7 @@ func (g *Govc) CreateRole(ctx context.Context, name string, privileges []string) } // SetGroupRoleOnObject sets a role for a given group on target object. -func (g *Govc) SetGroupRoleOnObject(ctx context.Context, principal string, role string, object string, domain string) error { +func (g *Govc) SetGroupRoleOnObject(ctx context.Context, principal, role, object, domain string) error { principal = principal + "@" + domain params := []string{ diff --git a/pkg/executables/kind.go b/pkg/executables/kind.go index e4726a9a1938..57dbbb25867b 100644 --- a/pkg/executables/kind.go +++ b/pkg/executables/kind.go @@ -234,7 +234,7 @@ func (k *Kind) buildConfigFile() error { return nil } -func (k *Kind) execArguments(clusterName string, kubeconfigName string) []string { +func (k *Kind) execArguments(clusterName, kubeconfigName string) []string { return []string{ "create", "cluster", "--name", getInternalName(clusterName), diff --git a/pkg/executables/kubectl.go b/pkg/executables/kubectl.go index 9e3a612c741c..b3505b5d717e 100644 --- a/pkg/executables/kubectl.go +++ b/pkg/executables/kubectl.go @@ -164,7 +164,7 @@ func (k *Kubectl) GetCAPIMachines(ctx context.Context, cluster *types.Cluster, c return response.Items, nil } -func (k *Kubectl) SearchCloudStackMachineConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.CloudStackMachineConfig, error) { +func (k *Kubectl) SearchCloudStackMachineConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.CloudStackMachineConfig, error) { params := []string{ "get", eksaCloudStackMachineResourceType, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--field-selector=metadata.name=" + name, @@ -183,7 +183,7 @@ func (k *Kubectl) SearchCloudStackMachineConfig(ctx context.Context, name string return response.Items, nil } -func (k *Kubectl) SearchCloudStackDatacenterConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.CloudStackDatacenterConfig, error) { +func (k *Kubectl) SearchCloudStackDatacenterConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.CloudStackDatacenterConfig, error) { params := []string{ "get", eksaCloudStackDatacenterResourceType, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--field-selector=metadata.name=" + name, @@ -202,7 +202,7 @@ func (k *Kubectl) SearchCloudStackDatacenterConfig(ctx context.Context, name str return response.Items, nil } -func (k *Kubectl) GetEksaCloudStackMachineConfig(ctx context.Context, cloudstackMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.CloudStackMachineConfig, error) { +func (k *Kubectl) GetEksaCloudStackMachineConfig(ctx context.Context, cloudstackMachineConfigName, kubeconfigFile, namespace string) (*v1alpha1.CloudStackMachineConfig, error) { response := &v1alpha1.CloudStackMachineConfig{} err := k.GetObject(ctx, eksaCloudStackMachineResourceType, cloudstackMachineConfigName, namespace, kubeconfigFile, response) if err != nil { @@ -212,7 +212,7 @@ func (k *Kubectl) GetEksaCloudStackMachineConfig(ctx context.Context, cloudstack return response, nil } -func (k *Kubectl) DeleteEksaCloudStackDatacenterConfig(ctx context.Context, cloudstackDatacenterConfigName string, kubeconfigFile string, namespace string) error { +func (k *Kubectl) DeleteEksaCloudStackDatacenterConfig(ctx context.Context, cloudstackDatacenterConfigName, kubeconfigFile, namespace string) error { params := []string{"delete", eksaCloudStackDatacenterResourceType, cloudstackDatacenterConfigName, "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--ignore-not-found=true"} _, err := k.Execute(ctx, params...) if err != nil { @@ -221,7 +221,7 @@ func (k *Kubectl) DeleteEksaCloudStackDatacenterConfig(ctx context.Context, clou return nil } -func (k *Kubectl) GetEksaCloudStackDatacenterConfig(ctx context.Context, cloudstackDatacenterConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.CloudStackDatacenterConfig, error) { +func (k *Kubectl) GetEksaCloudStackDatacenterConfig(ctx context.Context, cloudstackDatacenterConfigName, kubeconfigFile, namespace string) (*v1alpha1.CloudStackDatacenterConfig, error) { response := &v1alpha1.CloudStackDatacenterConfig{} err := k.GetObject(ctx, eksaCloudStackDatacenterResourceType, cloudstackDatacenterConfigName, namespace, kubeconfigFile, response) if err != nil { @@ -231,7 +231,7 @@ func (k *Kubectl) GetEksaCloudStackDatacenterConfig(ctx context.Context, cloudst return response, nil } -func (k *Kubectl) DeleteEksaCloudStackMachineConfig(ctx context.Context, cloudstackMachineConfigName string, kubeconfigFile string, namespace string) error { +func (k *Kubectl) DeleteEksaCloudStackMachineConfig(ctx context.Context, cloudstackMachineConfigName, kubeconfigFile, namespace string) error { params := []string{"delete", eksaCloudStackMachineResourceType, cloudstackMachineConfigName, "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--ignore-not-found=true"} _, err := k.Execute(ctx, params...) if err != nil { @@ -245,13 +245,13 @@ type VersionResponse struct { ServerVersion version.Info `json:"serverVersion"` } -func (k *Kubectl) GetNamespace(ctx context.Context, kubeconfig string, namespace string) error { +func (k *Kubectl) GetNamespace(ctx context.Context, kubeconfig, namespace string) error { params := []string{"get", "namespace", namespace, "--kubeconfig", kubeconfig} _, err := k.Execute(ctx, params...) return err } -func (k *Kubectl) CreateNamespace(ctx context.Context, kubeconfig string, namespace string) error { +func (k *Kubectl) CreateNamespace(ctx context.Context, kubeconfig, namespace string) error { params := []string{"create", "namespace", namespace, "--kubeconfig", kubeconfig} _, err := k.Execute(ctx, params...) if err != nil { @@ -260,14 +260,14 @@ func (k *Kubectl) CreateNamespace(ctx context.Context, kubeconfig string, namesp return nil } -func (k *Kubectl) CreateNamespaceIfNotPresent(ctx context.Context, kubeconfig string, namespace string) error { +func (k *Kubectl) CreateNamespaceIfNotPresent(ctx context.Context, kubeconfig, namespace string) error { if err := k.GetNamespace(ctx, kubeconfig, namespace); err != nil { return k.CreateNamespace(ctx, kubeconfig, namespace) } return nil } -func (k *Kubectl) DeleteNamespace(ctx context.Context, kubeconfig string, namespace string) error { +func (k *Kubectl) DeleteNamespace(ctx context.Context, kubeconfig, namespace string) error { params := []string{"delete", "namespace", namespace, "--kubeconfig", kubeconfig} _, err := k.Execute(ctx, params...) if err != nil { @@ -276,7 +276,7 @@ func (k *Kubectl) DeleteNamespace(ctx context.Context, kubeconfig string, namesp return nil } -func (k *Kubectl) LoadSecret(ctx context.Context, secretObject string, secretObjectType string, secretObjectName string, kubeConfFile string) error { +func (k *Kubectl) LoadSecret(ctx context.Context, secretObject, secretObjectType, secretObjectName, kubeConfFile string) error { params := []string{"create", "secret", "generic", secretObjectName, "--type", secretObjectType, "--from-literal", secretObject, "--kubeconfig", kubeConfFile, "--namespace", constants.EksaSystemNamespace} _, err := k.Execute(ctx, params...) if err != nil { @@ -293,7 +293,7 @@ func (k *Kubectl) ApplyManifest(ctx context.Context, kubeconfigPath, manifestPat return nil } -func (k *Kubectl) ApplyKubeSpecWithNamespace(ctx context.Context, cluster *types.Cluster, spec string, namespace string) error { +func (k *Kubectl) ApplyKubeSpecWithNamespace(ctx context.Context, cluster *types.Cluster, spec, namespace string) error { params := []string{"apply", "-f", spec, "--namespace", namespace} if cluster.KubeconfigFile != "" { params = append(params, "--kubeconfig", cluster.KubeconfigFile) @@ -370,32 +370,32 @@ func (k *Kubectl) DeleteKubeSpecFromBytes(ctx context.Context, cluster *types.Cl return nil } -func (k *Kubectl) WaitForClusterReady(ctx context.Context, cluster *types.Cluster, timeout string, clusterName string) error { +func (k *Kubectl) WaitForClusterReady(ctx context.Context, cluster *types.Cluster, timeout, clusterName string) error { return k.Wait(ctx, cluster.KubeconfigFile, timeout, "Ready", fmt.Sprintf("%s/%s", capiClustersResourceType, clusterName), constants.EksaSystemNamespace) } -func (k *Kubectl) WaitForControlPlaneReady(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error { +func (k *Kubectl) WaitForControlPlaneReady(ctx context.Context, cluster *types.Cluster, timeout, newClusterName string) error { return k.Wait(ctx, cluster.KubeconfigFile, timeout, "ControlPlaneReady", fmt.Sprintf("%s/%s", capiClustersResourceType, newClusterName), constants.EksaSystemNamespace) } // WaitForControlPlaneAvailable blocks until the first control plane is available. -func (k *Kubectl) WaitForControlPlaneAvailable(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error { +func (k *Kubectl) WaitForControlPlaneAvailable(ctx context.Context, cluster *types.Cluster, timeout, newClusterName string) error { return k.Wait(ctx, cluster.KubeconfigFile, timeout, "ControlPlaneInitialized", fmt.Sprintf("%s/%s", capiClustersResourceType, newClusterName), constants.EksaSystemNamespace) } -func (k *Kubectl) WaitForControlPlaneNotReady(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error { +func (k *Kubectl) WaitForControlPlaneNotReady(ctx context.Context, cluster *types.Cluster, timeout, newClusterName string) error { return k.Wait(ctx, cluster.KubeconfigFile, timeout, "ControlPlaneReady=false", fmt.Sprintf("%s/%s", capiClustersResourceType, newClusterName), constants.EksaSystemNamespace) } -func (k *Kubectl) WaitForManagedExternalEtcdReady(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error { +func (k *Kubectl) WaitForManagedExternalEtcdReady(ctx context.Context, cluster *types.Cluster, timeout, newClusterName string) error { return k.Wait(ctx, cluster.KubeconfigFile, timeout, "ManagedEtcdReady", fmt.Sprintf("clusters.%s/%s", clusterv1.GroupVersion.Group, newClusterName), constants.EksaSystemNamespace) } -func (k *Kubectl) WaitForManagedExternalEtcdNotReady(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error { +func (k *Kubectl) WaitForManagedExternalEtcdNotReady(ctx context.Context, cluster *types.Cluster, timeout, newClusterName string) error { return k.Wait(ctx, cluster.KubeconfigFile, timeout, "ManagedEtcdReady=false", fmt.Sprintf("clusters.%s/%s", clusterv1.GroupVersion.Group, newClusterName), constants.EksaSystemNamespace) } -func (k *Kubectl) WaitForMachineDeploymentReady(ctx context.Context, cluster *types.Cluster, timeout string, machineDeploymentName string) error { +func (k *Kubectl) WaitForMachineDeploymentReady(ctx context.Context, cluster *types.Cluster, timeout, machineDeploymentName string) error { return k.Wait(ctx, cluster.KubeconfigFile, timeout, "Ready=true", fmt.Sprintf("%s/%s", capiMachineDeploymentsType, machineDeploymentName), constants.EksaSystemNamespace) } @@ -404,7 +404,7 @@ func (k *Kubectl) WaitForMachineDeploymentReady(ctx context.Context, cluster *ty // Until more generic status matching comes around (possibly in 1.23), poll // the service, checking for an IP address. Would you like to know more? // https://github.com/kubernetes/kubernetes/issues/83094 -func (k *Kubectl) WaitForService(ctx context.Context, kubeconfig string, timeout string, target string, namespace string) error { +func (k *Kubectl) WaitForService(ctx context.Context, kubeconfig, timeout, target, namespace string) error { timeoutDur, err := time.ParseDuration(timeout) if err != nil { return fmt.Errorf("parsing duration %q: %w", timeout, err) @@ -443,12 +443,12 @@ func (k *Kubectl) WaitForService(ctx context.Context, kubeconfig string, timeout } } -func (k *Kubectl) WaitForDeployment(ctx context.Context, cluster *types.Cluster, timeout string, condition string, target string, namespace string) error { +func (k *Kubectl) WaitForDeployment(ctx context.Context, cluster *types.Cluster, timeout, condition, target, namespace string) error { return k.Wait(ctx, cluster.KubeconfigFile, timeout, condition, "deployments/"+target, namespace) } // WaitForResourceRolledout waits for a resource (deployment, daemonset, or statefulset) to be successfully rolled out before returning. -func (k *Kubectl) WaitForResourceRolledout(ctx context.Context, cluster *types.Cluster, timeout string, target string, namespace string, resource string) error { +func (k *Kubectl) WaitForResourceRolledout(ctx context.Context, cluster *types.Cluster, timeout, target, namespace, resource string) error { params := []string{"rollout", "status", resource, target, "--kubeconfig", cluster.KubeconfigFile, "--namespace", namespace, "--timeout", timeout} _, err := k.Execute(ctx, params...) if err != nil { @@ -458,31 +458,31 @@ func (k *Kubectl) WaitForResourceRolledout(ctx context.Context, cluster *types.C } // WaitForPod waits for a pod resource to reach desired condition before returning. -func (k *Kubectl) WaitForPod(ctx context.Context, cluster *types.Cluster, timeout string, condition string, target string, namespace string) error { +func (k *Kubectl) WaitForPod(ctx context.Context, cluster *types.Cluster, timeout, condition, target, namespace string) error { return k.Wait(ctx, cluster.KubeconfigFile, timeout, condition, "pod/"+target, namespace) } // WaitForRufioMachines blocks until all Rufio Machines have the desired condition. -func (k *Kubectl) WaitForRufioMachines(ctx context.Context, cluster *types.Cluster, timeout string, condition string, namespace string) error { +func (k *Kubectl) WaitForRufioMachines(ctx context.Context, cluster *types.Cluster, timeout, condition, namespace string) error { return k.Wait(ctx, cluster.KubeconfigFile, timeout, condition, rufioMachineResourceType, namespace, WithWaitAll()) } // WaitForJobCompleted waits for a job resource to reach desired condition before returning. -func (k *Kubectl) WaitForJobCompleted(ctx context.Context, kubeconfig, timeout string, condition string, target string, namespace string) error { +func (k *Kubectl) WaitForJobCompleted(ctx context.Context, kubeconfig, timeout, condition, target, namespace string) error { return k.Wait(ctx, kubeconfig, timeout, condition, "job/"+target, namespace) } // WaitForPackagesInstalled waits for a package resource to reach installed state before returning. -func (k *Kubectl) WaitForPackagesInstalled(ctx context.Context, cluster *types.Cluster, name string, timeout string, namespace string) error { +func (k *Kubectl) WaitForPackagesInstalled(ctx context.Context, cluster *types.Cluster, name, timeout, namespace string) error { return k.WaitJSONPathLoop(ctx, cluster.KubeconfigFile, timeout, "status.state", "installed", fmt.Sprintf("%s/%s", eksaPackagesType, name), namespace) } // WaitForPodCompleted waits for a pod to be terminated with a Completed state before returning. -func (k *Kubectl) WaitForPodCompleted(ctx context.Context, cluster *types.Cluster, name string, timeout string, namespace string) error { +func (k *Kubectl) WaitForPodCompleted(ctx context.Context, cluster *types.Cluster, name, timeout, namespace string) error { return k.WaitJSONPathLoop(ctx, cluster.KubeconfigFile, timeout, "status.containerStatuses[0].state.terminated.reason", "Completed", "pod/"+name, namespace) } -func (k *Kubectl) Wait(ctx context.Context, kubeconfig string, timeout string, forCondition string, property string, namespace string, opts ...KubectlOpt) error { +func (k *Kubectl) Wait(ctx context.Context, kubeconfig, timeout, forCondition, property, namespace string, opts ...KubectlOpt) error { // On each retry kubectl wait timeout values will have to be adjusted to only wait for the remaining timeout duration. // Here we establish an absolute timeout time for this based on the caller-specified timeout. timeoutDuration, err := time.ParseDuration(timeout) @@ -508,7 +508,7 @@ func (k *Kubectl) Wait(ctx context.Context, kubeconfig string, timeout string, f // WaitJSONPathLoop will wait for a given JSONPath to reach a required state similar to wait command for objects without conditions. // This will be deprecated in favor of WaitJSONPath after version 1.23. -func (k *Kubectl) WaitJSONPathLoop(ctx context.Context, kubeconfig string, timeout string, jsonpath, forCondition string, property string, namespace string, opts ...KubectlOpt) error { +func (k *Kubectl) WaitJSONPathLoop(ctx context.Context, kubeconfig, timeout, jsonpath, forCondition, property, namespace string, opts ...KubectlOpt) error { // On each retry kubectl wait timeout values will have to be adjusted to only wait for the remaining timeout duration. // Here we establish an absolute timeout time for this based on the caller-specified timeout. timeoutDuration, err := time.ParseDuration(timeout) @@ -532,7 +532,7 @@ func (k *Kubectl) WaitJSONPathLoop(ctx context.Context, kubeconfig string, timeo } // WaitJSONPath will wait for a given JSONPath of a required state. Only compatible on K8s 1.23+. -func (k *Kubectl) WaitJSONPath(ctx context.Context, kubeconfig string, timeout string, jsonpath, forCondition string, property string, namespace string, opts ...KubectlOpt) error { +func (k *Kubectl) WaitJSONPath(ctx context.Context, kubeconfig, timeout, jsonpath, forCondition, property, namespace string, opts ...KubectlOpt) error { // On each retry kubectl wait timeout values will have to be adjusted to only wait for the remaining timeout duration. // Here we establish an absolute timeout time for this based on the caller-specified timeout. timeoutDuration, err := time.ParseDuration(timeout) @@ -574,7 +574,7 @@ func (k *Kubectl) kubectlWaitRetryPolicy(totalRetries int, err error) (retry boo return false, 0 } -func (k *Kubectl) wait(ctx context.Context, kubeconfig string, timeoutTime time.Time, forCondition string, property string, namespace string, opts ...KubectlOpt) error { +func (k *Kubectl) wait(ctx context.Context, kubeconfig string, timeoutTime time.Time, forCondition, property, namespace string, opts ...KubectlOpt) error { secondsRemainingUntilTimeout := time.Until(timeoutTime).Seconds() if secondsRemainingUntilTimeout <= minimumWaitTimeout { return fmt.Errorf("error: timed out waiting for condition %v on %v", forCondition, property) @@ -592,7 +592,7 @@ func (k *Kubectl) wait(ctx context.Context, kubeconfig string, timeoutTime time. return nil } -func (k *Kubectl) waitJSONPath(ctx context.Context, kubeconfig, timeout string, jsonpath string, forCondition string, property string, namespace string, opts ...KubectlOpt) error { +func (k *Kubectl) waitJSONPath(ctx context.Context, kubeconfig, timeout, jsonpath, forCondition, property, namespace string, opts ...KubectlOpt) error { if jsonpath == "" || forCondition == "" { return fmt.Errorf("empty conditions params passed to waitJSONPath()") } @@ -607,7 +607,7 @@ func (k *Kubectl) waitJSONPath(ctx context.Context, kubeconfig, timeout string, } // waitJsonPathLoop will be deprecated in favor of waitJsonPath after version 1.23. -func (k *Kubectl) waitJSONPathLoop(ctx context.Context, kubeconfig string, timeout string, jsonpath string, forCondition string, property string, namespace string, opts ...KubectlOpt) error { +func (k *Kubectl) waitJSONPathLoop(ctx context.Context, kubeconfig, timeout, jsonpath, forCondition, property, namespace string, opts ...KubectlOpt) error { if jsonpath == "" || forCondition == "" { return fmt.Errorf("empty conditions params passed to waitJSONPathLoop()") } @@ -647,7 +647,7 @@ func (k *Kubectl) waitJSONPathLoop(ctx context.Context, kubeconfig string, timeo } } -func (k *Kubectl) DeleteEksaDatacenterConfig(ctx context.Context, eksaDatacenterResourceType string, eksaDatacenterConfigName string, kubeconfigFile string, namespace string) error { +func (k *Kubectl) DeleteEksaDatacenterConfig(ctx context.Context, eksaDatacenterResourceType, eksaDatacenterConfigName, kubeconfigFile, namespace string) error { params := []string{"delete", eksaDatacenterResourceType, eksaDatacenterConfigName, "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--ignore-not-found=true"} _, err := k.Execute(ctx, params...) if err != nil { @@ -656,7 +656,7 @@ func (k *Kubectl) DeleteEksaDatacenterConfig(ctx context.Context, eksaDatacenter return nil } -func (k *Kubectl) DeleteEksaMachineConfig(ctx context.Context, eksaMachineConfigResourceType string, eksaMachineConfigName string, kubeconfigFile string, namespace string) error { +func (k *Kubectl) DeleteEksaMachineConfig(ctx context.Context, eksaMachineConfigResourceType, eksaMachineConfigName, kubeconfigFile, namespace string) error { params := []string{"delete", eksaMachineConfigResourceType, eksaMachineConfigName, "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--ignore-not-found=true"} _, err := k.Execute(ctx, params...) if err != nil { @@ -824,7 +824,7 @@ func (k *Kubectl) GetControlPlaneNodes(ctx context.Context, kubeconfig string) ( } // GetVsphereMachine will return list of vSphere machines. -func (k *Kubectl) GetVsphereMachine(ctx context.Context, kubeconfig string, selector string) ([]vspherev1.VSphereMachine, error) { +func (k *Kubectl) GetVsphereMachine(ctx context.Context, kubeconfig, selector string) ([]vspherev1.VSphereMachine, error) { params := []string{"get", "vspheremachines", "-o", "json", "--namespace", constants.EksaSystemNamespace, "--kubeconfig", kubeconfig, "--selector=" + selector} stdOut, err := k.Execute(ctx, params...) if err != nil { @@ -905,7 +905,7 @@ func (k *Kubectl) ValidateControlPlaneNodes(ctx context.Context, cluster *types. return nil } -func (k *Kubectl) ValidateWorkerNodes(ctx context.Context, clusterName string, kubeconfig string) error { +func (k *Kubectl) ValidateWorkerNodes(ctx context.Context, clusterName, kubeconfig string) error { logger.V(6).Info("waiting for nodes", "cluster", clusterName) ready, total, err := k.CountMachineDeploymentReplicasReady(ctx, clusterName, kubeconfig) if err != nil { @@ -917,7 +917,7 @@ func (k *Kubectl) ValidateWorkerNodes(ctx context.Context, clusterName string, k return nil } -func (k *Kubectl) CountMachineDeploymentReplicasReady(ctx context.Context, clusterName string, kubeconfig string) (ready, total int, err error) { +func (k *Kubectl) CountMachineDeploymentReplicasReady(ctx context.Context, clusterName, kubeconfig string) (ready, total int, err error) { logger.V(6).Info("counting ready machine deployment replicas", "cluster", clusterName) deployments, err := k.GetMachineDeploymentsForCluster(ctx, clusterName, WithKubeconfig(kubeconfig), WithNamespace(constants.EksaSystemNamespace)) if err != nil { @@ -938,7 +938,7 @@ func (k *Kubectl) CountMachineDeploymentReplicasReady(ctx context.Context, clust return ready, total, nil } -func (k *Kubectl) VsphereWorkerNodesMachineTemplate(ctx context.Context, clusterName string, kubeconfig string, namespace string) (*vspherev1.VSphereMachineTemplate, error) { +func (k *Kubectl) VsphereWorkerNodesMachineTemplate(ctx context.Context, clusterName, kubeconfig, namespace string) (*vspherev1.VSphereMachineTemplate, error) { machineTemplateName, err := k.MachineTemplateName(ctx, clusterName, kubeconfig, WithNamespace(namespace)) if err != nil { return nil, err @@ -956,7 +956,7 @@ func (k *Kubectl) VsphereWorkerNodesMachineTemplate(ctx context.Context, cluster return machineTemplateSpec, nil } -func (k *Kubectl) CloudstackWorkerNodesMachineTemplate(ctx context.Context, clusterName string, kubeconfig string, namespace string) (*cloudstackv1.CloudStackMachineTemplate, error) { +func (k *Kubectl) CloudstackWorkerNodesMachineTemplate(ctx context.Context, clusterName, kubeconfig, namespace string) (*cloudstackv1.CloudStackMachineTemplate, error) { machineTemplateName, err := k.MachineTemplateName(ctx, clusterName, kubeconfig, WithNamespace(namespace)) if err != nil { return nil, err @@ -974,7 +974,7 @@ func (k *Kubectl) CloudstackWorkerNodesMachineTemplate(ctx context.Context, clus return machineTemplateSpec, nil } -func (k *Kubectl) MachineTemplateName(ctx context.Context, clusterName string, kubeconfig string, opts ...KubectlOpt) (string, error) { +func (k *Kubectl) MachineTemplateName(ctx context.Context, clusterName, kubeconfig string, opts ...KubectlOpt) (string, error) { template := "{{.spec.template.spec.infrastructureRef.name}}" params := []string{"get", capiMachineDeploymentsType, fmt.Sprintf("%s-md-0", clusterName), "-o", "go-template", "--template", template, "--kubeconfig", kubeconfig} applyOpts(¶ms, opts...) @@ -1498,7 +1498,7 @@ func (k *Kubectl) UpdateAnnotationInNamespace(ctx context.Context, resourceType, return k.UpdateAnnotation(ctx, resourceType, objectName, annotations, WithOverwrite(), WithCluster(cluster), WithNamespace(namespace)) } -func (k *Kubectl) RemoveAnnotation(ctx context.Context, resourceType, objectName string, key string, opts ...KubectlOpt) error { +func (k *Kubectl) RemoveAnnotation(ctx context.Context, resourceType, objectName, key string, opts ...KubectlOpt) error { params := []string{"annotate", resourceType, objectName, fmt.Sprintf("%s-", key)} applyOpts(¶ms, opts...) _, err := k.Execute(ctx, params...) @@ -1533,7 +1533,7 @@ func (k *Kubectl) GetEksaCluster(ctx context.Context, cluster *types.Cluster, cl return response, nil } -func (k *Kubectl) SearchVsphereMachineConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.VSphereMachineConfig, error) { +func (k *Kubectl) SearchVsphereMachineConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.VSphereMachineConfig, error) { params := []string{ "get", eksaVSphereMachineResourceType, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--field-selector=metadata.name=" + name, @@ -1553,7 +1553,7 @@ func (k *Kubectl) SearchVsphereMachineConfig(ctx context.Context, name string, k } // SearchTinkerbellMachineConfig returns the list of TinkerbellMachineConfig in the cluster. -func (k *Kubectl) SearchTinkerbellMachineConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.TinkerbellMachineConfig, error) { +func (k *Kubectl) SearchTinkerbellMachineConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.TinkerbellMachineConfig, error) { params := []string{ "get", eksaTinkerbellMachineResourceType, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--field-selector=metadata.name=" + name, @@ -1572,7 +1572,7 @@ func (k *Kubectl) SearchTinkerbellMachineConfig(ctx context.Context, name string return response.Items, nil } -func (k *Kubectl) SearchIdentityProviderConfig(ctx context.Context, ipName string, kind string, kubeconfigFile string, namespace string) ([]*v1alpha1.VSphereDatacenterConfig, error) { +func (k *Kubectl) SearchIdentityProviderConfig(ctx context.Context, ipName, kind, kubeconfigFile, namespace string) ([]*v1alpha1.VSphereDatacenterConfig, error) { var internalType string switch kind { @@ -1602,7 +1602,7 @@ func (k *Kubectl) SearchIdentityProviderConfig(ctx context.Context, ipName strin return response.Items, nil } -func (k *Kubectl) SearchVsphereDatacenterConfig(ctx context.Context, datacenterName string, kubeconfigFile string, namespace string) ([]*v1alpha1.VSphereDatacenterConfig, error) { +func (k *Kubectl) SearchVsphereDatacenterConfig(ctx context.Context, datacenterName, kubeconfigFile, namespace string) ([]*v1alpha1.VSphereDatacenterConfig, error) { params := []string{ "get", eksaVSphereDatacenterResourceType, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--field-selector=metadata.name=" + datacenterName, @@ -1622,7 +1622,7 @@ func (k *Kubectl) SearchVsphereDatacenterConfig(ctx context.Context, datacenterN } // SearchTinkerbellDatacenterConfig returns the list of TinkerbellDatacenterConfig in the cluster. -func (k *Kubectl) SearchTinkerbellDatacenterConfig(ctx context.Context, datacenterName string, kubeconfigFile string, namespace string) ([]*v1alpha1.TinkerbellDatacenterConfig, error) { +func (k *Kubectl) SearchTinkerbellDatacenterConfig(ctx context.Context, datacenterName, kubeconfigFile, namespace string) ([]*v1alpha1.TinkerbellDatacenterConfig, error) { params := []string{ "get", eksaTinkerbellDatacenterResourceType, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--field-selector=metadata.name=" + datacenterName, @@ -1641,7 +1641,7 @@ func (k *Kubectl) SearchTinkerbellDatacenterConfig(ctx context.Context, datacent return response.Items, nil } -func (k *Kubectl) GetEksaFluxConfig(ctx context.Context, gitOpsConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.FluxConfig, error) { +func (k *Kubectl) GetEksaFluxConfig(ctx context.Context, gitOpsConfigName, kubeconfigFile, namespace string) (*v1alpha1.FluxConfig, error) { params := []string{"get", eksaFluxConfigResourceType, gitOpsConfigName, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace} stdOut, err := k.Execute(ctx, params...) if err != nil { @@ -1657,7 +1657,7 @@ func (k *Kubectl) GetEksaFluxConfig(ctx context.Context, gitOpsConfigName string return response, nil } -func (k *Kubectl) GetEksaGitOpsConfig(ctx context.Context, gitOpsConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.GitOpsConfig, error) { +func (k *Kubectl) GetEksaGitOpsConfig(ctx context.Context, gitOpsConfigName, kubeconfigFile, namespace string) (*v1alpha1.GitOpsConfig, error) { params := []string{"get", eksaGitOpsResourceType, gitOpsConfigName, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace} stdOut, err := k.Execute(ctx, params...) if err != nil { @@ -1673,7 +1673,7 @@ func (k *Kubectl) GetEksaGitOpsConfig(ctx context.Context, gitOpsConfigName stri return response, nil } -func (k *Kubectl) GetEksaOIDCConfig(ctx context.Context, oidcConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.OIDCConfig, error) { +func (k *Kubectl) GetEksaOIDCConfig(ctx context.Context, oidcConfigName, kubeconfigFile, namespace string) (*v1alpha1.OIDCConfig, error) { params := []string{"get", eksaOIDCResourceType, oidcConfigName, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace} stdOut, err := k.Execute(ctx, params...) if err != nil { @@ -1689,7 +1689,7 @@ func (k *Kubectl) GetEksaOIDCConfig(ctx context.Context, oidcConfigName string, return response, nil } -func (k *Kubectl) GetEksaAWSIamConfig(ctx context.Context, awsIamConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.AWSIamConfig, error) { +func (k *Kubectl) GetEksaAWSIamConfig(ctx context.Context, awsIamConfigName, kubeconfigFile, namespace string) (*v1alpha1.AWSIamConfig, error) { params := []string{"get", eksaAwsIamResourceType, awsIamConfigName, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace} stdOut, err := k.Execute(ctx, params...) if err != nil { @@ -1705,7 +1705,7 @@ func (k *Kubectl) GetEksaAWSIamConfig(ctx context.Context, awsIamConfigName stri return response, nil } -func (k *Kubectl) GetEksaTinkerbellDatacenterConfig(ctx context.Context, tinkerbellDatacenterConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.TinkerbellDatacenterConfig, error) { +func (k *Kubectl) GetEksaTinkerbellDatacenterConfig(ctx context.Context, tinkerbellDatacenterConfigName, kubeconfigFile, namespace string) (*v1alpha1.TinkerbellDatacenterConfig, error) { params := []string{"get", eksaTinkerbellDatacenterResourceType, tinkerbellDatacenterConfigName, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace} stdOut, err := k.Execute(ctx, params...) if err != nil { @@ -1721,7 +1721,7 @@ func (k *Kubectl) GetEksaTinkerbellDatacenterConfig(ctx context.Context, tinkerb return response, nil } -func (k *Kubectl) GetEksaVSphereDatacenterConfig(ctx context.Context, vsphereDatacenterConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.VSphereDatacenterConfig, error) { +func (k *Kubectl) GetEksaVSphereDatacenterConfig(ctx context.Context, vsphereDatacenterConfigName, kubeconfigFile, namespace string) (*v1alpha1.VSphereDatacenterConfig, error) { params := []string{"get", eksaVSphereDatacenterResourceType, vsphereDatacenterConfigName, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace} stdOut, err := k.Execute(ctx, params...) if err != nil { @@ -1737,7 +1737,7 @@ func (k *Kubectl) GetEksaVSphereDatacenterConfig(ctx context.Context, vsphereDat return response, nil } -func (k *Kubectl) GetEksaTinkerbellMachineConfig(ctx context.Context, tinkerbellMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.TinkerbellMachineConfig, error) { +func (k *Kubectl) GetEksaTinkerbellMachineConfig(ctx context.Context, tinkerbellMachineConfigName, kubeconfigFile, namespace string) (*v1alpha1.TinkerbellMachineConfig, error) { params := []string{"get", eksaTinkerbellMachineResourceType, tinkerbellMachineConfigName, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace} stdOut, err := k.Execute(ctx, params...) if err != nil { @@ -1806,7 +1806,7 @@ func (k *Kubectl) GetProvisionedTinkerbellHardware(ctx context.Context, kubeconf return list.Items, nil } -func (k *Kubectl) GetEksaVSphereMachineConfig(ctx context.Context, vsphereMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.VSphereMachineConfig, error) { +func (k *Kubectl) GetEksaVSphereMachineConfig(ctx context.Context, vsphereMachineConfigName, kubeconfigFile, namespace string) (*v1alpha1.VSphereMachineConfig, error) { params := []string{"get", eksaVSphereMachineResourceType, vsphereMachineConfigName, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace} stdOut, err := k.Execute(ctx, params...) if err != nil { @@ -1822,7 +1822,7 @@ func (k *Kubectl) GetEksaVSphereMachineConfig(ctx context.Context, vsphereMachin return response, nil } -func (k *Kubectl) GetEksaAWSDatacenterConfig(ctx context.Context, awsDatacenterConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.AWSDatacenterConfig, error) { +func (k *Kubectl) GetEksaAWSDatacenterConfig(ctx context.Context, awsDatacenterConfigName, kubeconfigFile, namespace string) (*v1alpha1.AWSDatacenterConfig, error) { params := []string{"get", eksaAwsResourceType, awsDatacenterConfigName, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace} stdOut, err := k.Execute(ctx, params...) if err != nil { @@ -1966,11 +1966,11 @@ type Toleration struct { TolerationSeconds json.Number `json:"tolerationSeconds,omitempty"` } -func (k *Kubectl) ApplyTolerationsFromTaintsToDaemonSet(ctx context.Context, oldTaints []corev1.Taint, newTaints []corev1.Taint, dsName string, kubeconfigFile string) error { +func (k *Kubectl) ApplyTolerationsFromTaintsToDaemonSet(ctx context.Context, oldTaints, newTaints []corev1.Taint, dsName, kubeconfigFile string) error { return k.ApplyTolerationsFromTaints(ctx, oldTaints, newTaints, "ds", dsName, kubeconfigFile, "kube-system", "/spec/template/spec/tolerations") } -func (k *Kubectl) ApplyTolerationsFromTaints(ctx context.Context, oldTaints []corev1.Taint, newTaints []corev1.Taint, resource string, name string, kubeconfigFile string, namespace string, path string) error { +func (k *Kubectl) ApplyTolerationsFromTaints(ctx context.Context, oldTaints, newTaints []corev1.Taint, resource, name, kubeconfigFile, namespace, path string) error { params := []string{ "get", resource, name, "-o", "jsonpath={range .spec.template.spec}{.tolerations} {end}", @@ -2051,12 +2051,12 @@ func (k *Kubectl) MergePatchResource(ctx context.Context, resource, name, patch, return nil } -func (k *Kubectl) KubeconfigSecretAvailable(ctx context.Context, kubeconfig string, clusterName string, namespace string) (bool, error) { +func (k *Kubectl) KubeconfigSecretAvailable(ctx context.Context, kubeconfig, clusterName, namespace string) (bool, error) { return k.HasResource(ctx, "secret", fmt.Sprintf("%s-kubeconfig", clusterName), kubeconfig, namespace) } // HasResource implements KubectlRunner. -func (k *Kubectl) HasResource(ctx context.Context, resourceType string, name string, kubeconfig string, namespace string) (bool, error) { +func (k *Kubectl) HasResource(ctx context.Context, resourceType, name, kubeconfig, namespace string) (bool, error) { throwaway := &unstructured.Unstructured{} err := k.Get(ctx, resourceType, kubeconfig, throwaway, withGetResourceName(name), withNamespaceOrDefaultForGet(namespace)) if err != nil { @@ -2395,7 +2395,7 @@ func (k *Kubectl) ExecuteFromYaml(ctx context.Context, yaml []byte, opts ...stri return k.ExecuteWithStdin(ctx, yaml, opts...) } -func (k *Kubectl) SearchNutanixMachineConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.NutanixMachineConfig, error) { +func (k *Kubectl) SearchNutanixMachineConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.NutanixMachineConfig, error) { params := []string{ "get", eksaNutanixMachineResourceType, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--field-selector=metadata.name=" + name, @@ -2414,7 +2414,7 @@ func (k *Kubectl) SearchNutanixMachineConfig(ctx context.Context, name string, k return response.Items, nil } -func (k *Kubectl) SearchNutanixDatacenterConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.NutanixDatacenterConfig, error) { +func (k *Kubectl) SearchNutanixDatacenterConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.NutanixDatacenterConfig, error) { params := []string{ "get", eksaNutanixDatacenterResourceType, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--field-selector=metadata.name=" + name, @@ -2433,7 +2433,7 @@ func (k *Kubectl) SearchNutanixDatacenterConfig(ctx context.Context, name string return response.Items, nil } -func (k *Kubectl) GetEksaNutanixDatacenterConfig(ctx context.Context, nutanixDatacenterConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.NutanixDatacenterConfig, error) { +func (k *Kubectl) GetEksaNutanixDatacenterConfig(ctx context.Context, nutanixDatacenterConfigName, kubeconfigFile, namespace string) (*v1alpha1.NutanixDatacenterConfig, error) { response := &v1alpha1.NutanixDatacenterConfig{} err := k.GetObject(ctx, eksaNutanixDatacenterResourceType, nutanixDatacenterConfigName, namespace, kubeconfigFile, response) if err != nil { @@ -2443,7 +2443,7 @@ func (k *Kubectl) GetEksaNutanixDatacenterConfig(ctx context.Context, nutanixDat return response, nil } -func (k *Kubectl) GetEksaNutanixMachineConfig(ctx context.Context, nutanixMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.NutanixMachineConfig, error) { +func (k *Kubectl) GetEksaNutanixMachineConfig(ctx context.Context, nutanixMachineConfigName, kubeconfigFile, namespace string) (*v1alpha1.NutanixMachineConfig, error) { response := &v1alpha1.NutanixMachineConfig{} err := k.GetObject(ctx, eksaNutanixMachineResourceType, nutanixMachineConfigName, namespace, kubeconfigFile, response) if err != nil { @@ -2453,7 +2453,7 @@ func (k *Kubectl) GetEksaNutanixMachineConfig(ctx context.Context, nutanixMachin return response, nil } -func (k *Kubectl) DeleteEksaNutanixDatacenterConfig(ctx context.Context, nutanixDatacenterConfigName string, kubeconfigFile string, namespace string) error { +func (k *Kubectl) DeleteEksaNutanixDatacenterConfig(ctx context.Context, nutanixDatacenterConfigName, kubeconfigFile, namespace string) error { params := []string{"delete", eksaNutanixDatacenterResourceType, nutanixDatacenterConfigName, "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--ignore-not-found=true"} _, err := k.Execute(ctx, params...) if err != nil { @@ -2462,7 +2462,7 @@ func (k *Kubectl) DeleteEksaNutanixDatacenterConfig(ctx context.Context, nutanix return nil } -func (k *Kubectl) DeleteEksaNutanixMachineConfig(ctx context.Context, nutanixMachineConfigName string, kubeconfigFile string, namespace string) error { +func (k *Kubectl) DeleteEksaNutanixMachineConfig(ctx context.Context, nutanixMachineConfigName, kubeconfigFile, namespace string) error { params := []string{"delete", eksaNutanixMachineResourceType, nutanixMachineConfigName, "--kubeconfig", kubeconfigFile, "--namespace", namespace, "--ignore-not-found=true"} _, err := k.Execute(ctx, params...) if err != nil { diff --git a/pkg/executables/troubleshoot.go b/pkg/executables/troubleshoot.go index 1953e8ab73a0..8ea8dc440e2b 100644 --- a/pkg/executables/troubleshoot.go +++ b/pkg/executables/troubleshoot.go @@ -41,7 +41,7 @@ func (t *Troubleshoot) Collect(ctx context.Context, bundlePath string, sinceTime return archivePath, nil } -func (t *Troubleshoot) Analyze(ctx context.Context, bundleSpecPath string, archivePath string) ([]*SupportBundleAnalysis, error) { +func (t *Troubleshoot) Analyze(ctx context.Context, bundleSpecPath, archivePath string) ([]*SupportBundleAnalysis, error) { params := []string{"analyze", bundleSpecPath, "--bundle", archivePath, "--output", "json"} output, err := t.Execute(ctx, params...) if err != nil { diff --git a/pkg/features/mutexmap.go b/pkg/features/mutexmap.go index 1eca9d07f0f1..32aa848b557f 100644 --- a/pkg/features/mutexmap.go +++ b/pkg/features/mutexmap.go @@ -13,7 +13,7 @@ type mutexMap struct { sync.RWMutex } -func (m *mutexMap) load(key string) (value bool, ok bool) { +func (m *mutexMap) load(key string) (value, ok bool) { m.RLock() result, ok := m.internal[key] m.RUnlock() diff --git a/pkg/git/factory/gitfactory.go b/pkg/git/factory/gitfactory.go index 0b4ef852076b..7c8b0dc23c52 100644 --- a/pkg/git/factory/gitfactory.go +++ b/pkg/git/factory/gitfactory.go @@ -95,7 +95,7 @@ func Build(ctx context.Context, cluster *v1alpha1.Cluster, fluxConfig *v1alpha1. return &tools, nil } -func buildGitClient(ctx context.Context, auth transport.AuthMethod, repoUrl string, repo string) *gitclient.GitClient { +func buildGitClient(ctx context.Context, auth transport.AuthMethod, repoUrl, repo string) *gitclient.GitClient { opts := []gitclient.Opt{ gitclient.WithRepositoryUrl(repoUrl), gitclient.WithRepositoryDirectory(repo), @@ -133,7 +133,7 @@ func WithRepositoryDirectory(repoDir string) GitToolsOpt { } } -func getSSHAuthFromPrivateKey(privateKeyFile string, passphrase string, user string) (gogitssh.AuthMethod, error) { +func getSSHAuthFromPrivateKey(privateKeyFile, passphrase, user string) (gogitssh.AuthMethod, error) { signer, err := getSignerFromPrivateKeyFile(privateKeyFile, passphrase) if err != nil { return nil, err @@ -144,7 +144,7 @@ func getSSHAuthFromPrivateKey(privateKeyFile string, passphrase string, user str }, nil } -func getSignerFromPrivateKeyFile(privateKeyFile string, passphrase string) (ssh.Signer, error) { +func getSignerFromPrivateKeyFile(privateKeyFile, passphrase string) (ssh.Signer, error) { var signer ssh.Signer var err error diff --git a/pkg/git/gitclient/gitclient.go b/pkg/git/gitclient/gitclient.go index cc8c06b78a6e..7ac474c078d1 100644 --- a/pkg/git/gitclient/gitclient.go +++ b/pkg/git/gitclient/gitclient.go @@ -315,7 +315,7 @@ func (g *GitClient) remoteBranchExists(r *gogit.Repository, localBranchRef plumb type GoGit interface { AddGlob(f string, w *gogit.Worktree) error Checkout(w *gogit.Worktree, opts *gogit.CheckoutOptions) error - Clone(ctx context.Context, dir string, repoUrl string, auth transport.AuthMethod) (*gogit.Repository, error) + Clone(ctx context.Context, dir, repoUrl string, auth transport.AuthMethod) (*gogit.Repository, error) Commit(m string, sig *object.Signature, w *gogit.Worktree) (plumbing.Hash, error) CommitObject(r *gogit.Repository, h plumbing.Hash) (*object.Commit, error) Create(r *gogit.Repository, url string) (*gogit.Remote, error) @@ -335,7 +335,7 @@ type GoGit interface { type goGit struct{} -func (gg *goGit) Clone(ctx context.Context, dir string, repourl string, auth transport.AuthMethod) (*gogit.Repository, error) { +func (gg *goGit) Clone(ctx context.Context, dir, repourl string, auth transport.AuthMethod) (*gogit.Repository, error) { ctx, cancel := context.WithTimeout(ctx, gitTimeout) defer cancel() diff --git a/pkg/git/gogithub/gogithub.go b/pkg/git/gogithub/gogithub.go index 8e492e55d861..5f4f1e1b1882 100644 --- a/pkg/git/gogithub/gogithub.go +++ b/pkg/git/gogithub/gogithub.go @@ -144,7 +144,7 @@ func (g *GoGithub) GetAccessTokenPermissions(accessToken string) (string, error) return permissionsScopes, nil } -func (g *GoGithub) CheckAccessTokenPermissions(checkPATPermission string, allPermissionScopes string) error { +func (g *GoGithub) CheckAccessTokenPermissions(checkPATPermission, allPermissionScopes string) error { logger.Info("Checking Github Access Token permissions") allPermissions := strings.Split(allPermissionScopes, ", ") diff --git a/pkg/git/providers/github/github.go b/pkg/git/providers/github/github.go index ae980655aba2..0ef4032f193b 100644 --- a/pkg/git/providers/github/github.go +++ b/pkg/git/providers/github/github.go @@ -44,7 +44,7 @@ type GithubClient interface { AuthenticatedUser(ctx context.Context) (*goGithub.User, error) Organization(ctx context.Context, org string) (*goGithub.Organization, error) GetAccessTokenPermissions(accessToken string) (string, error) - CheckAccessTokenPermissions(checkPATPermission string, allPermissionScopes string) error + CheckAccessTokenPermissions(checkPATPermission, allPermissionScopes string) error PathExists(ctx context.Context, owner, repo, branch, path string) (bool, error) DeleteRepo(ctx context.Context, opts git.DeleteRepoOpts) error } @@ -162,6 +162,6 @@ func (e *GitProviderNotFoundError) Error() string { return fmt.Sprintf("git provider %s not found", e.Provider) } -func RepoUrl(owner string, repo string) string { +func RepoUrl(owner, repo string) string { return fmt.Sprintf(githubUrlTemplate, owner, repo) } diff --git a/pkg/gitops/flux/client.go b/pkg/gitops/flux/client.go index 9c5ce43853fa..da4cf2ea51e4 100644 --- a/pkg/gitops/flux/client.go +++ b/pkg/gitops/flux/client.go @@ -31,7 +31,7 @@ type FluxClient interface { type KubeClient interface { GetEksaCluster(ctx context.Context, cluster *types.Cluster, clusterName string) (*v1alpha1.Cluster, error) UpdateAnnotation(ctx context.Context, resourceType, objectName string, annotations map[string]string, opts ...executables.KubectlOpt) error - RemoveAnnotation(ctx context.Context, resourceType, objectName string, key string, opts ...executables.KubectlOpt) error + RemoveAnnotation(ctx context.Context, resourceType, objectName, key string, opts ...executables.KubectlOpt) error DeleteSecret(ctx context.Context, managementCluster *types.Cluster, secretName, namespace string) error } diff --git a/pkg/gitops/flux/upgrader.go b/pkg/gitops/flux/upgrader.go index 96b9bd973328..4cc3cabdf705 100644 --- a/pkg/gitops/flux/upgrader.go +++ b/pkg/gitops/flux/upgrader.go @@ -11,7 +11,7 @@ import ( const upgradeFluxconfigCommitMessage = "Upgrade commit of flux configuration; generated by EKS-A CLI" -func (f *Flux) Upgrade(ctx context.Context, managementCluster *types.Cluster, currentSpec *cluster.Spec, newSpec *cluster.Spec) (*types.ChangeDiff, error) { +func (f *Flux) Upgrade(ctx context.Context, managementCluster *types.Cluster, currentSpec, newSpec *cluster.Spec) (*types.ChangeDiff, error) { logger.V(1).Info("Checking for Flux upgrades") changeDiff := FluxChangeDiff(currentSpec, newSpec) diff --git a/pkg/govmomi/client.go b/pkg/govmomi/client.go index e28dce630db8..9828a92c4302 100644 --- a/pkg/govmomi/client.go +++ b/pkg/govmomi/client.go @@ -51,7 +51,7 @@ func (vsc *VMOMIClient) Username() string { return vsc.username } -func (vsc *VMOMIClient) GetPrivsOnEntity(ctx context.Context, path string, objType string, username string) ([]string, error) { +func (vsc *VMOMIClient) GetPrivsOnEntity(ctx context.Context, path, objType, username string) ([]string, error) { var vSphereObjectReference types.ManagedObjectReference emptyResult := []string{} var err error diff --git a/pkg/govmomi/clientbuilder.go b/pkg/govmomi/clientbuilder.go index 97985b53de68..385308fdc9e0 100644 --- a/pkg/govmomi/clientbuilder.go +++ b/pkg/govmomi/clientbuilder.go @@ -12,7 +12,7 @@ import ( type VSphereClient interface { Username() string - GetPrivsOnEntity(ctx context.Context, path string, objType string, username string) ([]string, error) + GetPrivsOnEntity(ctx context.Context, path, objType, username string) ([]string, error) } type VMOMIFinderBuilder interface { @@ -41,7 +41,7 @@ func NewVMOMIClientBuilderOverride(vfb VMOMIFinderBuilder, gcb VMOMISessionBuild return &vMOMIClientBuilder{vfb: vfb, gcb: gcb, amb: amb} } -func (vcb *vMOMIClientBuilder) Build(ctx context.Context, host string, username string, password string, insecure bool, datacenter string) (VSphereClient, error) { +func (vcb *vMOMIClientBuilder) Build(ctx context.Context, host, username, password string, insecure bool, datacenter string) (VSphereClient, error) { u, err := soap.ParseURL(host) u.User = url.UserPassword(username, password) if err != nil { diff --git a/pkg/networking/cilium/installation.go b/pkg/networking/cilium/installation.go index f3ac292258ff..f7140ba7f716 100644 --- a/pkg/networking/cilium/installation.go +++ b/pkg/networking/cilium/installation.go @@ -76,7 +76,7 @@ func getDaemonSet(ctx context.Context, client client.Client) (*appsv1.DaemonSet, return ds, nil } -func getConfigMap(ctx context.Context, client client.Client, name string, namespace string) (*corev1.ConfigMap, error) { +func getConfigMap(ctx context.Context, client client.Client, name, namespace string) (*corev1.ConfigMap, error) { c := &corev1.ConfigMap{} err := client.Get(ctx, types.NamespacedName{Name: name, Namespace: namespace}, c) if apierrors.IsNotFound(err) { diff --git a/pkg/networking/cilium/upgrade_plan_test.go b/pkg/networking/cilium/upgrade_plan_test.go index b2262b3e9e56..a90c1799aff7 100644 --- a/pkg/networking/cilium/upgrade_plan_test.go +++ b/pkg/networking/cilium/upgrade_plan_test.go @@ -561,7 +561,7 @@ func daemonSet(image string, opts ...dsOpt) *appsv1.DaemonSet { type cmOpt func(*corev1.ConfigMap) -func ciliumConfigMap(enforcementMode string, egressMasqueradeInterface string, opts ...cmOpt) *corev1.ConfigMap { +func ciliumConfigMap(enforcementMode, egressMasqueradeInterface string, opts ...cmOpt) *corev1.ConfigMap { cm := &corev1.ConfigMap{ TypeMeta: metav1.TypeMeta{ APIVersion: "v1", diff --git a/pkg/networkutils/networkutils.go b/pkg/networkutils/networkutils.go index 9279408dd87c..8ef913d47c8f 100644 --- a/pkg/networkutils/networkutils.go +++ b/pkg/networkutils/networkutils.go @@ -43,7 +43,7 @@ func IsIPInUse(client NetClient, ip string) bool { return err == nil || errors.Is(err, syscall.ECONNREFUSED) || errors.Is(err, syscall.ECONNRESET) } -func IsPortInUse(client NetClient, host string, port string) bool { +func IsPortInUse(client NetClient, host, port string) bool { address := net.JoinHostPort(host, port) conn, err := client.DialTimeout("tcp", address, 500*time.Millisecond) if err == nil { diff --git a/pkg/providers/cloudstack/cloudstack.go b/pkg/providers/cloudstack/cloudstack.go index 84233600d9e0..a8aa97417d4e 100644 --- a/pkg/providers/cloudstack/cloudstack.go +++ b/pkg/providers/cloudstack/cloudstack.go @@ -216,27 +216,27 @@ func (p *cloudstackProvider) ChangeDiff(currentSpec, newSpec *cluster.Spec) *typ } } -func (p *cloudstackProvider) RunPostControlPlaneUpgrade(ctx context.Context, oldClusterSpec *cluster.Spec, clusterSpec *cluster.Spec, workloadCluster *types.Cluster, managementCluster *types.Cluster) error { +func (p *cloudstackProvider) RunPostControlPlaneUpgrade(ctx context.Context, oldClusterSpec, clusterSpec *cluster.Spec, workloadCluster, managementCluster *types.Cluster) error { // Nothing to do return nil } type ProviderKubectlClient interface { ApplyKubeSpecFromBytes(ctx context.Context, cluster *types.Cluster, data []byte) error - CreateNamespaceIfNotPresent(ctx context.Context, kubeconfig string, namespace string) error - LoadSecret(ctx context.Context, secretObject string, secretObjType string, secretObjectName string, kubeConfFile string) error + CreateNamespaceIfNotPresent(ctx context.Context, kubeconfig, namespace string) error + LoadSecret(ctx context.Context, secretObject, secretObjType, secretObjectName, kubeConfFile string) error GetEksaCluster(ctx context.Context, cluster *types.Cluster, clusterName string) (*v1alpha1.Cluster, error) - GetEksaCloudStackDatacenterConfig(ctx context.Context, cloudstackDatacenterConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.CloudStackDatacenterConfig, error) - GetEksaCloudStackMachineConfig(ctx context.Context, cloudstackMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.CloudStackMachineConfig, error) + GetEksaCloudStackDatacenterConfig(ctx context.Context, cloudstackDatacenterConfigName, kubeconfigFile, namespace string) (*v1alpha1.CloudStackDatacenterConfig, error) + GetEksaCloudStackMachineConfig(ctx context.Context, cloudstackMachineConfigName, kubeconfigFile, namespace string) (*v1alpha1.CloudStackMachineConfig, error) GetKubeadmControlPlane(ctx context.Context, cluster *types.Cluster, clusterName string, opts ...executables.KubectlOpt) (*kubeadmv1beta1.KubeadmControlPlane, error) GetMachineDeployment(ctx context.Context, workerNodeGroupName string, opts ...executables.KubectlOpt) (*clusterv1.MachineDeployment, error) GetEtcdadmCluster(ctx context.Context, cluster *types.Cluster, clusterName string, opts ...executables.KubectlOpt) (*etcdv1beta1.EtcdadmCluster, error) GetSecretFromNamespace(ctx context.Context, kubeconfigFile, name, namespace string) (*corev1.Secret, error) UpdateAnnotation(ctx context.Context, resourceType, objectName string, annotations map[string]string, opts ...executables.KubectlOpt) error - SearchCloudStackMachineConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.CloudStackMachineConfig, error) - SearchCloudStackDatacenterConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.CloudStackDatacenterConfig, error) - DeleteEksaCloudStackDatacenterConfig(ctx context.Context, cloudstackDatacenterConfigName string, kubeconfigFile string, namespace string) error - DeleteEksaCloudStackMachineConfig(ctx context.Context, cloudstackMachineConfigName string, kubeconfigFile string, namespace string) error + SearchCloudStackMachineConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.CloudStackMachineConfig, error) + SearchCloudStackDatacenterConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.CloudStackDatacenterConfig, error) + DeleteEksaCloudStackDatacenterConfig(ctx context.Context, cloudstackDatacenterConfigName, kubeconfigFile, namespace string) error + DeleteEksaCloudStackMachineConfig(ctx context.Context, cloudstackMachineConfigName, kubeconfigFile, namespace string) error SetEksaControllerEnvVar(ctx context.Context, envVar, envVarVal, kubeconfig string) error } @@ -399,7 +399,7 @@ func (p *cloudstackProvider) SetupAndValidateCreateCluster(ctx context.Context, return nil } -func (p *cloudstackProvider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, currentSpec *cluster.Spec) error { +func (p *cloudstackProvider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec, currentSpec *cluster.Spec) error { if err := p.validateEnv(ctx); err != nil { return fmt.Errorf("validating environment variables: %v", err) } @@ -455,7 +455,7 @@ func NeedsNewWorkloadTemplate(oldSpec, newSpec *cluster.Spec, oldCsdc, newCsdc * return NeedNewMachineTemplate(oldCsdc, newCsdc, oldCsmc, newCsmc, log) } -func NeedsNewKubeadmConfigTemplate(newWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration) bool { +func NeedsNewKubeadmConfigTemplate(newWorkerNodeGroup, oldWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration) bool { return !v1alpha1.TaintsSliceEqual(newWorkerNodeGroup.Taints, oldWorkerNodeGroup.Taints) || !v1alpha1.MapEqual(newWorkerNodeGroup.Labels, oldWorkerNodeGroup.Labels) } diff --git a/pkg/providers/cloudstack/cloudstack_test.go b/pkg/providers/cloudstack/cloudstack_test.go index 695a9ce2d5e3..4b928a1c8c37 100644 --- a/pkg/providers/cloudstack/cloudstack_test.go +++ b/pkg/providers/cloudstack/cloudstack_test.go @@ -1878,7 +1878,7 @@ func TestClusterUpgradeNeededMachineConfigsChangedDiskOffering(t *testing.T) { machineConfigsMap := givenMachineConfigs(t, testClusterConfigMainFilename) getEksaCloudStackMachineConfig := kubectl.EXPECT().GetEksaCloudStackMachineConfig(ctx, gomock.Any(), cluster.KubeconfigFile, clusterSpec.Cluster.Namespace).AnyTimes() getEksaCloudStackMachineConfig.DoAndReturn( - func(ctx context.Context, cloudstackMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.CloudStackMachineConfig, error) { + func(ctx context.Context, cloudstackMachineConfigName, kubeconfigFile, namespace string) (*v1alpha1.CloudStackMachineConfig, error) { if cloudstackMachineConfigName == "test" { modifiedMachineConfig := machineConfigsMap["test"].DeepCopy() modifiedMachineConfig.Spec.DiskOffering = (*machineConfigsMap["test"].Spec.DiskOffering).DeepCopy() diff --git a/pkg/providers/cloudstack/validator.go b/pkg/providers/cloudstack/validator.go index 26306a72991d..7fc87872765e 100644 --- a/pkg/providers/cloudstack/validator.go +++ b/pkg/providers/cloudstack/validator.go @@ -41,14 +41,14 @@ type localAvailabilityZone struct { // ProviderCmkClient defines the methods used by Cmk as a separate interface to be mockable when injected into other objects. type ProviderCmkClient interface { GetManagementApiEndpoint(profile string) (string, error) - ValidateServiceOfferingPresent(ctx context.Context, profile string, zoneId string, serviceOffering anywherev1.CloudStackResourceIdentifier) error - ValidateDiskOfferingPresent(ctx context.Context, profile string, zoneId string, diskOffering anywherev1.CloudStackResourceDiskOffering) error - ValidateTemplatePresent(ctx context.Context, profile string, domainId string, zoneId string, account string, template anywherev1.CloudStackResourceIdentifier) error - ValidateAffinityGroupsPresent(ctx context.Context, profile string, domainId string, account string, affinityGroupIds []string) error + ValidateServiceOfferingPresent(ctx context.Context, profile, zoneId string, serviceOffering anywherev1.CloudStackResourceIdentifier) error + ValidateDiskOfferingPresent(ctx context.Context, profile, zoneId string, diskOffering anywherev1.CloudStackResourceDiskOffering) error + ValidateTemplatePresent(ctx context.Context, profile, domainId, zoneId, account string, template anywherev1.CloudStackResourceIdentifier) error + ValidateAffinityGroupsPresent(ctx context.Context, profile, domainId, account string, affinityGroupIds []string) error ValidateZoneAndGetId(ctx context.Context, profile string, zone anywherev1.CloudStackZone) (string, error) - ValidateNetworkPresent(ctx context.Context, profile string, domainId string, network anywherev1.CloudStackResourceIdentifier, zoneId string, account string) error - ValidateDomainAndGetId(ctx context.Context, profile string, domain string) (string, error) - ValidateAccountPresent(ctx context.Context, profile string, account string, domainId string) error + ValidateNetworkPresent(ctx context.Context, profile, domainId string, network anywherev1.CloudStackResourceIdentifier, zoneId, account string) error + ValidateDomainAndGetId(ctx context.Context, profile, domain string) (string, error) + ValidateAccountPresent(ctx context.Context, profile, account, domainId string) error } func (v *Validator) ValidateCloudStackDatacenterConfig(ctx context.Context, datacenterConfig *anywherev1.CloudStackDatacenterConfig) error { @@ -210,7 +210,7 @@ func (v *Validator) validateMachineConfig(ctx context.Context, datacenterConfig return nil } -func (v *Validator) validateTemplateMatchesKubernetesVersion(ctx context.Context, templateName string, kubernetesVersionName string) error { +func (v *Validator) validateTemplateMatchesKubernetesVersion(ctx context.Context, templateName, kubernetesVersionName string) error { // Replace 1.23, 1-23, 1_23 to 123 in the template name string. templateReplacer := strings.NewReplacer("-", "", ".", "", "_", "") template := templateReplacer.Replace(templateName) diff --git a/pkg/providers/docker/docker.go b/pkg/providers/docker/docker.go index c4bf36d48bb9..a0e69ab11c50 100644 --- a/pkg/providers/docker/docker.go +++ b/pkg/providers/docker/docker.go @@ -138,7 +138,7 @@ func (p *provider) SetupAndValidateDeleteCluster(ctx context.Context, _ *types.C return nil } -func (p *provider) SetupAndValidateUpgradeCluster(ctx context.Context, _ *types.Cluster, _ *cluster.Spec, _ *cluster.Spec) error { +func (p *provider) SetupAndValidateUpgradeCluster(ctx context.Context, _ *types.Cluster, _, _ *cluster.Spec) error { return nil } @@ -359,7 +359,7 @@ func NeedsNewWorkloadTemplate(oldSpec, newSpec *cluster.Spec, oldWorker, newWork return oldSpec.Bundles.Spec.Number != newSpec.Bundles.Spec.Number } -func NeedsNewKubeadmConfigTemplate(newWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration) bool { +func NeedsNewKubeadmConfigTemplate(newWorkerNodeGroup, oldWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration) bool { return !v1alpha1.TaintsSliceEqual(newWorkerNodeGroup.Taints, oldWorkerNodeGroup.Taints) || !v1alpha1.MapEqual(newWorkerNodeGroup.Labels, oldWorkerNodeGroup.Labels) } @@ -602,7 +602,7 @@ func (p *provider) ChangeDiff(currentSpec, newSpec *cluster.Spec) *types.Compone } } -func (p *provider) RunPostControlPlaneUpgrade(ctx context.Context, oldClusterSpec *cluster.Spec, clusterSpec *cluster.Spec, workloadCluster *types.Cluster, managementCluster *types.Cluster) error { +func (p *provider) RunPostControlPlaneUpgrade(ctx context.Context, oldClusterSpec, clusterSpec *cluster.Spec, workloadCluster, managementCluster *types.Cluster) error { return nil } diff --git a/pkg/providers/nutanix/client.go b/pkg/providers/nutanix/client.go index 4de7b5e52ffb..51f0bf9472b8 100644 --- a/pkg/providers/nutanix/client.go +++ b/pkg/providers/nutanix/client.go @@ -19,6 +19,6 @@ type Client interface { ListCategories(ctx context.Context, getEntitiesRequest *v3.CategoryListMetadata) (*v3.CategoryKeyListResponse, error) GetCategoryKey(ctx context.Context, name string) (*v3.CategoryKeyStatus, error) ListCategoryValues(ctx context.Context, name string, getEntitiesRequest *v3.CategoryListMetadata) (*v3.CategoryValueListResponse, error) - GetCategoryValue(ctx context.Context, name string, value string) (*v3.CategoryValueStatus, error) + GetCategoryValue(ctx context.Context, name, value string) (*v3.CategoryValueStatus, error) GetCategoryQuery(ctx context.Context, query *v3.CategoryQueryInput) (*v3.CategoryQueryResponse, error) } diff --git a/pkg/providers/nutanix/env_test.go b/pkg/providers/nutanix/env_test.go index 6a11d9d064d4..3360888d0374 100644 --- a/pkg/providers/nutanix/env_test.go +++ b/pkg/providers/nutanix/env_test.go @@ -9,11 +9,11 @@ import ( "github.com/aws/eks-anywhere/pkg/constants" ) -func fakeOSSetenv(key string, value string) error { +func fakeOSSetenv(key, value string) error { return errors.New("os.Setenv failed") } -func restoreOSSetenv(replace func(key string, value string) error) { +func restoreOSSetenv(replace func(key, value string) error) { osSetenv = replace } diff --git a/pkg/providers/nutanix/kubectl.go b/pkg/providers/nutanix/kubectl.go index e80fc57bd418..8b11f141bf66 100644 --- a/pkg/providers/nutanix/kubectl.go +++ b/pkg/providers/nutanix/kubectl.go @@ -15,12 +15,12 @@ type ProviderKubectlClient interface { ApplyKubeSpecFromBytes(ctx context.Context, cluster *types.Cluster, data []byte) error SetEksaControllerEnvVar(ctx context.Context, envVar, envVarVal, kubeconfig string) error GetEksaCluster(ctx context.Context, cluster *types.Cluster, clusterName string) (*v1alpha1.Cluster, error) - GetEksaNutanixDatacenterConfig(ctx context.Context, nutanixDatacenterConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.NutanixDatacenterConfig, error) - GetEksaNutanixMachineConfig(ctx context.Context, nutanixMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.NutanixMachineConfig, error) + GetEksaNutanixDatacenterConfig(ctx context.Context, nutanixDatacenterConfigName, kubeconfigFile, namespace string) (*v1alpha1.NutanixDatacenterConfig, error) + GetEksaNutanixMachineConfig(ctx context.Context, nutanixMachineConfigName, kubeconfigFile, namespace string) (*v1alpha1.NutanixMachineConfig, error) GetKubeadmControlPlane(ctx context.Context, cluster *types.Cluster, clusterName string, opts ...executables.KubectlOpt) (*kubeadmv1beta1.KubeadmControlPlane, error) GetMachineDeployment(ctx context.Context, workerNodeGroupName string, opts ...executables.KubectlOpt) (*clusterv1.MachineDeployment, error) - SearchNutanixMachineConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.NutanixMachineConfig, error) - SearchNutanixDatacenterConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.NutanixDatacenterConfig, error) - DeleteEksaNutanixDatacenterConfig(ctx context.Context, nutanixDatacenterConfigName string, kubeconfigFile string, namespace string) error - DeleteEksaNutanixMachineConfig(ctx context.Context, nutanixMachineConfigName string, kubeconfigFile string, namespace string) error + SearchNutanixMachineConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.NutanixMachineConfig, error) + SearchNutanixDatacenterConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.NutanixDatacenterConfig, error) + DeleteEksaNutanixDatacenterConfig(ctx context.Context, nutanixDatacenterConfigName, kubeconfigFile, namespace string) error + DeleteEksaNutanixMachineConfig(ctx context.Context, nutanixMachineConfigName, kubeconfigFile, namespace string) error } diff --git a/pkg/providers/nutanix/provider.go b/pkg/providers/nutanix/provider.go index e624a1e7df0d..fe64a8fef6eb 100644 --- a/pkg/providers/nutanix/provider.go +++ b/pkg/providers/nutanix/provider.go @@ -223,7 +223,7 @@ func (p *Provider) SetupAndValidateDeleteCluster(ctx context.Context, cluster *t } // SetupAndValidateUpgradeCluster - Performs necessary setup and validations for upgrade cluster operation. -func (p *Provider) SetupAndValidateUpgradeCluster(ctx context.Context, _ *types.Cluster, clusterSpec *cluster.Spec, _ *cluster.Spec) error { +func (p *Provider) SetupAndValidateUpgradeCluster(ctx context.Context, _ *types.Cluster, clusterSpec, _ *cluster.Spec) error { if err := p.validator.validateUpgradeRolloutStrategy(clusterSpec); err != nil { return fmt.Errorf("failed setup and validations: %v", err) } @@ -360,7 +360,7 @@ func (p *Provider) getWorkerNodeMachineConfigs(ctx context.Context, workloadClus return nil, nil, nil } -func (p *Provider) needsNewMachineTemplate(currentSpec, newClusterSpec *cluster.Spec, workerNodeGroupConfiguration v1alpha1.WorkerNodeGroupConfiguration, ndc *v1alpha1.NutanixDatacenterConfig, prevWorkerNodeGroupConfigs map[string]v1alpha1.WorkerNodeGroupConfiguration, oldWorkerMachineConfig *v1alpha1.NutanixMachineConfig, newWorkerMachineConfig *v1alpha1.NutanixMachineConfig) (bool, error) { +func (p *Provider) needsNewMachineTemplate(currentSpec, newClusterSpec *cluster.Spec, workerNodeGroupConfiguration v1alpha1.WorkerNodeGroupConfiguration, ndc *v1alpha1.NutanixDatacenterConfig, prevWorkerNodeGroupConfigs map[string]v1alpha1.WorkerNodeGroupConfiguration, oldWorkerMachineConfig, newWorkerMachineConfig *v1alpha1.NutanixMachineConfig) (bool, error) { if prevWorkerGroup, ok := prevWorkerNodeGroupConfigs[workerNodeGroupConfiguration.Name]; ok { needsNewWorkloadTemplate := NeedsNewWorkloadTemplate(currentSpec, newClusterSpec, oldWorkerMachineConfig, newWorkerMachineConfig, prevWorkerGroup, workerNodeGroupConfiguration) return needsNewWorkloadTemplate, nil @@ -368,7 +368,7 @@ func (p *Provider) needsNewMachineTemplate(currentSpec, newClusterSpec *cluster. return true, nil } -func (p *Provider) needsNewKubeadmConfigTemplate(workerNodeGroupConfiguration v1alpha1.WorkerNodeGroupConfiguration, prevWorkerNodeGroupConfigs map[string]v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeNmc *v1alpha1.NutanixMachineConfig, newWorkerNodeNmc *v1alpha1.NutanixMachineConfig) (bool, error) { +func (p *Provider) needsNewKubeadmConfigTemplate(workerNodeGroupConfiguration v1alpha1.WorkerNodeGroupConfiguration, prevWorkerNodeGroupConfigs map[string]v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeNmc, newWorkerNodeNmc *v1alpha1.NutanixMachineConfig) (bool, error) { if _, ok := prevWorkerNodeGroupConfigs[workerNodeGroupConfiguration.Name]; ok { existingWorkerNodeGroupConfig := prevWorkerNodeGroupConfigs[workerNodeGroupConfiguration.Name] return NeedsNewKubeadmConfigTemplate(&workerNodeGroupConfiguration, &existingWorkerNodeGroupConfig, oldWorkerNodeNmc, newWorkerNodeNmc), nil @@ -389,7 +389,7 @@ func NeedsNewWorkloadTemplate(oldSpec, newSpec *cluster.Spec, oldNmc, newNmc *v1 return AnyImmutableFieldChanged(oldNmc, newNmc) } -func NeedsNewKubeadmConfigTemplate(newWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeNmc *v1alpha1.NutanixMachineConfig, newWorkerNodeNmc *v1alpha1.NutanixMachineConfig) bool { +func NeedsNewKubeadmConfigTemplate(newWorkerNodeGroup, oldWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeNmc, newWorkerNodeNmc *v1alpha1.NutanixMachineConfig) bool { return !v1alpha1.TaintsSliceEqual(newWorkerNodeGroup.Taints, oldWorkerNodeGroup.Taints) || !v1alpha1.MapEqual(newWorkerNodeGroup.Labels, oldWorkerNodeGroup.Labels) || !v1alpha1.UsersSliceEqual(oldWorkerNodeNmc.Spec.Users, newWorkerNodeNmc.Spec.Users) } @@ -625,7 +625,7 @@ func (p *Provider) ChangeDiff(currentSpec, newSpec *cluster.Spec) *types.Compone } } -func (p *Provider) RunPostControlPlaneUpgrade(ctx context.Context, oldClusterSpec *cluster.Spec, clusterSpec *cluster.Spec, workloadCluster *types.Cluster, managementCluster *types.Cluster) error { +func (p *Provider) RunPostControlPlaneUpgrade(ctx context.Context, oldClusterSpec, clusterSpec *cluster.Spec, workloadCluster, managementCluster *types.Cluster) error { // TODO(nutanix): figure out if we need something else here return nil } diff --git a/pkg/providers/provider.go b/pkg/providers/provider.go index 9f37739d62be..ad9299360574 100644 --- a/pkg/providers/provider.go +++ b/pkg/providers/provider.go @@ -13,7 +13,7 @@ type Provider interface { Name() string SetupAndValidateCreateCluster(ctx context.Context, clusterSpec *cluster.Spec) error SetupAndValidateDeleteCluster(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error - SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, currentSpec *cluster.Spec) error + SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec, currentSpec *cluster.Spec) error UpdateSecrets(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error GenerateCAPISpecForCreate(ctx context.Context, managementCluster *types.Cluster, clusterSpec *cluster.Spec) (controlPlaneSpec, workersSpec []byte, err error) GenerateCAPISpecForUpgrade(ctx context.Context, bootstrapCluster, workloadCluster *types.Cluster, currrentSpec, newClusterSpec *cluster.Spec) (controlPlaneSpec, workersSpec []byte, err error) @@ -36,7 +36,7 @@ type Provider interface { MachineConfigs(clusterSpec *cluster.Spec) []MachineConfig ValidateNewSpec(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error ChangeDiff(currentSpec, newSpec *cluster.Spec) *types.ComponentChangeDiff - RunPostControlPlaneUpgrade(ctx context.Context, oldClusterSpec *cluster.Spec, clusterSpec *cluster.Spec, workloadCluster *types.Cluster, managementCluster *types.Cluster) error + RunPostControlPlaneUpgrade(ctx context.Context, oldClusterSpec, clusterSpec *cluster.Spec, workloadCluster, managementCluster *types.Cluster) error UpgradeNeeded(ctx context.Context, newSpec, currentSpec *cluster.Spec, cluster *types.Cluster) (bool, error) DeleteResources(ctx context.Context, clusterSpec *cluster.Spec) error InstallCustomProviderComponents(ctx context.Context, kubeconfigFile string) error diff --git a/pkg/providers/snow/reconciler/clientbuilder.go b/pkg/providers/snow/reconciler/clientbuilder.go index 3d9f723efc71..6ab4999e12e6 100644 --- a/pkg/providers/snow/reconciler/clientbuilder.go +++ b/pkg/providers/snow/reconciler/clientbuilder.go @@ -46,7 +46,7 @@ type credentialConfiguration struct { Region string `ini:"region"` } -func createAwsClients(ctx context.Context, credentials []byte, certificates []byte) (aws.Clients, error) { +func createAwsClients(ctx context.Context, credentials, certificates []byte) (aws.Clients, error) { var deviceIps []string credsCfg, err := ini.Load(credentials) if err != nil { diff --git a/pkg/providers/snow/snow.go b/pkg/providers/snow/snow.go index 33335143d820..fcf683affddc 100644 --- a/pkg/providers/snow/snow.go +++ b/pkg/providers/snow/snow.go @@ -86,7 +86,7 @@ func (p *SnowProvider) SetupAndValidateCreateCluster(ctx context.Context, cluste return nil } -func (p *SnowProvider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, _ *cluster.Spec) error { +func (p *SnowProvider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec, _ *cluster.Spec) error { if err := p.validateUpgradeRolloutStrategy(clusterSpec); err != nil { return fmt.Errorf("failed setup and validations: %v", err) } @@ -156,7 +156,7 @@ func (p *SnowProvider) GenerateCAPISpecForCreate(ctx context.Context, cluster *t return p.generateCAPISpec(ctx, cluster, clusterSpec) } -func (p *SnowProvider) GenerateCAPISpecForUpgrade(ctx context.Context, bootstrapCluster, _ *types.Cluster, _ *cluster.Spec, clusterSpec *cluster.Spec) (controlPlaneSpec, workersSpec []byte, err error) { +func (p *SnowProvider) GenerateCAPISpecForUpgrade(ctx context.Context, bootstrapCluster, _ *types.Cluster, _, clusterSpec *cluster.Spec) (controlPlaneSpec, workersSpec []byte, err error) { return p.generateCAPISpec(ctx, bootstrapCluster, clusterSpec) } @@ -264,7 +264,7 @@ func (p *SnowProvider) ChangeDiff(currentSpec, newSpec *cluster.Spec) *types.Com } } -func (p *SnowProvider) RunPostControlPlaneUpgrade(ctx context.Context, oldClusterSpec *cluster.Spec, clusterSpec *cluster.Spec, workloadCluster *types.Cluster, managementCluster *types.Cluster) error { +func (p *SnowProvider) RunPostControlPlaneUpgrade(ctx context.Context, oldClusterSpec, clusterSpec *cluster.Spec, workloadCluster, managementCluster *types.Cluster) error { return nil } diff --git a/pkg/providers/tinkerbell/hardware/index.go b/pkg/providers/tinkerbell/hardware/index.go index 9d0332604c12..e44663fd7c44 100644 --- a/pkg/providers/tinkerbell/hardware/index.go +++ b/pkg/providers/tinkerbell/hardware/index.go @@ -57,7 +57,7 @@ func (i *FieldIndexer) Insert(v interface{}) error { // Lookup uses the index associated with field to find and return all objects associated with key. // If field has no associated index created by IndexField ErrUnknownIndex is returned. -func (i *FieldIndexer) Lookup(field string, key string) ([]interface{}, error) { +func (i *FieldIndexer) Lookup(field, key string) ([]interface{}, error) { idx, ok := i.indexes[field] if !ok { return nil, ErrUnknownIndex{Field: field} diff --git a/pkg/providers/tinkerbell/stack/stack.go b/pkg/providers/tinkerbell/stack/stack.go index 59de307dfabe..258c7e84ccaf 100644 --- a/pkg/providers/tinkerbell/stack/stack.go +++ b/pkg/providers/tinkerbell/stack/stack.go @@ -42,7 +42,7 @@ const ( type Docker interface { CheckContainerExistence(ctx context.Context, name string) (bool, error) ForceRemove(ctx context.Context, name string) error - Run(ctx context.Context, image string, name string, cmd []string, flags ...string) error + Run(ctx context.Context, image, name string, cmd []string, flags ...string) error } type Helm interface { @@ -128,7 +128,7 @@ func (s *Installer) AddNoProxyIP(IP string) { } // NewInstaller returns a Tinkerbell StackInstaller which can be used to install or uninstall the Tinkerbell stack. -func NewInstaller(docker Docker, filewriter filewriter.FileWriter, helm Helm, namespace string, podCidrRange string, registryMirror *registrymirror.RegistryMirror, proxyConfig *v1alpha1.ProxyConfiguration) StackInstaller { +func NewInstaller(docker Docker, filewriter filewriter.FileWriter, helm Helm, namespace, podCidrRange string, registryMirror *registrymirror.RegistryMirror, proxyConfig *v1alpha1.ProxyConfiguration) StackInstaller { return &Installer{ docker: docker, filewriter: filewriter, @@ -378,7 +378,7 @@ func (s *Installer) authenticateHelmRegistry(ctx context.Context) error { } // Upgrade the Tinkerbell stack using images specified in bundle. -func (s *Installer) Upgrade(ctx context.Context, bundle releasev1alpha1.TinkerbellBundle, tinkerbellIP, kubeconfig string, hookOverride string, opts ...InstallOption) error { +func (s *Installer) Upgrade(ctx context.Context, bundle releasev1alpha1.TinkerbellBundle, tinkerbellIP, kubeconfig, hookOverride string, opts ...InstallOption) error { logger.V(6).Info("Upgrading Tinkerbell helm chart") for _, option := range opts { diff --git a/pkg/providers/tinkerbell/tinkerbell.go b/pkg/providers/tinkerbell/tinkerbell.go index 91346476de76..4e087ea7e2b5 100644 --- a/pkg/providers/tinkerbell/tinkerbell.go +++ b/pkg/providers/tinkerbell/tinkerbell.go @@ -76,22 +76,22 @@ type Provider struct { type ProviderKubectlClient interface { ApplyKubeSpecFromBytesForce(ctx context.Context, cluster *types.Cluster, data []byte) error ApplyKubeSpecFromBytesWithNamespace(ctx context.Context, cluster *types.Cluster, data []byte, namespace string) error - DeleteEksaDatacenterConfig(ctx context.Context, eksaTinkerbellDatacenterResourceType string, tinkerbellDatacenterConfigName string, kubeconfigFile string, namespace string) error - DeleteEksaMachineConfig(ctx context.Context, eksaTinkerbellMachineResourceType string, tinkerbellMachineConfigName string, kubeconfigFile string, namespace string) error + DeleteEksaDatacenterConfig(ctx context.Context, eksaTinkerbellDatacenterResourceType, tinkerbellDatacenterConfigName, kubeconfigFile, namespace string) error + DeleteEksaMachineConfig(ctx context.Context, eksaTinkerbellMachineResourceType, tinkerbellMachineConfigName, kubeconfigFile, namespace string) error GetMachineDeployment(ctx context.Context, machineDeploymentName string, opts ...executables.KubectlOpt) (*clusterv1.MachineDeployment, error) GetEksaCluster(ctx context.Context, cluster *types.Cluster, clusterName string) (*v1alpha1.Cluster, error) - GetEksaTinkerbellDatacenterConfig(ctx context.Context, tinkerbellDatacenterConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.TinkerbellDatacenterConfig, error) - GetEksaTinkerbellMachineConfig(ctx context.Context, tinkerbellMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.TinkerbellMachineConfig, error) + GetEksaTinkerbellDatacenterConfig(ctx context.Context, tinkerbellDatacenterConfigName, kubeconfigFile, namespace string) (*v1alpha1.TinkerbellDatacenterConfig, error) + GetEksaTinkerbellMachineConfig(ctx context.Context, tinkerbellMachineConfigName, kubeconfigFile, namespace string) (*v1alpha1.TinkerbellMachineConfig, error) GetKubeadmControlPlane(ctx context.Context, cluster *types.Cluster, clusterName string, opts ...executables.KubectlOpt) (*controlplanev1.KubeadmControlPlane, error) GetEtcdadmCluster(ctx context.Context, cluster *types.Cluster, clusterName string, opts ...executables.KubectlOpt) (*etcdv1.EtcdadmCluster, error) GetSecret(ctx context.Context, secretObjectName string, opts ...executables.KubectlOpt) (*corev1.Secret, error) UpdateAnnotation(ctx context.Context, resourceType, objectName string, annotations map[string]string, opts ...executables.KubectlOpt) error - WaitForDeployment(ctx context.Context, cluster *types.Cluster, timeout string, condition string, target string, namespace string) error + WaitForDeployment(ctx context.Context, cluster *types.Cluster, timeout, condition, target, namespace string) error GetUnprovisionedTinkerbellHardware(_ context.Context, kubeconfig, namespace string) ([]tinkv1alpha1.Hardware, error) GetProvisionedTinkerbellHardware(_ context.Context, kubeconfig, namespace string) ([]tinkv1alpha1.Hardware, error) - WaitForRufioMachines(ctx context.Context, cluster *types.Cluster, timeout string, condition string, namespace string) error - SearchTinkerbellMachineConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.TinkerbellMachineConfig, error) - SearchTinkerbellDatacenterConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.TinkerbellDatacenterConfig, error) + WaitForRufioMachines(ctx context.Context, cluster *types.Cluster, timeout, condition, namespace string) error + SearchTinkerbellMachineConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.TinkerbellMachineConfig, error) + SearchTinkerbellDatacenterConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.TinkerbellDatacenterConfig, error) AllTinkerbellHardware(ctx context.Context, kuebconfig string) ([]tinkv1alpha1.Hardware, error) AllBaseboardManagements(ctx context.Context, kubeconfig string) ([]rufiounreleased.BaseboardManagement, error) HasCRD(ctx context.Context, kubeconfig, crd string) (bool, error) diff --git a/pkg/providers/tinkerbell/upgrade.go b/pkg/providers/tinkerbell/upgrade.go index 1b37b777ffaf..d87ebae06a46 100644 --- a/pkg/providers/tinkerbell/upgrade.go +++ b/pkg/providers/tinkerbell/upgrade.go @@ -55,7 +55,7 @@ func needsNewKubeadmConfigTemplate(newWorkerNodeGroup, oldWorkerNodeGroup *v1alp return !v1alpha1.TaintsSliceEqual(newWorkerNodeGroup.Taints, oldWorkerNodeGroup.Taints) || !v1alpha1.MapEqual(newWorkerNodeGroup.Labels, oldWorkerNodeGroup.Labels) } -func (p *Provider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, currentClusterSpec *cluster.Spec) error { +func (p *Provider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec, currentClusterSpec *cluster.Spec) error { if clusterSpec.Cluster.Spec.ExternalEtcdConfiguration != nil { return errExternalEtcdUnsupported } @@ -210,7 +210,7 @@ func (p *Provider) PostMoveManagementToBootstrap(ctx context.Context, bootstrapC return nil } -func (p *Provider) RunPostControlPlaneUpgrade(ctx context.Context, oldClusterSpec *cluster.Spec, clusterSpec *cluster.Spec, workloadCluster *types.Cluster, managementCluster *types.Cluster) error { +func (p *Provider) RunPostControlPlaneUpgrade(ctx context.Context, oldClusterSpec, clusterSpec *cluster.Spec, workloadCluster, managementCluster *types.Cluster) error { // @TODO: do we need this for bare metal upgrade? // Use retrier so that cluster upgrade does not fail due to any intermittent failure while connecting to kube-api server @@ -351,7 +351,7 @@ func (p *Provider) hardwareCSVIsProvided() bool { return p.hardwareCSVFile != "" } -func (p *Provider) isScaleUpDown(oldCluster *v1alpha1.Cluster, newCluster *v1alpha1.Cluster) bool { +func (p *Provider) isScaleUpDown(oldCluster, newCluster *v1alpha1.Cluster) bool { if oldCluster.Spec.ControlPlaneConfiguration.Count != newCluster.Spec.ControlPlaneConfiguration.Count { return true } diff --git a/pkg/providers/vsphere/internal/templates/factory.go b/pkg/providers/vsphere/internal/templates/factory.go index 592898d818bb..277839204667 100644 --- a/pkg/providers/vsphere/internal/templates/factory.go +++ b/pkg/providers/vsphere/internal/templates/factory.go @@ -40,14 +40,14 @@ type GovcClient interface { AddTag(ctx context.Context, path, tag string) error ListCategories(ctx context.Context) ([]string, error) CreateCategoryForVM(ctx context.Context, name string) error - CreateUser(ctx context.Context, username string, password string) error + CreateUser(ctx context.Context, username, password string) error UserExists(ctx context.Context, username string) (bool, error) CreateGroup(ctx context.Context, name string) error GroupExists(ctx context.Context, name string) (bool, error) - AddUserToGroup(ctx context.Context, name string, username string) error + AddUserToGroup(ctx context.Context, name, username string) error RoleExists(ctx context.Context, name string) (bool, error) CreateRole(ctx context.Context, name string, privileges []string) error - SetGroupRoleOnObject(ctx context.Context, principal string, role string, object string, domain string) error + SetGroupRoleOnObject(ctx context.Context, principal, role, object, domain string) error } func NewFactory(client GovcClient, datacenter, datastore, network, resourcePool, templateLibrary string) *Factory { diff --git a/pkg/providers/vsphere/setupuser/setupuser.go b/pkg/providers/vsphere/setupuser/setupuser.go index cb3d47c156ad..02e236cbf66d 100644 --- a/pkg/providers/vsphere/setupuser/setupuser.go +++ b/pkg/providers/vsphere/setupuser/setupuser.go @@ -17,14 +17,14 @@ const ( // GovcClient specifies govc functions required to configure a vsphere user. type GovcClient interface { - CreateUser(ctx context.Context, username string, password string) error + CreateUser(ctx context.Context, username, password string) error UserExists(ctx context.Context, username string) (bool, error) CreateGroup(ctx context.Context, name string) error GroupExists(ctx context.Context, name string) (bool, error) - AddUserToGroup(ctx context.Context, name string, username string) error + AddUserToGroup(ctx context.Context, name, username string) error RoleExists(ctx context.Context, name string) (bool, error) CreateRole(ctx context.Context, name string, privileges []string) error - SetGroupRoleOnObject(ctx context.Context, principal string, role string, object string, domain string) error + SetGroupRoleOnObject(ctx context.Context, principal, role, object, domain string) error } // SetupGOVCEnv creates appropriate govc environment variables to build govc client. diff --git a/pkg/providers/vsphere/validator.go b/pkg/providers/vsphere/validator.go index 7b34f5301cb1..153a962d92b8 100644 --- a/pkg/providers/vsphere/validator.go +++ b/pkg/providers/vsphere/validator.go @@ -37,7 +37,7 @@ type missingPriv struct { } type VSphereClientBuilder interface { - Build(ctx context.Context, host string, username string, password string, insecure bool, datacenter string) (govmomi.VSphereClient, error) + Build(ctx context.Context, host, username, password string, insecure bool, datacenter string) (govmomi.VSphereClient, error) } type Validator struct { @@ -534,7 +534,7 @@ func (v *Validator) validatePrivs(ctx context.Context, privObjs []PrivAssociatio return passed, nil } -func checkRequiredPrivs(requiredPrivs []string, hasPrivs []string) []string { +func checkRequiredPrivs(requiredPrivs, hasPrivs []string) []string { hp := map[string]interface{}{} for _, val := range hasPrivs { hp[val] = 1 @@ -550,7 +550,7 @@ func checkRequiredPrivs(requiredPrivs []string, hasPrivs []string) []string { return missingPrivs } -func (v *Validator) getMissingPrivs(ctx context.Context, vsc govmomi.VSphereClient, path string, objType string, requiredPrivsContent string, username string) ([]string, error) { +func (v *Validator) getMissingPrivs(ctx context.Context, vsc govmomi.VSphereClient, path, objType, requiredPrivsContent, username string) ([]string, error) { var requiredPrivs []string err := json.Unmarshal([]byte(requiredPrivsContent), &requiredPrivs) if err != nil { diff --git a/pkg/providers/vsphere/vsphere.go b/pkg/providers/vsphere/vsphere.go index 8503d19f69fc..09c5e0a5eda0 100644 --- a/pkg/providers/vsphere/vsphere.go +++ b/pkg/providers/vsphere/vsphere.go @@ -106,37 +106,37 @@ type ProviderGovcClient interface { AddTag(ctx context.Context, path, tag string) error ListCategories(ctx context.Context) ([]string, error) CreateCategoryForVM(ctx context.Context, name string) error - CreateUser(ctx context.Context, username string, password string) error + CreateUser(ctx context.Context, username, password string) error UserExists(ctx context.Context, username string) (bool, error) CreateGroup(ctx context.Context, name string) error GroupExists(ctx context.Context, name string) (bool, error) - AddUserToGroup(ctx context.Context, name string, username string) error + AddUserToGroup(ctx context.Context, name, username string) error RoleExists(ctx context.Context, name string) (bool, error) CreateRole(ctx context.Context, name string, privileges []string) error - SetGroupRoleOnObject(ctx context.Context, principal string, role string, object string, domain string) error + SetGroupRoleOnObject(ctx context.Context, principal, role, object, domain string) error GetHardDiskSize(ctx context.Context, vm, datacenter string) (map[string]float64, error) GetResourcePoolInfo(ctx context.Context, datacenter, resourcepool string, args ...string) (map[string]int, error) } type ProviderKubectlClient interface { ApplyKubeSpecFromBytes(ctx context.Context, cluster *types.Cluster, data []byte) error - CreateNamespaceIfNotPresent(ctx context.Context, kubeconfig string, namespace string) error - LoadSecret(ctx context.Context, secretObject string, secretObjType string, secretObjectName string, kubeConfFile string) error + CreateNamespaceIfNotPresent(ctx context.Context, kubeconfig, namespace string) error + LoadSecret(ctx context.Context, secretObject, secretObjType, secretObjectName, kubeConfFile string) error GetEksaCluster(ctx context.Context, cluster *types.Cluster, clusterName string) (*v1alpha1.Cluster, error) - GetEksaVSphereDatacenterConfig(ctx context.Context, vsphereDatacenterConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.VSphereDatacenterConfig, error) - GetEksaVSphereMachineConfig(ctx context.Context, vsphereMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.VSphereMachineConfig, error) + GetEksaVSphereDatacenterConfig(ctx context.Context, vsphereDatacenterConfigName, kubeconfigFile, namespace string) (*v1alpha1.VSphereDatacenterConfig, error) + GetEksaVSphereMachineConfig(ctx context.Context, vsphereMachineConfigName, kubeconfigFile, namespace string) (*v1alpha1.VSphereMachineConfig, error) GetMachineDeployment(ctx context.Context, machineDeploymentName string, opts ...executables.KubectlOpt) (*clusterv1.MachineDeployment, error) GetKubeadmControlPlane(ctx context.Context, cluster *types.Cluster, clusterName string, opts ...executables.KubectlOpt) (*controlplanev1.KubeadmControlPlane, error) GetEtcdadmCluster(ctx context.Context, cluster *types.Cluster, clusterName string, opts ...executables.KubectlOpt) (*etcdv1.EtcdadmCluster, error) GetSecretFromNamespace(ctx context.Context, kubeconfigFile, name, namespace string) (*corev1.Secret, error) UpdateAnnotation(ctx context.Context, resourceType, objectName string, annotations map[string]string, opts ...executables.KubectlOpt) error RemoveAnnotationInNamespace(ctx context.Context, resourceType, objectName, key string, cluster *types.Cluster, namespace string) error - SearchVsphereMachineConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.VSphereMachineConfig, error) - SearchVsphereDatacenterConfig(ctx context.Context, name string, kubeconfigFile string, namespace string) ([]*v1alpha1.VSphereDatacenterConfig, error) + SearchVsphereMachineConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.VSphereMachineConfig, error) + SearchVsphereDatacenterConfig(ctx context.Context, name, kubeconfigFile, namespace string) ([]*v1alpha1.VSphereDatacenterConfig, error) SetDaemonSetImage(ctx context.Context, kubeconfigFile, name, namespace, container, image string) error - DeleteEksaDatacenterConfig(ctx context.Context, vsphereDatacenterResourceType string, vsphereDatacenterConfigName string, kubeconfigFile string, namespace string) error - DeleteEksaMachineConfig(ctx context.Context, vsphereMachineResourceType string, vsphereMachineConfigName string, kubeconfigFile string, namespace string) error - ApplyTolerationsFromTaintsToDaemonSet(ctx context.Context, oldTaints []corev1.Taint, newTaints []corev1.Taint, dsName string, kubeconfigFile string) error + DeleteEksaDatacenterConfig(ctx context.Context, vsphereDatacenterResourceType, vsphereDatacenterConfigName, kubeconfigFile, namespace string) error + DeleteEksaMachineConfig(ctx context.Context, vsphereMachineResourceType, vsphereMachineConfigName, kubeconfigFile, namespace string) error + ApplyTolerationsFromTaintsToDaemonSet(ctx context.Context, oldTaints, newTaints []corev1.Taint, dsName, kubeconfigFile string) error } // IPValidator is an interface that defines methods to validate the control plane IP. @@ -379,7 +379,7 @@ func (p *vsphereProvider) SetupAndValidateCreateCluster(ctx context.Context, clu return nil } -func (p *vsphereProvider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, _ *cluster.Spec) error { +func (p *vsphereProvider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec, _ *cluster.Spec) error { if err := p.validator.validateUpgradeRolloutStrategy(clusterSpec); err != nil { return fmt.Errorf("failed setup and validations: %v", err) } @@ -737,7 +737,7 @@ func NeedsNewWorkloadTemplate(oldSpec, newSpec *cluster.Spec, oldVdc, newVdc *v1 return AnyImmutableFieldChanged(oldVdc, newVdc, oldVmc, newVmc) } -func NeedsNewKubeadmConfigTemplate(newWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeVmc *v1alpha1.VSphereMachineConfig, newWorkerNodeVmc *v1alpha1.VSphereMachineConfig) bool { +func NeedsNewKubeadmConfigTemplate(newWorkerNodeGroup, oldWorkerNodeGroup *v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeVmc, newWorkerNodeVmc *v1alpha1.VSphereMachineConfig) bool { return !v1alpha1.TaintsSliceEqual(newWorkerNodeGroup.Taints, oldWorkerNodeGroup.Taints) || !v1alpha1.MapEqual(newWorkerNodeGroup.Labels, oldWorkerNodeGroup.Labels) || !v1alpha1.UsersSliceEqual(oldWorkerNodeVmc.Spec.Users, newWorkerNodeVmc.Spec.Users) } @@ -1144,7 +1144,7 @@ func (p *vsphereProvider) getWorkerNodeMachineConfigs(ctx context.Context, workl return nil, nil, nil } -func (p *vsphereProvider) needsNewMachineTemplate(currentSpec, newClusterSpec *cluster.Spec, workerNodeGroupConfiguration v1alpha1.WorkerNodeGroupConfiguration, vdc *v1alpha1.VSphereDatacenterConfig, prevWorkerNodeGroupConfigs map[string]v1alpha1.WorkerNodeGroupConfiguration, oldWorkerMachineConfig *v1alpha1.VSphereMachineConfig, newWorkerMachineConfig *v1alpha1.VSphereMachineConfig) (bool, error) { +func (p *vsphereProvider) needsNewMachineTemplate(currentSpec, newClusterSpec *cluster.Spec, workerNodeGroupConfiguration v1alpha1.WorkerNodeGroupConfiguration, vdc *v1alpha1.VSphereDatacenterConfig, prevWorkerNodeGroupConfigs map[string]v1alpha1.WorkerNodeGroupConfiguration, oldWorkerMachineConfig, newWorkerMachineConfig *v1alpha1.VSphereMachineConfig) (bool, error) { if prevWorkerNode, ok := prevWorkerNodeGroupConfigs[workerNodeGroupConfiguration.Name]; ok { needsNewWorkloadTemplate := NeedsNewWorkloadTemplate(currentSpec, newClusterSpec, vdc, newClusterSpec.VSphereDatacenter, oldWorkerMachineConfig, newWorkerMachineConfig, prevWorkerNode, workerNodeGroupConfiguration) return needsNewWorkloadTemplate, nil @@ -1152,7 +1152,7 @@ func (p *vsphereProvider) needsNewMachineTemplate(currentSpec, newClusterSpec *c return true, nil } -func (p *vsphereProvider) needsNewKubeadmConfigTemplate(workerNodeGroupConfiguration v1alpha1.WorkerNodeGroupConfiguration, prevWorkerNodeGroupConfigs map[string]v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeVmc *v1alpha1.VSphereMachineConfig, newWorkerNodeVmc *v1alpha1.VSphereMachineConfig) (bool, error) { +func (p *vsphereProvider) needsNewKubeadmConfigTemplate(workerNodeGroupConfiguration v1alpha1.WorkerNodeGroupConfiguration, prevWorkerNodeGroupConfigs map[string]v1alpha1.WorkerNodeGroupConfiguration, oldWorkerNodeVmc, newWorkerNodeVmc *v1alpha1.VSphereMachineConfig) (bool, error) { if _, ok := prevWorkerNodeGroupConfigs[workerNodeGroupConfiguration.Name]; ok { existingWorkerNodeGroupConfig := prevWorkerNodeGroupConfigs[workerNodeGroupConfiguration.Name] return NeedsNewKubeadmConfigTemplate(&workerNodeGroupConfiguration, &existingWorkerNodeGroupConfig, oldWorkerNodeVmc, newWorkerNodeVmc), nil @@ -1209,7 +1209,7 @@ func (p *vsphereProvider) ChangeDiff(currentSpec, newSpec *cluster.Spec) *types. } } -func (p *vsphereProvider) RunPostControlPlaneUpgrade(_ context.Context, _ *cluster.Spec, _ *cluster.Spec, _ *types.Cluster, _ *types.Cluster) error { +func (p *vsphereProvider) RunPostControlPlaneUpgrade(_ context.Context, _, _ *cluster.Spec, _, _ *types.Cluster) error { return nil } diff --git a/pkg/providers/vsphere/vsphere_test.go b/pkg/providers/vsphere/vsphere_test.go index d8d31acfdaf3..17786b933cb6 100644 --- a/pkg/providers/vsphere/vsphere_test.go +++ b/pkg/providers/vsphere/vsphere_test.go @@ -181,7 +181,7 @@ func (pc *DummyProviderGovcClient) CreateCategoryForVM(ctx context.Context, name return nil } -func (pc *DummyProviderGovcClient) AddUserToGroup(ctx context.Context, name string, username string) error { +func (pc *DummyProviderGovcClient) AddUserToGroup(ctx context.Context, name, username string) error { return nil } @@ -193,7 +193,7 @@ func (pc *DummyProviderGovcClient) CreateRole(ctx context.Context, name string, return nil } -func (pc *DummyProviderGovcClient) CreateUser(ctx context.Context, username string, password string) error { +func (pc *DummyProviderGovcClient) CreateUser(ctx context.Context, username, password string) error { return nil } @@ -209,7 +209,7 @@ func (pc *DummyProviderGovcClient) RoleExists(ctx context.Context, name string) return false, nil } -func (pc *DummyProviderGovcClient) SetGroupRoleOnObject(ctx context.Context, principal string, role string, object string, domain string) error { +func (pc *DummyProviderGovcClient) SetGroupRoleOnObject(ctx context.Context, principal, role, object, domain string) error { return nil } @@ -472,7 +472,7 @@ type mockVSphereClientBuilder struct { vsc *govmomi_mocks.MockVSphereClient } -func (mvscb *mockVSphereClientBuilder) Build(ctx context.Context, host string, username string, password string, insecure bool, datacenter string) (govmomi.VSphereClient, error) { +func (mvscb *mockVSphereClientBuilder) Build(ctx context.Context, host, username, password string, insecure bool, datacenter string) (govmomi.VSphereClient, error) { return mvscb.vsc, nil } diff --git a/pkg/registry/copy.go b/pkg/registry/copy.go index 4c05c1ae8683..2374c3424cab 100644 --- a/pkg/registry/copy.go +++ b/pkg/registry/copy.go @@ -8,7 +8,7 @@ import ( ) // Copy an image from a source to a destination. -func Copy(ctx context.Context, srcClient StorageClient, dstClient StorageClient, image Artifact) (err error) { +func Copy(ctx context.Context, srcClient, dstClient StorageClient, image Artifact) (err error) { srcStorage, err := srcClient.GetStorage(ctx, image) if err != nil { return fmt.Errorf("repository source: %v", err) diff --git a/pkg/task/task.go b/pkg/task/task.go index de2d5da191e7..f54ab1907f35 100644 --- a/pkg/task/task.go +++ b/pkg/task/task.go @@ -68,7 +68,7 @@ func (pp *Profiler) SetStartTask(taskName string) { } // this can be used to profile sub tasks. -func (pp *Profiler) SetStart(taskName string, msg string) { +func (pp *Profiler) SetStart(taskName, msg string) { if _, ok := pp.starts[taskName]; !ok { pp.starts[taskName] = map[string]time.Time{} } @@ -81,7 +81,7 @@ func (pp *Profiler) MarkDoneTask(taskName string) { } // this can be used to profile sub tasks. -func (pp *Profiler) MarkDone(taskName string, msg string) { +func (pp *Profiler) MarkDone(taskName, msg string) { if _, ok := pp.metrics[taskName]; !ok { pp.metrics[taskName] = map[string]time.Duration{} } @@ -260,7 +260,7 @@ When reading from a yaml file, there isn't a direct way in Go to do a type conve We use interface{} because the TaskCheckpoint type will vary depending on what's needed for a specific task. The known workaround for this is to marshal & unmarshal it into the checkpoint type. */ -func UnmarshalTaskCheckpoint(taskCheckpoint TaskCheckpoint, config TaskCheckpoint) error { +func UnmarshalTaskCheckpoint(taskCheckpoint, config TaskCheckpoint) error { checkpointYaml, err := yaml.Marshal(taskCheckpoint) if err != nil { return nil diff --git a/pkg/validations/kubectl.go b/pkg/validations/kubectl.go index 5d352565c2cc..0db9af7764c6 100644 --- a/pkg/validations/kubectl.go +++ b/pkg/validations/kubectl.go @@ -18,7 +18,7 @@ import ( type KubectlClient interface { List(ctx context.Context, kubeconfig string, list kubernetes.ObjectList) error ValidateControlPlaneNodes(ctx context.Context, cluster *types.Cluster, clusterName string) error - ValidateWorkerNodes(ctx context.Context, clusterName string, kubeconfig string) error + ValidateWorkerNodes(ctx context.Context, clusterName, kubeconfig string) error ValidateNodes(ctx context.Context, kubeconfig string) error ValidateClustersCRD(ctx context.Context, cluster *types.Cluster) error ValidateEKSAClustersCRD(ctx context.Context, cluster *types.Cluster) error @@ -26,14 +26,14 @@ type KubectlClient interface { GetClusters(ctx context.Context, cluster *types.Cluster) ([]types.CAPICluster, error) GetEksaCluster(ctx context.Context, cluster *types.Cluster, clusterName string) (*v1alpha1.Cluster, error) GetBundles(ctx context.Context, kubeconfigFile, name, namespace string) (*releasev1alpha1.Bundles, error) - GetEksaGitOpsConfig(ctx context.Context, gitOpsConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.GitOpsConfig, error) - GetEksaFluxConfig(ctx context.Context, fluxConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.FluxConfig, error) - GetEksaOIDCConfig(ctx context.Context, oidcConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.OIDCConfig, error) - GetEksaVSphereDatacenterConfig(ctx context.Context, vsphereDatacenterConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.VSphereDatacenterConfig, error) - GetEksaTinkerbellDatacenterConfig(ctx context.Context, tinkerbellDatacenterConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.TinkerbellDatacenterConfig, error) - GetEksaTinkerbellMachineConfig(ctx context.Context, tinkerbellMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.TinkerbellMachineConfig, error) - GetEksaAWSIamConfig(ctx context.Context, awsIamConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.AWSIamConfig, error) - SearchIdentityProviderConfig(ctx context.Context, ipName string, kind string, kubeconfigFile string, namespace string) ([]*v1alpha1.VSphereDatacenterConfig, error) + GetEksaGitOpsConfig(ctx context.Context, gitOpsConfigName, kubeconfigFile, namespace string) (*v1alpha1.GitOpsConfig, error) + GetEksaFluxConfig(ctx context.Context, fluxConfigName, kubeconfigFile, namespace string) (*v1alpha1.FluxConfig, error) + GetEksaOIDCConfig(ctx context.Context, oidcConfigName, kubeconfigFile, namespace string) (*v1alpha1.OIDCConfig, error) + GetEksaVSphereDatacenterConfig(ctx context.Context, vsphereDatacenterConfigName, kubeconfigFile, namespace string) (*v1alpha1.VSphereDatacenterConfig, error) + GetEksaTinkerbellDatacenterConfig(ctx context.Context, tinkerbellDatacenterConfigName, kubeconfigFile, namespace string) (*v1alpha1.TinkerbellDatacenterConfig, error) + GetEksaTinkerbellMachineConfig(ctx context.Context, tinkerbellMachineConfigName, kubeconfigFile, namespace string) (*v1alpha1.TinkerbellMachineConfig, error) + GetEksaAWSIamConfig(ctx context.Context, awsIamConfigName, kubeconfigFile, namespace string) (*v1alpha1.AWSIamConfig, error) + SearchIdentityProviderConfig(ctx context.Context, ipName, kind, kubeconfigFile, namespace string) ([]*v1alpha1.VSphereDatacenterConfig, error) GetObject(ctx context.Context, resourceType, name, namespace, kubeconfig string, obj runtime.Object) error } diff --git a/pkg/validations/skipvalidations.go b/pkg/validations/skipvalidations.go index 268b372ab918..6055117bcaaf 100644 --- a/pkg/validations/skipvalidations.go +++ b/pkg/validations/skipvalidations.go @@ -25,7 +25,7 @@ func validSkippableValidationsMap(skippableValidations []string) map[string]bool } // ValidateSkippableValidation validates if provided validations are supported by EKSA to skip for upgrades. -func ValidateSkippableValidation(skippedValidations []string, skippableValidations []string) (map[string]bool, error) { +func ValidateSkippableValidation(skippedValidations, skippableValidations []string) (map[string]bool, error) { svMap := validSkippableValidationsMap(skippableValidations) for i := range skippedValidations { diff --git a/pkg/validations/upgradevalidations/versions.go b/pkg/validations/upgradevalidations/versions.go index 89f03e9fd93c..f89ee663f404 100644 --- a/pkg/validations/upgradevalidations/versions.go +++ b/pkg/validations/upgradevalidations/versions.go @@ -10,7 +10,7 @@ import ( ) // ValidateServerVersionSkew validates Kubernetes version skew between upgrades for the CLI. -func ValidateServerVersionSkew(ctx context.Context, newCluster *anywherev1.Cluster, cluster *types.Cluster, mgmtCluster *types.Cluster, kubectl validations.KubectlClient) error { +func ValidateServerVersionSkew(ctx context.Context, newCluster *anywherev1.Cluster, cluster, mgmtCluster *types.Cluster, kubectl validations.KubectlClient) error { managementCluster := cluster if !cluster.ExistingManagement { managementCluster = mgmtCluster @@ -25,7 +25,7 @@ func ValidateServerVersionSkew(ctx context.Context, newCluster *anywherev1.Clust } // ValidateWorkerServerVersionSkew validates worker node group Kubernetes version skew between upgrades. -func ValidateWorkerServerVersionSkew(ctx context.Context, newCluster *anywherev1.Cluster, cluster *types.Cluster, mgmtCluster *types.Cluster, kubectl validations.KubectlClient) error { +func ValidateWorkerServerVersionSkew(ctx context.Context, newCluster *anywherev1.Cluster, cluster, mgmtCluster *types.Cluster, kubectl validations.KubectlClient) error { managementCluster := cluster if !cluster.ExistingManagement { managementCluster = mgmtCluster diff --git a/pkg/workflows/upgrade.go b/pkg/workflows/upgrade.go index e5d4bd5b0e15..93ff6a9df0e9 100644 --- a/pkg/workflows/upgrade.go +++ b/pkg/workflows/upgrade.go @@ -53,7 +53,7 @@ func NewUpgrade(bootstrapper interfaces.Bootstrapper, provider providers.Provide } } -func (c *Upgrade) Run(ctx context.Context, clusterSpec *cluster.Spec, managementCluster *types.Cluster, workloadCluster *types.Cluster, validator interfaces.Validator, forceCleanup bool) error { +func (c *Upgrade) Run(ctx context.Context, clusterSpec *cluster.Spec, managementCluster, workloadCluster *types.Cluster, validator interfaces.Validator, forceCleanup bool) error { commandContext := &task.CommandContext{ Bootstrapper: c.bootstrapper, Provider: c.provider, diff --git a/pkg/workflows/upgrade_test.go b/pkg/workflows/upgrade_test.go index 476219114764..742696bc994e 100644 --- a/pkg/workflows/upgrade_test.go +++ b/pkg/workflows/upgrade_test.go @@ -150,7 +150,7 @@ func (c *upgradeTestSetup) expectEnsureEtcdCAPIComponentsExistTask(expectedClust ) } -func (c *upgradeTestSetup) expectUpgradeCoreComponents(managementCluster *types.Cluster, workloadCluster *types.Cluster) { +func (c *upgradeTestSetup) expectUpgradeCoreComponents(managementCluster, workloadCluster *types.Cluster) { currentSpec := c.currentClusterSpec networkingChangeDiff := types.NewChangeDiff(&types.ComponentChangeDiff{ ComponentName: "cilium", @@ -241,7 +241,7 @@ func (c *upgradeTestSetup) expectNotToDeleteBootstrap() { c.bootstrapper.EXPECT().DeleteBootstrapCluster(c.ctx, c.bootstrapCluster, gomock.Any(), gomock.Any()).Times(0) } -func (c *upgradeTestSetup) expectUpgradeWorkload(managementCluster *types.Cluster, workloadCluster *types.Cluster) { +func (c *upgradeTestSetup) expectUpgradeWorkload(managementCluster, workloadCluster *types.Cluster) { calls := []*gomock.Call{ c.expectUpgradeWorkloadToReturn(managementCluster, workloadCluster, nil), } @@ -261,7 +261,7 @@ func (c *upgradeTestSetup) expectUpgradeWorkload(managementCluster *types.Cluste gomock.InOrder(calls...) } -func (c *upgradeTestSetup) expectUpgradeWorkloadToReturn(managementCluster *types.Cluster, workloadCluster *types.Cluster, err error) *gomock.Call { +func (c *upgradeTestSetup) expectUpgradeWorkloadToReturn(managementCluster, workloadCluster *types.Cluster, err error) *gomock.Call { return c.clusterManager.EXPECT().UpgradeCluster( c.ctx, managementCluster, workloadCluster, c.newClusterSpec, c.provider, ).Return(err) diff --git a/test/e2e/airgap.go b/test/e2e/airgap.go index 43acb0ed109b..e38e35b064c0 100644 --- a/test/e2e/airgap.go +++ b/test/e2e/airgap.go @@ -100,7 +100,7 @@ func runTinkerbellAirgapConfigProxyFlow(test *framework.ClusterE2ETest, localCID test.ValidateHardwareDecommissioned() } -func downloadFile(url string, output string) error { +func downloadFile(url, output string) error { out, err := os.Create(output) if err != nil { return err diff --git a/test/e2e/tools/eks-anywhere-test-tool/pkg/cloudwatch/cloudwatch.go b/test/e2e/tools/eks-anywhere-test-tool/pkg/cloudwatch/cloudwatch.go index d8cf8ef663fd..65a154875139 100644 --- a/test/e2e/tools/eks-anywhere-test-tool/pkg/cloudwatch/cloudwatch.go +++ b/test/e2e/tools/eks-anywhere-test-tool/pkg/cloudwatch/cloudwatch.go @@ -39,15 +39,15 @@ func New(account awsprofiles.EksAccount) (*Cloudwatch, error) { }, nil } -func (c *Cloudwatch) GetLogs(logGroupName string, logStreamName string) ([]*cloudwatchlogs.OutputLogEvent, error) { +func (c *Cloudwatch) GetLogs(logGroupName, logStreamName string) ([]*cloudwatchlogs.OutputLogEvent, error) { return c.getLogs(logGroupName, logStreamName, nil, nil) } -func (c *Cloudwatch) GetLogsInTimeframe(logGroupName string, logStreamName string, startTime int64, endTime int64) ([]*cloudwatchlogs.OutputLogEvent, error) { +func (c *Cloudwatch) GetLogsInTimeframe(logGroupName, logStreamName string, startTime, endTime int64) ([]*cloudwatchlogs.OutputLogEvent, error) { return c.getLogs(logGroupName, logStreamName, &startTime, &endTime) } -func (c *Cloudwatch) getLogs(logGroupName string, logStreamName string, startTime *int64, endTime *int64) ([]*cloudwatchlogs.OutputLogEvent, error) { +func (c *Cloudwatch) getLogs(logGroupName, logStreamName string, startTime, endTime *int64) ([]*cloudwatchlogs.OutputLogEvent, error) { var nextToken *string var output []*cloudwatchlogs.OutputLogEvent @@ -74,7 +74,7 @@ func (c *Cloudwatch) getLogs(logGroupName string, logStreamName string, startTim return output, nil } -func (c Cloudwatch) getLogSegment(logGroupName string, logStreamName string, startTime *int64, endTime *int64, nextToken *string) (*cloudwatchlogs.GetLogEventsOutput, error) { +func (c Cloudwatch) getLogSegment(logGroupName, logStreamName string, startTime, endTime *int64, nextToken *string) (*cloudwatchlogs.GetLogEventsOutput, error) { input := &cloudwatchlogs.GetLogEventsInput{ LogGroupName: aws.String(logGroupName), LogStreamName: aws.String(logStreamName), diff --git a/test/e2e/tools/eks-anywhere-test-tool/pkg/logfetcher/logfetcher.go b/test/e2e/tools/eks-anywhere-test-tool/pkg/logfetcher/logfetcher.go index 5caf2c13e1e8..74af36531d33 100644 --- a/test/e2e/tools/eks-anywhere-test-tool/pkg/logfetcher/logfetcher.go +++ b/test/e2e/tools/eks-anywhere-test-tool/pkg/logfetcher/logfetcher.go @@ -73,7 +73,7 @@ type testLogFetcher struct { processTest testConsumer } -func New(buildAccountCwClient *cloudwatch.Cloudwatch, testAccountCwClient *cloudwatch.Cloudwatch, buildAccountCodebuildClient *codebuild.Codebuild, opts ...LogFetcherOpt) *testLogFetcher { +func New(buildAccountCwClient, testAccountCwClient *cloudwatch.Cloudwatch, buildAccountCodebuildClient *codebuild.Codebuild, opts ...LogFetcherOpt) *testLogFetcher { l := &testLogFetcher{ buildAccountCwClient: buildAccountCwClient, testAccountCwClient: testAccountCwClient, @@ -140,7 +140,7 @@ func (l *testLogFetcher) FetchLogs(opts ...FetchLogsOpt) error { return nil } -func (l *testLogFetcher) GetBuildProjectLogs(project string, buildId string) ([]testresults.TestResult, error) { +func (l *testLogFetcher) GetBuildProjectLogs(project, buildId string) ([]testresults.TestResult, error) { logger.Info("Fetching build project logs...") build, err := l.buildAccountCodebuildClient.FetchBuildForProject(buildId) if err != nil { diff --git a/test/e2e/tools/eks-anywhere-test-tool/pkg/providerproxy/log_fetcher.go b/test/e2e/tools/eks-anywhere-test-tool/pkg/providerproxy/log_fetcher.go index 44ae329eb2ec..f5f4ebff7d22 100644 --- a/test/e2e/tools/eks-anywhere-test-tool/pkg/providerproxy/log_fetcher.go +++ b/test/e2e/tools/eks-anywhere-test-tool/pkg/providerproxy/log_fetcher.go @@ -57,7 +57,7 @@ type proxyLogFetcher struct { processRequests requestConsumer } -func New(buildAccountCwClient *cloudwatch.Cloudwatch, testAccountCwClient *cloudwatch.Cloudwatch, buildAccountCodebuildClient *codebuild.Codebuild, opts ...ProxyFetcherOpt) *proxyLogFetcher { +func New(buildAccountCwClient, testAccountCwClient *cloudwatch.Cloudwatch, buildAccountCodebuildClient *codebuild.Codebuild, opts ...ProxyFetcherOpt) *proxyLogFetcher { l := &proxyLogFetcher{ buildAccountCwClient: buildAccountCwClient, testAccountCwClient: testAccountCwClient, @@ -113,7 +113,7 @@ func (l *proxyLogFetcher) FetchProviderProxyLogs(opts ...FetchSessionOpts) error return nil } -func (l *proxyLogFetcher) FetchProviderProxyLogsForbuild(project string, buildId string) ([]*cloudwatchlogs.OutputLogEvent, error) { +func (l *proxyLogFetcher) FetchProviderProxyLogsForbuild(project, buildId string) ([]*cloudwatchlogs.OutputLogEvent, error) { logger.Info("Fetching provider proxy logs...") build, err := l.buildAccountCodebuildClient.FetchBuildForProject(buildId) if err != nil { diff --git a/test/e2e/tools/eks-anywhere-test-tool/pkg/s3/s3.go b/test/e2e/tools/eks-anywhere-test-tool/pkg/s3/s3.go index 30672c3acbde..547504a49780 100644 --- a/test/e2e/tools/eks-anywhere-test-tool/pkg/s3/s3.go +++ b/test/e2e/tools/eks-anywhere-test-tool/pkg/s3/s3.go @@ -48,7 +48,7 @@ func New(account awsprofiles.EksAccount) (*S3, error) { }, nil } -func (s *S3) ListObjects(bucket string, prefix string) (listedObjects []*s3.Object, err error) { +func (s *S3) ListObjects(bucket, prefix string) (listedObjects []*s3.Object, err error) { var nextToken *string var objects []*s3.Object @@ -77,7 +77,7 @@ func (s *S3) ListObjects(bucket string, prefix string) (listedObjects []*s3.Obje return objects, nil } -func (s *S3) GetObject(bucket string, key string) ([]byte, error) { +func (s *S3) GetObject(bucket, key string) ([]byte, error) { input := &s3.GetObjectInput{ Bucket: aws.String(bucket), Key: aws.String(key), diff --git a/test/framework/multi_template.go b/test/framework/multi_template.go index b61b8f724c65..85e350e871e9 100644 --- a/test/framework/multi_template.go +++ b/test/framework/multi_template.go @@ -123,7 +123,7 @@ func getWngNameToWng(wngConfigs []v1alpha1.WorkerNodeGroupConfiguration) map[str } // getWngNameFromMachine gets worker node group name from machine name by trimming cluster name prefix and two unix nano time suffix. -func getWngNameFromMachine(machineName string, clusterName string) (string, error) { +func getWngNameFromMachine(machineName, clusterName string) (string, error) { trimmedMachineName := strings.TrimPrefix(machineName, clusterName+"-") wngBaseParts := strings.Split(trimmedMachineName, "-") if len(wngBaseParts) < 3 { diff --git a/test/framework/testingt.go b/test/framework/testingt.go index 176f0a8126a5..cb2bef744119 100644 --- a/test/framework/testingt.go +++ b/test/framework/testingt.go @@ -119,7 +119,7 @@ func (t LoggingOnlyT) Run(_ string, _ func(*testing.T)) bool { } // Setenv implements T. -func (t LoggingOnlyT) Setenv(_ string, _ string) { +func (t LoggingOnlyT) Setenv(_, _ string) { panic("LoggingOnlyT implements only the logging methods of T") } diff --git a/test/framework/vsphere.go b/test/framework/vsphere.go index aaa0cc23d6b9..17075876eb68 100644 --- a/test/framework/vsphere.go +++ b/test/framework/vsphere.go @@ -328,7 +328,7 @@ func WithVSphereWorkerNodeGroup(name string, workerNodeGroup *WorkerNodeGroup, f } // WithMachineTemplate returns an api.ClusterConfigFiller that changes template in machine template. -func (v *VSphere) WithMachineTemplate(machineName string, template string) api.ClusterConfigFiller { +func (v *VSphere) WithMachineTemplate(machineName, template string) api.ClusterConfigFiller { return api.JoinClusterConfigFillers( api.VSphereToConfigFiller(api.WithMachineTemplate(machineName, template)), ) diff --git a/test/framework/workload.go b/test/framework/workload.go index 01e38b7b4699..5d8bcb007520 100644 --- a/test/framework/workload.go +++ b/test/framework/workload.go @@ -114,7 +114,7 @@ func (w *WorkloadCluster) ValidateClusterDelete() { } } -func (w *WorkloadCluster) writeKubeconfigToDisk(ctx context.Context, secretName string, filePath string) error { +func (w *WorkloadCluster) writeKubeconfigToDisk(ctx context.Context, secretName, filePath string) error { secret, err := w.KubectlClient.GetSecretFromNamespace(ctx, w.ManagementClusterKubeconfigFile(), secretName, constants.EksaSystemNamespace) if err != nil { return fmt.Errorf("failed to get kubeconfig for cluster: %s", err)