Skip to content

Commit 6f14057

Browse files
committed
Migrate away from deprecated ioutil
1 parent 25d519f commit 6f14057

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

pkg/config/generator.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package config
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
76
"log"
7+
"os"
88
"path"
99
"path/filepath"
1010
"strings"
@@ -36,7 +36,7 @@ func (m *Generator) Load(paths []string) error {
3636
upstreamDefined := make(map[string]bool)
3737

3838
for _, p := range paths {
39-
files, err := ioutil.ReadDir(p)
39+
files, err := os.ReadDir(p)
4040
if err != nil {
4141
return err
4242
}
@@ -57,7 +57,7 @@ func (m *Generator) Load(paths []string) error {
5757
}
5858
repoProxies = append(repoProxies, rpmRepoProxies...)
5959
for _, upstream := range rpmUpstreams {
60-
if _, ok := upstreamDefined[upstream.Name]; !ok { // Dedupe upstreams
60+
if _, ok := upstreamDefined[upstream.Name]; !ok { // Dedupe upstreams
6161
upstreamDefined[upstream.Name] = true
6262
upstreams = append(upstreams, upstream)
6363
}
@@ -76,7 +76,7 @@ func (m *Generator) Load(paths []string) error {
7676
if len(m.configPath) == 0 {
7777
log.Printf("template:\n%s", buf.String())
7878
} else {
79-
if err := ioutil.WriteFile(m.configPath, buf.Bytes(), 0640); err != nil {
79+
if err := os.WriteFile(m.configPath, buf.Bytes(), 0640); err != nil {
8080
return err
8181
}
8282
}

pkg/config/rpm.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package config
33
import (
44
b64 "encoding/base64"
55
"fmt"
6-
"io/ioutil"
76
"log"
87
"net"
98
"net/url"
9+
"os"
1010
"strings"
1111

1212
"github.com/go-ini/ini"
@@ -35,14 +35,14 @@ func getUsernamePassword(section *ini.Section) (string, error) {
3535
return "", fmt.Errorf("%s and %s must both be specified", usernameFileKey, passwordFileKey)
3636
}
3737
// Load username from file and remove nonstandard key
38-
usernameIn, err := ioutil.ReadFile(section.Key(usernameFileKey).Value())
38+
usernameIn, err := os.ReadFile(section.Key(usernameFileKey).Value())
3939
if err != nil {
4040
return "", fmt.Errorf("unable to read %s: %v", usernameFileKey, err)
4141
}
4242
section.DeleteKey(usernameFileKey)
4343

4444
// Load password from file and remove nonstandard key
45-
passwordIn, err := ioutil.ReadFile(section.Key(passwordFileKey).Value())
45+
passwordIn, err := os.ReadFile(section.Key(passwordFileKey).Value())
4646
if err != nil {
4747
return "", fmt.Errorf("unable to read %s: %v", passwordFileKey, err)
4848
}
@@ -123,9 +123,9 @@ func LoadRPMRepoUpstreams(iniFile string) ([]Upstream, []RepoProxy, error) {
123123
}
124124

125125
upstream := Upstream{
126-
Repo: true,
127-
Name: proxyPassURL.Host,
128-
Hosts: hosts,
126+
Repo: true,
127+
Name: proxyPassURL.Host,
128+
Hosts: hosts,
129129
}
130130

131131
repoProxy := RepoProxy{

0 commit comments

Comments
 (0)