Skip to content

Commit cfd20d4

Browse files
authored
chore: remove refs to deprecated io/ioutil (#111)
Signed-off-by: guoguangwu <[email protected]>
1 parent 9a126ff commit cfd20d4

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

pkg/client/acr/acr.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8-
"io/ioutil"
8+
"io"
99
"net/http"
1010
"sync"
1111
"time"
@@ -140,7 +140,7 @@ func (c *Client) getManifestsWithClient(ctx context.Context, client *acrClient,
140140
}
141141

142142
if resp.StatusCode != 200 {
143-
body, err := ioutil.ReadAll(resp.Body)
143+
body, err := io.ReadAll(resp.Body)
144144
if err != nil {
145145
return nil, fmt.Errorf("bad request for image host %s", host)
146146
}

pkg/client/docker/docker.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8-
"io/ioutil"
8+
"io"
99
"net/http"
1010
"strings"
1111
"time"
@@ -138,7 +138,7 @@ func (c *Client) doRequest(ctx context.Context, url string) (*TagResponse, error
138138
return nil, fmt.Errorf("failed to get docker image: %s", err)
139139
}
140140

141-
body, err := ioutil.ReadAll(resp.Body)
141+
body, err := io.ReadAll(resp.Body)
142142
if err != nil {
143143
return nil, err
144144
}
@@ -171,7 +171,7 @@ func basicAuthSetup(ctx context.Context, client *http.Client, opts Options) (str
171171
return "", err
172172
}
173173

174-
body, err := ioutil.ReadAll(resp.Body)
174+
body, err := io.ReadAll(resp.Body)
175175
if err != nil {
176176
return "", err
177177
}

pkg/client/gcr/gcr.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
"strconv"
1010
"time"
@@ -70,7 +70,7 @@ func (c *Client) Tags(ctx context.Context, host, repo, image string) ([]api.Imag
7070
return nil, fmt.Errorf("failed to get docker image: %s", err)
7171
}
7272

73-
body, err := ioutil.ReadAll(resp.Body)
73+
body, err := io.ReadAll(resp.Body)
7474
if err != nil {
7575
return nil, err
7676
}

pkg/client/selfhosted/selfhosted.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import (
77
"encoding/json"
88
"errors"
99
"fmt"
10-
"io/ioutil"
10+
"io"
1111
"net/http"
12+
"os"
1213
"regexp"
1314
"strings"
1415
"time"
@@ -228,7 +229,7 @@ func (c *Client) doRequest(ctx context.Context, url, header string, obj interfac
228229
return nil, fmt.Errorf("failed to get docker image: %s", err)
229230
}
230231

231-
body, err := ioutil.ReadAll(resp.Body)
232+
body, err := io.ReadAll(resp.Body)
232233
if err != nil {
233234
return nil, err
234235
}
@@ -267,7 +268,7 @@ func (c *Client) setupBasicAuth(ctx context.Context, url, tokenPath string) (str
267268
req.URL, err)
268269
}
269270

270-
body, err := ioutil.ReadAll(resp.Body)
271+
body, err := io.ReadAll(resp.Body)
271272
if err != nil {
272273
return "", err
273274
}
@@ -292,7 +293,7 @@ func newTLSConfig(insecure bool, CAPath string) (*tls.Config, error) {
292293
}
293294

294295
if CAPath != "" {
295-
certs, err := ioutil.ReadFile(CAPath)
296+
certs, err := os.ReadFile(CAPath)
296297
if err != nil {
297298
return nil, fmt.Errorf("Failed to append %q to RootCAs: %v", CAPath, err)
298299
}

0 commit comments

Comments
 (0)