lint: update for Go 1.19 / golangci-lint 1.50.1

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
This commit is contained in:
Milas Bowman 2023-02-01 10:31:35 -05:00
Родитель e821c36bcc
Коммит 020489241f
56 изменённых файлов: 122 добавлений и 125 удалений

Просмотреть файл

@ -6,12 +6,10 @@ linters:
enable-all: false
disable-all: true
enable:
- deadcode
- errcheck
- gocyclo
- gofmt
- goimports
- revive
- gosimple
- govet
- ineffassign
@ -19,17 +17,17 @@ linters:
- misspell
- nakedret
- staticcheck
- structcheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
linters-settings:
gocyclo:
min-complexity: 16
lll:
line-length: 200
goimports:
local-prefixes: github.com/docker/compose-cli
issues:
# golangci hides some golint warnings (the warning about exported things
# withtout documentation for example), this will make it show them anyway.

Просмотреть файл

@ -23,9 +23,10 @@ import (
"github.com/stretchr/testify/mock"
"gotest.tools/v3/assert"
"golang.org/x/oauth2"
"github.com/docker/compose-cli/aci/login"
"github.com/docker/compose-cli/api/containers"
"golang.org/x/oauth2"
)
func TestGetContainerName(t *testing.T) {

Просмотреть файл

@ -22,11 +22,12 @@ import (
"net/http"
"github.com/compose-spec/compose-go/types"
"github.com/docker/compose-cli/utils"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/progress"
"github.com/sirupsen/logrus"
"github.com/docker/compose-cli/utils"
"github.com/docker/compose-cli/aci/convert"
"github.com/docker/compose-cli/aci/login"
"github.com/docker/compose-cli/api/context/store"

Просмотреть файл

@ -218,7 +218,7 @@ func (s serviceConfigAciHelper) getResourceRequestsLimits() (*containerinstance.
}
if hasCPURequest() {
cpuRequest, err = strconv.ParseFloat(s.Deploy.Resources.Reservations.NanoCPUs, 0)
cpuRequest, err = strconv.ParseFloat(s.Deploy.Resources.Reservations.NanoCPUs, 64)
if err != nil {
return nil, err
}
@ -233,7 +233,7 @@ func (s serviceConfigAciHelper) getResourceRequestsLimits() (*containerinstance.
}
}
if s.Deploy.Resources.Limits.NanoCPUs != "" {
cpuLimit, err = strconv.ParseFloat(s.Deploy.Resources.Limits.NanoCPUs, 0)
cpuLimit, err = strconv.ParseFloat(s.Deploy.Resources.Limits.NanoCPUs, 64)
if err != nil {
return nil, err
}

Просмотреть файл

@ -19,7 +19,7 @@ package convert
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
@ -165,7 +165,7 @@ func (c cliRegistryHelper) autoLoginAcr(registry string, loginService login.Azur
if err != nil {
return errors.Wrap(err, "could not query ACR token")
}
bits, err := ioutil.ReadAll(res.Body)
bits, err := io.ReadAll(res.Body)
if err != nil {
return errors.Wrap(err, "could not read response body")
}

Просмотреть файл

@ -25,10 +25,11 @@ import (
"github.com/Azure/go-autorest/autorest/to"
"github.com/compose-spec/compose-go/types"
cliconfigtypes "github.com/docker/cli/cli/config/types"
"github.com/docker/compose-cli/aci/login"
"github.com/stretchr/testify/mock"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"github.com/docker/compose-cli/aci/login"
)
const getAllCredentials = "getAllRegistryCredentials"

Просмотреть файл

@ -19,7 +19,7 @@ package convert
import (
"encoding/base64"
"fmt"
"io/ioutil"
"os"
"path"
"strings"
@ -43,7 +43,7 @@ func (p projectAciHelper) getAciSecretVolumes() ([]containerinstance.Volume, err
for _, svc := range p.Services {
squashedTargetVolumes := make(map[string]containerinstance.Volume)
for _, scr := range svc.Secrets {
data, err := ioutil.ReadFile(p.Secrets[scr.Source].File)
data, err := os.ReadFile(p.Secrets[scr.Source].File)
if err != nil {
return secretVolumes, err
}

Просмотреть файл

@ -18,7 +18,6 @@ package convert
import (
"fmt"
"io/ioutil"
"os"
"path"
"testing"
@ -31,7 +30,7 @@ func TestConvertSecrets(t *testing.T) {
serviceName := "testservice"
secretName := "testsecret"
absBasePath := "/home/user"
tmpFile, err := ioutil.TempFile(os.TempDir(), "TestConvertProjectSecrets-")
tmpFile, err := os.CreateTemp(os.TempDir(), "TestConvertProjectSecrets-")
assert.NilError(t, err)
_, err = tmpFile.Write([]byte("test content"))
assert.NilError(t, err)

Просмотреть файл

@ -18,7 +18,7 @@ package main
import (
"fmt"
"io/ioutil"
"io"
"log"
"math/rand"
"net"
@ -75,7 +75,7 @@ func copy(url, ip string, w http.ResponseWriter) error {
w.Header().Set("source", ip)
buf, err := ioutil.ReadAll(resp.Body)
buf, err := io.ReadAll(resp.Body)
if err != nil {
return err
}

Просмотреть файл

@ -22,7 +22,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"net/url"
@ -533,10 +532,10 @@ func TestContainerRunAttached(t *testing.T) {
}
func overwriteFileStorageAccount(t *testing.T, absComposefileName string, storageAccount string) {
data, err := ioutil.ReadFile(absComposefileName)
data, err := os.ReadFile(absComposefileName)
assert.NilError(t, err)
override := strings.Replace(string(data), "dockertestvolumeaccount", storageAccount, 1)
err = ioutil.WriteFile(absComposefileName, []byte(override), 0644)
err = os.WriteFile(absComposefileName, []byte(override), 0644)
assert.NilError(t, err)
}

Просмотреть файл

@ -17,7 +17,6 @@
package etchosts
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
@ -35,7 +34,7 @@ func TestSetDomain(t *testing.T) {
err := SetHostNames(f, "foo", "bar", "zot")
assert.NilError(t, err)
got, err := ioutil.ReadFile(f)
got, err := os.ReadFile(f)
assert.NilError(t, err)
golden.Assert(t, string(got), "etchosts.golden")
}

Просмотреть файл

@ -17,7 +17,6 @@
package login
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
@ -26,7 +25,7 @@ import (
)
func TestClearErrorMessageIfNotAlreadyLoggedIn(t *testing.T) {
dir, err := ioutil.TempDir("", "test_store")
dir, err := os.MkdirTemp("", "test_store")
assert.NilError(t, err)
t.Cleanup(func() {
_ = os.RemoveAll(dir)

Просмотреть файл

@ -19,7 +19,7 @@ package login
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
@ -110,7 +110,7 @@ func (ces *cloudEnvironmentService) Get(name string) (CloudEnvironment, error) {
return CloudEnvironment{}, errors.Errorf("Cloud metadata retrieval from '%s' failed: server response was '%s'", ces.cloudMetadataURL, res.Status)
}
bytes, err := ioutil.ReadAll(res.Body)
bytes, err := io.ReadAll(res.Body)
if err != nil {
return CloudEnvironment{}, fmt.Errorf("Cloud metadata retrieval from '%s' failed: %w", ces.cloudMetadataURL, err)
}

Просмотреть файл

@ -20,10 +20,11 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"math/rand"
"net/http"
"net/url"
"os"
"os/exec"
"runtime"
"strings"
@ -74,7 +75,7 @@ func (helper azureAPIHelper) queryAPIWithHeader(ctx context.Context, authorizati
if err != nil {
return nil, 0, err
}
bits, err := ioutil.ReadAll(res.Body)
bits, err := io.ReadAll(res.Body)
if err != nil {
return nil, 0, err
}
@ -89,7 +90,7 @@ func (helper azureAPIHelper) queryToken(ce CloudEnvironment, data url.Values, te
if res.StatusCode != 200 {
return azureToken{}, errors.Errorf("error while renewing access token, status : %s", res.Status)
}
bits, err := ioutil.ReadAll(res.Body)
bits, err := io.ReadAll(res.Body)
if err != nil {
return azureToken{}, err
}
@ -117,7 +118,7 @@ func openbrowser(address string) error {
}
func isWsl() bool {
b, err := ioutil.ReadFile("/proc/version")
b, err := os.ReadFile("/proc/version")
if err != nil {
return false
}

Просмотреть файл

@ -19,7 +19,6 @@ package login
import (
"context"
"errors"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
@ -39,7 +38,7 @@ import (
)
func testLoginService(t *testing.T, apiHelperMock *MockAzureHelper, cloudEnvironmentSvc CloudEnvironmentService) (*azureLoginService, error) {
dir, err := ioutil.TempDir("", "test_store")
dir, err := os.MkdirTemp("", "test_store")
if err != nil {
return nil, err
}

Просмотреть файл

@ -19,7 +19,6 @@ package login
import (
"encoding/json"
"errors"
"io/ioutil"
"os"
"path/filepath"
@ -71,11 +70,11 @@ func (store tokenStore) writeLoginInfo(info TokenInfo) error {
if err != nil {
return err
}
return ioutil.WriteFile(store.filePath, bytes, 0644)
return os.WriteFile(store.filePath, bytes, 0644)
}
func (store tokenStore) readToken() (TokenInfo, error) {
bytes, err := ioutil.ReadFile(store.filePath)
bytes, err := os.ReadFile(store.filePath)
if err != nil {
return TokenInfo{}, err
}

Просмотреть файл

@ -17,7 +17,6 @@
package login
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
@ -26,7 +25,7 @@ import (
)
func TestCreateStoreFromExistingFolder(t *testing.T) {
existingDir, err := ioutil.TempDir("", "test_store")
existingDir, err := os.MkdirTemp("", "test_store")
assert.NilError(t, err)
storePath := filepath.Join(existingDir, tokenStoreFilename)
@ -36,7 +35,7 @@ func TestCreateStoreFromExistingFolder(t *testing.T) {
}
func TestCreateStoreFromNonExistingFolder(t *testing.T) {
existingDir, err := ioutil.TempDir("", "test_store")
existingDir, err := os.MkdirTemp("", "test_store")
assert.NilError(t, err)
storePath := filepath.Join(existingDir, "new", tokenStoreFilename)
@ -50,7 +49,7 @@ func TestCreateStoreFromNonExistingFolder(t *testing.T) {
}
func TestErrorIfParentFolderIsAFile(t *testing.T) {
existingDir, err := ioutil.TempFile("", "test_store")
existingDir, err := os.CreateTemp("", "test_store")
assert.NilError(t, err)
storePath := filepath.Join(existingDir.Name(), tokenStoreFilename)

Просмотреть файл

@ -18,7 +18,6 @@ package config
import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
@ -78,12 +77,12 @@ func writeFile(path string, content map[string]interface{}) error {
if err != nil {
return errors.Wrap(err, "unable to marshal config")
}
err = ioutil.WriteFile(path, d, 0644)
err = os.WriteFile(path, d, 0644)
return errors.Wrap(err, "unable to write config file")
}
func loadFile(path string, dest interface{}) error {
data, err := ioutil.ReadFile(path)
data, err := os.ReadFile(path)
if err != nil {
if os.IsNotExist(err) {
// Not an error if there is no config, we're just using defaults

Просмотреть файл

@ -17,7 +17,6 @@
package config
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
@ -31,7 +30,7 @@ var sampleConfig = []byte(`{
}`)
func testConfigDir(t *testing.T) string {
d, _ := ioutil.TempDir("", "")
d, _ := os.MkdirTemp("", "")
t.Cleanup(func() {
_ = os.RemoveAll(d)
})
@ -39,7 +38,7 @@ func testConfigDir(t *testing.T) string {
}
func writeSampleConfig(t *testing.T, d string) {
err := ioutil.WriteFile(filepath.Join(d, ConfigFileName), sampleConfig, 0644)
err := os.WriteFile(filepath.Join(d, ConfigFileName), sampleConfig, 0644)
assert.NilError(t, err)
}
@ -77,7 +76,7 @@ func TestWriteDefaultContextToEmptyConfig(t *testing.T) {
d := testConfigDir(t)
err := WriteCurrentContext(d, "default")
assert.NilError(t, err)
c, err := ioutil.ReadFile(filepath.Join(d, ConfigFileName))
c, err := os.ReadFile(filepath.Join(d, ConfigFileName))
assert.NilError(t, err)
assert.Equal(t, string(c), "{}")
}

Просмотреть файл

@ -19,7 +19,6 @@ package store
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
@ -160,7 +159,7 @@ func (s *store) GetEndpoint(name string, data interface{}) error {
}
func read(meta string) (*DockerContext, error) {
bytes, err := ioutil.ReadFile(meta)
bytes, err := os.ReadFile(meta)
if err != nil {
return nil, err
}
@ -246,12 +245,12 @@ func (s *store) Create(name string, contextType string, description string, data
return err
}
return ioutil.WriteFile(filepath.Join(metaDir, metaFile), bytes, 0644)
return os.WriteFile(filepath.Join(metaDir, metaFile), bytes, 0644)
}
func (s *store) List() ([]*DockerContext, error) {
root := filepath.Join(s.root, contextsDir, metadataDir)
c, err := ioutil.ReadDir(root)
c, err := os.ReadDir(root)
if err != nil {
return nil, err
}

Просмотреть файл

@ -18,7 +18,6 @@ package store
import (
_ "crypto/sha256"
"io/ioutil"
"os"
"testing"
@ -29,7 +28,7 @@ import (
)
func testStore(t *testing.T) Store {
d, err := ioutil.TempDir("", "store")
d, err := os.MkdirTemp("", "store")
assert.NilError(t, err)
t.Cleanup(func() {

Просмотреть файл

@ -17,8 +17,9 @@
package context
import (
"github.com/docker/compose-cli/cli/mobycli"
"github.com/spf13/cobra"
"github.com/docker/compose-cli/cli/mobycli"
)
// Command manages contexts

Просмотреть файл

@ -17,8 +17,9 @@
package context
import (
"github.com/docker/compose-cli/cli/mobycli"
"github.com/spf13/cobra"
"github.com/docker/compose-cli/cli/mobycli"
)
type removeOpts struct {

Просмотреть файл

@ -19,7 +19,6 @@ package cmd
import (
"fmt"
"io"
"io/ioutil"
"os"
"github.com/docker/compose/v2/cmd/formatter"
@ -73,7 +72,7 @@ func createSecret() *cobra.Command {
}
defer func() { _ = in.Close() }()
}
content, err := ioutil.ReadAll(in)
content, err := io.ReadAll(in)
if err != nil {
return fmt.Errorf("failed to read content from %q: %v", file, err)
}

Просмотреть файл

@ -17,7 +17,6 @@
package config
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
@ -32,11 +31,11 @@ var contextSetConfig = []byte(`{
}`)
func TestDetermineCurrentContext(t *testing.T) {
d, err := ioutil.TempDir("", "")
d, err := os.MkdirTemp("", "")
// nolint errcheck
defer os.RemoveAll(d)
assert.NilError(t, err)
err = ioutil.WriteFile(filepath.Join(d, config.ConfigFileName), contextSetConfig, 0644)
err = os.WriteFile(filepath.Join(d, config.ConfigFileName), contextSetConfig, 0644)
assert.NilError(t, err)
// If nothing set, fallback to default

Просмотреть файл

@ -32,8 +32,7 @@ type client struct {
}
type cliversion struct {
version string
f func() string
f func() string
}
// Command is a command

Просмотреть файл

@ -21,7 +21,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
@ -115,7 +114,7 @@ func buildxDriver(dockercfg *configfile.ConfigFile, buildArgs []string) string {
// "Name": "builder",
// "Global": false
// }
rawCurrent, err := ioutil.ReadFile(fileCurrent)
rawCurrent, err := os.ReadFile(fileCurrent)
if err != nil {
return driver
}
@ -167,7 +166,7 @@ func buildxDriver(dockercfg *configfile.ConfigFile, buildArgs []string) string {
// ],
// "Dynamic": false
// }
rawBuilder, err := ioutil.ReadFile(fileBuilder)
rawBuilder, err := os.ReadFile(fileBuilder)
if err != nil {
return driver
}

Просмотреть файл

@ -20,8 +20,9 @@ import (
"os"
"strings"
"github.com/docker/compose-cli/cli/metrics/metadata"
"github.com/docker/compose/v2/pkg/utils"
"github.com/docker/compose-cli/cli/metrics/metadata"
)
func (c *client) Track(context string, args []string, status string) {

Просмотреть файл

@ -28,13 +28,14 @@ import (
"runtime"
"strings"
"github.com/docker/compose/v2/pkg/compose"
"github.com/google/shlex"
"github.com/spf13/cobra"
apicontext "github.com/docker/compose-cli/api/context"
"github.com/docker/compose-cli/api/context/store"
"github.com/docker/compose-cli/cli/metrics"
"github.com/docker/compose-cli/cli/mobycli/resolvepath"
"github.com/docker/compose/v2/pkg/compose"
"github.com/google/shlex"
"github.com/spf13/cobra"
)
var delegatedContextTypes = []string{store.DefaultContextType}

Просмотреть файл

@ -23,8 +23,9 @@ import (
"gotest.tools/v3/assert"
"github.com/docker/compose-cli/api/context/store"
"github.com/stretchr/testify/require"
"github.com/docker/compose-cli/api/context/store"
)
func TestDelegateContextTypeToMoby(t *testing.T) {

Просмотреть файл

@ -18,7 +18,6 @@ package server
import (
"context"
"io/ioutil"
"os"
"path"
"testing"
@ -33,7 +32,7 @@ import (
)
func testContext(t *testing.T) context.Context {
dir, err := ioutil.TempDir("", "example")
dir, err := os.MkdirTemp("", "example")
assert.NilError(t, err)
t.Cleanup(func() {
@ -42,7 +41,7 @@ func testContext(t *testing.T) context.Context {
ctx := context.Background()
config.WithDir(dir)
err = ioutil.WriteFile(path.Join(dir, "config.json"), []byte(`{"currentContext": "default"}`), 0644)
err = os.WriteFile(path.Join(dir, "config.json"), []byte(`{"currentContext": "default"}`), 0644)
assert.NilError(t, err)
return ctx

Просмотреть файл

@ -23,13 +23,14 @@ package v1
import (
context "context"
reflect "reflect"
sync "sync"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (

Просмотреть файл

@ -23,13 +23,14 @@ package v1
import (
context "context"
reflect "reflect"
sync "sync"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (

Просмотреть файл

@ -23,14 +23,15 @@ package v1
import (
context "context"
reflect "reflect"
sync "sync"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
anypb "google.golang.org/protobuf/types/known/anypb"
reflect "reflect"
sync "sync"
)
const (

Просмотреть файл

@ -23,14 +23,15 @@ package v1
import (
context "context"
reflect "reflect"
sync "sync"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
_ "google.golang.org/protobuf/types/known/anypb"
reflect "reflect"
sync "sync"
)
const (

Просмотреть файл

@ -18,7 +18,6 @@ package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
@ -82,7 +81,7 @@ func loadLongDescription(cmd *cobra.Command, path ...string) error {
continue
}
content, err := ioutil.ReadFile(fullpath)
content, err := os.ReadFile(fullpath)
if err != nil {
return err
}

Просмотреть файл

@ -19,7 +19,7 @@ package ecs
import (
"context"
"fmt"
"io/ioutil"
"os"
"regexp"
"strings"
@ -38,12 +38,13 @@ import (
"github.com/compose-spec/compose-go/types"
"github.com/distribution/distribution/v3/reference"
cliconfig "github.com/docker/cli/cli/config"
"github.com/docker/compose-cli/api/config"
"github.com/docker/compose-cli/utils"
"github.com/docker/compose/v2/pkg/api"
"github.com/opencontainers/go-digest"
"sigs.k8s.io/kustomize/kyaml/yaml"
"sigs.k8s.io/kustomize/kyaml/yaml/merge2"
"github.com/docker/compose-cli/api/config"
"github.com/docker/compose-cli/utils"
)
func (b *ecsAPIService) Convert(ctx context.Context, project *types.Project, options api.ConvertOptions) ([]byte, error) {
@ -297,7 +298,7 @@ func (b *ecsAPIService) createSecret(project *types.Project, name string, s type
if s.External.External {
return nil
}
sensitiveData, err := ioutil.ReadFile(s.File)
sensitiveData, err := os.ReadFile(s.File)
if err != nil {
return err
}
@ -543,5 +544,6 @@ func volumeResourceName(service string) string {
}
func normalizeResourceName(s string) string {
//nolint:staticcheck // Preserving for compatibility
return strings.Title(regexp.MustCompile("[^a-zA-Z0-9]+").ReplaceAllString(s, ""))
}

Просмотреть файл

@ -20,7 +20,7 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"os"
"reflect"
"testing"
@ -41,7 +41,7 @@ import (
)
func TestSimpleConvert(t *testing.T) {
bytes, err := ioutil.ReadFile("testdata/input/simple-single-service.yaml")
bytes, err := os.ReadFile("testdata/input/simple-single-service.yaml")
assert.NilError(t, err)
template := convertYaml(t, string(bytes), nil, useDefaultVPC)
resultAsJSON, err := marshall(template, "yaml")

Просмотреть файл

@ -499,7 +499,7 @@ func toLinuxParameters(service types.ServiceConfig) *ecs.TaskDefinition_LinuxPar
}
func toTmpfs(tmpfs types.StringList) []ecs.TaskDefinition_Tmpfs {
if tmpfs == nil || len(tmpfs) == 0 {
if len(tmpfs) == 0 {
return nil
}
o := []ecs.TaskDefinition_Tmpfs{}
@ -549,7 +549,7 @@ func durationToInt(interval *types.Duration) int {
}
func toHostEntryPtr(hosts types.HostsList) []ecs.TaskDefinition_HostEntry {
if hosts == nil || len(hosts) == 0 {
if len(hosts) == 0 {
return nil
}
e := []ecs.TaskDefinition_HostEntry{}

Просмотреть файл

@ -19,9 +19,10 @@ package ecs
import (
"context"
"github.com/docker/compose-cli/utils"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/progress"
"github.com/docker/compose-cli/utils"
)
func (b *ecsAPIService) Down(ctx context.Context, projectName string, options api.DownOptions) error {

Просмотреть файл

@ -18,7 +18,6 @@ package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"path/filepath"
@ -54,7 +53,7 @@ func TestSecrets(t *testing.T) {
t.Run("create secret", func(t *testing.T) {
secretFile := filepath.Join(cmd.BinDir, "secret.txt")
err := ioutil.WriteFile(secretFile, []byte("pass1"), 0644)
err := os.WriteFile(secretFile, []byte("pass1"), 0644)
assert.Check(t, err == nil)
res := cmd.RunDockerCmd("secret", "create", secretName, secretFile)
assert.Check(t, strings.Contains(res.Stdout(), secretName), res.Stdout())

Просмотреть файл

@ -20,8 +20,9 @@ import (
"context"
"fmt"
"github.com/docker/compose-cli/utils"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose-cli/utils"
)
func (b *ecsAPIService) List(ctx context.Context, opts api.ListOptions) ([]api.Stack, error) {

Просмотреть файл

@ -19,8 +19,9 @@ package ecs
import (
"context"
"github.com/docker/compose-cli/utils"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose-cli/utils"
)
func (b *ecsAPIService) Ps(ctx context.Context, projectName string, options api.PsOptions) ([]api.ContainerSummary, error) {

Просмотреть файл

@ -17,7 +17,6 @@
package resolv
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
@ -35,7 +34,7 @@ func TestSetDomain(t *testing.T) {
err := SetSearchDomains(f, "foo", "bar", "zot")
assert.NilError(t, err)
got, err := ioutil.ReadFile(f)
got, err := os.ReadFile(f)
assert.NilError(t, err)
golden.Assert(t, string(got), "resolv.conf.golden")
}

Просмотреть файл

@ -938,7 +938,8 @@ func (s sdk) DescribeServiceTasks(ctx context.Context, cluster string, project s
Name: id.Resource,
Project: project,
Service: service,
State: strings.Title(strings.ToLower(aws.StringValue(t.LastStatus))),
//nolint:staticcheck // Preserving for compatibility
State: strings.Title(strings.ToLower(aws.StringValue(t.LastStatus))),
})
}

Просмотреть файл

@ -19,7 +19,6 @@ package secrets
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
)
@ -42,7 +41,7 @@ func CreateSecretFiles(secret Secret, path string) error {
if len(secret.Keys) == 0 {
// raw Secret
fmt.Printf("inject Secret %q info %s\n", secret.Name, secrets)
return ioutil.WriteFile(secrets, []byte(value), 0444)
return os.WriteFile(secrets, []byte(value), 0444)
}
var unmarshalled interface{}
@ -87,7 +86,7 @@ func CreateSecretFiles(secret Secret, path string) error {
}
}
err = ioutil.WriteFile(path, raw, 0444)
err = os.WriteFile(path, raw, 0444)
if err != nil {
return err
}

Просмотреть файл

@ -17,7 +17,6 @@
package secrets
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
@ -37,7 +36,7 @@ func TestRawSecret(t *testing.T) {
Keys: nil,
}, dir)
assert.NilError(t, err)
file, err := ioutil.ReadFile(filepath.Join(dir, "raw"))
file, err := os.ReadFile(filepath.Join(dir, "raw"))
assert.NilError(t, err)
content := string(file)
assert.Equal(t, content, "something_secret")
@ -58,7 +57,7 @@ func TestSelectedKeysSecret(t *testing.T) {
Keys: []string{"foo"},
}, dir)
assert.NilError(t, err)
file, err := ioutil.ReadFile(filepath.Join(dir, "json", "foo"))
file, err := os.ReadFile(filepath.Join(dir, "json", "foo"))
assert.NilError(t, err)
content := string(file)
assert.Equal(t, content, "bar")
@ -82,12 +81,12 @@ func TestAllKeysSecret(t *testing.T) {
Keys: []string{"*"},
}, dir)
assert.NilError(t, err)
file, err := ioutil.ReadFile(filepath.Join(dir, "json", "foo"))
file, err := os.ReadFile(filepath.Join(dir, "json", "foo"))
assert.NilError(t, err)
content := string(file)
assert.Equal(t, content, "bar")
file, err = ioutil.ReadFile(filepath.Join(dir, "json", "zot"))
file, err = os.ReadFile(filepath.Join(dir, "json", "zot"))
assert.NilError(t, err)
content = string(file)
assert.Equal(t, content, "qix")

Просмотреть файл

@ -24,10 +24,11 @@ import (
"syscall"
"github.com/compose-spec/compose-go/types"
"github.com/docker/compose-cli/utils"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/progress"
"github.com/sirupsen/logrus"
"github.com/docker/compose-cli/utils"
)
func (b *ecsAPIService) Up(ctx context.Context, project *types.Project, options api.UpOptions) error {

Просмотреть файл

@ -28,10 +28,11 @@ import (
"strings"
"github.com/compose-spec/compose-go/types"
"github.com/docker/compose-cli/kube/resources"
"github.com/pkg/errors"
"gopkg.in/yaml.v3"
"github.com/docker/compose-cli/kube/resources"
chart "helm.sh/helm/v3/pkg/chart"
loader "helm.sh/helm/v3/pkg/chart/loader"
"k8s.io/apimachinery/pkg/runtime"

Просмотреть файл

@ -23,10 +23,11 @@ import (
"fmt"
"os"
"github.com/docker/compose-cli/api/context/store"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
"github.com/docker/compose-cli/api/context/store"
)
// ListAvailableKubeConfigContexts list kube contexts

Просмотреть файл

@ -20,7 +20,7 @@
package resources
import (
"io/ioutil"
"os"
"strings"
"github.com/compose-spec/compose-go/types"
@ -37,7 +37,7 @@ func toSecretSpecs(project *types.Project) ([]corev1.Secret, error) {
}
name := strings.ReplaceAll(s.Name, "_", "-")
// load secret file content
sensitiveData, err := ioutil.ReadFile(s.File)
sensitiveData, err := os.ReadFile(s.File)
if err != nil {
return nil, err
}

Просмотреть файл

@ -18,7 +18,6 @@ package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime"
@ -326,13 +325,13 @@ func TestLoginCommandDelegation(t *testing.T) {
func TestMissingExistingCLI(t *testing.T) {
t.Parallel()
home, err := ioutil.TempDir("", "")
home, err := os.MkdirTemp("", "")
assert.NilError(t, err)
t.Cleanup(func() {
_ = os.RemoveAll(home)
})
bin, err := ioutil.TempDir("", "")
bin, err := os.MkdirTemp("", "")
assert.NilError(t, err)
t.Cleanup(func() {
_ = os.RemoveAll(bin)

Просмотреть файл

@ -17,7 +17,6 @@
package e2e
import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
@ -71,12 +70,12 @@ func TestKillChildProcess(t *testing.T) {
}
func writeDockerfile(t *testing.T) string {
d, err := ioutil.TempDir("", "")
d, err := os.MkdirTemp("", "")
assert.NilError(t, err)
t.Cleanup(func() {
_ = os.RemoveAll(d)
})
err = ioutil.WriteFile(filepath.Join(d, "Dockerfile"), []byte(`FROM alpine:3.10
err = os.WriteFile(filepath.Join(d, "Dockerfile"), []byte(`FROM alpine:3.10
RUN sleep 100`), 0644)
assert.NilError(t, err)
return d

Просмотреть файл

@ -21,10 +21,11 @@ import (
"fmt"
"strings"
"github.com/docker/compose-cli/api/config"
"github.com/docker/compose/v2/pkg/api"
"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
"github.com/docker/compose-cli/api/config"
)
// CheckUnsupported checks if a flag was used when it shouldn't and adds an error in case

Просмотреть файл

@ -19,7 +19,6 @@ package e2e
import (
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"os/exec"
@ -70,12 +69,12 @@ func NewE2eCLI(t *testing.T, binDir string) *E2eCLI {
}
func newE2eCLI(t *testing.T, binDir string) *E2eCLI {
d, err := ioutil.TempDir("", "")
d, err := os.MkdirTemp("", "")
assert.Check(t, is.Nil(err))
t.Cleanup(func() {
if t.Failed() {
conf, _ := ioutil.ReadFile(filepath.Join(d, "config.json"))
conf, _ := os.ReadFile(filepath.Join(d, "config.json"))
t.Errorf("Config: %s\n", string(conf))
t.Error("Contents of config dir:")
for _, p := range dirContents(d) {
@ -124,7 +123,7 @@ func SetupExistingCLI() (string, func(), error) {
}
}
d, err := ioutil.TempDir("", "")
d, err := os.MkdirTemp("", "")
if err != nil {
return "", nil, err
}
@ -315,7 +314,7 @@ func HTTPGetWithRetry(t *testing.T, endpoint string, expectedStatus int, retryDe
}
poll.WaitOn(t, checkUp, poll.WithDelay(retryDelay), poll.WithTimeout(timeout))
if r != nil {
b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
assert.NilError(t, err)
return string(b)
}

Просмотреть файл

@ -17,7 +17,7 @@
package e2e
import (
"io/ioutil"
"io"
"log"
"net"
"net/http"
@ -42,7 +42,7 @@ func NewMetricsServer(socket string) *MockMetricsServer {
}
func (s *MockMetricsServer) handlePostUsage(c echo.Context) error {
body, error := ioutil.ReadAll(c.Request().Body)
body, error := io.ReadAll(c.Request().Body)
if error != nil {
return error
}