@@ -13,27 +13,27 @@ import (
1313 "k8s.io/client-go/rest"
1414)
1515
16- func GetMetricValue (restConfig * rest.Config , url string , family string , expectedLabels []string ) (float64 , error ) {
17- value , err := getMetricValue (restConfig , url , family , expectedLabels , getValue )
16+ func GetMetricValue (restConfig * rest.Config , baseURL string , family string , expectedLabels []string ) (float64 , error ) {
17+ value , err := getMetricValue (restConfig , baseURL , family , expectedLabels , getValue )
1818 if value == nil {
1919 return - 1 , err
2020 }
2121 return * value , err
2222}
2323
24- func GetHistogramBuckets (restConfig * rest.Config , url string , family string , expectedLabels []string ) ([]* dto.Bucket , error ) {
25- value , err := getMetricValue (restConfig , url , family , expectedLabels , getBuckets )
24+ func GetHistogramBuckets (restConfig * rest.Config , baseURL string , family string , expectedLabels []string ) ([]* dto.Bucket , error ) {
25+ value , err := getMetricValue (restConfig , baseURL , family , expectedLabels , getBuckets )
2626 if value == nil {
2727 return nil , err
2828 }
2929 return * value , err
3030}
3131
32- func getMetricValue [T any ](restConfig * rest.Config , url string , family string , expectedLabels []string , getValue func (dto.MetricType , * dto.Metric ) (* T , error )) (* T , error ) {
32+ func getMetricValue [T any ](restConfig * rest.Config , baseURL string , family string , expectedLabels []string , getValue func (dto.MetricType , * dto.Metric ) (* T , error )) (* T , error ) {
3333 if len (expectedLabels )% 2 != 0 {
3434 return nil , fmt .Errorf ("received odd number of label arguments, labels must be key-value pairs" )
3535 }
36- uri := fmt . Sprintf ( "https://%s/ metrics", url )
36+ uri := baseURL + "/ metrics"
3737 var metrics []byte
3838
3939 client := http.Client {
@@ -128,8 +128,8 @@ func getBuckets(t dto.MetricType, m *dto.Metric) (*[]*dto.Bucket, error) {
128128}
129129
130130// GetMetricLabels return all labels (indexed by key) for all metrics of the given `family`
131- func GetMetricLabels (restConfig * rest.Config , url string , family string ) ([]map [string ]string , error ) {
132- uri := fmt . Sprintf ( "https://%s/ metrics", url )
131+ func GetMetricLabels (restConfig * rest.Config , baseURL string , family string ) ([]map [string ]string , error ) {
132+ uri := baseURL + "/ metrics"
133133 var metrics []byte
134134
135135 client := http.Client {
0 commit comments