Update deprecated io/ioutil functions
ioutil has been deprecated since go 1.16, this fixes all of the deprecated functions we are using: ioutil.ReadFile -> os.ReadFile ioutil.ReadAll -> io.ReadAll ioutil.WriteFile -> os.WriteFile ioutil.TempFile -> os.CreateTemp ioutil.TempDir -> os.MkdirTemp All of the above are a simple name change, the function arguments and results are exactly the same as before. ioutil.ReadDir -> os.ReadDir now returns a os.DirEntry but the IsDir and Name functions work the same. The difference is that the FileInfo must be retrieved with the Info() function which can also return an error. These were identified by running: golangci-lint run --build-tags=integration ./...
This commit is contained in:
parent
0e4a5b34b2
commit
7a4bb863dd
37 changed files with 113 additions and 126 deletions
|
|
@ -1,10 +1,10 @@
|
|||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -37,7 +37,7 @@ func (ckp certificateKeyPair) key() string {
|
|||
}
|
||||
|
||||
func newSelfSignedCertificateKeyPair(subj string) (*certificateKeyPair, error) {
|
||||
dir, err := ioutil.TempDir("", "osbuild-auth-tests-")
|
||||
dir, err := os.MkdirTemp("", "osbuild-auth-tests-")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot create a temporary directory for the certificate: %v", err)
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@ func (c ca) key() string {
|
|||
}
|
||||
|
||||
func newCA(subj string) (*ca, error) {
|
||||
baseDir, err := ioutil.TempDir("", "osbuild-auth-tests-ca")
|
||||
baseDir, err := os.MkdirTemp("", "osbuild-auth-tests-ca")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot create a temporary dir for a new CA: %v", err)
|
||||
}
|
||||
|
|
@ -139,7 +139,7 @@ func newCA(subj string) (*ca, error) {
|
|||
}
|
||||
|
||||
func (c ca) newCertificateKeyPair(subj, extensions, addext string) (*certificateKeyPair, error) {
|
||||
dir, err := ioutil.TempDir("", "osbuild-auth-tests-")
|
||||
dir, err := os.MkdirTemp("", "osbuild-auth-tests-")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot create a temporary directory for the certificate: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import (
|
|||
"crypto/x509"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
|
@ -24,7 +24,7 @@ type connectionConfig struct {
|
|||
}
|
||||
|
||||
func createTLSConfig(config *connectionConfig) (*tls.Config, error) {
|
||||
caCertPEM, err := ioutil.ReadFile(config.CACertFile)
|
||||
caCertPEM, err := os.ReadFile(config.CACertFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -160,7 +160,7 @@ func TestStatusCommands(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSourcesCommands(t *testing.T) {
|
||||
sources_toml, err := ioutil.TempFile("", "SOURCES-*.TOML")
|
||||
sources_toml, err := os.CreateTemp("", "SOURCES-*.TOML")
|
||||
require.NoErrorf(t, err, "Could not create temporary file: %v", err)
|
||||
defer os.Remove(sources_toml.Name())
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ func getLogs(t *testing.T, uuid uuid.UUID) string {
|
|||
}
|
||||
|
||||
func pushBlueprint(t *testing.T, bp *blueprint.Blueprint) {
|
||||
tmpfile, err := ioutil.TempFile("", "osbuild-test-")
|
||||
tmpfile, err := os.CreateTemp("", "osbuild-test-")
|
||||
require.Nilf(t, err, "Could not create temporary file: %v", err)
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
|
|
@ -386,10 +386,10 @@ func runComposer(t *testing.T, command ...string) []byte {
|
|||
err = cmd.Start()
|
||||
require.Nilf(t, err, "Could not start command: %v", err)
|
||||
|
||||
contents, err := ioutil.ReadAll(stdout)
|
||||
contents, err := io.ReadAll(stdout)
|
||||
require.NoError(t, err, "Could not read stdout from command")
|
||||
|
||||
errcontents, err := ioutil.ReadAll(stderr)
|
||||
errcontents, err := io.ReadAll(stderr)
|
||||
require.NoError(t, err, "Could not read stderr from command")
|
||||
|
||||
err = cmd.Wait()
|
||||
|
|
@ -453,8 +453,8 @@ func NewTemporaryWorkDir(t *testing.T, pattern string) TemporaryWorkDir {
|
|||
d.OldWorkDir, err = os.Getwd()
|
||||
require.Nilf(t, err, "os.GetWd: %v", err)
|
||||
|
||||
d.Path, err = ioutil.TempDir("", pattern)
|
||||
require.Nilf(t, err, "ioutil.TempDir: %v", err)
|
||||
d.Path, err = os.MkdirTemp("", pattern)
|
||||
require.Nilf(t, err, "os.MkdirTemp: %v", err)
|
||||
|
||||
err = os.Chdir(d.Path)
|
||||
require.Nilf(t, err, "os.ChDir: %v", err)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import (
|
|||
"crypto/x509"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
|
|
@ -389,7 +388,7 @@ func createTLSConfig(c *connectionConfig) (*tls.Config, error) {
|
|||
var roots *x509.CertPool
|
||||
|
||||
if c.CACertFile != "" {
|
||||
caCertPEM, err := ioutil.ReadFile(c.CACertFile)
|
||||
caCertPEM, err := os.ReadFile(c.CACertFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -574,7 +573,7 @@ func guessPipelineToExport(rawManifest json.RawMessage) string {
|
|||
// tests the result
|
||||
func runTestcase(t *testing.T, testcase testcaseStruct, store string) {
|
||||
_ = os.Mkdir("/var/lib/osbuild-composer-tests", 0755)
|
||||
outputDirectory, err := ioutil.TempDir("/var/lib/osbuild-composer-tests", "osbuild-image-tests-*")
|
||||
outputDirectory, err := os.MkdirTemp("/var/lib/osbuild-composer-tests", "osbuild-image-tests-*")
|
||||
require.NoError(t, err, "error creating temporary output directory")
|
||||
|
||||
defer func() {
|
||||
|
|
@ -594,7 +593,7 @@ func runTestcase(t *testing.T, testcase testcaseStruct, store string) {
|
|||
|
||||
// getAllCases returns paths to all testcases in the testcase directory
|
||||
func getAllCases() ([]string, error) {
|
||||
cases, err := ioutil.ReadDir(constants.TestPaths.TestCasesDirectory)
|
||||
cases, err := os.ReadDir(constants.TestPaths.TestCasesDirectory)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot list test cases: %v", err)
|
||||
}
|
||||
|
|
@ -615,7 +614,7 @@ func getAllCases() ([]string, error) {
|
|||
// runTests opens, parses and runs all the specified testcases
|
||||
func runTests(t *testing.T, cases []string) {
|
||||
_ = os.Mkdir("/var/lib/osbuild-composer-tests", 0755)
|
||||
store, err := ioutil.TempDir("/var/lib/osbuild-composer-tests", "osbuild-image-tests-*")
|
||||
store, err := os.MkdirTemp("/var/lib/osbuild-composer-tests", "osbuild-image-tests-*")
|
||||
require.NoError(t, err, "error creating temporary store")
|
||||
|
||||
defer func() {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// currently run as a "base test". Instead, it's run as a part of the
|
||||
// koji.sh test because it needs a working Koji instance to pass.
|
||||
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package main
|
||||
|
|
@ -12,7 +13,6 @@ import (
|
|||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -37,7 +37,7 @@ func TestKojiRefund(t *testing.T) {
|
|||
|
||||
// use the self-signed certificate generated by run-koji-container
|
||||
certPool := x509.NewCertPool()
|
||||
cert, err := ioutil.ReadFile(shareDir + "/ca-crt.pem")
|
||||
cert, err := os.ReadFile(shareDir + "/ca-crt.pem")
|
||||
require.NoError(t, err)
|
||||
|
||||
ok := certPool.AppendCertsFromPEM(cert)
|
||||
|
|
@ -98,7 +98,7 @@ func TestKojiImport(t *testing.T) {
|
|||
|
||||
// use the self-signed certificate generated by run-koji-container
|
||||
certPool := x509.NewCertPool()
|
||||
cert, err := ioutil.ReadFile(shareDir + "/ca-crt.pem")
|
||||
cert, err := os.ReadFile(shareDir + "/ca-crt.pem")
|
||||
require.NoError(t, err)
|
||||
|
||||
ok := certPool.AppendCertsFromPEM(cert)
|
||||
|
|
@ -125,7 +125,7 @@ func TestKojiImport(t *testing.T) {
|
|||
}()
|
||||
|
||||
// Create a random file
|
||||
f, err := ioutil.TempFile("", "osbuild-koji-test-*.qcow2")
|
||||
f, err := os.CreateTemp("", "osbuild-koji-test-*.qcow2")
|
||||
require.NoError(t, err)
|
||||
defer func() {
|
||||
assert.NoError(t, f.Close())
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ import (
|
|||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/big"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ func main() {
|
|||
E string `json:"e"`
|
||||
}
|
||||
|
||||
rsaPubBytes, err := ioutil.ReadFile(rsaPubPem)
|
||||
rsaPubBytes, err := os.ReadFile(rsaPubPem)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ func main() {
|
|||
token := jwt.NewWithClaims(jwt.SigningMethodRS256, cc)
|
||||
token.Header["kid"] = "key-id"
|
||||
|
||||
rsaPrivBytes, err := ioutil.ReadFile(rsaPem)
|
||||
rsaPrivBytes, err := os.ReadFile(rsaPem)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
|
|
@ -97,7 +96,7 @@ func main() {
|
|||
panic("Could not open compose request: " + err.Error())
|
||||
}
|
||||
}
|
||||
file, err := ioutil.ReadAll(reader)
|
||||
file, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
panic("Could not read compose request: " + err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
|
|
@ -63,7 +62,7 @@ func main() {
|
|||
panic("Could not open path to image options: " + err.Error())
|
||||
}
|
||||
}
|
||||
file, err := ioutil.ReadAll(reader)
|
||||
file, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
panic("Could not read image options: " + err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/cloud/gcp"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
|
@ -62,7 +62,7 @@ func main() {
|
|||
var credentials []byte
|
||||
if credentialsPath != "" {
|
||||
var err error
|
||||
credentials, err = ioutil.ReadFile(credentialsPath)
|
||||
credentials, err = os.ReadFile(credentialsPath)
|
||||
if err != nil {
|
||||
logrus.Fatalf("[GCP] Error while reading credentials: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ package main
|
|||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/oci"
|
||||
"github.com/spf13/cobra"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/big"
|
||||
"os"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/oci"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -77,7 +77,7 @@ func uploaderFromConfig() (oci.Uploader, error) {
|
|||
return nil, fmt.Errorf("when suppling a private key the following args are mandatory as well:" +
|
||||
" fingerprint, tenancy, region, and user-id")
|
||||
}
|
||||
pk, err := ioutil.ReadFile(privateKeyFile)
|
||||
pk, err := os.ReadFile(privateKeyFile)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read private key file %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/big"
|
||||
"net/url"
|
||||
|
|
@ -295,7 +294,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
}
|
||||
}()
|
||||
|
||||
outputDirectory, err = ioutil.TempDir(impl.Output, job.Id().String()+"-*")
|
||||
outputDirectory, err = os.MkdirTemp(impl.Output, job.Id().String()+"-*")
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating temporary output directory: %v", err)
|
||||
}
|
||||
|
|
@ -440,7 +439,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
Datastore: targetOptions.Datastore,
|
||||
}
|
||||
|
||||
tempDirectory, err := ioutil.TempDir(impl.Output, job.Id().String()+"-vmware-*")
|
||||
tempDirectory, err := os.MkdirTemp(impl.Output, job.Id().String()+"-vmware-*")
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
|
@ -48,7 +47,7 @@ type JobImplementation interface {
|
|||
}
|
||||
|
||||
func createTLSConfig(config *connectionConfig) (*tls.Config, error) {
|
||||
caCertPEM, err := ioutil.ReadFile(config.CACertFile)
|
||||
caCertPEM, err := os.ReadFile(config.CACertFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -274,7 +273,7 @@ func main() {
|
|||
|
||||
token := ""
|
||||
if config.Authentication.OfflineTokenPath != "" {
|
||||
t, err := ioutil.ReadFile(config.Authentication.OfflineTokenPath)
|
||||
t, err := os.ReadFile(config.Authentication.OfflineTokenPath)
|
||||
if err != nil {
|
||||
logrus.Fatalf("Could not read offline token: %v", err)
|
||||
}
|
||||
|
|
@ -283,7 +282,7 @@ func main() {
|
|||
|
||||
clientSecret := ""
|
||||
if config.Authentication.ClientSecretPath != "" {
|
||||
cs, err := ioutil.ReadFile(config.Authentication.ClientSecretPath)
|
||||
cs, err := os.ReadFile(config.Authentication.ClientSecretPath)
|
||||
if err != nil {
|
||||
logrus.Fatalf("Could not read client secret: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import (
|
|||
"context"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/openshift-online/ocm-sdk-go/authentication"
|
||||
"github.com/openshift-online/ocm-sdk-go/logging"
|
||||
|
|
@ -39,7 +39,7 @@ func BuildJWTAuthHandler(keysURLs []string, caFile, aclFile string, exclude []st
|
|||
if caFile != "" {
|
||||
logger.Warn(context.Background(),
|
||||
"A custom CA is specified to verify jwt tokens, this shouldn't be enabled in a production setting.")
|
||||
caPEM, err := ioutil.ReadFile(caFile)
|
||||
caPEM, err := os.ReadFile(caFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package boot
|
||||
|
|
@ -6,7 +7,6 @@ import (
|
|||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
|
|
@ -60,7 +60,7 @@ func encodeBase64(input string) string {
|
|||
// CreateUserData creates cloud-init's user-data that contains user redhat with
|
||||
// the specified public key
|
||||
func CreateUserData(publicKeyFile string) (string, error) {
|
||||
publicKey, err := ioutil.ReadFile(publicKeyFile)
|
||||
publicKey, err := os.ReadFile(publicKeyFile)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot read the public key: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package azuretest
|
||||
|
|
@ -6,7 +7,6 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/url"
|
||||
"os"
|
||||
|
|
@ -137,7 +137,7 @@ func DeleteImageFromAzure(c *azureCredentials, imageName string) error {
|
|||
|
||||
// readPublicKey reads the public key from a file and returns it as a string
|
||||
func readPublicKey(publicKeyFile string) (string, error) {
|
||||
publicKey, err := ioutil.ReadFile(publicKeyFile)
|
||||
publicKey, err := os.ReadFile(publicKeyFile)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot read the public key file: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package boot
|
||||
|
|
@ -5,7 +6,6 @@ package boot
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -38,9 +38,9 @@ func WithNetworkNamespace(f func(ns NetNS) error) error {
|
|||
}
|
||||
|
||||
// withTempFile provides the function f with a new temporary file
|
||||
// dir and pattern parameters have the same semantics as in ioutil.TempFile
|
||||
// dir and pattern parameters have the same semantics as in os.CreateTemp
|
||||
func withTempFile(dir, pattern string, f func(file *os.File) error) error {
|
||||
tempFile, err := ioutil.TempFile(dir, pattern)
|
||||
tempFile, err := os.CreateTemp(dir, pattern)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot create the temporary file: %v", err)
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ func withTempFile(dir, pattern string, f func(file *os.File) error) error {
|
|||
}
|
||||
|
||||
func withTempDir(dir, pattern string, f func(dir string) error) error {
|
||||
tempDir, err := ioutil.TempDir(dir, pattern)
|
||||
tempDir, err := os.MkdirTemp(dir, pattern)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot create the temporary directory %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package boot
|
||||
|
|
@ -5,7 +6,6 @@ package boot
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -45,7 +45,7 @@ func newNetworkNamespace() (NetNS, error) {
|
|||
}
|
||||
}
|
||||
|
||||
f, err := ioutil.TempFile(netnsDir, "osbuild-composer-namespace")
|
||||
f, err := os.CreateTemp(netnsDir, "osbuild-composer-namespace")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot create a tempfile: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package vmwaretest
|
||||
|
|
@ -5,7 +6,7 @@ package vmwaretest
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
|
@ -130,7 +131,7 @@ func runWithStdout(args []string) (string, int) {
|
|||
retcode := cli.Run(args)
|
||||
|
||||
w.Close()
|
||||
out, _ := ioutil.ReadAll(r)
|
||||
out, _ := io.ReadAll(r)
|
||||
os.Stdout = oldStdout
|
||||
|
||||
return strings.TrimSpace(string(out)), retcode
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
|
@ -91,7 +90,7 @@ func NewAPIResponse(body []byte) (*APIResponse, error) {
|
|||
func apiError(resp *http.Response) (*APIResponse, error) {
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -124,7 +123,7 @@ func GetRaw(socket *http.Client, method, path string) ([]byte, *APIResponse, err
|
|||
}
|
||||
defer body.Close()
|
||||
|
||||
bodyBytes, err := ioutil.ReadAll(body)
|
||||
bodyBytes, err := io.ReadAll(body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
@ -179,7 +178,7 @@ func PostRaw(socket *http.Client, path, body string, headers map[string]string)
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
responseBody, err := ioutil.ReadAll(resp.Body)
|
||||
responseBody, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
@ -216,7 +215,7 @@ func DeleteRaw(socket *http.Client, path string) ([]byte, *APIResponse, error) {
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
responseBody, err := ioutil.ReadAll(resp.Body)
|
||||
responseBody, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ package client
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ func TestUnknownComposeInfoV0(t *testing.T) {
|
|||
|
||||
// Test compose image for unknown uuid
|
||||
func TestComposeInvalidImageV0(t *testing.T) {
|
||||
resp, err := WriteComposeImageV0(testState.socket, ioutil.Discard, "c91818f9-8025-47af-89d2-f030d7000c2c")
|
||||
resp, err := WriteComposeImageV0(testState.socket, io.Discard, "c91818f9-8025-47af-89d2-f030d7000c2c")
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.NotNil(t, resp)
|
||||
require.False(t, resp.Status)
|
||||
|
|
@ -173,7 +173,7 @@ func TestComposeInvalidImageV0(t *testing.T) {
|
|||
|
||||
// Test compose logs for unknown uuid
|
||||
func TestComposeInvalidLogsV0(t *testing.T) {
|
||||
resp, err := WriteComposeLogsV0(testState.socket, ioutil.Discard, "c91818f9-8025-47af-89d2-f030d7000c2c")
|
||||
resp, err := WriteComposeLogsV0(testState.socket, io.Discard, "c91818f9-8025-47af-89d2-f030d7000c2c")
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.NotNil(t, resp)
|
||||
require.False(t, resp.Status)
|
||||
|
|
@ -184,7 +184,7 @@ func TestComposeInvalidLogsV0(t *testing.T) {
|
|||
|
||||
// Test compose log for unknown uuid
|
||||
func TestComposeInvalidLogV0(t *testing.T) {
|
||||
resp, err := WriteComposeLogV0(testState.socket, ioutil.Discard, "c91818f9-8025-47af-89d2-f030d7000c2c")
|
||||
resp, err := WriteComposeLogV0(testState.socket, io.Discard, "c91818f9-8025-47af-89d2-f030d7000c2c")
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.NotNil(t, resp)
|
||||
require.False(t, resp.Status)
|
||||
|
|
@ -195,7 +195,7 @@ func TestComposeInvalidLogV0(t *testing.T) {
|
|||
|
||||
// Test compose metadata for unknown uuid
|
||||
func TestComposeInvalidMetadataV0(t *testing.T) {
|
||||
resp, err := WriteComposeMetadataV0(testState.socket, ioutil.Discard, "c91818f9-8025-47af-89d2-f030d7000c2c")
|
||||
resp, err := WriteComposeMetadataV0(testState.socket, io.Discard, "c91818f9-8025-47af-89d2-f030d7000c2c")
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.NotNil(t, resp)
|
||||
require.False(t, resp.Status)
|
||||
|
|
@ -206,7 +206,7 @@ func TestComposeInvalidMetadataV0(t *testing.T) {
|
|||
|
||||
// Test compose results for unknown uuid
|
||||
func TestComposeInvalidResultsV0(t *testing.T) {
|
||||
resp, err := WriteComposeResultsV0(testState.socket, ioutil.Discard, "c91818f9-8025-47af-89d2-f030d7000c2c")
|
||||
resp, err := WriteComposeResultsV0(testState.socket, io.Discard, "c91818f9-8025-47af-89d2-f030d7000c2c")
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.NotNil(t, resp)
|
||||
require.False(t, resp.Status)
|
||||
|
|
@ -350,17 +350,17 @@ func TestFailedComposeV0(t *testing.T) {
|
|||
require.Equal(t, buildID, info.ID)
|
||||
|
||||
// Test requesting the compose logs for the failed build
|
||||
resp, err = WriteComposeLogsV0(testState.socket, ioutil.Discard, buildID.String())
|
||||
resp, err = WriteComposeLogsV0(testState.socket, io.Discard, buildID.String())
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
|
||||
// Test requesting the compose metadata for the failed build
|
||||
resp, err = WriteComposeMetadataV0(testState.socket, ioutil.Discard, buildID.String())
|
||||
resp, err = WriteComposeMetadataV0(testState.socket, io.Discard, buildID.String())
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
|
||||
// Test requesting the compose results for the failed build
|
||||
resp, err = WriteComposeResultsV0(testState.socket, ioutil.Discard, buildID.String())
|
||||
resp, err = WriteComposeResultsV0(testState.socket, io.Discard, buildID.String())
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
|
||||
|
|
@ -455,17 +455,17 @@ func TestFinishedComposeV0(t *testing.T) {
|
|||
require.Equal(t, buildID, info.ID)
|
||||
|
||||
// Test requesting the compose logs for the finished build
|
||||
resp, err = WriteComposeLogsV0(testState.socket, ioutil.Discard, buildID.String())
|
||||
resp, err = WriteComposeLogsV0(testState.socket, io.Discard, buildID.String())
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
|
||||
// Test requesting the compose metadata for the finished build
|
||||
resp, err = WriteComposeMetadataV0(testState.socket, ioutil.Discard, buildID.String())
|
||||
resp, err = WriteComposeMetadataV0(testState.socket, io.Discard, buildID.String())
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
|
||||
// Test requesting the compose results for the finished build
|
||||
resp, err = WriteComposeResultsV0(testState.socket, ioutil.Discard, buildID.String())
|
||||
resp, err = WriteComposeResultsV0(testState.socket, io.Discard, buildID.String())
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package gcp
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
cloudbuild "cloud.google.com/go/cloudbuild/apiv1"
|
||||
compute "cloud.google.com/go/compute/apiv1"
|
||||
|
|
@ -58,7 +58,7 @@ func New(credentials []byte) (*GCP, error) {
|
|||
// NewFromFile loads the credentials from a file and returns an authenticated
|
||||
// *GCP object instance.
|
||||
func NewFromFile(path string) (*GCP, error) {
|
||||
gcpCredentials, err := ioutil.ReadFile(path)
|
||||
gcpCredentials, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot load GCP credentials from file %q: %v", path, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package container_test
|
|||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -76,7 +75,7 @@ func TestClientAuthFilePath(t *testing.T) {
|
|||
assert.Equal(t, authFilePath, container.GetDefaultAuthFile())
|
||||
|
||||
// make sure the file is accessible
|
||||
_, err = ioutil.ReadFile(authFilePath)
|
||||
_, err = os.ReadFile(authFilePath)
|
||||
assert.True(t, err == nil || os.IsNotExist(err))
|
||||
|
||||
t.Run("XDG_RUNTIME_DIR", func(t *testing.T) {
|
||||
|
|
@ -95,7 +94,7 @@ func TestClientAuthFilePath(t *testing.T) {
|
|||
|
||||
authFilePath := container.GetDefaultAuthFile()
|
||||
assert.NotEmpty(t, authFilePath)
|
||||
_, err = ioutil.ReadFile(authFilePath)
|
||||
_, err = os.ReadFile(authFilePath)
|
||||
assert.True(t, err == nil || os.IsNotExist(err))
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package distro_test_common
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
|
@ -51,7 +51,7 @@ func TestDistro_Manifest(t *testing.T, pipelinePath string, prefix string, regis
|
|||
Manifest distro.Manifest `json:"manifest,omitempty"`
|
||||
Containers []container.Spec `json:"containers,omitempty"`
|
||||
}
|
||||
file, err := ioutil.ReadFile(fileName)
|
||||
file, err := os.ReadFile(fileName)
|
||||
assert.NoErrorf(err, "Could not read test-case '%s': %v", fileName, err)
|
||||
err = json.Unmarshal([]byte(file), &tt)
|
||||
assert.NoErrorf(err, "Could not parse test-case '%s': %v", fileName, err)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package jsondb
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
|
@ -93,7 +92,7 @@ func (db *JSONDatabase) Write(name string, document interface{}) error {
|
|||
// writing succeeded. `writer` gets passed the open file handle to write to and
|
||||
// does not need to take care of closing it.
|
||||
func writeFileAtomically(dir, filename string, mode os.FileMode, writer func(f *os.File) error) error {
|
||||
tmpfile, err := ioutil.TempFile(dir, filename+"-*.tmp")
|
||||
tmpfile, err := os.CreateTemp(dir, filename+"-*.tmp")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package jsondb
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
|
@ -26,14 +25,16 @@ func TestWriteFileAtomically(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
// ensure that there are no stray temporary files
|
||||
infos, err := ioutil.ReadDir(dir)
|
||||
infos, err := os.ReadDir(dir)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(infos))
|
||||
require.Equal(t, "octopus", infos[0].Name())
|
||||
require.Equal(t, perm, infos[0].Mode())
|
||||
i, err := infos[0].Info()
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, perm, i.Mode())
|
||||
|
||||
filename := path.Join(dir, "octopus")
|
||||
contents, err := ioutil.ReadFile(filename)
|
||||
contents, err := os.ReadFile(filename)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, octopus, contents)
|
||||
|
||||
|
|
@ -51,7 +52,7 @@ func TestWriteFileAtomically(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
|
||||
// ensure there are no stray temporary files
|
||||
infos, err := ioutil.ReadDir(dir)
|
||||
infos, err := os.ReadDir(dir)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 0, len(infos))
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package jsondb_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
|
@ -42,7 +41,7 @@ func TestDegenerate(t *testing.T) {
|
|||
db := jsondb.New(dir, 0755)
|
||||
|
||||
// write-only file
|
||||
err := ioutil.WriteFile(path.Join(dir, "one.json"), []byte("{"), 0600)
|
||||
err := os.WriteFile(path.Join(dir, "one.json"), []byte("{"), 0600)
|
||||
require.NoError(t, err)
|
||||
|
||||
var d document
|
||||
|
|
@ -54,7 +53,7 @@ func TestDegenerate(t *testing.T) {
|
|||
func TestCorrupt(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(path.Join(dir, "one.json"), []byte("{"), 0600)
|
||||
err := os.WriteFile(path.Join(dir, "one.json"), []byte("{"), 0600)
|
||||
require.NoError(t, err)
|
||||
|
||||
db := jsondb.New(dir, 0755)
|
||||
|
|
@ -66,7 +65,7 @@ func TestCorrupt(t *testing.T) {
|
|||
func TestRead(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(path.Join(dir, "one.json"), []byte("true"), 0600)
|
||||
err := os.WriteFile(path.Join(dir, "one.json"), []byte("true"), 0600)
|
||||
require.NoError(t, err)
|
||||
|
||||
db := jsondb.New(dir, 0755)
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ import (
|
|||
"crypto/x509"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
|
@ -80,7 +81,7 @@ func ResolveRef(location, ref string, consumerCerts bool, subs *rhsm.Subscriptio
|
|||
}
|
||||
|
||||
if ca != nil {
|
||||
caCertPEM, err := ioutil.ReadFile(*ca)
|
||||
caCertPEM, err := os.ReadFile(*ca)
|
||||
if err != nil {
|
||||
return "", NewResolveRefError("error adding rhsm certificates when resolving ref")
|
||||
}
|
||||
|
|
@ -120,7 +121,7 @@ func ResolveRef(location, ref string, consumerCerts bool, subs *rhsm.Subscriptio
|
|||
if resp.StatusCode != http.StatusOK {
|
||||
return "", NewResolveRefError("ostree repository %q returned status: %s", u.String(), resp.Status)
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", NewResolveRefError(fmt.Sprintf("error reading response from ostree repository %q: %v", u.String(), err))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import (
|
|||
"crypto/x509"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ func NewMTLSServer(handler http.Handler) (*MTLSServer, error) {
|
|||
clientKeyPath := filepath.Join(certsPath, "client.key")
|
||||
clientCrtPath := filepath.Join(certsPath, "client.crt")
|
||||
|
||||
caCertPem, err := ioutil.ReadFile(caPath)
|
||||
caCertPem, err := os.ReadFile(caPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package rhsm
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
|
@ -65,7 +64,7 @@ func getListOfSubscriptions() ([]subscription, error) {
|
|||
// documented in `man yum.conf`. The same parsing mechanism could
|
||||
// be used for any other repo file in /etc/yum.repos.d/.
|
||||
availableSubscriptionsFile := "/etc/yum.repos.d/redhat.repo"
|
||||
content, err := ioutil.ReadFile(availableSubscriptionsFile)
|
||||
content, err := os.ReadFile(availableSubscriptionsFile)
|
||||
if err != nil {
|
||||
if pErr, ok := err.(*os.PathError); ok {
|
||||
if pErr.Err.Error() == "no such file or directory" {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -256,7 +255,7 @@ func LoadAllRepositories(confPaths []string) (DistrosRepoConfigs, error) {
|
|||
for _, confPath := range confPaths {
|
||||
reposPath := filepath.Join(confPath, "repositories")
|
||||
|
||||
fileEntries, err := ioutil.ReadDir(reposPath)
|
||||
fileEntries, err := os.ReadDir(reposPath)
|
||||
if os.IsNotExist(err) {
|
||||
continue
|
||||
} else if err != nil {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package store
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
|
@ -304,7 +304,7 @@ func Test_upgrade(t *testing.T) {
|
|||
require.Greaterf(t, len(fileNames), 0, "No test stores found in %s", testPath)
|
||||
for _, fileName := range fileNames {
|
||||
var storeStruct storeV0
|
||||
file, err := ioutil.ReadFile(fileName)
|
||||
file, err := os.ReadFile(fileName)
|
||||
assert.NoErrorf(err, "Could not read test-store '%s': %v", fileName, err)
|
||||
err = json.Unmarshal([]byte(file), &storeStruct)
|
||||
assert.NoErrorf(err, "Could not parse test-store '%s': %v", fileName, err)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
|
@ -72,7 +71,7 @@ func (a APICall) Do(t *testing.T) APICallResult {
|
|||
a.Handler.ServeHTTP(respRecorder, req)
|
||||
resp := respRecorder.Result()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.NoErrorf(t, err, "%s: could not read response body", a.Path)
|
||||
|
||||
if a.ExpectedStatus != 0 {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
|
@ -107,7 +107,7 @@ func TestRouteWithReply(t *testing.T, api http.Handler, external bool, method, p
|
|||
}
|
||||
|
||||
var err error
|
||||
replyJSON, err = ioutil.ReadAll(resp.Body)
|
||||
replyJSON, err = io.ReadAll(resp.Body)
|
||||
require.NoErrorf(t, err, "%s: could not read response body", path)
|
||||
|
||||
assert.Equalf(t, expectedStatus, resp.StatusCode, "SendHTTP failed for path %s: %v", path, string(replyJSON))
|
||||
|
|
@ -147,7 +147,7 @@ func TestTOMLRoute(t *testing.T, api http.Handler, external bool, method, path,
|
|||
t.Skip("This test is for internal testing only")
|
||||
}
|
||||
|
||||
replyTOML, err := ioutil.ReadAll(resp.Body)
|
||||
replyTOML, err := io.ReadAll(resp.Body)
|
||||
require.NoErrorf(t, err, "%s: could not read response body", path)
|
||||
|
||||
assert.Equalf(t, expectedStatus, resp.StatusCode, "SendHTTP failed for path %s: %v", path, string(replyTOML))
|
||||
|
|
@ -177,7 +177,7 @@ func TestNonJsonRoute(t *testing.T, api http.Handler, external bool, method, pat
|
|||
response := SendHTTP(api, external, method, path, body)
|
||||
assert.Equalf(t, expectedStatus, response.StatusCode, "%s: status mismatch", path)
|
||||
|
||||
responseBodyBytes, err := ioutil.ReadAll(response.Body)
|
||||
responseBodyBytes, err := io.ReadAll(response.Body)
|
||||
require.NoErrorf(t, err, "%s: could not read response body", path)
|
||||
|
||||
responseBody := string(responseBodyBytes)
|
||||
|
|
@ -209,7 +209,7 @@ func CompareImageTypes() cmp.Option {
|
|||
|
||||
// Create a temporary repository
|
||||
func SetUpTemporaryRepository() (string, error) {
|
||||
dir, err := ioutil.TempDir("/tmp", "osbuild-composer-test-")
|
||||
dir, err := os.MkdirTemp("/tmp", "osbuild-composer-test-")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import (
|
|||
"fmt"
|
||||
"hash/adler32"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
|
|
@ -325,7 +324,7 @@ func (k *Koji) uploadChunk(chunk []byte, filepath, filename string, offset uint6
|
|||
|
||||
defer respData.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(respData.Body)
|
||||
body, err := io.ReadAll(respData.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import (
|
|||
errors_package "errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math"
|
||||
"math/big"
|
||||
|
|
@ -812,7 +811,7 @@ func DecodeSourceConfigV0(body io.Reader, contentType string) (source SourceConf
|
|||
} else if contentType == "text/x-toml" {
|
||||
// Read all of body in case it needs to be parsed twice
|
||||
var data []byte
|
||||
data, err = ioutil.ReadAll(body)
|
||||
data, err = io.ReadAll(body)
|
||||
if err != nil {
|
||||
return source, err
|
||||
}
|
||||
|
|
@ -845,7 +844,7 @@ func DecodeSourceConfigV1(body io.Reader, contentType string) (source SourceConf
|
|||
} else if contentType == "text/x-toml" {
|
||||
// Read all of body in case it needs to be parsed twice
|
||||
var data []byte
|
||||
data, err = ioutil.ReadAll(body)
|
||||
data, err = io.ReadAll(body)
|
||||
if err != nil {
|
||||
return source, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
|
@ -511,7 +510,7 @@ func TestBlueprintsCustomizationInfoToml(t *testing.T) {
|
|||
}
|
||||
}`
|
||||
resp := test.SendHTTP(api, true, "POST", "/api/v0/blueprints/new", testBlueprint)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode, string(body))
|
||||
|
||||
|
|
@ -520,7 +519,7 @@ func TestBlueprintsCustomizationInfoToml(t *testing.T) {
|
|||
api.ServeHTTP(recorder, req)
|
||||
|
||||
resp = recorder.Result()
|
||||
body, err = ioutil.ReadAll(resp.Body)
|
||||
body, err = io.ReadAll(resp.Body)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode, string(body))
|
||||
|
||||
|
|
@ -804,7 +803,7 @@ func TestBlueprintChange(t *testing.T) {
|
|||
test.SendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"`+id+`","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.2"}`)
|
||||
|
||||
resp := test.SendHTTP(api, true, "GET", "/api/v0/blueprints/changes/"+id, ``)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
|
|
@ -818,7 +817,7 @@ func TestBlueprintChange(t *testing.T) {
|
|||
// Get the blueprint's oldest commit
|
||||
route := fmt.Sprintf("/api/v1/blueprints/change/%s/%s", id, commit)
|
||||
resp = test.SendHTTP(api, true, "GET", route, ``)
|
||||
body, err = ioutil.ReadAll(resp.Body)
|
||||
body, err = io.ReadAll(resp.Body)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
|
|
@ -861,7 +860,7 @@ func TestOldBlueprintsUndo(t *testing.T) {
|
|||
test.TestRoute(t, api, true, "GET", "/api/v0/blueprints/changes/test-old-changes", ``, http.StatusOK, oldBlueprintsUndoResponse, ignoreFields...)
|
||||
|
||||
resp := test.SendHTTP(api, true, "GET", "/api/v0/blueprints/changes/test-old-changes", ``)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
|
|
@ -899,7 +898,7 @@ func TestNewBlueprintsUndo(t *testing.T) {
|
|||
test.TestRoute(t, api, true, "GET", "/api/v0/blueprints/changes/"+id, ``, http.StatusOK, `{"blueprints":[{"changes":[{"commit":"","message":"Recipe `+id+`, version 0.1.0 saved.","revision":null,"timestamp":""},{"commit":"","message":"Recipe `+id+`, version 0.0.1 saved.","revision":null,"timestamp":""}],"name":"`+id+`","total":2}],"errors":[],"limit":20,"offset":0}`, ignoreFields...)
|
||||
|
||||
resp := test.SendHTTP(api, true, "GET", "/api/v0/blueprints/changes/"+id, ``)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue