Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/cmd/dockerregistry/dockerregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"os/signal"
Expand Down Expand Up @@ -252,7 +251,7 @@ func NewServer(ctx context.Context, dockerConfig *configuration.Configuration, e
pool := x509.NewCertPool()

for _, ca := range dockerConfig.HTTP.TLS.ClientCAs {
caPem, err := ioutil.ReadFile(ca)
caPem, err := os.ReadFile(ca)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/dockerregistry/server/blobdescriptorservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package server
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestBlobDescriptorServiceIsApplied(t *testing.T) {
}

if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusAccepted {
content, err := ioutil.ReadAll(resp.Body)
content, err := io.ReadAll(resp.Body)
if err != nil {
t.Errorf("[%s] failed to read body: %v", tc.name, err)
} else if len(content) > 0 {
Expand Down
3 changes: 1 addition & 2 deletions pkg/dockerregistry/server/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/url"
"os"
"reflect"
Expand Down Expand Up @@ -181,7 +180,7 @@ type versionInfo struct {
// openshift specific configuration.
// Environment variables may be used to override configuration parameters.
func Parse(rd io.Reader) (*configuration.Configuration, *Configuration, error) {
in, err := ioutil.ReadAll(rd)
in, err := io.ReadAll(rd)
if err != nil {
return nil, nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/dockerregistry/server/signaturedispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"

kapierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -100,7 +100,7 @@ func (s *signatureHandler) Put(w http.ResponseWriter, r *http.Request) {
}

sig := signature{}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
s.handleError(s.ctx, ErrorCodeSignatureInvalid.WithDetail(err.Error()), w)
return
Expand Down
4 changes: 2 additions & 2 deletions pkg/dockerregistry/server/signaturedispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestSignatureGet(t *testing.T) {
t.Fatalf("unexpected response status: %v", resp.StatusCode)
}

content, err := ioutil.ReadAll(resp.Body)
content, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatalf("failed to read body: %v", err)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/dockerregistry/server/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package server

import (
"context"
"io/ioutil"
"net/http"
"os"
"testing"
Expand Down Expand Up @@ -31,7 +30,7 @@ func Test_getImportContext(t *testing.T) {
icsp := operatorfake.NewSimpleClientset().OperatorV1alpha1().ImageContentSourcePolicies()
idms := cfgfake.NewSimpleClientset().ConfigV1().ImageDigestMirrorSets()
itms := cfgfake.NewSimpleClientset().ConfigV1().ImageTagMirrorSets()
tmpCredDir, err := ioutil.TempDir("", "credentials")
tmpCredDir, err := os.MkdirTemp("", "credentials")
if err != nil {
t.Fatalf("error creating temp dir: %v", err)
}
Expand Down Expand Up @@ -129,7 +128,7 @@ func Test_getImportContext(t *testing.T) {
}

if len(tt.creds) > 0 {
if err := ioutil.WriteFile(
if err := os.WriteFile(
tmpCredDir+"/config.json", tt.creds, 0644,
); err != nil {
t.Errorf("error writing config.json: %v", err)
Expand Down
8 changes: 4 additions & 4 deletions pkg/kubernetes-common/credentialprovider/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -99,7 +99,7 @@ func ReadDockercfgFile(searchPaths []string) (cfg DockerConfig, err error) {
continue
}
klog.V(4).Infof("looking for .dockercfg at %s", absDockerConfigFileLocation)
contents, err := ioutil.ReadFile(absDockerConfigFileLocation)
contents, err := os.ReadFile(absDockerConfigFileLocation)
if os.IsNotExist(err) {
continue
}
Expand Down Expand Up @@ -147,7 +147,7 @@ func ReadDockerConfigJSONFile(searchPaths []string) (cfg DockerConfig, err error
func ReadSpecificDockerConfigJsonFile(filePath string) (cfg DockerConfig, err error) {
var contents []byte

if contents, err = ioutil.ReadFile(filePath); err != nil {
if contents, err = os.ReadFile(filePath); err != nil {
return nil, err
}
return readDockerConfigJsonFileFromBytes(contents)
Expand Down Expand Up @@ -195,7 +195,7 @@ func ReadUrl(url string, client *http.Client, header *http.Header) (body []byte,
}
}

contents, err := ioutil.ReadAll(resp.Body)
contents, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/kubernetes-common/credentialprovider/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package credentialprovider

import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand All @@ -32,7 +31,7 @@ func TestReadDockerConfigFile(t *testing.T) {
//test dockerconfig json
inputDockerconfigJsonFile := "{ \"auths\": { \"http://foo.example.com\":{\"auth\":\"Zm9vOmJhcgo=\",\"email\":\"foo@example.com\"}}}"

preferredPath, err := ioutil.TempDir("", "test_foo_bar_dockerconfigjson_")
preferredPath, err := os.MkdirTemp("", "test_foo_bar_dockerconfigjson_")
if err != nil {
t.Fatalf("Creating tmp dir fail: %v", err)
return
Expand Down
3 changes: 1 addition & 2 deletions pkg/origin-common/clientcmd/clientcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package clientcmd

import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -146,7 +145,7 @@ func (cfg *Config) bindEnv() error {
cfg.CommonConfig.BearerToken = value
}
if value, ok := getEnv("BEARER_TOKEN_FILE"); ok && len(cfg.CommonConfig.BearerToken) == 0 {
if tokenData, tokenErr := ioutil.ReadFile(value); tokenErr == nil {
if tokenData, tokenErr := os.ReadFile(value); tokenErr == nil {
cfg.CommonConfig.BearerToken = strings.TrimSpace(string(tokenData))
if len(cfg.CommonConfig.BearerToken) == 0 {
err = fmt.Errorf("BEARER_TOKEN_FILE %q was empty", value)
Expand Down
4 changes: 2 additions & 2 deletions pkg/testframework/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"sync/atomic"
Expand Down Expand Up @@ -535,7 +535,7 @@ func checkRoute(host string) error {
// if deployed registry leverages basic authentication a StatusUnauthorized will
// be returned so we consider this status as valid as well.
if res.StatusCode != http.StatusOK && res.StatusCode != http.StatusUnauthorized {
dt, err := ioutil.ReadAll(res.Body)
dt, err := io.ReadAll(res.Body)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/testutil/logrus.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package testutil

import (
"context"
"io/ioutil"
"io"
"strings"
"testing"

Expand Down Expand Up @@ -35,7 +35,7 @@ func (h *logrusHook) Fire(e *logrus.Entry) error {
func WithTestLogger(parent context.Context, t *testing.T) context.Context {
log := logrus.New()
log.Level = logrus.DebugLevel
log.Out = ioutil.Discard
log.Out = io.Discard
log.Hooks.Add(&logrusHook{t: t})
return dcontext.WithLogger(parent, logrus.NewEntry(log))
}
4 changes: 2 additions & 2 deletions test/integration/imagelayers/imagelayers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package integration

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"testing"

Expand Down Expand Up @@ -35,7 +35,7 @@ func getSchema1Manifest(repo *testframework.Repository, tag string) (distributio
return nil, fmt.Errorf("get manifest %s:%s: %s", repo.RepoName(), tag, resp.Status)
}

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("read manifest %s:%s: %v", repo.RepoName(), tag, err)
}
Expand Down
4 changes: 2 additions & 2 deletions test/integration/pullthrough/pullthrough_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"testing"
"time"
Expand Down Expand Up @@ -45,7 +45,7 @@ func testPullThroughGetManifest(baseURL string, stream *imageapiv1.ImageStreamIm
return fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("error reading manifest: %v", err)
}
Expand Down
10 changes: 5 additions & 5 deletions test/integration/v2/v2_docker_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"
"testing"
Expand Down Expand Up @@ -158,7 +158,7 @@ func TestV2RegistryGetTags(t *testing.T) {
if resp.StatusCode != http.StatusOK {
t.Fatalf("unexpected status code: %d", resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatalf("error retrieving manifest: %v", err)
}
Expand Down Expand Up @@ -188,7 +188,7 @@ func TestV2RegistryGetTags(t *testing.T) {
if resp.StatusCode != http.StatusOK {
t.Fatalf("unexpected status code: %d", resp.StatusCode)
}
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
if err != nil {
t.Fatalf("error retrieving manifest: %v", err)
}
Expand Down Expand Up @@ -347,7 +347,7 @@ func getTags(baseURL, namespace, streamName, user, token string) ([]string, erro
if resp.StatusCode != http.StatusOK {
return []string{}, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return []string{}, fmt.Errorf("error retrieving manifest: %v", err)
}
Expand Down Expand Up @@ -387,7 +387,7 @@ func ping(baseURL, user, token string) error {
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("error retrieving manifest: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions tools/import-verifier/import-verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -303,7 +302,7 @@ func mergePackages(existingPackages, currPackages []Package) []Package {
}

func loadImportRestrictions(configFile string) ([]ImportRestriction, error) {
config, err := ioutil.ReadFile(configFile)
config, err := os.ReadFile(configFile)
if err != nil {
return nil, fmt.Errorf("failed to load configuration from %s: %v", configFile, err)
}
Expand Down