diff --git a/caddyfile/fromlabels_test.go b/caddyfile/fromlabels_test.go index 724c60f6..fd0f3e8c 100644 --- a/caddyfile/fromlabels_test.go +++ b/caddyfile/fromlabels_test.go @@ -2,7 +2,7 @@ package caddyfile import ( "fmt" - "io/ioutil" + "os" "regexp" "strings" "testing" @@ -13,7 +13,7 @@ import ( func TestLabelsToCaddyfile(t *testing.T) { // load the list of test files from the dir - files, err := ioutil.ReadDir("./testdata/labels") + files, err := os.ReadDir("./testdata/labels") if err != nil { t.Errorf("failed to read labels dir: %s", err) } @@ -30,7 +30,7 @@ func TestLabelsToCaddyfile(t *testing.T) { filename := f.Name() t.Run(filename, func(t *testing.T) { - data, err := ioutil.ReadFile("./testdata/labels/" + filename) + data, err := os.ReadFile("./testdata/labels/" + filename) if err != nil { t.Errorf("failed to read %s dir: %s", filename, err) } diff --git a/caddyfile/marshal_test.go b/caddyfile/marshal_test.go index e90f92ae..b20ab7dc 100644 --- a/caddyfile/marshal_test.go +++ b/caddyfile/marshal_test.go @@ -1,7 +1,7 @@ package caddyfile import ( - "io/ioutil" + "os" "regexp" "strings" "testing" @@ -14,7 +14,7 @@ func TestMarshalUnmarshal(t *testing.T) { const folder = "./testdata/marshal" // load the list of test files from the dir - files, err := ioutil.ReadDir(folder) + files, err := os.ReadDir(folder) if err != nil { t.Errorf("failed to read process dir: %s", err) } @@ -31,7 +31,7 @@ func TestMarshalUnmarshal(t *testing.T) { filename := f.Name() t.Run(filename, func(t *testing.T) { - data, err := ioutil.ReadFile(folder + "/" + filename) + data, err := os.ReadFile(folder + "/" + filename) if err != nil { t.Errorf("failed to read %s dir: %s", filename, err) } diff --git a/caddyfile/merge_test.go b/caddyfile/merge_test.go index 00e8deda..22011eb1 100644 --- a/caddyfile/merge_test.go +++ b/caddyfile/merge_test.go @@ -1,7 +1,7 @@ package caddyfile import ( - "io/ioutil" + "os" "regexp" "strings" "testing" @@ -14,7 +14,7 @@ func TestMerge(t *testing.T) { const folder = "./testdata/merge" // load the list of test files from the dir - files, err := ioutil.ReadDir(folder) + files, err := os.ReadDir(folder) if err != nil { t.Errorf("failed to read process dir: %s", err) } @@ -31,7 +31,7 @@ func TestMerge(t *testing.T) { filename := f.Name() t.Run(filename, func(t *testing.T) { - data, err := ioutil.ReadFile(folder + "/" + filename) + data, err := os.ReadFile(folder + "/" + filename) if err != nil { t.Errorf("failed to read %s dir: %s", filename, err) } diff --git a/caddyfile/processor_test.go b/caddyfile/processor_test.go index a3af53e1..4cc8f71d 100644 --- a/caddyfile/processor_test.go +++ b/caddyfile/processor_test.go @@ -1,7 +1,7 @@ package caddyfile import ( - "io/ioutil" + "os" "regexp" "strings" "testing" @@ -13,7 +13,7 @@ import ( func TestProcessCaddyfile(t *testing.T) { // load the list of test files from the dir - files, err := ioutil.ReadDir("./testdata/process") + files, err := os.ReadDir("./testdata/process") if err != nil { t.Errorf("failed to read process dir: %s", err) } @@ -30,7 +30,7 @@ func TestProcessCaddyfile(t *testing.T) { filename := f.Name() t.Run(filename, func(t *testing.T) { - data, err := ioutil.ReadFile("./testdata/process/" + filename) + data, err := os.ReadFile("./testdata/process/" + filename) if err != nil { t.Errorf("failed to read %s dir: %s", filename, err) } diff --git a/docker/utils.go b/docker/utils.go index 2da76062..9559a5d2 100644 --- a/docker/utils.go +++ b/docker/utils.go @@ -1,7 +1,6 @@ package docker import ( - "io/ioutil" "os" "regexp" "runtime" @@ -38,7 +37,7 @@ func (wrapper *dockerUtils) GetCurrentContainerID() (string, error) { } func (wrapper *dockerUtils) getCurrentContainerIDFromMountInfo() (string, error) { - bytes, err := ioutil.ReadFile("/proc/self/mountinfo") + bytes, err := os.ReadFile("/proc/self/mountinfo") if err != nil { return "", err } @@ -47,7 +46,7 @@ func (wrapper *dockerUtils) getCurrentContainerIDFromMountInfo() (string, error) } func (wrapper *dockerUtils) getCurrentContainerIDFromCGroup() (string, error) { - bytes, err := ioutil.ReadFile("/proc/self/cgroup") + bytes, err := os.ReadFile("/proc/self/cgroup") if err != nil { return "", err } diff --git a/generator/generator.go b/generator/generator.go index b7f9f513..40b3a287 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -4,8 +4,8 @@ import ( "bytes" "context" "fmt" - "io/ioutil" "net" + "os" "regexp" "time" @@ -72,7 +72,7 @@ func (g *CaddyfileGenerator) GenerateCaddyfile(logger *zap.Logger) ([]byte, []st // Add caddyfile from path if g.options.CaddyfilePath != "" { - dat, err := ioutil.ReadFile(g.options.CaddyfilePath) + dat, err := os.ReadFile(g.options.CaddyfilePath) if err != nil { logger.Error("Failed to read Caddyfile", zap.String("path", g.options.CaddyfilePath), zap.Error(err)) } else { diff --git a/generator/generator_test.go b/generator/generator_test.go index 66749403..392e4e0b 100644 --- a/generator/generator_test.go +++ b/generator/generator_test.go @@ -4,7 +4,7 @@ import ( "bufio" "bytes" "fmt" - "io/ioutil" + "io" "log" "testing" @@ -31,7 +31,7 @@ const swarmIsDisabledLog = `INFO Swarm is available {"new": false}` + newLine const commonLogs = containerIdLog + ingressNetworksMapLog + swarmIsAvailableLog func init() { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) } func fmtLabel(s string) string { diff --git a/generator/labels_test.go b/generator/labels_test.go index c22d3b23..6fe51e0a 100644 --- a/generator/labels_test.go +++ b/generator/labels_test.go @@ -2,7 +2,7 @@ package generator import ( "fmt" - "io/ioutil" + "os" "regexp" "strings" "testing" @@ -12,7 +12,7 @@ import ( func TestLabelsToCaddyfile(t *testing.T) { // load the list of test files from the dir - files, err := ioutil.ReadDir("./testdata/labels") + files, err := os.ReadDir("./testdata/labels") if err != nil { t.Errorf("failed to read labels dir: %s", err) } @@ -27,7 +27,7 @@ func TestLabelsToCaddyfile(t *testing.T) { // read the test file filename := f.Name() - data, err := ioutil.ReadFile("./testdata/labels/" + filename) + data, err := os.ReadFile("./testdata/labels/" + filename) if err != nil { t.Errorf("failed to read %s dir: %s", filename, err) } diff --git a/loader.go b/loader.go index 5f91b7af..834b27a5 100644 --- a/loader.go +++ b/loader.go @@ -5,7 +5,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "path/filepath" "sync" @@ -314,7 +314,7 @@ func (dockerLoader *DockerLoader) updateServer(wg *sync.WaitGroup, server string return } - bodyBytes, err := ioutil.ReadAll(resp.Body) + bodyBytes, err := io.ReadAll(resp.Body) if err != nil { log.Error("Failed to read response from", zap.String("server", server), zap.Error(err)) return