Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump go version (1.20) #4518

Merged
merged 9 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix some linting issues
Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>
  • Loading branch information
JorTurFer committed May 3, 2023
commit f0cfad752fea04df4f33bcc37be59a9d1f4bc274
8 changes: 3 additions & 5 deletions pkg/certificates/certificate_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (cm CertManager) AddCertificateRotation(ctx context.Context, mgr manager.Ma
extraDNSNames = append(extraDNSNames, getDNSNames(cm.MetricsServerService)...)

cm.Logger.V(1).Info("setting up cert rotation")
if err := rotator.AddRotator(mgr, &rotator.CertRotator{
err = rotator.AddRotator(mgr, &rotator.CertRotator{
SecretKey: types.NamespacedName{
Namespace: kedautil.GetPodNamespace(),
Name: cm.SecretName,
Expand All @@ -91,10 +91,8 @@ func (cm CertManager) AddCertificateRotation(ctx context.Context, mgr manager.Ma
x509.ExtKeyUsageServerAuth,
x509.ExtKeyUsageClientAuth,
},
}); err != nil {
return err
}
return nil
})
return err
}

// getDNSNames creates all the possible DNS names for a given service
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/azure/azure_aad_workload_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (wiTokenProvider *ADWorkloadIdentityTokenProvider) EnsureFresh() error {
}

// GetToken is for implementing the auth.TokenProvider interface
func (wiTokenProvider *ADWorkloadIdentityTokenProvider) GetToken(uri string) (*amqpAuth.Token, error) {
func (wiTokenProvider *ADWorkloadIdentityTokenProvider) GetToken(_ string) (*amqpAuth.Token, error) {
err := wiTokenProvider.Refresh()
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/scalers/rabbitmq_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ func getSum(q []queueInfo) (int, int, float64) {

func getAverage(q []queueInfo) (int, int, float64) {
sumMessages, sumReady, sumRate := getSum(q)
len := len(q)
return sumMessages / len, sumReady / len, sumRate / float64(len)
lenght := len(q)
return sumMessages / lenght, sumReady / lenght, sumRate / float64(lenght)
}

func getMaximum(q []queueInfo) (int, int, float64) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/scaling/executor/scale_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ type ScalingStrategy interface {
type defaultScalingStrategy struct {
}

func (s defaultScalingStrategy) GetEffectiveMaxScale(maxScale, runningJobCount, pendingJobCount, maxReplicaCount int64) int64 {
func (s defaultScalingStrategy) GetEffectiveMaxScale(maxScale, runningJobCount, _, maxReplicaCount int64) int64 {
return maxScale - runningJobCount
}

Expand All @@ -404,7 +404,7 @@ type customScalingStrategy struct {
CustomScalingRunningJobPercentage *float64
}

func (s customScalingStrategy) GetEffectiveMaxScale(maxScale, runningJobCount, pendingJobCount, maxReplicaCount int64) int64 {
func (s customScalingStrategy) GetEffectiveMaxScale(maxScale, runningJobCount, _, maxReplicaCount int64) int64 {
return min(maxScale-int64(*s.CustomScalingQueueLengthDeduction)-int64(float64(runningJobCount)*(*s.CustomScalingRunningJobPercentage)), maxReplicaCount)
}

Expand Down
12 changes: 6 additions & 6 deletions tests/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ func GetKedaKubernetesClient(t *testing.T) *v1alpha1.KedaV1alpha1Client {

// Creates a new namespace. If it already exists, make sure it is deleted first.
func CreateNamespace(t *testing.T, kc *kubernetes.Clientset, nsName string) {
DeleteNamespace(t, kc, nsName)
WaitForNamespaceDeletion(t, kc, nsName)
DeleteNamespace(t, nsName)
WaitForNamespaceDeletion(t, nsName)

t.Logf("Creating namespace - %s", nsName)
namespace := &corev1.Namespace{
Expand All @@ -235,7 +235,7 @@ func CreateNamespace(t *testing.T, kc *kubernetes.Clientset, nsName string) {
assert.NoErrorf(t, err, "cannot create kubernetes namespace - %s", err)
}

func DeleteNamespace(t *testing.T, kc *kubernetes.Clientset, nsName string) {
func DeleteNamespace(t *testing.T, nsName string) {
t.Logf("deleting namespace %s", nsName)
period := int64(0)
err := KubeClient.CoreV1().Namespaces().Delete(context.Background(), nsName, metav1.DeleteOptions{
Expand Down Expand Up @@ -287,7 +287,7 @@ func WaitForAllJobsSuccess(t *testing.T, kc *kubernetes.Clientset, namespace str
return false
}

func WaitForNamespaceDeletion(t *testing.T, kc *kubernetes.Clientset, nsName string) bool {
func WaitForNamespaceDeletion(t *testing.T, nsName string) bool {
for i := 0; i < 120; i++ {
t.Logf("waiting for namespace %s deletion", nsName)
_, err := KubeClient.CoreV1().Namespaces().Get(context.Background(), nsName, metav1.GetOptions{})
Expand Down Expand Up @@ -582,8 +582,8 @@ func CreateKubernetesResources(t *testing.T, kc *kubernetes.Clientset, nsName st

func DeleteKubernetesResources(t *testing.T, kc *kubernetes.Clientset, nsName string, data interface{}, templates []Template) {
KubectlDeleteMultipleWithTemplate(t, data, templates)
DeleteNamespace(t, kc, nsName)
deleted := WaitForNamespaceDeletion(t, kc, nsName)
DeleteNamespace(t, nsName)
deleted := WaitForNamespaceDeletion(t, nsName)
assert.Truef(t, deleted, "%s namespace not deleted", nsName)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func cleanupArgo(t *testing.T, kc *kubernetes.Clientset) {
_, err := ExecuteCommand(cmdWithNamespace)

assert.NoErrorf(t, err, "cannot delete argo resources - %s", err)
DeleteNamespace(t, kc, argoNamespace)
DeleteNamespace(t, argoNamespace)
}

func testScaleOut(t *testing.T, kc *kubernetes.Clientset) {
Expand Down
4 changes: 2 additions & 2 deletions tests/scalers/arangodb/arangodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ func TestArangoDBScaler(t *testing.T) {
KubectlDeleteMultipleWithTemplate(t, data, templates)
arangodb.UninstallArangoDB(t, kc, testNamespace)

DeleteNamespace(t, kc, testNamespace)
WaitForNamespaceDeletion(t, kc, testNamespace)
DeleteNamespace(t, testNamespace)
WaitForNamespaceDeletion(t, testNamespace)
}

func getTemplateData() (templateData, []Template) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func TestAzureManagedPrometheusScaler(t *testing.T, data TemplateData) {

// cleanup
helper.KubectlDeleteMultipleWithTemplate(t, data, templates)
helper.DeleteNamespace(t, kc, data.TestNamespace)
helper.DeleteNamespace(t, data.TestNamespace)
}

func testActivation(t *testing.T, kc *kubernetes.Clientset, data TemplateData) {
Expand Down
4 changes: 2 additions & 2 deletions tests/scalers/loki/loki_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,6 @@ func installLoki(t *testing.T, kc *kubernetes.Clientset, namespace string) {
func uninstallLoki(t *testing.T, kc *kubernetes.Clientset, namespace string) {
_, err := ExecuteCommand(fmt.Sprintf("helm uninstall loki --wait --namespace=%s", namespace))
assert.NoErrorf(t, err, "cannot execute command - %s", err)
DeleteNamespace(t, kc, namespace)
WaitForNamespaceDeletion(t, kc, namespace)
DeleteNamespace(t, namespace)
WaitForNamespaceDeletion(t, namespace)
}
2 changes: 1 addition & 1 deletion tests/scalers/mongodb/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,5 @@ func testScaleOut(t *testing.T, kc *kubernetes.Clientset, mongoPod string) {
func cleanupMongo(t *testing.T, kc *kubernetes.Clientset) {
_, err := ExecuteCommand(fmt.Sprintf("helm uninstall mongodb --namespace %s", mongoNamespace))
assert.NoErrorf(t, err, "cannot execute command - %s", err)
DeleteNamespace(t, kc, mongoNamespace)
DeleteNamespace(t, mongoNamespace)
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func TestNATSJetStreamScalerClusterWithStreamReplicas(t *testing.T) {

// Cleanup nats namespace
removeClusterWithJetStream(t)
DeleteNamespace(t, kc, natsNamespace)
deleted := WaitForNamespaceDeletion(t, kc, natsNamespace)
DeleteNamespace(t, natsNamespace)
deleted := WaitForNamespaceDeletion(t, natsNamespace)
assert.Truef(t, deleted, "%s namespace not deleted", natsNamespace)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ func TestNATSJetStreamScaler(t *testing.T) {

// Cleanup nats namespace
removeServerWithJetStream(t, kc, natsNamespace)
DeleteNamespace(t, kc, natsNamespace)
deleted := WaitForNamespaceDeletion(t, kc, natsNamespace)
DeleteNamespace(t, natsNamespace)
deleted := WaitForNamespaceDeletion(t, natsNamespace)
assert.Truef(t, deleted, "%s namespace not deleted", natsNamespace)
// Cleanup test namespace
DeleteKubernetesResources(t, kc, testNamespace, data, templates)
Expand Down Expand Up @@ -245,7 +245,7 @@ func removeServerWithJetStream(t *testing.T, kc *k8s.Clientset, namespace string
}

KubectlDeleteWithTemplate(t, data, "natsServerTemplate", natsServerTemplate)
DeleteNamespace(t, kc, namespace)
DeleteNamespace(t, namespace)
}

func testActivation(t *testing.T, kc *k8s.Clientset, data nats.JetStreamDeploymentTemplateData) {
Expand Down
2 changes: 1 addition & 1 deletion tests/scalers/prometheus/prometheus_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,5 +504,5 @@ func Uninstall(t *testing.T, kc *kubernetes.Clientset, name, namespace string) {
PrometheusServerName: name,
}
helper.KubectlDeleteMultipleWithTemplate(t, data, prometheusTemplates)
helper.DeleteNamespace(t, kc, namespace)
helper.DeleteNamespace(t, namespace)
}
2 changes: 1 addition & 1 deletion tests/scalers/rabbitmq/rabbitmq_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func RMQUninstall(t *testing.T, kc *kubernetes.Clientset, namespace, user, passw
}

helper.KubectlDeleteWithTemplate(t, data, "rmqDeploymentTemplate", deploymentTemplate)
helper.DeleteNamespace(t, kc, namespace)
helper.DeleteNamespace(t, namespace)
}

func RMQPublishMessages(t *testing.T, namespace, connectionString, queueName string, messageCount int) {
Expand Down
6 changes: 3 additions & 3 deletions tests/scalers/redis/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func RemoveStandalone(t *testing.T, kc *kubernetes.Clientset, name, namespace st
RedisName: name,
}
helper.KubectlApplyMultipleWithTemplate(t, data, redisStandaloneTemplates)
helper.DeleteNamespace(t, kc, namespace)
helper.DeleteNamespace(t, namespace)
}

func InstallSentinel(t *testing.T, kc *kubernetes.Clientset, name, namespace, password string) {
Expand All @@ -103,7 +103,7 @@ func RemoveSentinel(t *testing.T, kc *kubernetes.Clientset, name, namespace stri
name,
namespace))
assert.NoErrorf(t, err, "cannot execute command - %s", err)
helper.DeleteNamespace(t, kc, namespace)
helper.DeleteNamespace(t, namespace)
}

func InstallCluster(t *testing.T, kc *kubernetes.Clientset, name, namespace, password string) {
Expand All @@ -124,5 +124,5 @@ func RemoveCluster(t *testing.T, kc *kubernetes.Clientset, name, namespace strin
name,
namespace))
assert.NoErrorf(t, err, "cannot execute command - %s", err)
helper.DeleteNamespace(t, kc, namespace)
helper.DeleteNamespace(t, namespace)
}
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func cleanupHashiCorpVault(t *testing.T, kc *kubernetes.Clientset) {
_, err = ExecuteCommand("helm repo remove hashicorp")
assert.NoErrorf(t, err, "cannot remove hashicorp repo - %s", err)

DeleteNamespace(t, kc, vaultNamespace)
DeleteNamespace(t, vaultNamespace)
}

func testActivation(t *testing.T, kc *kubernetes.Clientset, data templateData) {
Expand Down
2 changes: 1 addition & 1 deletion tests/sequential/disruption/disruption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestScaler(t *testing.T) {
KubectlDeleteMultipleWithTemplate(t, data, sutDeployment)
KubectlDeleteMultipleWithTemplate(t, data, scaledObject)
}
DeleteNamespace(t, kc, testNamespace)
DeleteNamespace(t, testNamespace)
}

func testScaleOut(t *testing.T, kc *kubernetes.Clientset) {
Expand Down
10 changes: 5 additions & 5 deletions tests/utils/cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestRemoveAadPodIdentityComponents(t *testing.T) {

KubeClient = GetKubernetesClient(t)

DeleteNamespace(t, KubeClient, AzureAdPodIdentityNamespace)
DeleteNamespace(t, AzureAdPodIdentityNamespace)
}

func TestRemoveWorkloadIdentityComponents(t *testing.T) {
Expand All @@ -44,7 +44,7 @@ func TestRemoveWorkloadIdentityComponents(t *testing.T) {

KubeClient = GetKubernetesClient(t)

DeleteNamespace(t, KubeClient, AzureWorkloadIdentityNamespace)
DeleteNamespace(t, AzureWorkloadIdentityNamespace)
}

func TestRemoveAwsIdentityComponents(t *testing.T) {
Expand All @@ -57,7 +57,7 @@ func TestRemoveAwsIdentityComponents(t *testing.T) {

KubeClient = GetKubernetesClient(t)

DeleteNamespace(t, KubeClient, AwsIdentityNamespace)
DeleteNamespace(t, AwsIdentityNamespace)
}

func TestRemoveGcpIdentityComponents(t *testing.T) {
Expand All @@ -70,7 +70,7 @@ func TestRemoveGcpIdentityComponents(t *testing.T) {

KubeClient = GetKubernetesClient(t)

DeleteNamespace(t, KubeClient, GcpIdentityNamespace)
DeleteNamespace(t, GcpIdentityNamespace)
}

func TestRemoveCertManager(t *testing.T) {
Expand All @@ -83,7 +83,7 @@ func TestRemoveCertManager(t *testing.T) {

KubeClient = GetKubernetesClient(t)

DeleteNamespace(t, KubeClient, CertManagerNamespace)
DeleteNamespace(t, CertManagerNamespace)
}

func TestRemoveAzureManagedPrometheusComponents(t *testing.T) {
Expand Down