Skip to content

Commit

Permalink
fixing transport client
Browse files Browse the repository at this point in the history
Signed-off-by: aman-bansal <bansalaman2905@gmail.com>
  • Loading branch information
aman-bansal committed Sep 11, 2020
1 parent 393ddc7 commit 56539f9
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/scalers/metrics_api_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,26 @@ func NewMetricsAPIScaler(resolvedEnv, metadata, authParams map[string]string) (S
return nil, fmt.Errorf("error parsing metric API metadata: %s", err)
}

var transport *http.Transport
if meta.enableTLS {
config, err := kedautil.NewTLSConfig(meta.cert, meta.key, meta.ca)
if err != nil {
return nil, err
}

transport = &http.Transport{TLSClientConfig: config}
transport := &http.Transport{TLSClientConfig: config}
return &metricsAPIScaler{
metadata: meta,
client: &http.Client{
Timeout: 3 * time.Second,
Transport: transport,
},
}, nil
}

return &metricsAPIScaler{
metadata: meta,
client: &http.Client{
Timeout: 3 * time.Second,
Transport: transport,
Timeout: 3 * time.Second,
},
}, nil
}
Expand Down Expand Up @@ -305,6 +310,11 @@ func getMetricAPIServerRequest(meta *metricsAPIScalerMetadata) (*http.Request, e
}

req.SetBasicAuth(meta.username, meta.password)
} else {
req, err = http.NewRequest("GET", meta.url, nil)
if err != nil {
return nil, err
}
}

return req, nil
Expand Down

0 comments on commit 56539f9

Please sign in to comment.