summaryrefslogtreecommitdiff
path: root/config/config.go
diff options
context:
space:
mode:
authorRandall Meyer <[email protected]>2023-02-15 10:34:04 -0800
committerRandall Meyer <[email protected]>2023-02-20 10:28:21 -0800
commitaba993ed378297f48ff6be18b17c6a963d3fd190 (patch)
treec78832e8851c2dc39c4db56fbb3b2469802e9f1f /config/config.go
parente0305ad041549f5f7ff90baa9cae58cf88a9c346 (diff)
lint/deprecation cleanup
Diffstat (limited to 'config/config.go')
-rw-r--r--config/config.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/config/config.go b/config/config.go
index 8d9eaa5..f223ec5 100644
--- a/config/config.go
+++ b/config/config.go
@@ -19,7 +19,6 @@ import (
"encoding/json"
"fmt"
"io"
- "io/ioutil"
"net/http"
"net/url"
"strings"
@@ -59,7 +58,16 @@ func (c *Config) Get(configHost string, configPath string, keyLogger io.Writer)
configPath = "/" + configPath
}
c.Source = fmt.Sprintf("https://%s%s", configHost, configPath)
- resp, err := configClient.Get(c.Source)
+ req, err := http.NewRequest("GET", c.Source, nil)
+ if err != nil {
+ return fmt.Errorf(
+ "Error: Could not create request for configuration host %s: %v\n",
+ configHost,
+ err,
+ )
+ }
+
+ resp, err := configClient.Do(req)
if err != nil {
return fmt.Errorf(
"could not connect to configuration host %s: %v",
@@ -67,8 +75,17 @@ func (c *Config) Get(configHost string, configPath string, keyLogger io.Writer)
err,
)
}
+ defer resp.Body.Close()
+
+ if resp.StatusCode != 200 {
+ return fmt.Errorf(
+ "Error: Configuration host %s returned %d for config request\n",
+ configHost,
+ resp.StatusCode,
+ )
+ }
- jsonConfig, err := ioutil.ReadAll(resp.Body)
+ jsonConfig, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf(
"could not read configuration content downloaded from %s: %v",