Skip to content

Commit

Permalink
Update precommit and golangci-lint
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Turrado <[email protected]>
  • Loading branch information
JorTurFer committed Nov 2, 2024
1 parent 3e79d6a commit ff00d97
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ jobs:
with:
go-version: "1.23"
- name: Get golangci
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.1
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
- uses: pre-commit/[email protected]

trivy-scan:
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
default_stages: [commit, push]
minimum_pre_commit_version: "1.20.0"
default_stages: [pre-commit, pre-push]
minimum_pre_commit_version: "4.0.0"
exclude: (^vendor/|^pkg/generated/)
repos:
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.3.5
rev: v0.5.1
hooks:
- id: go-fmt
name: Run go fmt against the code
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: detect-private-key
Expand All @@ -17,7 +17,7 @@ repos:
- id: check-merge-conflict
- id: mixed-line-ending
- repo: https://github.com/thlorenz/doctoc.git
rev: v2.0.0
rev: v2.2.0
hooks:
- id: doctoc
name: Add TOC for md files
Expand Down
2 changes: 1 addition & 1 deletion controllers/keda/scaledjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (r *ScaledJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
// Check jobTargetRef is specified
if scaledJob.Spec.JobTargetRef == nil {
errMsg := "ScaledJob.spec.jobTargetRef not found"
err := fmt.Errorf(errMsg)
err := fmt.Errorf("%s", errMsg)
reqLogger.Error(err, errMsg)
r.EventEmitter.Emit(scaledJob, req.NamespacedName.Namespace, corev1.EventTypeWarning, eventingv1alpha1.ScaledJobFailedType, eventreason.ScaledJobCheckFailed, errMsg)
return ctrl.Result{}, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/metricscollector/opentelemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func NewOtelMetrics(options ...metric.Option) *OtelMetrics {
}

if err != nil {
fmt.Printf("Error:" + err.Error())
fmt.Printf("Error: %s", err.Error())
return nil
}
options = []metric.Option{metric.WithReader(metric.NewPeriodicReader(exporter))}
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/apache_kafka_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ func (s *apacheKafkaScaler) Close(context.Context) error {

func (s *apacheKafkaScaler) GetMetricSpecForScaling(context.Context) []v2.MetricSpec {
var metricName string
if s.metadata.Topic != nil && len(s.metadata.Topic) > 0 {
if len(s.metadata.Topic) > 0 {
metricName = fmt.Sprintf("kafka-%s", strings.Join(s.metadata.Topic, ","))
} else {
metricName = fmt.Sprintf("kafka-%s-topics", s.metadata.Group)
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/aws_cloudwatch_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func (s *awsCloudwatchScaler) GetCloudwatchMetrics(ctx context.Context) (float64
if len(output.MetricDataResults) > 0 && len(output.MetricDataResults[0].Values) == 0 && !s.metadata.IgnoreNullValues {
emptyMetricsErrMsg := "empty metric data received, ignoreNullValues is false, returning error"
s.logger.Error(nil, emptyMetricsErrMsg)
return -1, fmt.Errorf(emptyMetricsErrMsg)
return -1, fmt.Errorf("%s", emptyMetricsErrMsg)
}

var metricValue float64
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/azure_monitor_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (s *azureMonitorScaler) requestMetric(ctx context.Context) (float64, error)
return -1, err
}

if response.Value == nil || len(response.Value) == 0 {
if len(response.Value) == 0 {
err := fmt.Errorf("got an empty response for metric %s/%s and aggregate type %s", "azMetricRequest.ResourceProviderNamespace", "azMetricRequest.MetricName", "azMetricRequest.Aggregation")
return -1, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/scalers/cassandra_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ func TestParseCassandraTLS(t *testing.T) {
if meta.cert != testData.authParams["cert"] {
err := assertCertContents(testData, meta, "cert")
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
}
if meta.key != testData.authParams["key"] {
err := assertCertContents(testData, meta, "key")
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/huawei_cloudeye_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (s *huaweiCloudeyeScaler) GetCloudeyeMetrics() (float64, error) {

var metricValue float64

if metricdatas[0].Datapoints != nil && len(metricdatas[0].Datapoints) > 0 {
if len(metricdatas[0].Datapoints) > 0 {
v, ok := metricdatas[0].Datapoints[0][s.metadata.metricFilter].(float64)
if ok {
metricValue = v
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/ibmmq_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (s *ibmmqScaler) getQueueDepthViaHTTP(ctx context.Context) (int64, error) {
return 0, fmt.Errorf("failed to parse JSON: %w", err)
}

if response.CommandResponse == nil || len(response.CommandResponse) == 0 {
if len(response.CommandResponse) == 0 {
return 0, fmt.Errorf("failed to parse response from REST call")
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/scalers/kafka_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,13 @@ func TestKafkaAuthParamsInTriggerAuthentication(t *testing.T) {
if testData.authParams["keytab"] != "" {
err := testFileContents(testData, meta, "keytab")
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
}
if !testData.isError {
err := testFileContents(testData, meta, "kerberosConfig")
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
}
if meta.kerberosServiceName != testData.authParams["kerberosServiceName"] {
Expand Down
4 changes: 2 additions & 2 deletions pkg/scalers/openstack/keystone_authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (keystone *KeystoneAuthRequest) getToken(ctx context.Context) (string, erro
return "", err
}

return "", fmt.Errorf(string(errBody))
return "", fmt.Errorf("%s", string(errBody))
}

// getCatalog retrives the OpenStack catalog according to the current authorization
Expand Down Expand Up @@ -343,7 +343,7 @@ func (keystone *KeystoneAuthRequest) getCatalog(ctx context.Context, token strin
return nil, err
}

return nil, fmt.Errorf(string(errBody))
return nil, fmt.Errorf("%s", string(errBody))
}

// getServiceURL retrieves a public URL for an OpenStack project from the OpenStack catalog
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/openstack_metrics_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (s *openstackMetricScaler) readOpenstackMetrics(ctx context.Context) (float
return defaultValueWhenError, readError
}

return defaultValueWhenError, fmt.Errorf(string(bodyError))
return defaultValueWhenError, fmt.Errorf("%s", string(bodyError))
}

m := measureResult{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/rabbitmq_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ func getMaximum(q []queueInfo) (int, int, float64) {
// Mask host for log purposes
func (s *rabbitMQScaler) anonymizeRabbitMQError(err error) error {
errorMessage := fmt.Sprintf("error inspecting rabbitMQ: %s", err)
return fmt.Errorf(rabbitMQAnonymizePattern.ReplaceAllString(errorMessage, "user:password@"))
return fmt.Errorf("%s", rabbitMQAnonymizePattern.ReplaceAllString(errorMessage, "user:password@"))
}

// connectionName is used to provide a deterministic AMQP connection name when
Expand Down
2 changes: 1 addition & 1 deletion pkg/scaling/resolver/scale_resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func ResolveScaleTargetPodSpec(ctx context.Context, kubeClient client.Client, sc
podTemplateSpec.Spec = withPods.Spec.Template.Spec
}

if podTemplateSpec.Spec.Containers == nil || len(podTemplateSpec.Spec.Containers) == 0 {
if len(podTemplateSpec.Spec.Containers) == 0 {
logger.V(1).Info("There aren't any containers found in the ScaleTarget, therefore it is no possible to inject environment properties", "scaleTargetRef.Name", obj.Spec.ScaleTargetRef.Name)
return nil, "", nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/scaling/scale_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ func (h *scaleHandler) GetScaledObjectMetrics(ctx context.Context, scaledObjectN
}

if len(matchingMetrics) == 0 {
return nil, fmt.Errorf("no matching metrics found for " + metricsName)
return nil, fmt.Errorf("no matching metrics found for %s", metricsName)
}

// handle scalingModifiers here and simply return the matchingMetrics
Expand Down

0 comments on commit ff00d97

Please sign in to comment.