Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 0204892

Browse files
committed
lint: update for Go 1.19 / golangci-lint 1.50.1
Signed-off-by: Milas Bowman <[email protected]>
1 parent e821c36 commit 0204892

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+122
-125
lines changed

.golangci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,28 @@ linters:
66
enable-all: false
77
disable-all: true
88
enable:
9-
- deadcode
109
- errcheck
1110
- gocyclo
1211
- gofmt
1312
- goimports
14-
- revive
1513
- gosimple
1614
- govet
1715
- ineffassign
1816
- lll
1917
- misspell
2018
- nakedret
2119
- staticcheck
22-
- structcheck
2320
- typecheck
2421
- unconvert
2522
- unparam
2623
- unused
27-
- varcheck
2824
linters-settings:
2925
gocyclo:
3026
min-complexity: 16
3127
lll:
3228
line-length: 200
29+
goimports:
30+
local-prefixes: github.com/docker/compose-cli
3331
issues:
3432
# golangci hides some golint warnings (the warning about exported things
3533
# withtout documentation for example), this will make it show them anyway.

aci/backend_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ import (
2323
"github.com/stretchr/testify/mock"
2424
"gotest.tools/v3/assert"
2525

26+
"golang.org/x/oauth2"
27+
2628
"github.com/docker/compose-cli/aci/login"
2729
"github.com/docker/compose-cli/api/containers"
28-
"golang.org/x/oauth2"
2930
)
3031

3132
func TestGetContainerName(t *testing.T) {

aci/compose.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ import (
2222
"net/http"
2323

2424
"github.com/compose-spec/compose-go/types"
25-
"github.com/docker/compose-cli/utils"
2625
"github.com/docker/compose/v2/pkg/api"
2726
"github.com/docker/compose/v2/pkg/progress"
2827
"github.com/sirupsen/logrus"
2928

29+
"github.com/docker/compose-cli/utils"
30+
3031
"github.com/docker/compose-cli/aci/convert"
3132
"github.com/docker/compose-cli/aci/login"
3233
"github.com/docker/compose-cli/api/context/store"

aci/convert/convert.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func (s serviceConfigAciHelper) getResourceRequestsLimits() (*containerinstance.
218218
}
219219

220220
if hasCPURequest() {
221-
cpuRequest, err = strconv.ParseFloat(s.Deploy.Resources.Reservations.NanoCPUs, 0)
221+
cpuRequest, err = strconv.ParseFloat(s.Deploy.Resources.Reservations.NanoCPUs, 64)
222222
if err != nil {
223223
return nil, err
224224
}
@@ -233,7 +233,7 @@ func (s serviceConfigAciHelper) getResourceRequestsLimits() (*containerinstance.
233233
}
234234
}
235235
if s.Deploy.Resources.Limits.NanoCPUs != "" {
236-
cpuLimit, err = strconv.ParseFloat(s.Deploy.Resources.Limits.NanoCPUs, 0)
236+
cpuLimit, err = strconv.ParseFloat(s.Deploy.Resources.Limits.NanoCPUs, 64)
237237
if err != nil {
238238
return nil, err
239239
}

aci/convert/registry_credentials.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package convert
1919
import (
2020
"encoding/json"
2121
"fmt"
22-
"io/ioutil"
22+
"io"
2323
"net/http"
2424
"net/url"
2525
"os"
@@ -165,7 +165,7 @@ func (c cliRegistryHelper) autoLoginAcr(registry string, loginService login.Azur
165165
if err != nil {
166166
return errors.Wrap(err, "could not query ACR token")
167167
}
168-
bits, err := ioutil.ReadAll(res.Body)
168+
bits, err := io.ReadAll(res.Body)
169169
if err != nil {
170170
return errors.Wrap(err, "could not read response body")
171171
}

aci/convert/registry_credentials_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ import (
2525
"github.com/Azure/go-autorest/autorest/to"
2626
"github.com/compose-spec/compose-go/types"
2727
cliconfigtypes "github.com/docker/cli/cli/config/types"
28-
"github.com/docker/compose-cli/aci/login"
2928
"github.com/stretchr/testify/mock"
3029
"gotest.tools/v3/assert"
3130
is "gotest.tools/v3/assert/cmp"
31+
32+
"github.com/docker/compose-cli/aci/login"
3233
)
3334

3435
const getAllCredentials = "getAllRegistryCredentials"

aci/convert/secrets.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package convert
1919
import (
2020
"encoding/base64"
2121
"fmt"
22-
"io/ioutil"
22+
"os"
2323
"path"
2424
"strings"
2525

@@ -43,7 +43,7 @@ func (p projectAciHelper) getAciSecretVolumes() ([]containerinstance.Volume, err
4343
for _, svc := range p.Services {
4444
squashedTargetVolumes := make(map[string]containerinstance.Volume)
4545
for _, scr := range svc.Secrets {
46-
data, err := ioutil.ReadFile(p.Secrets[scr.Source].File)
46+
data, err := os.ReadFile(p.Secrets[scr.Source].File)
4747
if err != nil {
4848
return secretVolumes, err
4949
}

aci/convert/secrets_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package convert
1818

1919
import (
2020
"fmt"
21-
"io/ioutil"
2221
"os"
2322
"path"
2423
"testing"
@@ -31,7 +30,7 @@ func TestConvertSecrets(t *testing.T) {
3130
serviceName := "testservice"
3231
secretName := "testsecret"
3332
absBasePath := "/home/user"
34-
tmpFile, err := ioutil.TempFile(os.TempDir(), "TestConvertProjectSecrets-")
33+
tmpFile, err := os.CreateTemp(os.TempDir(), "TestConvertProjectSecrets-")
3534
assert.NilError(t, err)
3635
_, err = tmpFile.Write([]byte("test content"))
3736
assert.NilError(t, err)

aci/e2e/aci-demo/web/dispatcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package main
1818

1919
import (
2020
"fmt"
21-
"io/ioutil"
21+
"io"
2222
"log"
2323
"math/rand"
2424
"net"
@@ -75,7 +75,7 @@ func copy(url, ip string, w http.ResponseWriter) error {
7575

7676
w.Header().Set("source", ip)
7777

78-
buf, err := ioutil.ReadAll(resp.Body)
78+
buf, err := io.ReadAll(resp.Body)
7979
if err != nil {
8080
return err
8181
}

aci/e2e/e2e-aci_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"encoding/json"
2323
"errors"
2424
"fmt"
25-
"io/ioutil"
2625
"math/rand"
2726
"net/http"
2827
"net/url"
@@ -533,10 +532,10 @@ func TestContainerRunAttached(t *testing.T) {
533532
}
534533

535534
func overwriteFileStorageAccount(t *testing.T, absComposefileName string, storageAccount string) {
536-
data, err := ioutil.ReadFile(absComposefileName)
535+
data, err := os.ReadFile(absComposefileName)
537536
assert.NilError(t, err)
538537
override := strings.Replace(string(data), "dockertestvolumeaccount", storageAccount, 1)
539-
err = ioutil.WriteFile(absComposefileName, []byte(override), 0644)
538+
err = os.WriteFile(absComposefileName, []byte(override), 0644)
540539
assert.NilError(t, err)
541540
}
542541

0 commit comments

Comments
 (0)