From ee21e4a2bc69a91552700971d75b231c4933e8ab Mon Sep 17 00:00:00 2001 From: Teiva Harsanyi Date: Sun, 1 Oct 2023 15:00:47 +0200 Subject: [PATCH 1/4] Pkg linting issues Signed-off-by: Teiva Harsanyi --- pkg/certificates/certificate_manager.go | 2 +- pkg/metricscollector/metricscollectors.go | 8 ++++---- pkg/metricscollector/opentelemetry.go | 4 ++-- pkg/metricscollector/prommetrics.go | 4 ++-- pkg/metricsservice/api/metrics.pb.go | 5 +++-- pkg/metricsservice/api/metrics_grpc.pb.go | 1 + pkg/scalers/authentication/authentication_helpers.go | 2 +- pkg/scalers/azure/azure_cloud_environment.go | 6 +++--- pkg/scalers/azure/azure_eventhub_checkpoint.go | 8 ++++---- .../azure/azure_managed_prometheus_http_round_tripper.go | 4 ++-- pkg/scalers/azure_servicebus_scaler.go | 2 +- pkg/scalers/cpu_memory_scaler.go | 2 +- pkg/scalers/datadog_scaler.go | 4 ++-- pkg/scalers/externalscaler/externalscaler.pb.go | 5 +++-- pkg/scalers/externalscaler/externalscaler_grpc.pb.go | 1 + pkg/scalers/gcp_cloud_tasks_scaler.go | 2 +- pkg/scalers/gcp_stackdriver_client.go | 2 +- pkg/scalers/liiklus/LiiklusService.pb.go | 5 +++-- pkg/scalers/liiklus/LiiklusService_grpc.pb.go | 1 + pkg/scalers/pulsar_scaler.go | 4 ++-- pkg/scalers/rabbitmq_scaler_test.go | 6 +++--- pkg/scalers/scaler.go | 4 ++-- pkg/scalers/solace_scaler.go | 8 ++++---- pkg/scaling/cache/scalers_cache.go | 2 +- pkg/scaling/executor/scale_jobs.go | 4 ++-- pkg/scaling/scaledjob/metrics_test.go | 2 +- pkg/util/conver_types.go | 2 +- 27 files changed, 53 insertions(+), 47 deletions(-) diff --git a/pkg/certificates/certificate_manager.go b/pkg/certificates/certificate_manager.go index 1a9434ebe20..5f390e1b205 100644 --- a/pkg/certificates/certificate_manager.go +++ b/pkg/certificates/certificate_manager.go @@ -68,7 +68,7 @@ func (cm CertManager) AddCertificateRotation(ctx context.Context, mgr manager.Ma if err != nil { return err } - extraDNSNames := []string{} + var extraDNSNames []string extraDNSNames = append(extraDNSNames, getDNSNames(cm.OperatorService, cm.K8sClusterDomain)...) extraDNSNames = append(extraDNSNames, getDNSNames(cm.WebhookService, cm.K8sClusterDomain)...) extraDNSNames = append(extraDNSNames, getDNSNames(cm.MetricsServerService, cm.K8sClusterDomain)...) diff --git a/pkg/metricscollector/metricscollectors.go b/pkg/metricscollector/metricscollectors.go index eba335f8e0a..41077b1a4ed 100644 --- a/pkg/metricscollector/metricscollectors.go +++ b/pkg/metricscollector/metricscollectors.go @@ -35,7 +35,7 @@ type MetricsCollector interface { // RecordScalerLatency create a measurement of the latency to external metric RecordScalerLatency(namespace string, scaledObject string, scaler string, scalerIndex int, metric string, value float64) - // RecordScaledObjectLatency create a measurement of the latency executing scalable object loop + // RecordScalableObjectLatency create a measurement of the latency executing scalable object loop RecordScalableObjectLatency(namespace string, name string, isScaledObject bool, value float64) // RecordScalerActive create a measurement of the activity of the scaler @@ -44,7 +44,7 @@ type MetricsCollector interface { // RecordScalerError counts the number of errors occurred in trying get an external metric used by the HPA RecordScalerError(namespace string, scaledObject string, scaler string, scalerIndex int, metric string, err error) - // RecordScaleObjectError counts the number of errors with the scaled object + // RecordScaledObjectError counts the number of errors with the scaled object RecordScaledObjectError(namespace string, scaledObject string, err error) IncrementTriggerTotal(triggerType string) @@ -82,7 +82,7 @@ func RecordScalerLatency(namespace string, scaledObject string, scaler string, s } } -// RecordScaledObjectLatency create a measurement of the latency executing scalable object loop +// RecordScalableObjectLatency create a measurement of the latency executing scalable object loop func RecordScalableObjectLatency(namespace string, name string, isScaledObject bool, value float64) { for _, element := range collectors { element.RecordScalableObjectLatency(namespace, name, isScaledObject, value) @@ -103,7 +103,7 @@ func RecordScalerError(namespace string, scaledObject string, scaler string, sca } } -// RecordScaleObjectError counts the number of errors with the scaled object +// RecordScaledObjectError counts the number of errors with the scaled object func RecordScaledObjectError(namespace string, scaledObject string, err error) { for _, element := range collectors { element.RecordScaledObjectError(namespace, scaledObject, err) diff --git a/pkg/metricscollector/opentelemetry.go b/pkg/metricscollector/opentelemetry.go index 9681c09d6bb..ad9ca08d240 100644 --- a/pkg/metricscollector/opentelemetry.go +++ b/pkg/metricscollector/opentelemetry.go @@ -111,7 +111,7 @@ func (o *OtelMetrics) RecordScalerLatency(namespace string, scaledObject string, } } -// RecordScaledObjectLatency create a measurement of the latency executing scalable object loop +// RecordScalableObjectLatency create a measurement of the latency executing scalable object loop func (o *OtelMetrics) RecordScalableObjectLatency(namespace string, name string, isScaledObject bool, value float64) { resourceType := "scaledjob" if isScaledObject { @@ -167,7 +167,7 @@ func (o *OtelMetrics) RecordScalerError(namespace string, scaledObject string, s } } -// RecordScaleObjectError counts the number of errors with the scaled object +// RecordScaledObjectError counts the number of errors with the scaled object func (o *OtelMetrics) RecordScaledObjectError(namespace string, scaledObject string, err error) { opt := api.WithAttributes( attribute.Key("namespace").String(namespace), diff --git a/pkg/metricscollector/prommetrics.go b/pkg/metricscollector/prommetrics.go index fe9421db92a..94ec66854bb 100644 --- a/pkg/metricscollector/prommetrics.go +++ b/pkg/metricscollector/prommetrics.go @@ -158,7 +158,7 @@ func (p *PromMetrics) RecordScalerLatency(namespace string, scaledObject string, scalerMetricsLatency.With(getLabels(namespace, scaledObject, scaler, scalerIndex, metric)).Set(value) } -// RecordScaledObjectLatency create a measurement of the latency executing scalable object loop +// RecordScalableObjectLatency create a measurement of the latency executing scalable object loop func (p *PromMetrics) RecordScalableObjectLatency(namespace string, name string, isScaledObject bool, value float64) { resourceType := "scaledjob" if isScaledObject { @@ -192,7 +192,7 @@ func (p *PromMetrics) RecordScalerError(namespace string, scaledObject string, s } } -// RecordScaleObjectError counts the number of errors with the scaled object +// RecordScaledObjectError counts the number of errors with the scaled object func (p *PromMetrics) RecordScaledObjectError(namespace string, scaledObject string, err error) { labels := prometheus.Labels{"namespace": namespace, "scaledObject": scaledObject} if err != nil { diff --git a/pkg/metricsservice/api/metrics.pb.go b/pkg/metricsservice/api/metrics.pb.go index 919cb333713..a1d84c220c2 100644 --- a/pkg/metricsservice/api/metrics.pb.go +++ b/pkg/metricsservice/api/metrics.pb.go @@ -22,11 +22,12 @@ package api import ( + reflect "reflect" + sync "sync" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" v1beta1 "k8s.io/metrics/pkg/apis/external_metrics/v1beta1" - reflect "reflect" - sync "sync" ) const ( diff --git a/pkg/metricsservice/api/metrics_grpc.pb.go b/pkg/metricsservice/api/metrics_grpc.pb.go index 9eae639dc04..5274921d260 100644 --- a/pkg/metricsservice/api/metrics_grpc.pb.go +++ b/pkg/metricsservice/api/metrics_grpc.pb.go @@ -23,6 +23,7 @@ package api import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/pkg/scalers/authentication/authentication_helpers.go b/pkg/scalers/authentication/authentication_helpers.go index e56485e659c..1545afe0da3 100644 --- a/pkg/scalers/authentication/authentication_helpers.go +++ b/pkg/scalers/authentication/authentication_helpers.go @@ -31,7 +31,7 @@ func GetAuthConfigs(triggerMetadata, authParams map[string]string) (out *AuthMet authTypes := strings.Split(authModes, ",") for _, t := range authTypes { - authType := Type(strings.TrimSpace(t)) + authType := strings.TrimSpace(t) switch authType { case BearerAuthType: diff --git a/pkg/scalers/azure/azure_cloud_environment.go b/pkg/scalers/azure/azure_cloud_environment.go index f166ad18cf8..fef9e754266 100644 --- a/pkg/scalers/azure/azure_cloud_environment.go +++ b/pkg/scalers/azure/azure_cloud_environment.go @@ -13,13 +13,13 @@ const ( // PrivateCloud cloud type PrivateCloud string = "Private" - // Default Endpoint key in trigger metadata + // DefaultEndpointSuffixKey is the default endpoint key in trigger metadata DefaultEndpointSuffixKey string = "endpointSuffix" - // Default Storage Endpoint key in trigger metadata + // DefaultStorageSuffixKey is the default storage endpoint key in trigger metadata DefaultStorageSuffixKey string = "storageEndpointSuffix" - // Default Active Directory Endpoint Key in trigger metadata + // DefaultActiveDirectoryEndpointKey is the default active directory endpoint key in trigger metadata DefaultActiveDirectoryEndpointKey string = "activeDirectoryEndpoint" ) diff --git a/pkg/scalers/azure/azure_eventhub_checkpoint.go b/pkg/scalers/azure/azure_eventhub_checkpoint.go index e14c2aa53ab..ad2ba3d0a93 100644 --- a/pkg/scalers/azure/azure_eventhub_checkpoint.go +++ b/pkg/scalers/azure/azure_eventhub_checkpoint.go @@ -100,22 +100,22 @@ func GetCheckpointFromBlobStorage(ctx context.Context, httpClient util.HTTPDoer, func newCheckpointer(info EventHubInfo, partitionID string) checkpointer { switch { - case (info.CheckpointStrategy == "goSdk"): + case info.CheckpointStrategy == "goSdk": return &goSdkCheckpointer{ containerName: info.BlobContainer, partitionID: partitionID, } - case (info.CheckpointStrategy == "dapr"): + case info.CheckpointStrategy == "dapr": return &daprCheckpointer{ containerName: info.BlobContainer, partitionID: partitionID, } - case (info.CheckpointStrategy == "blobMetadata"): + case info.CheckpointStrategy == "blobMetadata": return &blobMetadataCheckpointer{ containerName: info.BlobContainer, partitionID: partitionID, } - case (info.CheckpointStrategy == "azureFunction" || info.BlobContainer == ""): + case info.CheckpointStrategy == "azureFunction" || info.BlobContainer == "": return &azureFunctionCheckpointer{ containerName: "azure-webjobs-eventhub", partitionID: partitionID, diff --git a/pkg/scalers/azure/azure_managed_prometheus_http_round_tripper.go b/pkg/scalers/azure/azure_managed_prometheus_http_round_tripper.go index 8ad2fefd915..33dc15dbb85 100644 --- a/pkg/scalers/azure/azure_managed_prometheus_http_round_tripper.go +++ b/pkg/scalers/azure/azure_managed_prometheus_http_round_tripper.go @@ -26,7 +26,7 @@ type azureManagedPrometheusHTTPRoundTripper struct { resourceURL string } -// Tries to get a round tripper. +// TryAndGetAzureManagedPrometheusHTTPRoundTripper tries to get a round tripper. // If the pod identity represents azure auth, it creates a round tripper and returns that. Returns error if fails to create one. // If its not azure auth, then this becomes a no-op. Neither returns round tripper nor error. func TryAndGetAzureManagedPrometheusHTTPRoundTripper(logger logr.Logger, podIdentity kedav1alpha1.AuthPodIdentity, triggerMetadata map[string]string) (http.RoundTripper, error) { @@ -68,7 +68,7 @@ func TryAndGetAzureManagedPrometheusHTTPRoundTripper(logger logr.Logger, podIden return nil, nil } -// Sets Auhtorization header for requests +// RoundTrip sets authorization header for requests func (rt *azureManagedPrometheusHTTPRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { token, err := rt.chainedCredential.GetToken(req.Context(), policy.TokenRequestOptions{Scopes: []string{rt.resourceURL}}) diff --git a/pkg/scalers/azure_servicebus_scaler.go b/pkg/scalers/azure_servicebus_scaler.go index f2b04e651da..6c9d58894af 100755 --- a/pkg/scalers/azure_servicebus_scaler.go +++ b/pkg/scalers/azure_servicebus_scaler.go @@ -227,7 +227,7 @@ func (s *azureServiceBusScaler) Close(context.Context) error { return nil } -// Returns the metric spec to be used by the HPA +// GetMetricSpecForScaling returns the metric spec to be used by the HPA func (s *azureServiceBusScaler) GetMetricSpecForScaling(context.Context) []v2.MetricSpec { metricName := "" diff --git a/pkg/scalers/cpu_memory_scaler.go b/pkg/scalers/cpu_memory_scaler.go index 83851b360f1..8fc81a3b998 100644 --- a/pkg/scalers/cpu_memory_scaler.go +++ b/pkg/scalers/cpu_memory_scaler.go @@ -118,7 +118,7 @@ func (s *cpuMemoryScaler) GetMetricSpecForScaling(context.Context) []v2.MetricSp return []v2.MetricSpec{metricSpec} } -// GetMetrics no need for cpu/memory scaler and always active for cpu/memory scaler +// GetMetricsAndActivity no need for cpu/memory scaler and always active for cpu/memory scaler func (s *cpuMemoryScaler) GetMetricsAndActivity(_ context.Context, _ string) ([]external_metrics.ExternalMetricValue, bool, error) { return nil, true, nil } diff --git a/pkg/scalers/datadog_scaler.go b/pkg/scalers/datadog_scaler.go index 8e643fe118d..641c87879d5 100644 --- a/pkg/scalers/datadog_scaler.go +++ b/pkg/scalers/datadog_scaler.go @@ -396,7 +396,7 @@ func (s *datadogScaler) GetMetricsAndActivity(ctx context.Context, metricName st return []external_metrics.ExternalMetricValue{metric}, num > s.metadata.activationQueryValue, nil } -// Find the largest value in a slice of floats +// MaxFloatFromSlice finds the largest value in a slice of floats func MaxFloatFromSlice(results []float64) float64 { max := results[0] for _, result := range results { @@ -407,7 +407,7 @@ func MaxFloatFromSlice(results []float64) float64 { return max } -// Find the average value in a slice of floats +// AvgFloatFromSlice finds the average value in a slice of floats func AvgFloatFromSlice(results []float64) float64 { total := 0.0 for _, result := range results { diff --git a/pkg/scalers/externalscaler/externalscaler.pb.go b/pkg/scalers/externalscaler/externalscaler.pb.go index a8515ecc162..2810d9e8444 100644 --- a/pkg/scalers/externalscaler/externalscaler.pb.go +++ b/pkg/scalers/externalscaler/externalscaler.pb.go @@ -7,10 +7,11 @@ package externalscaler import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/pkg/scalers/externalscaler/externalscaler_grpc.pb.go b/pkg/scalers/externalscaler/externalscaler_grpc.pb.go index 5489ae58ac4..642a7dde4cd 100644 --- a/pkg/scalers/externalscaler/externalscaler_grpc.pb.go +++ b/pkg/scalers/externalscaler/externalscaler_grpc.pb.go @@ -8,6 +8,7 @@ package externalscaler import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/pkg/scalers/gcp_cloud_tasks_scaler.go b/pkg/scalers/gcp_cloud_tasks_scaler.go index e482824b68e..ba2f7c42b22 100644 --- a/pkg/scalers/gcp_cloud_tasks_scaler.go +++ b/pkg/scalers/gcp_cloud_tasks_scaler.go @@ -35,7 +35,7 @@ type gcpCloudTaskMetadata struct { scalerIndex int } -// NewCloudTaskScaler creates a new cloudTaskScaler +// NewGcpCloudTasksScaler creates a new cloudTaskScaler func NewGcpCloudTasksScaler(config *ScalerConfig) (Scaler, error) { metricType, err := GetMetricTargetType(config) if err != nil { diff --git a/pkg/scalers/gcp_stackdriver_client.go b/pkg/scalers/gcp_stackdriver_client.go index dbd14e6bb1d..5beb42f404f 100644 --- a/pkg/scalers/gcp_stackdriver_client.go +++ b/pkg/scalers/gcp_stackdriver_client.go @@ -47,7 +47,7 @@ func NewStackDriverClient(ctx context.Context, credentials string) (*StackDriver }, nil } -// NewStackDriverClient creates a new stackdriver client with the credentials underlying +// NewStackDriverClientPodIdentity creates a new stackdriver client with the credentials underlying func NewStackDriverClientPodIdentity(ctx context.Context) (*StackDriverClient, error) { client, err := monitoring.NewMetricClient(ctx) if err != nil { diff --git a/pkg/scalers/liiklus/LiiklusService.pb.go b/pkg/scalers/liiklus/LiiklusService.pb.go index 54a8f7b33c8..9accdfa36a8 100644 --- a/pkg/scalers/liiklus/LiiklusService.pb.go +++ b/pkg/scalers/liiklus/LiiklusService.pb.go @@ -7,12 +7,13 @@ package liiklus import ( + reflect "reflect" + sync "sync" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" - reflect "reflect" - sync "sync" ) const ( diff --git a/pkg/scalers/liiklus/LiiklusService_grpc.pb.go b/pkg/scalers/liiklus/LiiklusService_grpc.pb.go index 51480c39dae..167fd8b6a98 100644 --- a/pkg/scalers/liiklus/LiiklusService_grpc.pb.go +++ b/pkg/scalers/liiklus/LiiklusService_grpc.pb.go @@ -8,6 +8,7 @@ package liiklus import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/pkg/scalers/pulsar_scaler.go b/pkg/scalers/pulsar_scaler.go index 7e4442b84f6..131ab9b80ac 100644 --- a/pkg/scalers/pulsar_scaler.go +++ b/pkg/scalers/pulsar_scaler.go @@ -205,7 +205,7 @@ func parsePulsarMetadata(config *ScalerConfig, logger logr.Logger) (pulsarMetada if authModes, authModesOk := config.TriggerMetadata[authentication.AuthModesKey]; authModesOk { config.TriggerMetadata[authentication.AuthModesKey] = fmt.Sprintf("%s,%s", authModes, authentication.TLSAuthType) } else { - config.TriggerMetadata[authentication.AuthModesKey] = string(authentication.TLSAuthType) + config.TriggerMetadata[authentication.AuthModesKey] = authentication.TLSAuthType } } } @@ -298,7 +298,7 @@ func (s *pulsarScaler) getMsgBackLog(ctx context.Context) (int64, bool, error) { return v.Msgbacklog, found, nil } -// GetGetMetricsAndActivityMetrics returns value for a supported metric and an error if there is a problem getting the metric +// GetMetricsAndActivity returns value for a supported metric and an error if there is a problem getting the metric func (s *pulsarScaler) GetMetricsAndActivity(ctx context.Context, metricName string) ([]external_metrics.ExternalMetricValue, bool, error) { msgBacklog, found, err := s.getMsgBackLog(ctx) if err != nil { diff --git a/pkg/scalers/rabbitmq_scaler_test.go b/pkg/scalers/rabbitmq_scaler_test.go index 4f57366716f..11a10e2e8c7 100644 --- a/pkg/scalers/rabbitmq_scaler_test.go +++ b/pkg/scalers/rabbitmq_scaler_test.go @@ -335,7 +335,7 @@ func Test_getVhostAndPathFromURL(t *testing.T) { } func TestGetQueueInfo(t *testing.T) { - allTestData := []getQueueInfoTestData{} + var allTestData []getQueueInfoTestData allTestData = append(allTestData, testQueueInfoTestDataSingleVhost...) for _, testData := range testQueueInfoTestData { for _, vhostAnsSubpathsData := range getVhostAndPathFromURLTestData { @@ -477,7 +477,7 @@ var testRegexQueueInfoTestData = []getQueueInfoTestData{ } func TestGetQueueInfoWithRegex(t *testing.T) { - allTestData := []getQueueInfoTestData{} + var allTestData []getQueueInfoTestData for _, testData := range testRegexQueueInfoTestData { for _, vhostAndSubpathsData := range getVhostAndPathFromURLTestData { testData := testData @@ -563,7 +563,7 @@ var testRegexPageSizeTestData = []getRegexPageSizeTestData{ } func TestGetPageSizeWithRegex(t *testing.T) { - allTestData := []getRegexPageSizeTestData{} + var allTestData []getRegexPageSizeTestData for _, testData := range testRegexPageSizeTestData { for _, vhostAndSubpathsData := range getVhostAndPathFromURLTestData { testData := testData diff --git a/pkg/scalers/scaler.go b/pkg/scalers/scaler.go index 3aaa1bad11a..b2f8c067e3c 100644 --- a/pkg/scalers/scaler.go +++ b/pkg/scalers/scaler.go @@ -42,10 +42,10 @@ func init() { // Scaler interface type Scaler interface { - // The scaler returns the metric values and activity for a metric Name + // GetMetricsAndActivity returns the metric values and activity for a metric Name GetMetricsAndActivity(ctx context.Context, metricName string) ([]external_metrics.ExternalMetricValue, bool, error) - // Returns the metrics based on which this scaler determines that the ScaleTarget scales. This is used to construct the HPA spec that is created for + // GetMetricSpecForScaling returns the metrics based on which this scaler determines that the ScaleTarget scales. This is used to construct the HPA spec that is created for // this scaled object. The labels used should match the selectors used in GetMetrics GetMetricSpecForScaling(ctx context.Context) []v2.MetricSpec diff --git a/pkg/scalers/solace_scaler.go b/pkg/scalers/solace_scaler.go index 5c0585e1f30..5340a2cc3fc 100644 --- a/pkg/scalers/solace_scaler.go +++ b/pkg/scalers/solace_scaler.go @@ -62,7 +62,7 @@ const ( solaceTriggermsgrxrate = "msgrcvrate" ) -// Struct for Observed Metric Values +// SolaceMetricValues is the struct for Observed Metric Values type SolaceMetricValues struct { // Observed Message Count msgCount int @@ -134,7 +134,7 @@ type solaceSEMPMetadata struct { ResponseCode int `json:"responseCode"` } -// Constructor for SolaceScaler +// NewSolaceScaler is the constructor for SolaceScaler func NewSolaceScaler(config *ScalerConfig) (Scaler, error) { // Create HTTP Client httpClient := kedautil.CreateHTTPClient(config.GlobalHTTPTimeout, false) @@ -428,9 +428,9 @@ func (s *SolaceScaler) GetMetricsAndActivity(ctx context.Context, metricName str return []external_metrics.ExternalMetricValue{}, false, err } return []external_metrics.ExternalMetricValue{metric}, - (metricValues.msgCount > s.metadata.activationMsgCountTarget || + metricValues.msgCount > s.metadata.activationMsgCountTarget || metricValues.msgSpoolUsage > s.metadata.activationMsgSpoolUsageTarget || - metricValues.msgRcvRate > s.metadata.activationMsgRxRateTarget), + metricValues.msgRcvRate > s.metadata.activationMsgRxRateTarget, nil } diff --git a/pkg/scaling/cache/scalers_cache.go b/pkg/scaling/cache/scalers_cache.go index 3fbd8133908..4cb16eebeb0 100644 --- a/pkg/scaling/cache/scalers_cache.go +++ b/pkg/scaling/cache/scalers_cache.go @@ -59,7 +59,7 @@ func (c *ScalersCache) GetScalers() ([]scalers.Scaler, []scalers.ScalerConfig) { return scalersList, configsList } -// GetPushScaler returns array of push scalers stored in the cache +// GetPushScalers returns array of push scalers stored in the cache func (c *ScalersCache) GetPushScalers() []scalers.PushScaler { var result []scalers.PushScaler for _, s := range c.Scalers { diff --git a/pkg/scaling/executor/scale_jobs.go b/pkg/scaling/executor/scale_jobs.go index 8cb09647c49..8adb25a8d74 100644 --- a/pkg/scaling/executor/scale_jobs.go +++ b/pkg/scaling/executor/scale_jobs.go @@ -290,8 +290,8 @@ func (e *scaleExecutor) cleanUp(ctx context.Context, scaledJob *kedav1alpha1.Sca return err } - completedJobs := []batchv1.Job{} - failedJobs := []batchv1.Job{} + var completedJobs []batchv1.Job + var failedJobs []batchv1.Job for _, job := range jobs.Items { job := job finishedJobConditionType := e.getFinishedJobConditionType(&job) diff --git a/pkg/scaling/scaledjob/metrics_test.go b/pkg/scaling/scaledjob/metrics_test.go index de8d07ffca0..b873b6ce1cb 100644 --- a/pkg/scaling/scaledjob/metrics_test.go +++ b/pkg/scaling/scaledjob/metrics_test.go @@ -10,7 +10,7 @@ import ( func TestTargetAverageValue(t *testing.T) { // count = 0 - specs := []v2.MetricSpec{} + var specs []v2.MetricSpec metricName := "s0-messageCount" targetAverageValue := getTargetAverageValue(specs) assert.Equal(t, float64(0), targetAverageValue) diff --git a/pkg/util/conver_types.go b/pkg/util/conver_types.go index 6d7559a8ee9..ffc04135d35 100644 --- a/pkg/util/conver_types.go +++ b/pkg/util/conver_types.go @@ -16,7 +16,7 @@ limitations under the License. package util -// String returns a pointer to the string value passed in. +// StringPointer returns a pointer to the string value passed in. func StringPointer(v string) *string { return &v } From 95cd1c1c2e389cb615a5cb0cd3a9d08c8459d642 Mon Sep 17 00:00:00 2001 From: Teiva Harsanyi Date: Sun, 1 Oct 2023 15:03:40 +0200 Subject: [PATCH 2/4] Discard proto changes Signed-off-by: Teiva Harsanyi --- pkg/metricsservice/api/metrics.pb.go | 5 ++--- pkg/metricsservice/api/metrics_grpc.pb.go | 1 - pkg/scalers/externalscaler/externalscaler.pb.go | 5 ++--- pkg/scalers/externalscaler/externalscaler_grpc.pb.go | 1 - pkg/scalers/liiklus/LiiklusService.pb.go | 5 ++--- pkg/scalers/liiklus/LiiklusService_grpc.pb.go | 1 - 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/pkg/metricsservice/api/metrics.pb.go b/pkg/metricsservice/api/metrics.pb.go index a1d84c220c2..919cb333713 100644 --- a/pkg/metricsservice/api/metrics.pb.go +++ b/pkg/metricsservice/api/metrics.pb.go @@ -22,12 +22,11 @@ package api import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" v1beta1 "k8s.io/metrics/pkg/apis/external_metrics/v1beta1" + reflect "reflect" + sync "sync" ) const ( diff --git a/pkg/metricsservice/api/metrics_grpc.pb.go b/pkg/metricsservice/api/metrics_grpc.pb.go index 5274921d260..9eae639dc04 100644 --- a/pkg/metricsservice/api/metrics_grpc.pb.go +++ b/pkg/metricsservice/api/metrics_grpc.pb.go @@ -23,7 +23,6 @@ package api import ( context "context" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/pkg/scalers/externalscaler/externalscaler.pb.go b/pkg/scalers/externalscaler/externalscaler.pb.go index 2810d9e8444..a8515ecc162 100644 --- a/pkg/scalers/externalscaler/externalscaler.pb.go +++ b/pkg/scalers/externalscaler/externalscaler.pb.go @@ -7,11 +7,10 @@ package externalscaler import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( diff --git a/pkg/scalers/externalscaler/externalscaler_grpc.pb.go b/pkg/scalers/externalscaler/externalscaler_grpc.pb.go index 642a7dde4cd..5489ae58ac4 100644 --- a/pkg/scalers/externalscaler/externalscaler_grpc.pb.go +++ b/pkg/scalers/externalscaler/externalscaler_grpc.pb.go @@ -8,7 +8,6 @@ package externalscaler import ( context "context" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/pkg/scalers/liiklus/LiiklusService.pb.go b/pkg/scalers/liiklus/LiiklusService.pb.go index 9accdfa36a8..54a8f7b33c8 100644 --- a/pkg/scalers/liiklus/LiiklusService.pb.go +++ b/pkg/scalers/liiklus/LiiklusService.pb.go @@ -7,13 +7,12 @@ package liiklus import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" ) const ( diff --git a/pkg/scalers/liiklus/LiiklusService_grpc.pb.go b/pkg/scalers/liiklus/LiiklusService_grpc.pb.go index 167fd8b6a98..51480c39dae 100644 --- a/pkg/scalers/liiklus/LiiklusService_grpc.pb.go +++ b/pkg/scalers/liiklus/LiiklusService_grpc.pb.go @@ -8,7 +8,6 @@ package liiklus import ( context "context" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" From 2aa0bb553f020a8ad3a0a4837ca213d4f71acd6a Mon Sep 17 00:00:00 2001 From: Teiva Harsanyi Date: Sun, 1 Oct 2023 15:31:36 +0200 Subject: [PATCH 3/4] Fixing CI Signed-off-by: Teiva Harsanyi --- pkg/scalers/authentication/authentication_helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/scalers/authentication/authentication_helpers.go b/pkg/scalers/authentication/authentication_helpers.go index 1545afe0da3..e56485e659c 100644 --- a/pkg/scalers/authentication/authentication_helpers.go +++ b/pkg/scalers/authentication/authentication_helpers.go @@ -31,7 +31,7 @@ func GetAuthConfigs(triggerMetadata, authParams map[string]string) (out *AuthMet authTypes := strings.Split(authModes, ",") for _, t := range authTypes { - authType := strings.TrimSpace(t) + authType := Type(strings.TrimSpace(t)) switch authType { case BearerAuthType: From d410011832bea71905684be8a7171bdee379baf2 Mon Sep 17 00:00:00 2001 From: Teiva Harsanyi Date: Sun, 1 Oct 2023 15:39:09 +0200 Subject: [PATCH 4/4] Fixing CI Signed-off-by: Teiva Harsanyi --- pkg/scalers/pulsar_scaler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/scalers/pulsar_scaler.go b/pkg/scalers/pulsar_scaler.go index 131ab9b80ac..4e20320a904 100644 --- a/pkg/scalers/pulsar_scaler.go +++ b/pkg/scalers/pulsar_scaler.go @@ -205,7 +205,7 @@ func parsePulsarMetadata(config *ScalerConfig, logger logr.Logger) (pulsarMetada if authModes, authModesOk := config.TriggerMetadata[authentication.AuthModesKey]; authModesOk { config.TriggerMetadata[authentication.AuthModesKey] = fmt.Sprintf("%s,%s", authModes, authentication.TLSAuthType) } else { - config.TriggerMetadata[authentication.AuthModesKey] = authentication.TLSAuthType + config.TriggerMetadata[authentication.AuthModesKey] = string(authentication.TLSAuthType) } } }