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
|
// +build integration
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
@ -37,7 +37,7 @@ func (ckp certificateKeyPair) key() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSelfSignedCertificateKeyPair(subj string) (*certificateKeyPair, error) {
|
func newSelfSignedCertificateKeyPair(subj string) (*certificateKeyPair, error) {
|
||||||
dir, err := ioutil.TempDir("", "osbuild-auth-tests-")
|
dir, err := os.MkdirTemp("", "osbuild-auth-tests-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot create a temporary directory for the certificate: %v", err)
|
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) {
|
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 {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot create a temporary dir for a new CA: %v", err)
|
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) {
|
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 {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot create a temporary directory for the certificate: %v", err)
|
return nil, fmt.Errorf("cannot create a temporary directory for the certificate: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
@ -24,7 +24,7 @@ type connectionConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTLSConfig(config *connectionConfig) (*tls.Config, error) {
|
func createTLSConfig(config *connectionConfig) (*tls.Config, error) {
|
||||||
caCertPEM, err := ioutil.ReadFile(config.CACertFile)
|
caCertPEM, err := os.ReadFile(config.CACertFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
@ -160,7 +160,7 @@ func TestStatusCommands(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSourcesCommands(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)
|
require.NoErrorf(t, err, "Could not create temporary file: %v", err)
|
||||||
defer os.Remove(sources_toml.Name())
|
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) {
|
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)
|
require.Nilf(t, err, "Could not create temporary file: %v", err)
|
||||||
defer os.Remove(tmpfile.Name())
|
defer os.Remove(tmpfile.Name())
|
||||||
|
|
||||||
|
|
@ -386,10 +386,10 @@ func runComposer(t *testing.T, command ...string) []byte {
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
require.Nilf(t, err, "Could not start command: %v", err)
|
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")
|
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")
|
require.NoError(t, err, "Could not read stderr from command")
|
||||||
|
|
||||||
err = cmd.Wait()
|
err = cmd.Wait()
|
||||||
|
|
@ -453,8 +453,8 @@ func NewTemporaryWorkDir(t *testing.T, pattern string) TemporaryWorkDir {
|
||||||
d.OldWorkDir, err = os.Getwd()
|
d.OldWorkDir, err = os.Getwd()
|
||||||
require.Nilf(t, err, "os.GetWd: %v", err)
|
require.Nilf(t, err, "os.GetWd: %v", err)
|
||||||
|
|
||||||
d.Path, err = ioutil.TempDir("", pattern)
|
d.Path, err = os.MkdirTemp("", pattern)
|
||||||
require.Nilf(t, err, "ioutil.TempDir: %v", err)
|
require.Nilf(t, err, "os.MkdirTemp: %v", err)
|
||||||
|
|
||||||
err = os.Chdir(d.Path)
|
err = os.Chdir(d.Path)
|
||||||
require.Nilf(t, err, "os.ChDir: %v", err)
|
require.Nilf(t, err, "os.ChDir: %v", err)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -389,7 +388,7 @@ func createTLSConfig(c *connectionConfig) (*tls.Config, error) {
|
||||||
var roots *x509.CertPool
|
var roots *x509.CertPool
|
||||||
|
|
||||||
if c.CACertFile != "" {
|
if c.CACertFile != "" {
|
||||||
caCertPEM, err := ioutil.ReadFile(c.CACertFile)
|
caCertPEM, err := os.ReadFile(c.CACertFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
@ -574,7 +573,7 @@ func guessPipelineToExport(rawManifest json.RawMessage) string {
|
||||||
// tests the result
|
// tests the result
|
||||||
func runTestcase(t *testing.T, testcase testcaseStruct, store string) {
|
func runTestcase(t *testing.T, testcase testcaseStruct, store string) {
|
||||||
_ = os.Mkdir("/var/lib/osbuild-composer-tests", 0755)
|
_ = 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")
|
require.NoError(t, err, "error creating temporary output directory")
|
||||||
|
|
||||||
defer func() {
|
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
|
// getAllCases returns paths to all testcases in the testcase directory
|
||||||
func getAllCases() ([]string, error) {
|
func getAllCases() ([]string, error) {
|
||||||
cases, err := ioutil.ReadDir(constants.TestPaths.TestCasesDirectory)
|
cases, err := os.ReadDir(constants.TestPaths.TestCasesDirectory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot list test cases: %v", err)
|
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
|
// runTests opens, parses and runs all the specified testcases
|
||||||
func runTests(t *testing.T, cases []string) {
|
func runTests(t *testing.T, cases []string) {
|
||||||
_ = os.Mkdir("/var/lib/osbuild-composer-tests", 0755)
|
_ = 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")
|
require.NoError(t, err, "error creating temporary store")
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
// currently run as a "base test". Instead, it's run as a part of the
|
// 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.
|
// koji.sh test because it needs a working Koji instance to pass.
|
||||||
|
|
||||||
|
//go:build integration
|
||||||
// +build integration
|
// +build integration
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
@ -12,7 +13,6 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
@ -37,14 +37,14 @@ func TestKojiRefund(t *testing.T) {
|
||||||
|
|
||||||
// use the self-signed certificate generated by run-koji-container
|
// use the self-signed certificate generated by run-koji-container
|
||||||
certPool := x509.NewCertPool()
|
certPool := x509.NewCertPool()
|
||||||
cert, err := ioutil.ReadFile(shareDir + "/ca-crt.pem")
|
cert, err := os.ReadFile(shareDir + "/ca-crt.pem")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
ok := certPool.AppendCertsFromPEM(cert)
|
ok := certPool.AppendCertsFromPEM(cert)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
transport.TLSClientConfig = &tls.Config{
|
transport.TLSClientConfig = &tls.Config{
|
||||||
RootCAs: certPool,
|
RootCAs: certPool,
|
||||||
MinVersion: tls.VersionTLS12,
|
MinVersion: tls.VersionTLS12,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,14 +98,14 @@ func TestKojiImport(t *testing.T) {
|
||||||
|
|
||||||
// use the self-signed certificate generated by run-koji-container
|
// use the self-signed certificate generated by run-koji-container
|
||||||
certPool := x509.NewCertPool()
|
certPool := x509.NewCertPool()
|
||||||
cert, err := ioutil.ReadFile(shareDir + "/ca-crt.pem")
|
cert, err := os.ReadFile(shareDir + "/ca-crt.pem")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
ok := certPool.AppendCertsFromPEM(cert)
|
ok := certPool.AppendCertsFromPEM(cert)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
transport.TLSClientConfig = &tls.Config{
|
transport.TLSClientConfig = &tls.Config{
|
||||||
RootCAs: certPool,
|
RootCAs: certPool,
|
||||||
MinVersion: tls.VersionTLS12,
|
MinVersion: tls.VersionTLS12,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,7 +125,7 @@ func TestKojiImport(t *testing.T) {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Create a random file
|
// Create a random file
|
||||||
f, err := ioutil.TempFile("", "osbuild-koji-test-*.qcow2")
|
f, err := os.CreateTemp("", "osbuild-koji-test-*.qcow2")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer func() {
|
defer func() {
|
||||||
assert.NoError(t, f.Close())
|
assert.NoError(t, f.Close())
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ func main() {
|
||||||
E string `json:"e"`
|
E string `json:"e"`
|
||||||
}
|
}
|
||||||
|
|
||||||
rsaPubBytes, err := ioutil.ReadFile(rsaPubPem)
|
rsaPubBytes, err := os.ReadFile(rsaPubPem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +116,7 @@ func main() {
|
||||||
token := jwt.NewWithClaims(jwt.SigningMethodRS256, cc)
|
token := jwt.NewWithClaims(jwt.SigningMethodRS256, cc)
|
||||||
token.Header["kid"] = "key-id"
|
token.Header["kid"] = "key-id"
|
||||||
|
|
||||||
rsaPrivBytes, err := ioutil.ReadFile(rsaPem)
|
rsaPrivBytes, err := os.ReadFile(rsaPem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
|
|
@ -97,7 +96,7 @@ func main() {
|
||||||
panic("Could not open compose request: " + err.Error())
|
panic("Could not open compose request: " + err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file, err := ioutil.ReadAll(reader)
|
file, err := io.ReadAll(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Could not read compose request: " + err.Error())
|
panic("Could not read compose request: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
|
|
@ -63,7 +62,7 @@ func main() {
|
||||||
panic("Could not open path to image options: " + err.Error())
|
panic("Could not open path to image options: " + err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file, err := ioutil.ReadAll(reader)
|
file, err := io.ReadAll(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Could not read image options: " + err.Error())
|
panic("Could not read image options: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
"github.com/osbuild/osbuild-composer/internal/cloud/gcp"
|
"github.com/osbuild/osbuild-composer/internal/cloud/gcp"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
@ -62,7 +62,7 @@ func main() {
|
||||||
var credentials []byte
|
var credentials []byte
|
||||||
if credentialsPath != "" {
|
if credentialsPath != "" {
|
||||||
var err error
|
var err error
|
||||||
credentials, err = ioutil.ReadFile(credentialsPath)
|
credentials, err = os.ReadFile(credentialsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatalf("[GCP] Error while reading credentials: %v", err)
|
logrus.Fatalf("[GCP] Error while reading credentials: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@ package main
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/osbuild/osbuild-composer/internal/upload/oci"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/osbuild/osbuild-composer/internal/upload/oci"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
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:" +
|
return nil, fmt.Errorf("when suppling a private key the following args are mandatory as well:" +
|
||||||
" fingerprint, tenancy, region, and user-id")
|
" fingerprint, tenancy, region, and user-id")
|
||||||
}
|
}
|
||||||
pk, err := ioutil.ReadFile(privateKeyFile)
|
pk, err := os.ReadFile(privateKeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read private key file %w", err)
|
return nil, fmt.Errorf("failed to read private key file %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net/url"
|
"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 {
|
if err != nil {
|
||||||
return fmt.Errorf("error creating temporary output directory: %v", err)
|
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,
|
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 {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -48,7 +47,7 @@ type JobImplementation interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTLSConfig(config *connectionConfig) (*tls.Config, error) {
|
func createTLSConfig(config *connectionConfig) (*tls.Config, error) {
|
||||||
caCertPEM, err := ioutil.ReadFile(config.CACertFile)
|
caCertPEM, err := os.ReadFile(config.CACertFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -274,7 +273,7 @@ func main() {
|
||||||
|
|
||||||
token := ""
|
token := ""
|
||||||
if config.Authentication.OfflineTokenPath != "" {
|
if config.Authentication.OfflineTokenPath != "" {
|
||||||
t, err := ioutil.ReadFile(config.Authentication.OfflineTokenPath)
|
t, err := os.ReadFile(config.Authentication.OfflineTokenPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatalf("Could not read offline token: %v", err)
|
logrus.Fatalf("Could not read offline token: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -283,7 +282,7 @@ func main() {
|
||||||
|
|
||||||
clientSecret := ""
|
clientSecret := ""
|
||||||
if config.Authentication.ClientSecretPath != "" {
|
if config.Authentication.ClientSecretPath != "" {
|
||||||
cs, err := ioutil.ReadFile(config.Authentication.ClientSecretPath)
|
cs, err := os.ReadFile(config.Authentication.ClientSecretPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatalf("Could not read client secret: %v", err)
|
logrus.Fatalf("Could not read client secret: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/openshift-online/ocm-sdk-go/authentication"
|
"github.com/openshift-online/ocm-sdk-go/authentication"
|
||||||
"github.com/openshift-online/ocm-sdk-go/logging"
|
"github.com/openshift-online/ocm-sdk-go/logging"
|
||||||
|
|
@ -39,7 +39,7 @@ func BuildJWTAuthHandler(keysURLs []string, caFile, aclFile string, exclude []st
|
||||||
if caFile != "" {
|
if caFile != "" {
|
||||||
logger.Warn(context.Background(),
|
logger.Warn(context.Background(),
|
||||||
"A custom CA is specified to verify jwt tokens, this shouldn't be enabled in a production setting.")
|
"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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build integration
|
||||||
// +build integration
|
// +build integration
|
||||||
|
|
||||||
package boot
|
package boot
|
||||||
|
|
@ -6,7 +7,6 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"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
|
// CreateUserData creates cloud-init's user-data that contains user redhat with
|
||||||
// the specified public key
|
// the specified public key
|
||||||
func CreateUserData(publicKeyFile string) (string, error) {
|
func CreateUserData(publicKeyFile string) (string, error) {
|
||||||
publicKey, err := ioutil.ReadFile(publicKeyFile)
|
publicKey, err := os.ReadFile(publicKeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("cannot read the public key: %v", err)
|
return "", fmt.Errorf("cannot read the public key: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build integration
|
||||||
// +build integration
|
// +build integration
|
||||||
|
|
||||||
package azuretest
|
package azuretest
|
||||||
|
|
@ -6,7 +7,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"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
|
// readPublicKey reads the public key from a file and returns it as a string
|
||||||
func readPublicKey(publicKeyFile string) (string, error) {
|
func readPublicKey(publicKeyFile string) (string, error) {
|
||||||
publicKey, err := ioutil.ReadFile(publicKeyFile)
|
publicKey, err := os.ReadFile(publicKeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("cannot read the public key file: %v", err)
|
return "", fmt.Errorf("cannot read the public key file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build integration
|
||||||
// +build integration
|
// +build integration
|
||||||
|
|
||||||
package boot
|
package boot
|
||||||
|
|
@ -5,7 +6,6 @@ package boot
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
@ -38,9 +38,9 @@ func WithNetworkNamespace(f func(ns NetNS) error) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// withTempFile provides the function f with a new temporary file
|
// 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 {
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot create the temporary file: %v", err)
|
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 {
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot create the temporary directory %v", err)
|
return fmt.Errorf("cannot create the temporary directory %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build integration
|
||||||
// +build integration
|
// +build integration
|
||||||
|
|
||||||
package boot
|
package boot
|
||||||
|
|
@ -5,7 +6,6 @@ package boot
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"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 {
|
if err != nil {
|
||||||
return "", fmt.Errorf("cannot create a tempfile: %v", err)
|
return "", fmt.Errorf("cannot create a tempfile: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +90,7 @@ func newNetworkNamespace() (NetNS, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("cannot set up a loopback device in the new namespace: %v", err)
|
return "", fmt.Errorf("cannot set up a loopback device in the new namespace: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// There's no potential command injection vector here
|
// There's no potential command injection vector here
|
||||||
/* #nosec G204 */
|
/* #nosec G204 */
|
||||||
cmd = exec.Command("mount", "-o", "bind", "/proc/self/ns/net", f.Name())
|
cmd = exec.Command("mount", "-o", "bind", "/proc/self/ns/net", f.Name())
|
||||||
|
|
@ -134,7 +134,7 @@ func (n NetNS) Path() string {
|
||||||
// Delete deletes the namespaces
|
// Delete deletes the namespaces
|
||||||
func (n NetNS) Delete() error {
|
func (n NetNS) Delete() error {
|
||||||
// There's no potential command injection vector here
|
// There's no potential command injection vector here
|
||||||
/* #nosec G204 */
|
/* #nosec G204 */
|
||||||
cmd := exec.Command("umount", n.Path())
|
cmd := exec.Command("umount", n.Path())
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build integration
|
||||||
// +build integration
|
// +build integration
|
||||||
|
|
||||||
package vmwaretest
|
package vmwaretest
|
||||||
|
|
@ -5,7 +6,7 @@ package vmwaretest
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -130,7 +131,7 @@ func runWithStdout(args []string) (string, int) {
|
||||||
retcode := cli.Run(args)
|
retcode := cli.Run(args)
|
||||||
|
|
||||||
w.Close()
|
w.Close()
|
||||||
out, _ := ioutil.ReadAll(r)
|
out, _ := io.ReadAll(r)
|
||||||
os.Stdout = oldStdout
|
os.Stdout = oldStdout
|
||||||
|
|
||||||
return strings.TrimSpace(string(out)), retcode
|
return strings.TrimSpace(string(out)), retcode
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -91,7 +90,7 @@ func NewAPIResponse(body []byte) (*APIResponse, error) {
|
||||||
func apiError(resp *http.Response) (*APIResponse, error) {
|
func apiError(resp *http.Response) (*APIResponse, error) {
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +123,7 @@ func GetRaw(socket *http.Client, method, path string) ([]byte, *APIResponse, err
|
||||||
}
|
}
|
||||||
defer body.Close()
|
defer body.Close()
|
||||||
|
|
||||||
bodyBytes, err := ioutil.ReadAll(body)
|
bodyBytes, err := io.ReadAll(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -179,7 +178,7 @@ func PostRaw(socket *http.Client, path, body string, headers map[string]string)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
responseBody, err := ioutil.ReadAll(resp.Body)
|
responseBody, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -216,7 +215,7 @@ func DeleteRaw(socket *http.Client, path string) ([]byte, *APIResponse, error) {
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
responseBody, err := ioutil.ReadAll(resp.Body)
|
responseBody, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ func TestUnknownComposeInfoV0(t *testing.T) {
|
||||||
|
|
||||||
// Test compose image for unknown uuid
|
// Test compose image for unknown uuid
|
||||||
func TestComposeInvalidImageV0(t *testing.T) {
|
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.NoError(t, err, "failed with a client error")
|
||||||
require.NotNil(t, resp)
|
require.NotNil(t, resp)
|
||||||
require.False(t, resp.Status)
|
require.False(t, resp.Status)
|
||||||
|
|
@ -173,7 +173,7 @@ func TestComposeInvalidImageV0(t *testing.T) {
|
||||||
|
|
||||||
// Test compose logs for unknown uuid
|
// Test compose logs for unknown uuid
|
||||||
func TestComposeInvalidLogsV0(t *testing.T) {
|
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.NoError(t, err, "failed with a client error")
|
||||||
require.NotNil(t, resp)
|
require.NotNil(t, resp)
|
||||||
require.False(t, resp.Status)
|
require.False(t, resp.Status)
|
||||||
|
|
@ -184,7 +184,7 @@ func TestComposeInvalidLogsV0(t *testing.T) {
|
||||||
|
|
||||||
// Test compose log for unknown uuid
|
// Test compose log for unknown uuid
|
||||||
func TestComposeInvalidLogV0(t *testing.T) {
|
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.NoError(t, err, "failed with a client error")
|
||||||
require.NotNil(t, resp)
|
require.NotNil(t, resp)
|
||||||
require.False(t, resp.Status)
|
require.False(t, resp.Status)
|
||||||
|
|
@ -195,7 +195,7 @@ func TestComposeInvalidLogV0(t *testing.T) {
|
||||||
|
|
||||||
// Test compose metadata for unknown uuid
|
// Test compose metadata for unknown uuid
|
||||||
func TestComposeInvalidMetadataV0(t *testing.T) {
|
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.NoError(t, err, "failed with a client error")
|
||||||
require.NotNil(t, resp)
|
require.NotNil(t, resp)
|
||||||
require.False(t, resp.Status)
|
require.False(t, resp.Status)
|
||||||
|
|
@ -206,7 +206,7 @@ func TestComposeInvalidMetadataV0(t *testing.T) {
|
||||||
|
|
||||||
// Test compose results for unknown uuid
|
// Test compose results for unknown uuid
|
||||||
func TestComposeInvalidResultsV0(t *testing.T) {
|
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.NoError(t, err, "failed with a client error")
|
||||||
require.NotNil(t, resp)
|
require.NotNil(t, resp)
|
||||||
require.False(t, resp.Status)
|
require.False(t, resp.Status)
|
||||||
|
|
@ -350,17 +350,17 @@ func TestFailedComposeV0(t *testing.T) {
|
||||||
require.Equal(t, buildID, info.ID)
|
require.Equal(t, buildID, info.ID)
|
||||||
|
|
||||||
// Test requesting the compose logs for the failed build
|
// 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.NoError(t, err, "failed with a client error")
|
||||||
require.Nil(t, resp)
|
require.Nil(t, resp)
|
||||||
|
|
||||||
// Test requesting the compose metadata for the failed build
|
// 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.NoError(t, err, "failed with a client error")
|
||||||
require.Nil(t, resp)
|
require.Nil(t, resp)
|
||||||
|
|
||||||
// Test requesting the compose results for the failed build
|
// 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.NoError(t, err, "failed with a client error")
|
||||||
require.Nil(t, resp)
|
require.Nil(t, resp)
|
||||||
|
|
||||||
|
|
@ -455,17 +455,17 @@ func TestFinishedComposeV0(t *testing.T) {
|
||||||
require.Equal(t, buildID, info.ID)
|
require.Equal(t, buildID, info.ID)
|
||||||
|
|
||||||
// Test requesting the compose logs for the finished build
|
// 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.NoError(t, err, "failed with a client error")
|
||||||
require.Nil(t, resp)
|
require.Nil(t, resp)
|
||||||
|
|
||||||
// Test requesting the compose metadata for the finished build
|
// 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.NoError(t, err, "failed with a client error")
|
||||||
require.Nil(t, resp)
|
require.Nil(t, resp)
|
||||||
|
|
||||||
// Test requesting the compose results for the finished build
|
// 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.NoError(t, err, "failed with a client error")
|
||||||
require.Nil(t, resp)
|
require.Nil(t, resp)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package gcp
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
cloudbuild "cloud.google.com/go/cloudbuild/apiv1"
|
cloudbuild "cloud.google.com/go/cloudbuild/apiv1"
|
||||||
compute "cloud.google.com/go/compute/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
|
// NewFromFile loads the credentials from a file and returns an authenticated
|
||||||
// *GCP object instance.
|
// *GCP object instance.
|
||||||
func NewFromFile(path string) (*GCP, error) {
|
func NewFromFile(path string) (*GCP, error) {
|
||||||
gcpCredentials, err := ioutil.ReadFile(path)
|
gcpCredentials, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot load GCP credentials from file %q: %v", path, err)
|
return nil, fmt.Errorf("cannot load GCP credentials from file %q: %v", path, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package container_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -76,7 +75,7 @@ func TestClientAuthFilePath(t *testing.T) {
|
||||||
assert.Equal(t, authFilePath, container.GetDefaultAuthFile())
|
assert.Equal(t, authFilePath, container.GetDefaultAuthFile())
|
||||||
|
|
||||||
// make sure the file is accessible
|
// make sure the file is accessible
|
||||||
_, err = ioutil.ReadFile(authFilePath)
|
_, err = os.ReadFile(authFilePath)
|
||||||
assert.True(t, err == nil || os.IsNotExist(err))
|
assert.True(t, err == nil || os.IsNotExist(err))
|
||||||
|
|
||||||
t.Run("XDG_RUNTIME_DIR", func(t *testing.T) {
|
t.Run("XDG_RUNTIME_DIR", func(t *testing.T) {
|
||||||
|
|
@ -95,7 +94,7 @@ func TestClientAuthFilePath(t *testing.T) {
|
||||||
|
|
||||||
authFilePath := container.GetDefaultAuthFile()
|
authFilePath := container.GetDefaultAuthFile()
|
||||||
assert.NotEmpty(t, authFilePath)
|
assert.NotEmpty(t, authFilePath)
|
||||||
_, err = ioutil.ReadFile(authFilePath)
|
_, err = os.ReadFile(authFilePath)
|
||||||
assert.True(t, err == nil || os.IsNotExist(err))
|
assert.True(t, err == nil || os.IsNotExist(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package distro_test_common
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -51,7 +51,7 @@ func TestDistro_Manifest(t *testing.T, pipelinePath string, prefix string, regis
|
||||||
Manifest distro.Manifest `json:"manifest,omitempty"`
|
Manifest distro.Manifest `json:"manifest,omitempty"`
|
||||||
Containers []container.Spec `json:"containers,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)
|
assert.NoErrorf(err, "Could not read test-case '%s': %v", fileName, err)
|
||||||
err = json.Unmarshal([]byte(file), &tt)
|
err = json.Unmarshal([]byte(file), &tt)
|
||||||
assert.NoErrorf(err, "Could not parse test-case '%s': %v", fileName, err)
|
assert.NoErrorf(err, "Could not parse test-case '%s': %v", fileName, err)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ package jsondb
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"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
|
// writing succeeded. `writer` gets passed the open file handle to write to and
|
||||||
// does not need to take care of closing it.
|
// does not need to take care of closing it.
|
||||||
func writeFileAtomically(dir, filename string, mode os.FileMode, writer func(f *os.File) error) error {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package jsondb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -26,14 +25,16 @@ func TestWriteFileAtomically(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// ensure that there are no stray temporary files
|
// ensure that there are no stray temporary files
|
||||||
infos, err := ioutil.ReadDir(dir)
|
infos, err := os.ReadDir(dir)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, 1, len(infos))
|
require.Equal(t, 1, len(infos))
|
||||||
require.Equal(t, "octopus", infos[0].Name())
|
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")
|
filename := path.Join(dir, "octopus")
|
||||||
contents, err := ioutil.ReadFile(filename)
|
contents, err := os.ReadFile(filename)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, octopus, contents)
|
require.Equal(t, octopus, contents)
|
||||||
|
|
||||||
|
|
@ -51,7 +52,7 @@ func TestWriteFileAtomically(t *testing.T) {
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
// ensure there are no stray temporary files
|
// ensure there are no stray temporary files
|
||||||
infos, err := ioutil.ReadDir(dir)
|
infos, err := os.ReadDir(dir)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, 0, len(infos))
|
require.Equal(t, 0, len(infos))
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package jsondb_test
|
package jsondb_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -42,7 +41,7 @@ func TestDegenerate(t *testing.T) {
|
||||||
db := jsondb.New(dir, 0755)
|
db := jsondb.New(dir, 0755)
|
||||||
|
|
||||||
// write-only file
|
// 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)
|
require.NoError(t, err)
|
||||||
|
|
||||||
var d document
|
var d document
|
||||||
|
|
@ -54,7 +53,7 @@ func TestDegenerate(t *testing.T) {
|
||||||
func TestCorrupt(t *testing.T) {
|
func TestCorrupt(t *testing.T) {
|
||||||
dir := t.TempDir()
|
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)
|
require.NoError(t, err)
|
||||||
|
|
||||||
db := jsondb.New(dir, 0755)
|
db := jsondb.New(dir, 0755)
|
||||||
|
|
@ -66,7 +65,7 @@ func TestCorrupt(t *testing.T) {
|
||||||
func TestRead(t *testing.T) {
|
func TestRead(t *testing.T) {
|
||||||
dir := t.TempDir()
|
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)
|
require.NoError(t, err)
|
||||||
|
|
||||||
db := jsondb.New(dir, 0755)
|
db := jsondb.New(dir, 0755)
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,10 @@ import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -80,7 +81,7 @@ func ResolveRef(location, ref string, consumerCerts bool, subs *rhsm.Subscriptio
|
||||||
}
|
}
|
||||||
|
|
||||||
if ca != nil {
|
if ca != nil {
|
||||||
caCertPEM, err := ioutil.ReadFile(*ca)
|
caCertPEM, err := os.ReadFile(*ca)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", NewResolveRefError("error adding rhsm certificates when resolving ref")
|
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 {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return "", NewResolveRefError("ostree repository %q returned status: %s", u.String(), resp.Status)
|
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 {
|
if err != nil {
|
||||||
return "", NewResolveRefError(fmt.Sprintf("error reading response from ostree repository %q: %v", u.String(), err))
|
return "", NewResolveRefError(fmt.Sprintf("error reading response from ostree repository %q: %v", u.String(), err))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ func NewMTLSServer(handler http.Handler) (*MTLSServer, error) {
|
||||||
clientKeyPath := filepath.Join(certsPath, "client.key")
|
clientKeyPath := filepath.Join(certsPath, "client.key")
|
||||||
clientCrtPath := filepath.Join(certsPath, "client.crt")
|
clientCrtPath := filepath.Join(certsPath, "client.crt")
|
||||||
|
|
||||||
caCertPem, err := ioutil.ReadFile(caPath)
|
caCertPem, err := os.ReadFile(caPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package rhsm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -65,7 +64,7 @@ func getListOfSubscriptions() ([]subscription, error) {
|
||||||
// documented in `man yum.conf`. The same parsing mechanism could
|
// documented in `man yum.conf`. The same parsing mechanism could
|
||||||
// be used for any other repo file in /etc/yum.repos.d/.
|
// be used for any other repo file in /etc/yum.repos.d/.
|
||||||
availableSubscriptionsFile := "/etc/yum.repos.d/redhat.repo"
|
availableSubscriptionsFile := "/etc/yum.repos.d/redhat.repo"
|
||||||
content, err := ioutil.ReadFile(availableSubscriptionsFile)
|
content, err := os.ReadFile(availableSubscriptionsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if pErr, ok := err.(*os.PathError); ok {
|
if pErr, ok := err.(*os.PathError); ok {
|
||||||
if pErr.Err.Error() == "no such file or directory" {
|
if pErr.Err.Error() == "no such file or directory" {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -256,7 +255,7 @@ func LoadAllRepositories(confPaths []string) (DistrosRepoConfigs, error) {
|
||||||
for _, confPath := range confPaths {
|
for _, confPath := range confPaths {
|
||||||
reposPath := filepath.Join(confPath, "repositories")
|
reposPath := filepath.Join(confPath, "repositories")
|
||||||
|
|
||||||
fileEntries, err := ioutil.ReadDir(reposPath)
|
fileEntries, err := os.ReadDir(reposPath)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
continue
|
continue
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package store
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -304,7 +304,7 @@ func Test_upgrade(t *testing.T) {
|
||||||
require.Greaterf(t, len(fileNames), 0, "No test stores found in %s", testPath)
|
require.Greaterf(t, len(fileNames), 0, "No test stores found in %s", testPath)
|
||||||
for _, fileName := range fileNames {
|
for _, fileName := range fileNames {
|
||||||
var storeStruct storeV0
|
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)
|
assert.NoErrorf(err, "Could not read test-store '%s': %v", fileName, err)
|
||||||
err = json.Unmarshal([]byte(file), &storeStruct)
|
err = json.Unmarshal([]byte(file), &storeStruct)
|
||||||
assert.NoErrorf(err, "Could not parse test-store '%s': %v", fileName, err)
|
assert.NoErrorf(err, "Could not parse test-store '%s': %v", fileName, err)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -72,7 +71,7 @@ func (a APICall) Do(t *testing.T) APICallResult {
|
||||||
a.Handler.ServeHTTP(respRecorder, req)
|
a.Handler.ServeHTTP(respRecorder, req)
|
||||||
resp := respRecorder.Result()
|
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)
|
require.NoErrorf(t, err, "%s: could not read response body", a.Path)
|
||||||
|
|
||||||
if a.ExpectedStatus != 0 {
|
if a.ExpectedStatus != 0 {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
|
@ -107,7 +107,7 @@ func TestRouteWithReply(t *testing.T, api http.Handler, external bool, method, p
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
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)
|
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))
|
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")
|
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)
|
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))
|
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)
|
response := SendHTTP(api, external, method, path, body)
|
||||||
assert.Equalf(t, expectedStatus, response.StatusCode, "%s: status mismatch", path)
|
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)
|
require.NoErrorf(t, err, "%s: could not read response body", path)
|
||||||
|
|
||||||
responseBody := string(responseBodyBytes)
|
responseBody := string(responseBodyBytes)
|
||||||
|
|
@ -209,7 +209,7 @@ func CompareImageTypes() cmp.Option {
|
||||||
|
|
||||||
// Create a temporary repository
|
// Create a temporary repository
|
||||||
func SetUpTemporaryRepository() (string, error) {
|
func SetUpTemporaryRepository() (string, error) {
|
||||||
dir, err := ioutil.TempDir("/tmp", "osbuild-composer-test-")
|
dir, err := os.MkdirTemp("/tmp", "osbuild-composer-test-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash/adler32"
|
"hash/adler32"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -325,7 +324,7 @@ func (k *Koji) uploadChunk(chunk []byte, filepath, filename string, offset uint6
|
||||||
|
|
||||||
defer respData.Body.Close()
|
defer respData.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(respData.Body)
|
body, err := io.ReadAll(respData.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import (
|
||||||
errors_package "errors"
|
errors_package "errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
@ -812,7 +811,7 @@ func DecodeSourceConfigV0(body io.Reader, contentType string) (source SourceConf
|
||||||
} else if contentType == "text/x-toml" {
|
} else if contentType == "text/x-toml" {
|
||||||
// Read all of body in case it needs to be parsed twice
|
// Read all of body in case it needs to be parsed twice
|
||||||
var data []byte
|
var data []byte
|
||||||
data, err = ioutil.ReadAll(body)
|
data, err = io.ReadAll(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return source, err
|
return source, err
|
||||||
}
|
}
|
||||||
|
|
@ -845,7 +844,7 @@ func DecodeSourceConfigV1(body io.Reader, contentType string) (source SourceConf
|
||||||
} else if contentType == "text/x-toml" {
|
} else if contentType == "text/x-toml" {
|
||||||
// Read all of body in case it needs to be parsed twice
|
// Read all of body in case it needs to be parsed twice
|
||||||
var data []byte
|
var data []byte
|
||||||
data, err = ioutil.ReadAll(body)
|
data, err = io.ReadAll(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return source, err
|
return source, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
|
@ -511,7 +510,7 @@ func TestBlueprintsCustomizationInfoToml(t *testing.T) {
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
resp := test.SendHTTP(api, true, "POST", "/api/v0/blueprints/new", testBlueprint)
|
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.Nil(t, err)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, string(body))
|
require.Equal(t, http.StatusOK, resp.StatusCode, string(body))
|
||||||
|
|
||||||
|
|
@ -520,7 +519,7 @@ func TestBlueprintsCustomizationInfoToml(t *testing.T) {
|
||||||
api.ServeHTTP(recorder, req)
|
api.ServeHTTP(recorder, req)
|
||||||
|
|
||||||
resp = recorder.Result()
|
resp = recorder.Result()
|
||||||
body, err = ioutil.ReadAll(resp.Body)
|
body, err = io.ReadAll(resp.Body)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, string(body))
|
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"}`)
|
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, ``)
|
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.Nil(t, err)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||||
|
|
||||||
|
|
@ -818,7 +817,7 @@ func TestBlueprintChange(t *testing.T) {
|
||||||
// Get the blueprint's oldest commit
|
// Get the blueprint's oldest commit
|
||||||
route := fmt.Sprintf("/api/v1/blueprints/change/%s/%s", id, commit)
|
route := fmt.Sprintf("/api/v1/blueprints/change/%s/%s", id, commit)
|
||||||
resp = test.SendHTTP(api, true, "GET", route, ``)
|
resp = test.SendHTTP(api, true, "GET", route, ``)
|
||||||
body, err = ioutil.ReadAll(resp.Body)
|
body, err = io.ReadAll(resp.Body)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
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...)
|
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", ``)
|
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.Nil(t, err)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
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...)
|
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, ``)
|
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.Nil(t, err)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue