Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
Signed-off-by: Ara Pulido <[email protected]>
  • Loading branch information
arapulido committed Feb 9, 2024
1 parent 7450dc9 commit 76a58a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
12 changes: 4 additions & 8 deletions pkg/scalers/datadog_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type datadogMetadata struct {
bearerToken string

// TriggerMetadata Cluster Agent Proxy
datadogMetricServiceUrl string
datadogMetricServiceURL string
datadogMetricName string
datadogMetricNamespace string
activationTargetValue float64
Expand Down Expand Up @@ -116,7 +116,6 @@ func NewDatadogScaler(ctx context.Context, config *scalersconfig.ScalerConfig) (
}
httpClient.Transport = kedautil.CreateHTTPTransportWithTLSConfig(config)
}

} else {
meta, err = parseDatadogAPIMetadata(config, logger)
if err != nil {
Expand Down Expand Up @@ -149,7 +148,6 @@ func parseDatadogQuery(q string) (bool, error) {

// buildClusterAgentURL builds the URL for the Cluster Agent Metrics API service
func buildClusterAgentURL(datadogMetricsService, datadogNamespace string, datadogMetricsServicePort int) string {

return fmt.Sprintf("https://%s.%s.svc.cluster.local:%d/apis/external.metrics.k8s.io/v1beta1", datadogMetricsService, datadogNamespace, datadogMetricsServicePort)
}

Expand Down Expand Up @@ -339,7 +337,7 @@ func parseDatadogClusterAgentMetadata(config *scalersconfig.ScalerConfig, logger
meta.datadogMetricsServicePort = 8443
}

meta.datadogMetricServiceUrl = buildClusterAgentURL(meta.datadogMetricsService, meta.datadogNamespace, meta.datadogMetricsServicePort)
meta.datadogMetricServiceURL = buildClusterAgentURL(meta.datadogMetricsService, meta.datadogNamespace, meta.datadogMetricsServicePort)

meta.unsafeSsl = false
if val, ok := config.AuthParams["unsafeSsl"]; ok {
Expand Down Expand Up @@ -612,7 +610,7 @@ func (s *datadogScaler) getDatadogMetricValue(req *http.Request) (float64, error
}

defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)

if resp.StatusCode != http.StatusOK {
r := gjson.GetBytes(body, "message")
Expand All @@ -639,7 +637,6 @@ func (s *datadogScaler) getDatadogMetricValue(req *http.Request) (float64, error
}

func (s *datadogScaler) getDatadogClusterAgentHTTPRequest(ctx context.Context, url string) (*http.Request, error) {

var req *http.Request
var err error

Expand Down Expand Up @@ -682,13 +679,12 @@ func (s *datadogScaler) GetMetricSpecForScaling(context.Context) []v2.MetricSpec

// GetMetricsAndActivity returns value for a supported metric and an error if there is a problem getting the metric
func (s *datadogScaler) GetMetricsAndActivity(ctx context.Context, metricName string) ([]external_metrics.ExternalMetricValue, bool, error) {

var metric external_metrics.ExternalMetricValue
var num float64
var err error

if s.useClusterAgentProxy {
url := buildMetricURL(s.metadata.datadogMetricServiceUrl, s.metadata.datadogMetricNamespace, s.metadata.hpaMetricName)
url := buildMetricURL(s.metadata.datadogMetricServiceURL, s.metadata.datadogMetricNamespace, s.metadata.hpaMetricName)

req, err := s.getDatadogClusterAgentHTTPRequest(ctx, url)
if (err != nil) || (req == nil) {
Expand Down
1 change: 0 additions & 1 deletion pkg/scalers/datadog_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ var datadogMetricIdentifiers = []datadogMetricIdentifier{
}

func TestDatadogGetMetricSpecForScaling(t *testing.T) {

var err error
var meta *datadogMetadata

Expand Down

0 comments on commit 76a58a9

Please sign in to comment.