mirror of https://github.com/docker/cli.git
Update gometalinter
The update includes bug fixes in gometalinter and updates to linters, which discovered more linter problems. Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
0856c20e04
commit
d956386b2d
|
@ -185,6 +185,7 @@ func setRawTerminal(streams command.Streams) error {
|
||||||
return streams.Out().SetRawTerminal()
|
return streams.Out().SetRawTerminal()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint: unparam
|
||||||
func restoreTerminal(streams command.Streams, in io.Closer) error {
|
func restoreTerminal(streams command.Streams, in io.Closer) error {
|
||||||
streams.In().RestoreTerminal()
|
streams.In().RestoreTerminal()
|
||||||
streams.Out().RestoreTerminal()
|
streams.Out().RestoreTerminal()
|
||||||
|
|
|
@ -43,6 +43,7 @@ func TestValidateAttach(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint: unparam
|
||||||
func parseRun(args []string) (*container.Config, *container.HostConfig, *networktypes.NetworkingConfig, error) {
|
func parseRun(args []string) (*container.Config, *container.HostConfig, *networktypes.NetworkingConfig, error) {
|
||||||
flags := pflag.NewFlagSet("run", pflag.ContinueOnError)
|
flags := pflag.NewFlagSet("run", pflag.ContinueOnError)
|
||||||
flags.SetOutput(ioutil.Discard)
|
flags.SetOutput(ioutil.Discard)
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/docker/notary/passphrase"
|
"github.com/docker/notary/passphrase"
|
||||||
"github.com/docker/notary/trustpinning"
|
"github.com/docker/notary/trustpinning"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func unsetENV() {
|
func unsetENV() {
|
||||||
|
@ -67,6 +68,7 @@ func TestAddTargetToAllSignableRolesError(t *testing.T) {
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever("password"), trustpinning.TrustPinConfig{})
|
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever("password"), trustpinning.TrustPinConfig{})
|
||||||
|
require.NoError(t, err)
|
||||||
target := client.Target{}
|
target := client.Target{}
|
||||||
err = AddTargetToAllSignableRoles(notaryRepo, &target)
|
err = AddTargetToAllSignableRoles(notaryRepo, &target)
|
||||||
assert.EqualError(t, err, "client is offline")
|
assert.EqualError(t, err, "client is offline")
|
||||||
|
|
|
@ -104,13 +104,12 @@ func checkDaemonIsSwarmManager(ctx context.Context, dockerCli command.Cli) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// pruneServices removes services that are no longer referenced in the source
|
// pruneServices removes services that are no longer referenced in the source
|
||||||
func pruneServices(ctx context.Context, dockerCli command.Cli, namespace convert.Namespace, services map[string]struct{}) bool {
|
func pruneServices(ctx context.Context, dockerCli command.Cli, namespace convert.Namespace, services map[string]struct{}) {
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
|
|
||||||
oldServices, err := getServices(ctx, client, namespace.Name())
|
oldServices, err := getServices(ctx, client, namespace.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(dockerCli.Err(), "Failed to list services: %s", err)
|
fmt.Fprintf(dockerCli.Err(), "Failed to list services: %s", err)
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pruneServices := []swarm.Service{}
|
pruneServices := []swarm.Service{}
|
||||||
|
@ -119,5 +118,5 @@ func pruneServices(ctx context.Context, dockerCli command.Cli, namespace convert
|
||||||
pruneServices = append(pruneServices, service)
|
pruneServices = append(pruneServices, service)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return removeServices(ctx, dockerCli, pruneServices)
|
removeServices(ctx, dockerCli, pruneServices)
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ func TestStackPsEmptyStack(t *testing.T) {
|
||||||
})
|
})
|
||||||
cmd := newPsCommand(fakeCli)
|
cmd := newPsCommand(fakeCli)
|
||||||
cmd.SetArgs([]string{"foo"})
|
cmd.SetArgs([]string{"foo"})
|
||||||
|
cmd.SetOutput(ioutil.Discard)
|
||||||
|
|
||||||
assert.Error(t, cmd.Execute())
|
assert.Error(t, cmd.Execute())
|
||||||
assert.EqualError(t, cmd.Execute(), "nothing found in stack: foo")
|
assert.EqualError(t, cmd.Execute(), "nothing found in stack: foo")
|
||||||
|
|
|
@ -15,24 +15,20 @@ import (
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
type unlockOptions struct{}
|
|
||||||
|
|
||||||
func newUnlockCommand(dockerCli command.Cli) *cobra.Command {
|
func newUnlockCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
opts := unlockOptions{}
|
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "unlock",
|
Use: "unlock",
|
||||||
Short: "Unlock swarm",
|
Short: "Unlock swarm",
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return runUnlock(dockerCli, opts)
|
return runUnlock(dockerCli)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func runUnlock(dockerCli command.Cli, opts unlockOptions) error {
|
func runUnlock(dockerCli command.Cli) error {
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/docker/notary/passphrase"
|
"github.com/docker/notary/passphrase"
|
||||||
"github.com/docker/notary/trustpinning"
|
"github.com/docker/notary/trustpinning"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestTrustRevokeCommandErrors(t *testing.T) {
|
func TestTrustRevokeCommandErrors(t *testing.T) {
|
||||||
|
@ -140,6 +141,7 @@ func TestGetSignableRolesForTargetAndRemoveError(t *testing.T) {
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever("password"), trustpinning.TrustPinConfig{})
|
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever("password"), trustpinning.TrustPinConfig{})
|
||||||
|
require.NoError(t, err)
|
||||||
target := client.Target{}
|
target := client.Target{}
|
||||||
err = getSignableRolesForTargetAndRemove(target, notaryRepo)
|
err = getSignableRolesForTargetAndRemove(target, notaryRepo)
|
||||||
assert.EqualError(t, err, "client is offline")
|
assert.EqualError(t, err, "client is offline")
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
"github.com/docker/notary/trustpinning"
|
"github.com/docker/notary/trustpinning"
|
||||||
"github.com/docker/notary/tuf/data"
|
"github.com/docker/notary/tuf/data"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
const passwd = "password"
|
const passwd = "password"
|
||||||
|
@ -151,6 +152,7 @@ func TestAddStageSigners(t *testing.T) {
|
||||||
NewThreshold: notary.MinThreshold,
|
NewThreshold: notary.MinThreshold,
|
||||||
AddKeys: data.KeyList([]data.PublicKey{userKey}),
|
AddKeys: data.KeyList([]data.PublicKey{userKey}),
|
||||||
})
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
expectedChange := changelist.NewTUFChange(
|
expectedChange := changelist.NewTUFChange(
|
||||||
changelist.ActionCreate,
|
changelist.ActionCreate,
|
||||||
userRole,
|
userRole,
|
||||||
|
@ -165,6 +167,7 @@ func TestAddStageSigners(t *testing.T) {
|
||||||
expectedJSON, err = json.Marshal(&changelist.TUFDelegation{
|
expectedJSON, err = json.Marshal(&changelist.TUFDelegation{
|
||||||
AddPaths: []string{""},
|
AddPaths: []string{""},
|
||||||
})
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
expectedChange = changelist.NewTUFChange(
|
expectedChange = changelist.NewTUFChange(
|
||||||
changelist.ActionCreate,
|
changelist.ActionCreate,
|
||||||
userRole,
|
userRole,
|
||||||
|
@ -182,6 +185,7 @@ func TestAddStageSigners(t *testing.T) {
|
||||||
NewThreshold: notary.MinThreshold,
|
NewThreshold: notary.MinThreshold,
|
||||||
AddKeys: data.KeyList([]data.PublicKey{userKey}),
|
AddKeys: data.KeyList([]data.PublicKey{userKey}),
|
||||||
})
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
expectedChange = changelist.NewTUFChange(
|
expectedChange = changelist.NewTUFChange(
|
||||||
changelist.ActionCreate,
|
changelist.ActionCreate,
|
||||||
releasesRole,
|
releasesRole,
|
||||||
|
@ -196,6 +200,7 @@ func TestAddStageSigners(t *testing.T) {
|
||||||
expectedJSON, err = json.Marshal(&changelist.TUFDelegation{
|
expectedJSON, err = json.Marshal(&changelist.TUFDelegation{
|
||||||
AddPaths: []string{""},
|
AddPaths: []string{""},
|
||||||
})
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
expectedChange = changelist.NewTUFChange(
|
expectedChange = changelist.NewTUFChange(
|
||||||
changelist.ActionCreate,
|
changelist.ActionCreate,
|
||||||
releasesRole,
|
releasesRole,
|
||||||
|
@ -268,18 +273,24 @@ func TestPrettyPrintExistingSignatureInfo(t *testing.T) {
|
||||||
assert.Contains(t, fakeCli.OutBuffer().String(), "Existing signatures for tag tagName digest abc123 from:\nAlice, Bob, Carol")
|
assert.Contains(t, fakeCli.OutBuffer().String(), "Existing signatures for tag tagName digest abc123 from:\nAlice, Bob, Carol")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestChangeList(t *testing.T) {
|
func TestSignCommandChangeListIsCleanedOnError(t *testing.T) {
|
||||||
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
|
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
config.SetDir(tmpDir)
|
config.SetDir(tmpDir)
|
||||||
cmd := newSignCommand(
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
test.NewFakeCli(&fakeClient{}))
|
cli.SetNotaryClient(getLoadedNotaryRepository)
|
||||||
|
cmd := newSignCommand(cli)
|
||||||
cmd.SetArgs([]string{"ubuntu:latest"})
|
cmd.SetArgs([]string{"ubuntu:latest"})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
|
|
||||||
err = cmd.Execute()
|
err = cmd.Execute()
|
||||||
|
require.Error(t, err)
|
||||||
|
|
||||||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "docker.io/library/ubuntu", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
|
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "docker.io/library/ubuntu", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
cl, err := notaryRepo.GetChangelist()
|
cl, err := notaryRepo.GetChangelist()
|
||||||
|
require.NoError(t, err)
|
||||||
assert.Equal(t, len(cl.List()), 0)
|
assert.Equal(t, len(cl.List()), 0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,9 @@ func lookupTrustInfo(cli command.Cli, remote string) error {
|
||||||
// If we do not have additional signers, do not display
|
// If we do not have additional signers, do not display
|
||||||
if len(signerRoleToKeyIDs) > 0 {
|
if len(signerRoleToKeyIDs) > 0 {
|
||||||
fmt.Fprintf(cli.Out(), "\nList of signers and their keys for %s:\n\n", strings.Split(remote, ":")[0])
|
fmt.Fprintf(cli.Out(), "\nList of signers and their keys for %s:\n\n", strings.Split(remote, ":")[0])
|
||||||
printSignerInfo(cli.Out(), signerRoleToKeyIDs)
|
if err := printSignerInfo(cli.Out(), signerRoleToKeyIDs); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will always have the root and targets information
|
// This will always have the root and targets information
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/docker/notary/trustpinning"
|
"github.com/docker/notary/trustpinning"
|
||||||
digest "github.com/opencontainers/go-digest"
|
digest "github.com/opencontainers/go-digest"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetTag(t *testing.T) {
|
func TestGetTag(t *testing.T) {
|
||||||
|
@ -53,6 +54,7 @@ func TestGetSignableRolesError(t *testing.T) {
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever("password"), trustpinning.TrustPinConfig{})
|
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever("password"), trustpinning.TrustPinConfig{})
|
||||||
|
require.NoError(t, err)
|
||||||
target := client.Target{}
|
target := client.Target{}
|
||||||
_, err = GetSignableRoles(notaryRepo, &target)
|
_, err = GetSignableRoles(notaryRepo, &target)
|
||||||
assert.EqualError(t, err, "client is offline")
|
assert.EqualError(t, err, "client is offline")
|
||||||
|
|
|
@ -2,7 +2,7 @@ FROM golang:1.8.3-alpine
|
||||||
|
|
||||||
RUN apk add -U git
|
RUN apk add -U git
|
||||||
|
|
||||||
ARG GOMETALINTER_SHA=4306381615a2ba2a207f8fcea02c08c6b2b0803f
|
ARG GOMETALINTER_SHA=8eca55135021737bbc65ed68b548b3336853274c
|
||||||
RUN go get -d github.com/alecthomas/gometalinter && \
|
RUN go get -d github.com/alecthomas/gometalinter && \
|
||||||
cd /go/src/github.com/alecthomas/gometalinter && \
|
cd /go/src/github.com/alecthomas/gometalinter && \
|
||||||
git checkout -q "$GOMETALINTER_SHA" && \
|
git checkout -q "$GOMETALINTER_SHA" && \
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
"gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type cmdOption struct {
|
type cmdOption struct {
|
||||||
|
@ -46,18 +46,17 @@ type cmdDoc struct {
|
||||||
|
|
||||||
// GenYamlTree creates yaml structured ref files
|
// GenYamlTree creates yaml structured ref files
|
||||||
func GenYamlTree(cmd *cobra.Command, dir string) error {
|
func GenYamlTree(cmd *cobra.Command, dir string) error {
|
||||||
identity := func(s string) string { return s }
|
|
||||||
emptyStr := func(s string) string { return "" }
|
emptyStr := func(s string) string { return "" }
|
||||||
return GenYamlTreeCustom(cmd, dir, emptyStr, identity)
|
return GenYamlTreeCustom(cmd, dir, emptyStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenYamlTreeCustom creates yaml structured ref files
|
// GenYamlTreeCustom creates yaml structured ref files
|
||||||
func GenYamlTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error {
|
func GenYamlTreeCustom(cmd *cobra.Command, dir string, filePrepender func(string) string) error {
|
||||||
for _, c := range cmd.Commands() {
|
for _, c := range cmd.Commands() {
|
||||||
if !c.IsAvailableCommand() || c.IsHelpCommand() {
|
if !c.IsAvailableCommand() || c.IsHelpCommand() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := GenYamlTreeCustom(c, dir, filePrepender, linkHandler); err != nil {
|
if err := GenYamlTreeCustom(c, dir, filePrepender); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
{
|
{
|
||||||
"Vendor": true,
|
"Vendor": true,
|
||||||
"Deadline": "2m",
|
"Deadline": "2m",
|
||||||
"Sort": ["linter", "severity", "path"],
|
"Sort": ["linter", "severity", "path", "line"],
|
||||||
"Exclude": ["cli/compose/schema/bindata.go"],
|
"Exclude": [
|
||||||
|
"cli/compose/schema/bindata.go",
|
||||||
|
"parameter .* always receives"
|
||||||
|
],
|
||||||
|
"EnableGC": true,
|
||||||
|
|
||||||
"DisableAll": true,
|
"DisableAll": true,
|
||||||
"Enable": [
|
"Enable": [
|
||||||
|
|
Loading…
Reference in New Issue