(endpointURL url.URL, namespace string)
| 139 | } |
| 140 | |
| 141 | func (e *Exporter) getFunctions(endpointURL url.URL, namespace string) ([]types.FunctionStatus, error) { |
| 142 | timeout := 5 * time.Second |
| 143 | proxyClient := e.getHTTPClient(timeout) |
| 144 | |
| 145 | endpointURL.Path = path.Join(endpointURL.Path, "/system/functions") |
| 146 | if len(namespace) > 0 { |
| 147 | q := endpointURL.Query() |
| 148 | q.Set("namespace", namespace) |
| 149 | endpointURL.RawQuery = q.Encode() |
| 150 | } |
| 151 | |
| 152 | get, _ := http.NewRequest(http.MethodGet, endpointURL.String(), nil) |
| 153 | if e.credentials != nil { |
| 154 | get.SetBasicAuth(e.credentials.User, e.credentials.Password) |
| 155 | } |
| 156 | |
| 157 | services := []types.FunctionStatus{} |
| 158 | res, err := proxyClient.Do(get) |
| 159 | if err != nil { |
| 160 | return services, err |
| 161 | } |
| 162 | |
| 163 | var body []byte |
| 164 | if res.Body != nil { |
| 165 | defer res.Body.Close() |
| 166 | |
| 167 | if b, err := io.ReadAll(res.Body); err != nil { |
| 168 | return services, err |
| 169 | } else { |
| 170 | body = b |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | if len(body) == 0 { |
| 175 | return services, fmt.Errorf("no response body from /system/functions") |
| 176 | } |
| 177 | |
| 178 | if err := json.Unmarshal(body, &services); err != nil { |
| 179 | return services, fmt.Errorf("error unmarshalling response: %s, error: %s", |
| 180 | string(body), err) |
| 181 | } |
| 182 | |
| 183 | return services, nil |
| 184 | } |
| 185 | |
| 186 | func (e *Exporter) getNamespaces(endpointURL url.URL) ([]string, error) { |
| 187 | namespaces := []string{} |
no test coverage detected