Skip to content

Commit 8f6280b

Browse files
committed
Fix golangci error output
Signed-off-by: dttung2905 <[email protected]>
1 parent 0f8c79b commit 8f6280b

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

pkg/scalers/datadog_scaler.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type datadogMetadata struct {
5252
ActivationTargetValue float64 `keda:"name=activationTargetValue, order=triggerMetadata, default=0"`
5353

5454
// AuthParams Datadog API
55-
ApiKey string `keda:"name=apiKey, order=authParams, optional"`
55+
APIKey string `keda:"name=apiKey, order=authParams, optional"`
5656
AppKey string `keda:"name=appKey, order=authParams, optional"`
5757
DatadogSite string `keda:"name=datadogSite, order=authParams, default=datadoghq.com"`
5858

@@ -70,10 +70,8 @@ type datadogMetadata struct {
7070
UseFiller bool
7171
TargetValue float64 `keda:"name=targetValue;queryValue, order=triggerMetadata, default=-1"`
7272
vType v2.MetricTargetType
73-
triggerIndex int
7473
}
7574

76-
const maxString = "max"
7775
const avgString = "average"
7876

7977
var filter *regexp.Regexp
@@ -157,13 +155,12 @@ func parseDatadogAPIMetadata(config *scalersconfig.ScalerConfig, logger logr.Log
157155

158156
if meta.Age < 60 {
159157
logger.Info("selecting a window smaller than 60 seconds can cause Datadog not finding a metric value for the query")
160-
161158
}
162159
if meta.AppKey == "" {
163160
return nil, fmt.Errorf("error parsing Datadog metadata: missing AppKey")
164161
}
165-
if meta.ApiKey == "" {
166-
return nil, fmt.Errorf("error parsing Datadog metadata: missing ApiKey")
162+
if meta.APIKey == "" {
163+
return nil, fmt.Errorf("error parsing Datadog metadata: missing APIKey")
167164
}
168165
if meta.TargetValue == -1 {
169166
if config.AsMetricSource {
@@ -203,6 +200,7 @@ func parseDatadogAPIMetadata(config *scalersconfig.ScalerConfig, logger logr.Log
203200
} else {
204201
meta.HpaMetricName = "datadogmetric@" + meta.DatadogMetricNamespace + ":" + meta.DatadogMetricName
205202
}
203+
206204
return meta, nil
207205
}
208206

@@ -264,7 +262,7 @@ func newDatadogAPIConnection(ctx context.Context, meta *datadogMetadata, config
264262
datadog.ContextAPIKeys,
265263
map[string]datadog.APIKey{
266264
"apiKeyAuth": {
267-
Key: meta.ApiKey,
265+
Key: meta.APIKey,
268266
},
269267
"appKeyAuth": {
270268
Key: meta.AppKey,
@@ -305,7 +303,7 @@ func (s *datadogScaler) getQueryResult(ctx context.Context) (float64, error) {
305303
datadog.ContextAPIKeys,
306304
map[string]datadog.APIKey{
307305
"apiKeyAuth": {
308-
Key: s.metadata.ApiKey,
306+
Key: s.metadata.APIKey,
309307
},
310308
"appKeyAuth": {
311309
Key: s.metadata.AppKey,
@@ -546,7 +544,6 @@ func (s *datadogMetadata) Validate() error {
546544
default:
547545
return fmt.Errorf("err incorrect value for authMode is given: %s", s.AuthMode)
548546
}
549-
550547
}
551548
return nil
552549
}

pkg/scalers/datadog_scaler_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ var testDatadogClusterAgentMetadata = []datadogAuthMetadataTestData{
108108
{"", map[string]string{"useClusterAgentProxy": "true", "datadogMetricName": "nginx-hits", "datadogMetricNamespace": "default", "targetValue": "2", "type": "global"}, map[string]string{"token": "token", "datadogNamespace": "datadog", "datadogMetricsService": "datadog-cluster-agent-metrics-api", "unsafeSsl": "true", "authMode": "bearer"}, false},
109109

110110
// TODO: Fix this failed test case
111-
//both metadata type and trigger type
111+
// both metadata type and trigger type
112112
{v2.AverageValueMetricType, map[string]string{"useClusterAgentProxy": "true", "datadogMetricName": "nginx-hits", "datadogMetricNamespace": "default", "targetValue": "2", "type": "global"}, map[string]string{"token": "token", "datadogNamespace": "datadog", "datadogMetricsService": "datadog-cluster-agent-metrics-api", "unsafeSsl": "true", "authMode": "bearer"}, true},
113-
//missing DatadogMetric name
113+
// missing DatadogMetric name
114114
{"", map[string]string{"useClusterAgentProxy": "true", "datadogMetricNamespace": "default", "targetValue": "2", "type": "global"}, map[string]string{"token": "token", "datadogNamespace": "datadog", "datadogMetricsService": "datadog-cluster-agent-metrics-api", "unsafeSsl": "true", "authMode": "bearer"}, true},
115115
// missing DatadogMetric namespace
116116
{"", map[string]string{"useClusterAgentProxy": "true", "datadogMetricName": "nginx-hits", "targetValue": "2", "type": "global"}, map[string]string{"token": "token", "datadogNamespace": "datadog", "datadogMetricsService": "datadog-cluster-agent-metrics-api", "unsafeSsl": "true", "authMode": "bearer"}, true},
@@ -139,13 +139,13 @@ var testDatadogAPIMetadata = []datadogAuthMetadataTestData{
139139
{"", map[string]string{"query": "sum:trace.redis.command.hits{env:none,service:redis}.as_count()", "queryValue": "7", "age": "60"}, map[string]string{"apiKey": "apiKey", "appKey": "appKey", "datadogSite": "datadogSite"}, false},
140140
// wrong type
141141
{"", map[string]string{"query": "sum:trace.redis.command.hits{env:none,service:redis}.as_count()", "queryValue": "7", "type": "invalid", "age": "60"}, map[string]string{"apiKey": "apiKey", "appKey": "appKey", "datadogSite": "datadogSite"}, true},
142-
//both metadata type and trigger type
142+
// both metadata type and trigger type
143143
{v2.AverageValueMetricType, map[string]string{"query": "sum:trace.redis.command.hits{env:none,service:redis}.as_count()", "queryValue": "7", "type": "average", "age": "60"}, map[string]string{"apiKey": "apiKey", "appKey": "appKey", "datadogSite": "datadogSite"}, true},
144-
//missing query
144+
// missing query
145145
{"", map[string]string{"queryValue": "7", "type": "average", "age": "60"}, map[string]string{"apiKey": "apiKey", "appKey": "appKey", "datadogSite": "datadogSite"}, true},
146-
//missing queryValue
146+
// missing queryValue
147147
{"", map[string]string{"query": "sum:trace.redis.command.hits{env:none,service:redis}.as_count()", "type": "average", "age": "60"}, map[string]string{"apiKey": "apiKey", "appKey": "appKey", "datadogSite": "datadogSite"}, true},
148-
//wrong query value type
148+
// wrong query value type
149149
{"", map[string]string{"query": "sum:trace.redis.command.hits{env:none,service:redis}.as_count()", "queryValue": "notanint", "type": "average", "age": "60"}, map[string]string{"apiKey": "apiKey", "appKey": "appKey", "datadogSite": "datadogSite"}, true},
150150
// wrong queryAggregator value
151151
{"", map[string]string{"query": "sum:trace.redis.command.hits{env:none,service:redis}.as_count()", "queryValue": "notanint", "queryAggegrator": "1.0", "type": "average", "age": "60"}, map[string]string{"apiKey": "apiKey", "appKey": "appKey", "datadogSite": "datadogSite"}, true},

0 commit comments

Comments
 (0)