Skip to content

Commit

Permalink
fix: solve golangci errors
Browse files Browse the repository at this point in the history
Signed-off-by: Xoán Mallón <[email protected]>
  • Loading branch information
xoanmm committed Mar 15, 2022
1 parent dae4213 commit aee976b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 6 additions & 6 deletions pkg/scalers/prometheus_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (
promQuery = "query"
promThreshold = "threshold"
promNamespace = "namespace"
promCortexScopeOrgId = "cortexOrgId"
promCortexScopeOrgID = "cortexOrgID"
promCortexHeaderKey = "X-Scope-OrgID"
)

Expand All @@ -44,7 +44,7 @@ type prometheusMetadata struct {
prometheusAuth *authentication.AuthMeta
namespace string
scalerIndex int
cortexOrgId string
cortexOrgID string
}

type promQueryResult struct {
Expand Down Expand Up @@ -121,8 +121,8 @@ func parsePrometheusMetadata(config *ScalerConfig) (meta *prometheusMetadata, er
meta.namespace = val
}

if val, ok := config.TriggerMetadata[promCortexScopeOrgId]; ok && val != "" {
meta.cortexOrgId = val
if val, ok := config.TriggerMetadata[promCortexScopeOrgID]; ok && val != "" {
meta.cortexOrgID = val
}

meta.scalerIndex = config.ScalerIndex
Expand Down Expand Up @@ -189,8 +189,8 @@ func (s *prometheusScaler) ExecutePromQuery(ctx context.Context) (float64, error
req.SetBasicAuth(s.metadata.prometheusAuth.Username, s.metadata.prometheusAuth.Password)
}

if s.metadata.cortexOrgId != "" {
req.Header.Add(promCortexHeaderKey, s.metadata.cortexOrgId)
if s.metadata.cortexOrgID != "" {
req.Header.Add(promCortexHeaderKey, s.metadata.cortexOrgID)
}

r, err := s.httpClient.Do(req)
Expand Down
3 changes: 1 addition & 2 deletions pkg/scalers/prometheus_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,12 @@ func TestPrometheusScalerCortexHeader(t *testing.T) {
scaler := prometheusScaler{
metadata: &prometheusMetadata{
serverAddress: server.URL,
cortexOrgId: cortexOrgValue,
cortexOrgID: cortexOrgValue,
},
httpClient: http.DefaultClient,
}

_, err := scaler.ExecutePromQuery(context.TODO())

assert.NoError(t, err)

}

0 comments on commit aee976b

Please sign in to comment.