mirror of https://github.com/docker/cli.git
commit
2bfac7fcda
|
@ -111,12 +111,7 @@ func runExec(dockerCli command.Cli, options *execOptions, container string, exec
|
||||||
Tty: execConfig.Tty,
|
Tty: execConfig.Tty,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := client.ContainerExecStart(ctx, execID, execStartCheck); err != nil {
|
return client.ContainerExecStart(ctx, execID, execStartCheck)
|
||||||
return err
|
|
||||||
}
|
|
||||||
// For now don't print this - wait for when we support exec wait()
|
|
||||||
// fmt.Fprintf(dockerCli.Out(), "%s\n", execID)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interactive exec requested.
|
// Interactive exec requested.
|
||||||
|
|
|
@ -110,7 +110,7 @@ func (h *hijackedIOStreamer) setupInput() (restore func(), err error) {
|
||||||
|
|
||||||
func (h *hijackedIOStreamer) beginOutputStream(restoreInput func()) <-chan error {
|
func (h *hijackedIOStreamer) beginOutputStream(restoreInput func()) <-chan error {
|
||||||
if h.outputStream == nil && h.errorStream == nil {
|
if h.outputStream == nil && h.errorStream == nil {
|
||||||
// Ther is no need to copy output.
|
// There is no need to copy output.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
deviceCgroupRuleRegexp = regexp.MustCompile("^[acb] ([0-9]+|\\*):([0-9]+|\\*) [rwm]{1,3}$")
|
deviceCgroupRuleRegexp = regexp.MustCompile(`^[acb] ([0-9]+|\*):([0-9]+|\*) [rwm]{1,3}$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
// containerOptions is a data object with all the options for creating a container
|
// containerOptions is a data object with all the options for creating a container
|
||||||
|
|
|
@ -61,16 +61,14 @@ func parseRun(args []string) (*container.Config, *container.HostConfig, *network
|
||||||
return containerConfig.Config, containerConfig.HostConfig, containerConfig.NetworkingConfig, err
|
return containerConfig.Config, containerConfig.HostConfig, containerConfig.NetworkingConfig, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func parsetest(t *testing.T, args string) (*container.Config, *container.HostConfig, error) {
|
func parseMustError(t *testing.T, args string) {
|
||||||
config, hostConfig, _, err := parseRun(strings.Split(args+" ubuntu bash", " "))
|
_, _, _, err := parseRun(strings.Split(args+" ubuntu bash", " "))
|
||||||
return config, hostConfig, err
|
assert.Error(t, err, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
func mustParse(t *testing.T, args string) (*container.Config, *container.HostConfig) {
|
func mustParse(t *testing.T, args string) (*container.Config, *container.HostConfig) {
|
||||||
config, hostConfig, err := parsetest(t, args)
|
config, hostConfig, _, err := parseRun(append(strings.Split(args, " "), "ubuntu", "bash"))
|
||||||
if err != nil {
|
assert.NoError(t, err)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
return config, hostConfig
|
return config, hostConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +84,6 @@ func TestParseRunLinks(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint: gocyclo
|
|
||||||
func TestParseRunAttach(t *testing.T) {
|
func TestParseRunAttach(t *testing.T) {
|
||||||
if config, _ := mustParse(t, "-a stdin"); !config.AttachStdin || config.AttachStdout || config.AttachStderr {
|
if config, _ := mustParse(t, "-a stdin"); !config.AttachStdin || config.AttachStdout || config.AttachStderr {
|
||||||
t.Fatalf("Error parsing attach flags. Expect only Stdin enabled. Received: in: %v, out: %v, err: %v", config.AttachStdin, config.AttachStdout, config.AttachStderr)
|
t.Fatalf("Error parsing attach flags. Expect only Stdin enabled. Received: in: %v, out: %v, err: %v", config.AttachStdin, config.AttachStdout, config.AttachStderr)
|
||||||
|
@ -103,31 +100,17 @@ func TestParseRunAttach(t *testing.T) {
|
||||||
if config, _ := mustParse(t, "-i"); !config.AttachStdin || !config.AttachStdout || !config.AttachStderr {
|
if config, _ := mustParse(t, "-i"); !config.AttachStdin || !config.AttachStdout || !config.AttachStderr {
|
||||||
t.Fatalf("Error parsing attach flags. Expect Stdin enabled. Received: in: %v, out: %v, err: %v", config.AttachStdin, config.AttachStdout, config.AttachStderr)
|
t.Fatalf("Error parsing attach flags. Expect Stdin enabled. Received: in: %v, out: %v, err: %v", config.AttachStdin, config.AttachStdout, config.AttachStderr)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if _, _, err := parsetest(t, "-a"); err == nil {
|
func TestParseRunWithInvalidArgs(t *testing.T) {
|
||||||
t.Fatal("Error parsing attach flags, `-a` should be an error but is not")
|
parseMustError(t, "-a")
|
||||||
}
|
parseMustError(t, "-a invalid")
|
||||||
if _, _, err := parsetest(t, "-a invalid"); err == nil {
|
parseMustError(t, "-a invalid -a stdout")
|
||||||
t.Fatal("Error parsing attach flags, `-a invalid` should be an error but is not")
|
parseMustError(t, "-a stdout -a stderr -d")
|
||||||
}
|
parseMustError(t, "-a stdin -d")
|
||||||
if _, _, err := parsetest(t, "-a invalid -a stdout"); err == nil {
|
parseMustError(t, "-a stdout -d")
|
||||||
t.Fatal("Error parsing attach flags, `-a stdout -a invalid` should be an error but is not")
|
parseMustError(t, "-a stderr -d")
|
||||||
}
|
parseMustError(t, "-d --rm")
|
||||||
if _, _, err := parsetest(t, "-a stdout -a stderr -d"); err == nil {
|
|
||||||
t.Fatal("Error parsing attach flags, `-a stdout -a stderr -d` should be an error but is not")
|
|
||||||
}
|
|
||||||
if _, _, err := parsetest(t, "-a stdin -d"); err == nil {
|
|
||||||
t.Fatal("Error parsing attach flags, `-a stdin -d` should be an error but is not")
|
|
||||||
}
|
|
||||||
if _, _, err := parsetest(t, "-a stdout -d"); err == nil {
|
|
||||||
t.Fatal("Error parsing attach flags, `-a stdout -d` should be an error but is not")
|
|
||||||
}
|
|
||||||
if _, _, err := parsetest(t, "-a stderr -d"); err == nil {
|
|
||||||
t.Fatal("Error parsing attach flags, `-a stderr -d` should be an error but is not")
|
|
||||||
}
|
|
||||||
if _, _, err := parsetest(t, "-d --rm"); err == nil {
|
|
||||||
t.Fatal("Error parsing attach flags, `-d --rm` should be an error but is not")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint: gocyclo
|
// nolint: gocyclo
|
||||||
|
|
|
@ -106,7 +106,7 @@ func runStats(dockerCli *command.DockerCli, opts *statsOptions) error {
|
||||||
closeChan <- err
|
closeChan <- err
|
||||||
}
|
}
|
||||||
for _, container := range cs {
|
for _, container := range cs {
|
||||||
s := formatter.NewContainerStats(container.ID[:12], daemonOSType)
|
s := formatter.NewContainerStats(container.ID[:12])
|
||||||
if cStats.add(s) {
|
if cStats.add(s) {
|
||||||
waitFirst.Add(1)
|
waitFirst.Add(1)
|
||||||
go collect(ctx, s, dockerCli.Client(), !opts.noStream, waitFirst)
|
go collect(ctx, s, dockerCli.Client(), !opts.noStream, waitFirst)
|
||||||
|
@ -123,7 +123,7 @@ func runStats(dockerCli *command.DockerCli, opts *statsOptions) error {
|
||||||
eh := command.InitEventHandler()
|
eh := command.InitEventHandler()
|
||||||
eh.Handle("create", func(e events.Message) {
|
eh.Handle("create", func(e events.Message) {
|
||||||
if opts.all {
|
if opts.all {
|
||||||
s := formatter.NewContainerStats(e.ID[:12], daemonOSType)
|
s := formatter.NewContainerStats(e.ID[:12])
|
||||||
if cStats.add(s) {
|
if cStats.add(s) {
|
||||||
waitFirst.Add(1)
|
waitFirst.Add(1)
|
||||||
go collect(ctx, s, dockerCli.Client(), !opts.noStream, waitFirst)
|
go collect(ctx, s, dockerCli.Client(), !opts.noStream, waitFirst)
|
||||||
|
@ -132,7 +132,7 @@ func runStats(dockerCli *command.DockerCli, opts *statsOptions) error {
|
||||||
})
|
})
|
||||||
|
|
||||||
eh.Handle("start", func(e events.Message) {
|
eh.Handle("start", func(e events.Message) {
|
||||||
s := formatter.NewContainerStats(e.ID[:12], daemonOSType)
|
s := formatter.NewContainerStats(e.ID[:12])
|
||||||
if cStats.add(s) {
|
if cStats.add(s) {
|
||||||
waitFirst.Add(1)
|
waitFirst.Add(1)
|
||||||
go collect(ctx, s, dockerCli.Client(), !opts.noStream, waitFirst)
|
go collect(ctx, s, dockerCli.Client(), !opts.noStream, waitFirst)
|
||||||
|
@ -158,7 +158,7 @@ func runStats(dockerCli *command.DockerCli, opts *statsOptions) error {
|
||||||
// Artificially send creation events for the containers we were asked to
|
// Artificially send creation events for the containers we were asked to
|
||||||
// monitor (same code path than we use when monitoring all containers).
|
// monitor (same code path than we use when monitoring all containers).
|
||||||
for _, name := range opts.containers {
|
for _, name := range opts.containers {
|
||||||
s := formatter.NewContainerStats(name, daemonOSType)
|
s := formatter.NewContainerStats(name)
|
||||||
if cStats.add(s) {
|
if cStats.add(s) {
|
||||||
waitFirst.Add(1)
|
waitFirst.Add(1)
|
||||||
go collect(ctx, s, dockerCli.Client(), !opts.noStream, waitFirst)
|
go collect(ctx, s, dockerCli.Client(), !opts.noStream, waitFirst)
|
||||||
|
|
|
@ -16,9 +16,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type stats struct {
|
type stats struct {
|
||||||
ostype string
|
mu sync.Mutex
|
||||||
mu sync.Mutex
|
cs []*formatter.ContainerStats
|
||||||
cs []*formatter.ContainerStats
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// daemonOSType is set once we have at least one stat for a container
|
// daemonOSType is set once we have at least one stat for a container
|
||||||
|
|
|
@ -171,11 +171,11 @@ func (c *containerContext) Command() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *containerContext) CreatedAt() string {
|
func (c *containerContext) CreatedAt() string {
|
||||||
return time.Unix(int64(c.c.Created), 0).String()
|
return time.Unix(c.c.Created, 0).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *containerContext) RunningFor() string {
|
func (c *containerContext) RunningFor() string {
|
||||||
createdAt := time.Unix(int64(c.c.Created), 0)
|
createdAt := time.Unix(c.c.Created, 0)
|
||||||
return units.HumanDuration(time.Now().UTC().Sub(createdAt)) + " ago"
|
return units.HumanDuration(time.Now().UTC().Sub(createdAt)) + " ago"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ reclaimable: {{.Reclaimable}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *DiskUsageContext) Write() (err error) {
|
func (ctx *DiskUsageContext) Write() (err error) {
|
||||||
if ctx.Verbose == false {
|
if !ctx.Verbose {
|
||||||
ctx.buffer = bytes.NewBufferString("")
|
ctx.buffer = bytes.NewBufferString("")
|
||||||
ctx.preFormat()
|
ctx.preFormat()
|
||||||
|
|
||||||
|
@ -234,7 +234,6 @@ func (c *diskUsageImagesContext) Reclaimable() string {
|
||||||
|
|
||||||
type diskUsageContainersContext struct {
|
type diskUsageContainersContext struct {
|
||||||
HeaderContext
|
HeaderContext
|
||||||
verbose bool
|
|
||||||
containers []*types.Container
|
containers []*types.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +296,6 @@ func (c *diskUsageContainersContext) Reclaimable() string {
|
||||||
|
|
||||||
type diskUsageVolumesContext struct {
|
type diskUsageVolumesContext struct {
|
||||||
HeaderContext
|
HeaderContext
|
||||||
verbose bool
|
|
||||||
volumes []*types.Volume
|
volumes []*types.Volume
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,21 +79,18 @@ func (c *historyContext) ID() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *historyContext) CreatedAt() string {
|
func (c *historyContext) CreatedAt() string {
|
||||||
var created string
|
return units.HumanDuration(time.Now().UTC().Sub(time.Unix(c.h.Created, 0)))
|
||||||
created = units.HumanDuration(time.Now().UTC().Sub(time.Unix(int64(c.h.Created), 0)))
|
|
||||||
return created
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *historyContext) CreatedSince() string {
|
func (c *historyContext) CreatedSince() string {
|
||||||
var created string
|
created := units.HumanDuration(time.Now().UTC().Sub(time.Unix(c.h.Created, 0)))
|
||||||
created = units.HumanDuration(time.Now().UTC().Sub(time.Unix(int64(c.h.Created), 0)))
|
|
||||||
return created + " ago"
|
return created + " ago"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *historyContext) CreatedBy() string {
|
func (c *historyContext) CreatedBy() string {
|
||||||
createdBy := strings.Replace(c.h.CreatedBy, "\t", " ", -1)
|
createdBy := strings.Replace(c.h.CreatedBy, "\t", " ", -1)
|
||||||
if c.trunc {
|
if c.trunc {
|
||||||
createdBy = stringutils.Ellipsis(createdBy, 45)
|
return stringutils.Ellipsis(createdBy, 45)
|
||||||
}
|
}
|
||||||
return createdBy
|
return createdBy
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,12 +234,12 @@ func (c *imageContext) Digest() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *imageContext) CreatedSince() string {
|
func (c *imageContext) CreatedSince() string {
|
||||||
createdAt := time.Unix(int64(c.i.Created), 0)
|
createdAt := time.Unix(c.i.Created, 0)
|
||||||
return units.HumanDuration(time.Now().UTC().Sub(createdAt)) + " ago"
|
return units.HumanDuration(time.Now().UTC().Sub(createdAt)) + " ago"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *imageContext) CreatedAt() string {
|
func (c *imageContext) CreatedAt() string {
|
||||||
return time.Unix(int64(c.i.Created), 0).String()
|
return time.Unix(c.i.Created, 0).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *imageContext) Size() string {
|
func (c *imageContext) Size() string {
|
||||||
|
|
|
@ -12,7 +12,7 @@ func (d *dummy) Func1() string {
|
||||||
return "Func1"
|
return "Func1"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dummy) func2() string {
|
func (d *dummy) func2() string { // nolint: unused
|
||||||
return "func2(should not be marshalled)"
|
return "func2(should not be marshalled)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,10 +109,8 @@ func NewStatsFormat(source, osType string) Format {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewContainerStats returns a new ContainerStats entity and sets in it the given name
|
// NewContainerStats returns a new ContainerStats entity and sets in it the given name
|
||||||
func NewContainerStats(container, osType string) *ContainerStats {
|
func NewContainerStats(container string) *ContainerStats {
|
||||||
return &ContainerStats{
|
return &ContainerStats{StatsEntry: StatsEntry{Container: container}}
|
||||||
StatsEntry: StatsEntry{Container: container},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerStatsWrite renders the context for a list of containers statistics
|
// ContainerStatsWrite renders the context for a list of containers statistics
|
||||||
|
|
|
@ -6,24 +6,17 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/command"
|
|
||||||
"github.com/docker/cli/cli/internal/test"
|
"github.com/docker/cli/cli/internal/test"
|
||||||
"github.com/docker/distribution/reference"
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/pkg/testutil"
|
"github.com/docker/docker/pkg/testutil"
|
||||||
"github.com/docker/docker/pkg/testutil/golden"
|
"github.com/docker/docker/pkg/testutil/golden"
|
||||||
"github.com/docker/docker/registry"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"golang.org/x/net/context"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewPullCommandErrors(t *testing.T) {
|
func TestNewPullCommandErrors(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectedError string
|
expectedError string
|
||||||
trustedPullFunc func(ctx context.Context, cli command.Cli, repoInfo *registry.RepositoryInfo, ref reference.Named,
|
|
||||||
authConfig types.AuthConfig, requestPrivilege types.RequestPrivilegeFunc) error
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "wrong-args",
|
name: "wrong-args",
|
||||||
|
@ -57,10 +50,8 @@ func TestNewPullCommandErrors(t *testing.T) {
|
||||||
|
|
||||||
func TestNewPullCommandSuccess(t *testing.T) {
|
func TestNewPullCommandSuccess(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
trustedPullFunc func(ctx context.Context, cli command.Cli, repoInfo *registry.RepositoryInfo, ref reference.Named,
|
|
||||||
authConfig types.AuthConfig, requestPrivilege types.RequestPrivilegeFunc) error
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "simple",
|
name: "simple",
|
||||||
|
|
|
@ -7,15 +7,11 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/command"
|
|
||||||
"github.com/docker/cli/cli/internal/test"
|
"github.com/docker/cli/cli/internal/test"
|
||||||
"github.com/docker/distribution/reference"
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/pkg/testutil"
|
"github.com/docker/docker/pkg/testutil"
|
||||||
"github.com/docker/docker/registry"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"golang.org/x/net/context"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewPushCommandErrors(t *testing.T) {
|
func TestNewPushCommandErrors(t *testing.T) {
|
||||||
|
@ -60,11 +56,8 @@ func TestNewPushCommandErrors(t *testing.T) {
|
||||||
|
|
||||||
func TestNewPushCommandSuccess(t *testing.T) {
|
func TestNewPushCommandSuccess(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
trustedPushFunc func(ctx context.Context, cli command.Cli, repoInfo *registry.RepositoryInfo,
|
|
||||||
ref reference.Named, authConfig types.AuthConfig,
|
|
||||||
requestPrivilege types.RequestPrivilegeFunc) error
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "simple",
|
name: "simple",
|
||||||
|
|
|
@ -11,7 +11,6 @@ type nodeOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type annotations struct {
|
type annotations struct {
|
||||||
name string
|
|
||||||
labels opts.ListOpts
|
labels opts.ListOpts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ type loginOptions struct {
|
||||||
serverAddress string
|
serverAddress string
|
||||||
user string
|
user string
|
||||||
password string
|
password string
|
||||||
email string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLoginCommand creates a new `docker login` command
|
// NewLoginCommand creates a new `docker login` command
|
||||||
|
|
|
@ -164,7 +164,7 @@ func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error {
|
||||||
|
|
||||||
// getMaxLength gets the maximum length of the number in base 10
|
// getMaxLength gets the maximum length of the number in base 10
|
||||||
func getMaxLength(i int) int {
|
func getMaxLength(i int) int {
|
||||||
return len(strconv.FormatInt(int64(i), 10))
|
return len(strconv.Itoa(i))
|
||||||
}
|
}
|
||||||
|
|
||||||
type taskFormatter struct {
|
type taskFormatter struct {
|
||||||
|
|
|
@ -354,7 +354,7 @@ func convertNetworks(ctx context.Context, apiClient client.NetworkAPIClient, net
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
netAttach = append(netAttach, swarm.NetworkAttachmentConfig{Target: net.Target, Aliases: net.Aliases, DriverOpts: net.DriverOpts})
|
netAttach = append(netAttach, swarm.NetworkAttachmentConfig(net))
|
||||||
}
|
}
|
||||||
sort.Sort(byNetworkTarget(netAttach))
|
sort.Sort(byNetworkTarget(netAttach))
|
||||||
return netAttach, nil
|
return netAttach, nil
|
||||||
|
|
|
@ -134,10 +134,7 @@ func getConfigDetails(composefile string) (composetypes.ConfigDetails, error) {
|
||||||
// TODO: support multiple files
|
// TODO: support multiple files
|
||||||
details.ConfigFiles = []composetypes.ConfigFile{*configFile}
|
details.ConfigFiles = []composetypes.ConfigFile{*configFile}
|
||||||
details.Environment, err = buildEnvironment(os.Environ())
|
details.Environment, err = buildEnvironment(os.Environ())
|
||||||
if err != nil {
|
return details, err
|
||||||
return details, err
|
|
||||||
}
|
|
||||||
return details, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildEnvironment(env []string) (map[string]string, error) {
|
func buildEnvironment(env []string) (map[string]string, error) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ func getStacks(ctx context.Context, apiclient client.APIClient) ([]*formatter.St
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
m := make(map[string]*formatter.Stack, 0)
|
m := make(map[string]*formatter.Stack)
|
||||||
for _, service := range services {
|
for _, service := range services {
|
||||||
labels := service.Spec.Labels
|
labels := service.Spec.Labels
|
||||||
name, ok := labels[convert.LabelNamespace]
|
name, ok := labels[convert.LabelNamespace]
|
||||||
|
|
|
@ -92,7 +92,7 @@ func runInit(dockerCli command.Cli, flags *pflag.FlagSet, opts initOptions) erro
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "could not fetch unlock key")
|
return errors.Wrap(err, "could not fetch unlock key")
|
||||||
}
|
}
|
||||||
printUnlockCommand(ctx, dockerCli, unlockKeyResp.UnlockKey)
|
printUnlockCommand(dockerCli.Out(), unlockKeyResp.UnlockKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -217,13 +217,13 @@ func parseExternalCA(caSpec string) (*swarm.ExternalCA, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func addSwarmCAFlags(flags *pflag.FlagSet, opts *swarmOptions) {
|
func addSwarmCAFlags(flags *pflag.FlagSet, opts *swarmOptions) {
|
||||||
flags.DurationVar(&opts.nodeCertExpiry, flagCertExpiry, time.Duration(90*24*time.Hour), "Validity period for node certificates (ns|us|ms|s|m|h)")
|
flags.DurationVar(&opts.nodeCertExpiry, flagCertExpiry, 90*24*time.Hour, "Validity period for node certificates (ns|us|ms|s|m|h)")
|
||||||
flags.Var(&opts.externalCA, flagExternalCA, "Specifications of one or more certificate signing endpoints")
|
flags.Var(&opts.externalCA, flagExternalCA, "Specifications of one or more certificate signing endpoints")
|
||||||
}
|
}
|
||||||
|
|
||||||
func addSwarmFlags(flags *pflag.FlagSet, opts *swarmOptions) {
|
func addSwarmFlags(flags *pflag.FlagSet, opts *swarmOptions) {
|
||||||
flags.Int64Var(&opts.taskHistoryLimit, flagTaskHistoryLimit, 5, "Task history retention limit")
|
flags.Int64Var(&opts.taskHistoryLimit, flagTaskHistoryLimit, 5, "Task history retention limit")
|
||||||
flags.DurationVar(&opts.dispatcherHeartbeat, flagDispatcherHeartbeat, time.Duration(5*time.Second), "Dispatcher heartbeat period (ns|us|ms|s|m|h)")
|
flags.DurationVar(&opts.dispatcherHeartbeat, flagDispatcherHeartbeat, 5*time.Second, "Dispatcher heartbeat period (ns|us|ms|s|m|h)")
|
||||||
flags.Uint64Var(&opts.maxSnapshots, flagMaxSnapshots, 0, "Number of additional Raft snapshots to retain")
|
flags.Uint64Var(&opts.maxSnapshots, flagMaxSnapshots, 0, "Number of additional Raft snapshots to retain")
|
||||||
flags.SetAnnotation(flagMaxSnapshots, "version", []string{"1.25"})
|
flags.SetAnnotation(flagMaxSnapshots, "version", []string{"1.25"})
|
||||||
flags.Uint64Var(&opts.snapshotInterval, flagSnapshotInterval, 10000, "Number of log entries between Raft snapshots")
|
flags.Uint64Var(&opts.snapshotInterval, flagSnapshotInterval, 10000, "Number of log entries between Raft snapshots")
|
||||||
|
|
|
@ -2,6 +2,7 @@ package swarm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
|
@ -74,16 +75,15 @@ func runUnlockKey(dockerCli command.Cli, opts unlockKeyOptions) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
printUnlockCommand(ctx, dockerCli, unlockKeyResp.UnlockKey)
|
printUnlockCommand(dockerCli.Out(), unlockKeyResp.UnlockKey)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func printUnlockCommand(ctx context.Context, dockerCli command.Cli, unlockKey string) {
|
func printUnlockCommand(out io.Writer, unlockKey string) {
|
||||||
if len(unlockKey) > 0 {
|
if len(unlockKey) > 0 {
|
||||||
fmt.Fprintf(dockerCli.Out(), "To unlock a swarm manager after it restarts, "+
|
fmt.Fprintf(out, "To unlock a swarm manager after it restarts, "+
|
||||||
"run the `docker swarm unlock`\ncommand and provide the following key:\n\n %s\n\n"+
|
"run the `docker swarm unlock`\ncommand and provide the following key:\n\n %s\n\n"+
|
||||||
"Please remember to store this key in a password manager, since without it you\n"+
|
"Please remember to store this key in a password manager, since without it you\n"+
|
||||||
"will not be able to restart the manager.\n", unlockKey)
|
"will not be able to restart the manager.\n", unlockKey)
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ func TestSwarmUnlockErrors(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
input string
|
|
||||||
swarmUnlockFunc func(req swarm.UnlockRequest) error
|
swarmUnlockFunc func(req swarm.UnlockRequest) error
|
||||||
infoFunc func() (types.Info, error)
|
infoFunc func() (types.Info, error)
|
||||||
expectedError string
|
expectedError string
|
||||||
|
|
|
@ -65,7 +65,7 @@ func runUpdate(dockerCli command.Cli, flags *pflag.FlagSet, opts swarmOptions) e
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "could not fetch unlock key")
|
return errors.Wrap(err, "could not fetch unlock key")
|
||||||
}
|
}
|
||||||
printUnlockCommand(ctx, dockerCli, unlockKeyResp.UnlockKey)
|
printUnlockCommand(dockerCli.Out(), unlockKeyResp.UnlockKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
|
@ -120,7 +119,7 @@ func prettyPrintInfo(dockerCli *command.DockerCli, info types.Info) error {
|
||||||
fmt.Fprintf(dockerCli.Out(), " Heartbeat Tick: %d\n", info.Swarm.Cluster.Spec.Raft.HeartbeatTick)
|
fmt.Fprintf(dockerCli.Out(), " Heartbeat Tick: %d\n", info.Swarm.Cluster.Spec.Raft.HeartbeatTick)
|
||||||
fmt.Fprintf(dockerCli.Out(), " Election Tick: %d\n", info.Swarm.Cluster.Spec.Raft.ElectionTick)
|
fmt.Fprintf(dockerCli.Out(), " Election Tick: %d\n", info.Swarm.Cluster.Spec.Raft.ElectionTick)
|
||||||
fmt.Fprintf(dockerCli.Out(), " Dispatcher:\n")
|
fmt.Fprintf(dockerCli.Out(), " Dispatcher:\n")
|
||||||
fmt.Fprintf(dockerCli.Out(), " Heartbeat Period: %s\n", units.HumanDuration(time.Duration(info.Swarm.Cluster.Spec.Dispatcher.HeartbeatPeriod)))
|
fmt.Fprintf(dockerCli.Out(), " Heartbeat Period: %s\n", units.HumanDuration(info.Swarm.Cluster.Spec.Dispatcher.HeartbeatPeriod))
|
||||||
fmt.Fprintf(dockerCli.Out(), " CA Configuration:\n")
|
fmt.Fprintf(dockerCli.Out(), " CA Configuration:\n")
|
||||||
fmt.Fprintf(dockerCli.Out(), " Expiry Duration: %s\n", units.HumanDuration(info.Swarm.Cluster.Spec.CAConfig.NodeCertExpiry))
|
fmt.Fprintf(dockerCli.Out(), " Expiry Duration: %s\n", units.HumanDuration(info.Swarm.Cluster.Spec.CAConfig.NodeCertExpiry))
|
||||||
fmt.Fprintf(dockerCli.Out(), " Force Rotate: %d\n", info.Swarm.Cluster.Spec.CAConfig.ForceRotate)
|
fmt.Fprintf(dockerCli.Out(), " Force Rotate: %d\n", info.Swarm.Cluster.Spec.CAConfig.ForceRotate)
|
||||||
|
@ -264,7 +263,7 @@ func prettyPrintInfo(dockerCli *command.DockerCli, info types.Info) error {
|
||||||
if info.RegistryConfig != nil && (len(info.RegistryConfig.InsecureRegistryCIDRs) > 0 || len(info.RegistryConfig.IndexConfigs) > 0) {
|
if info.RegistryConfig != nil && (len(info.RegistryConfig.InsecureRegistryCIDRs) > 0 || len(info.RegistryConfig.IndexConfigs) > 0) {
|
||||||
fmt.Fprintln(dockerCli.Out(), "Insecure Registries:")
|
fmt.Fprintln(dockerCli.Out(), "Insecure Registries:")
|
||||||
for _, registry := range info.RegistryConfig.IndexConfigs {
|
for _, registry := range info.RegistryConfig.IndexConfigs {
|
||||||
if registry.Secure == false {
|
if !registry.Secure {
|
||||||
fmt.Fprintf(dockerCli.Out(), " %s\n", registry.Name)
|
fmt.Fprintf(dockerCli.Out(), " %s\n", registry.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -563,9 +563,6 @@ func convertCredentialSpec(spec composetypes.CredentialSpecConfig) (*swarm.Crede
|
||||||
if spec.File != "" && spec.Registry != "" {
|
if spec.File != "" && spec.Registry != "" {
|
||||||
return nil, errors.New("Invalid credential spec - must provide one of `File` or `Registry`")
|
return nil, errors.New("Invalid credential spec - must provide one of `File` or `Registry`")
|
||||||
}
|
}
|
||||||
|
swarmCredSpec := swarm.CredentialSpec(spec)
|
||||||
return &swarm.CredentialSpec{
|
return &swarmCredSpec, nil
|
||||||
File: spec.File,
|
|
||||||
Registry: spec.Registry,
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,10 +632,6 @@ func durationPtr(value time.Duration) *time.Duration {
|
||||||
return &value
|
return &value
|
||||||
}
|
}
|
||||||
|
|
||||||
func int64Ptr(value int64) *int64 {
|
|
||||||
return &value
|
|
||||||
}
|
|
||||||
|
|
||||||
func uint64Ptr(value uint64) *uint64 {
|
func uint64Ptr(value uint64) *uint64 {
|
||||||
return &value
|
return &value
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ func (c *nativeStore) GetAll() (map[string]types.AuthConfig, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ac, _ := fileConfigs[registry] // might contain Email
|
ac := fileConfigs[registry] // might contain Email
|
||||||
ac.Username = creds.Username
|
ac.Username = creds.Username
|
||||||
ac.Password = creds.Password
|
ac.Password = creds.Password
|
||||||
ac.IdentityToken = creds.IdentityToken
|
ac.IdentityToken = creds.IdentityToken
|
||||||
|
|
|
@ -18,11 +18,11 @@ func (c *FakeClient) NetworkConnect(ctx context.Context, networkID, container st
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworkCreate fakes creating a network
|
// NetworkCreate fakes creating a network
|
||||||
func (c *FakeClient) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) {
|
func (c *FakeClient) NetworkCreate(_ context.Context, _ string, options types.NetworkCreate) (types.NetworkCreateResponse, error) {
|
||||||
return types.NetworkCreateResponse{}, nil
|
return types.NetworkCreateResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworkDisconnect fakes disconencting from a network
|
// NetworkDisconnect fakes disconnecting from a network
|
||||||
func (c *FakeClient) NetworkDisconnect(ctx context.Context, networkID, container string, force bool) error {
|
func (c *FakeClient) NetworkDisconnect(ctx context.Context, networkID, container string, force bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,12 @@ func (c *FakeClient) NetworkInspect(ctx context.Context, networkID string, optio
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworkInspectWithRaw fakes inspecting a network with a raw response
|
// NetworkInspectWithRaw fakes inspecting a network with a raw response
|
||||||
func (c *FakeClient) NetworkInspectWithRaw(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error) {
|
func (c *FakeClient) NetworkInspectWithRaw(_ context.Context, _ string, _ types.NetworkInspectOptions) (types.NetworkResource, []byte, error) {
|
||||||
return types.NetworkResource{}, nil, nil
|
return types.NetworkResource{}, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworkList fakes listing networks
|
// NetworkList fakes listing networks
|
||||||
func (c *FakeClient) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
|
func (c *FakeClient) NetworkList(_ context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,6 @@ func (c *FakeClient) NetworkRemove(ctx context.Context, networkID string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworksPrune fakes pruning networks
|
// NetworksPrune fakes pruning networks
|
||||||
func (c *FakeClient) NetworksPrune(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error) {
|
func (c *FakeClient) NetworksPrune(_ context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error) {
|
||||||
return types.NetworksPruneReport{}, nil
|
return types.NetworksPruneReport{}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,7 @@ func (c *fakeStore) Get(serverAddress string) (types.AuthConfig, error) {
|
||||||
if c.getFunc != nil {
|
if c.getFunc != nil {
|
||||||
return c.getFunc(serverAddress)
|
return c.getFunc(serverAddress)
|
||||||
}
|
}
|
||||||
authConfig, _ := c.store[serverAddress]
|
return c.store[serverAddress], nil
|
||||||
return authConfig, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *fakeStore) GetAll() (map[string]types.AuthConfig, error) {
|
func (c *fakeStore) GetAll() (map[string]types.AuthConfig, error) {
|
||||||
|
|
|
@ -161,7 +161,7 @@ func GetNotaryRepository(streams command.Streams, repoInfo *registry.RepositoryI
|
||||||
}
|
}
|
||||||
tokenHandler := auth.NewTokenHandlerWithOptions(tokenHandlerOptions)
|
tokenHandler := auth.NewTokenHandlerWithOptions(tokenHandlerOptions)
|
||||||
basicHandler := auth.NewBasicHandler(creds)
|
basicHandler := auth.NewBasicHandler(creds)
|
||||||
modifiers = append(modifiers, transport.RequestModifier(auth.NewAuthorizer(challengeManager, tokenHandler, basicHandler)))
|
modifiers = append(modifiers, auth.NewAuthorizer(challengeManager, tokenHandler, basicHandler))
|
||||||
tr := transport.NewTransport(base, modifiers...)
|
tr := transport.NewTransport(base, modifiers...)
|
||||||
|
|
||||||
return client.NewNotaryRepository(
|
return client.NewNotaryRepository(
|
||||||
|
|
|
@ -2,10 +2,11 @@ FROM golang:1.8.3-alpine
|
||||||
|
|
||||||
RUN apk add -U git
|
RUN apk add -U git
|
||||||
|
|
||||||
RUN go get -u gopkg.in/alecthomas/gometalinter.v1 && \
|
RUN go get -u gopkg.in/dnephin/gometalinter.v1 && \
|
||||||
mv /go/bin/gometalinter.v1 /usr/local/bin/gometalinter && \
|
mv /go/bin/gometalinter.v1 /usr/local/bin/gometalinter && \
|
||||||
gometalinter --install
|
gometalinter --install
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/docker/cli
|
WORKDIR /go/src/github.com/docker/cli
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
ENTRYPOINT ["/usr/local/bin/gometalinter"]
|
ENTRYPOINT ["/usr/local/bin/gometalinter"]
|
||||||
CMD ["--config=gometalinter.json", "./..."]
|
CMD ["--config=gometalinter.json", "./..."]
|
||||||
|
|
|
@ -66,14 +66,14 @@ func GenYamlTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandle
|
||||||
if _, err := io.WriteString(f, filePrepender(filename)); err != nil {
|
if _, err := io.WriteString(f, filePrepender(filename)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := GenYamlCustom(cmd, f, linkHandler); err != nil {
|
if err := GenYamlCustom(cmd, f); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenYamlCustom creates custom yaml output
|
// GenYamlCustom creates custom yaml output
|
||||||
func GenYamlCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) string) error {
|
func GenYamlCustom(cmd *cobra.Command, w io.Writer) error {
|
||||||
cliDoc := cmdDoc{}
|
cliDoc := cmdDoc{}
|
||||||
cliDoc.Name = cmd.CommandPath()
|
cliDoc.Name = cmd.CommandPath()
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,14 @@
|
||||||
"gofmt",
|
"gofmt",
|
||||||
"goimports",
|
"goimports",
|
||||||
"golint",
|
"golint",
|
||||||
|
"gosimple",
|
||||||
"ineffassign",
|
"ineffassign",
|
||||||
"interfacer",
|
"interfacer",
|
||||||
"lll",
|
"lll",
|
||||||
|
"misspell",
|
||||||
|
"unconvert",
|
||||||
|
"unparam",
|
||||||
|
"unused",
|
||||||
"vet"
|
"vet"
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ func (opts *MapOpts) GetAll() map[string]string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (opts *MapOpts) String() string {
|
func (opts *MapOpts) String() string {
|
||||||
return fmt.Sprintf("%v", map[string]string((opts.values)))
|
return fmt.Sprintf("%v", opts.values)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type returns a string name for this Option type
|
// Type returns a string name for this Option type
|
||||||
|
|
|
@ -18,7 +18,7 @@ func (s *QuotedString) Type() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *QuotedString) String() string {
|
func (s *QuotedString) String() string {
|
||||||
return string(*s.value)
|
return *s.value
|
||||||
}
|
}
|
||||||
|
|
||||||
func trimQuotes(value string) string {
|
func trimQuotes(value string) string {
|
||||||
|
|
|
@ -52,10 +52,7 @@ func ValidateThrottleIOpsDevice(val string) (*blkiodev.ThrottleDevice, error) {
|
||||||
return nil, fmt.Errorf("invalid rate for device: %s. The correct format is <device-path>:<number>. Number must be a positive integer", val)
|
return nil, fmt.Errorf("invalid rate for device: %s. The correct format is <device-path>:<number>. Number must be a positive integer", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &blkiodev.ThrottleDevice{
|
return &blkiodev.ThrottleDevice{Path: split[0], Rate: rate}, nil
|
||||||
Path: split[0],
|
|
||||||
Rate: uint64(rate),
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ThrottledeviceOpt defines a map of ThrottleDevices
|
// ThrottledeviceOpt defines a map of ThrottleDevices
|
||||||
|
|
|
@ -75,12 +75,7 @@ func (opt *WeightdeviceOpt) String() string {
|
||||||
|
|
||||||
// GetList returns a slice of pointers to WeightDevices.
|
// GetList returns a slice of pointers to WeightDevices.
|
||||||
func (opt *WeightdeviceOpt) GetList() []*blkiodev.WeightDevice {
|
func (opt *WeightdeviceOpt) GetList() []*blkiodev.WeightDevice {
|
||||||
var weightdevice []*blkiodev.WeightDevice
|
return opt.values
|
||||||
for _, v := range opt.values {
|
|
||||||
weightdevice = append(weightdevice, v)
|
|
||||||
}
|
|
||||||
|
|
||||||
return weightdevice
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type returns the option type
|
// Type returns the option type
|
||||||
|
|
Loading…
Reference in New Issue