mirror of https://github.com/docker/docs.git
Merge pull request #14784 from brahmaroutu/lint_api_client
fix golint errors/warnings
This commit is contained in:
commit
e77ea5aa7a
|
@ -59,8 +59,8 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
||||||
flMemoryString := cmd.String([]string{"m", "-memory"}, "", "Memory limit")
|
flMemoryString := cmd.String([]string{"m", "-memory"}, "", "Memory limit")
|
||||||
flMemorySwap := cmd.String([]string{"-memory-swap"}, "", "Total memory (memory + swap), '-1' to disable swap")
|
flMemorySwap := cmd.String([]string{"-memory-swap"}, "", "Total memory (memory + swap), '-1' to disable swap")
|
||||||
flCPUShares := cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)")
|
flCPUShares := cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)")
|
||||||
flCpuPeriod := cmd.Int64([]string{"-cpu-period"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) period")
|
flCPUPeriod := cmd.Int64([]string{"-cpu-period"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) period")
|
||||||
flCpuQuota := cmd.Int64([]string{"-cpu-quota"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) quota")
|
flCPUQuota := cmd.Int64([]string{"-cpu-quota"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) quota")
|
||||||
flCPUSetCpus := cmd.String([]string{"-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)")
|
flCPUSetCpus := cmd.String([]string{"-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)")
|
||||||
flCPUSetMems := cmd.String([]string{"-cpuset-mems"}, "", "MEMs in which to allow execution (0-3, 0,1)")
|
flCPUSetMems := cmd.String([]string{"-cpuset-mems"}, "", "MEMs in which to allow execution (0-3, 0,1)")
|
||||||
flCgroupParent := cmd.String([]string{"-cgroup-parent"}, "", "Optional parent cgroup for the container")
|
flCgroupParent := cmd.String([]string{"-cgroup-parent"}, "", "Optional parent cgroup for the container")
|
||||||
|
@ -241,8 +241,8 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
||||||
v.Set("cpusetcpus", *flCPUSetCpus)
|
v.Set("cpusetcpus", *flCPUSetCpus)
|
||||||
v.Set("cpusetmems", *flCPUSetMems)
|
v.Set("cpusetmems", *flCPUSetMems)
|
||||||
v.Set("cpushares", strconv.FormatInt(*flCPUShares, 10))
|
v.Set("cpushares", strconv.FormatInt(*flCPUShares, 10))
|
||||||
v.Set("cpuquota", strconv.FormatInt(*flCpuQuota, 10))
|
v.Set("cpuquota", strconv.FormatInt(*flCPUQuota, 10))
|
||||||
v.Set("cpuperiod", strconv.FormatInt(*flCpuPeriod, 10))
|
v.Set("cpuperiod", strconv.FormatInt(*flCPUPeriod, 10))
|
||||||
v.Set("memory", strconv.FormatInt(memory, 10))
|
v.Set("memory", strconv.FormatInt(memory, 10))
|
||||||
v.Set("memswap", strconv.FormatInt(memorySwap, 10))
|
v.Set("memswap", strconv.FormatInt(memorySwap, 10))
|
||||||
v.Set("cgroupparent", *flCgroupParent)
|
v.Set("cgroupparent", *flCgroupParent)
|
||||||
|
@ -250,11 +250,11 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
||||||
v.Set("dockerfile", relDockerfile)
|
v.Set("dockerfile", relDockerfile)
|
||||||
|
|
||||||
ulimitsVar := flUlimits.GetList()
|
ulimitsVar := flUlimits.GetList()
|
||||||
ulimitsJson, err := json.Marshal(ulimitsVar)
|
ulimitsJSON, err := json.Marshal(ulimitsVar)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
v.Set("ulimits", string(ulimitsJson))
|
v.Set("ulimits", string(ulimitsJSON))
|
||||||
|
|
||||||
headers := http.Header(make(map[string][]string))
|
headers := http.Header(make(map[string][]string))
|
||||||
buf, err := json.Marshal(cli.configFile.AuthConfigs)
|
buf, err := json.Marshal(cli.configFile.AuthConfigs)
|
||||||
|
|
|
@ -58,6 +58,8 @@ type DockerCli struct {
|
||||||
transport *http.Transport
|
transport *http.Transport
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize calls the init function that will setup the configuration for the client
|
||||||
|
// such as the TLS, tcp and other parameters used to run the client.
|
||||||
func (cli *DockerCli) Initialize() error {
|
func (cli *DockerCli) Initialize() error {
|
||||||
if cli.init == nil {
|
if cli.init == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -77,6 +79,8 @@ func (cli *DockerCli) CheckTtyInput(attachStdin, ttyMode bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PsFormat returns the format string specified in the configuration.
|
||||||
|
// String contains columns and format specification, for example {{ID}\t{{Name}}.
|
||||||
func (cli *DockerCli) PsFormat() string {
|
func (cli *DockerCli) PsFormat() string {
|
||||||
return cli.configFile.PsFormat
|
return cli.configFile.PsFormat
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
Cli "github.com/docker/docker/cli"
|
Cli "github.com/docker/docker/cli"
|
||||||
|
@ -22,7 +21,7 @@ func (cli *DockerCli) CmdExport(args ...string) error {
|
||||||
cmd.ParseFlags(args, true)
|
cmd.ParseFlags(args, true)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
output io.Writer = cli.out
|
output = cli.out
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if *outfile != "" {
|
if *outfile != "" {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
nwclient "github.com/docker/libnetwork/client"
|
nwclient "github.com/docker/libnetwork/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CmdNetwork is used to create, display and configure network endpoints.
|
||||||
func (cli *DockerCli) CmdNetwork(args ...string) error {
|
func (cli *DockerCli) CmdNetwork(args ...string) error {
|
||||||
nCli := nwclient.NewNetworkCli(cli.out, cli.err, nwclient.CallFunc(cli.callWrapper))
|
nCli := nwclient.NewNetworkCli(cli.out, cli.err, nwclient.CallFunc(cli.callWrapper))
|
||||||
args = append([]string{"network"}, args...)
|
args = append([]string{"network"}, args...)
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestContainerContextID(t *testing.T) {
|
func TestContainerContextID(t *testing.T) {
|
||||||
containerId := stringid.GenerateNonCryptoID()
|
containerID := stringid.GenerateRandomID()
|
||||||
unix := time.Now().Unix()
|
unix := time.Now().Unix()
|
||||||
|
|
||||||
var ctx containerContext
|
var ctx containerContext
|
||||||
|
@ -22,7 +22,7 @@ func TestContainerContextID(t *testing.T) {
|
||||||
expHeader string
|
expHeader string
|
||||||
call func() string
|
call func() string
|
||||||
}{
|
}{
|
||||||
{types.Container{ID: containerId}, true, stringid.TruncateID(containerId), idHeader, ctx.ID},
|
{types.Container{ID: containerID}, true, stringid.TruncateID(containerID), idHeader, ctx.ID},
|
||||||
{types.Container{Names: []string{"/foobar_baz"}}, true, "foobar_baz", namesHeader, ctx.Names},
|
{types.Container{Names: []string{"/foobar_baz"}}, true, "foobar_baz", namesHeader, ctx.Names},
|
||||||
{types.Container{Image: "ubuntu"}, true, "ubuntu", imageHeader, ctx.Image},
|
{types.Container{Image: "ubuntu"}, true, "ubuntu", imageHeader, ctx.Image},
|
||||||
{types.Container{Image: ""}, true, "<no image>", imageHeader, ctx.Image},
|
{types.Container{Image: ""}, true, "<no image>", imageHeader, ctx.Image},
|
||||||
|
|
|
@ -14,14 +14,22 @@ const (
|
||||||
defaultQuietFormat = "{{.ID}}"
|
defaultQuietFormat = "{{.ID}}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Context contains information required by the formatter to print the output as desired.
|
||||||
type Context struct {
|
type Context struct {
|
||||||
|
// Output is the output stream to which the formatted string is written.
|
||||||
Output io.Writer
|
Output io.Writer
|
||||||
|
// Format is used to choose raw, table or custom format for the output.
|
||||||
Format string
|
Format string
|
||||||
|
// Size when set to true will display the size of the output.
|
||||||
Size bool
|
Size bool
|
||||||
|
// Quiet when set to true will simply print minimal information.
|
||||||
Quiet bool
|
Quiet bool
|
||||||
|
// Trunc when set to true will truncate the output of certain fields such as Container ID.
|
||||||
Trunc bool
|
Trunc bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Format helps to format the output using the parameters set in the Context.
|
||||||
|
// Currently Format allow to display in raw, table or custom format the output.
|
||||||
func Format(ctx Context, containers []types.Container) {
|
func Format(ctx Context, containers []types.Container) {
|
||||||
switch ctx.Format {
|
switch ctx.Format {
|
||||||
case tableFormatKey:
|
case tableFormatKey:
|
||||||
|
|
|
@ -2,7 +2,6 @@ package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
@ -23,7 +22,7 @@ func (cli *DockerCli) CmdSave(args ...string) error {
|
||||||
cmd.ParseFlags(args, true)
|
cmd.ParseFlags(args, true)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
output io.Writer = cli.out
|
output = cli.out
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if *outfile != "" {
|
if *outfile != "" {
|
||||||
|
|
|
@ -8,6 +8,8 @@ import (
|
||||||
nwclient "github.com/docker/libnetwork/client"
|
nwclient "github.com/docker/libnetwork/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CmdService is used to manage network services.
|
||||||
|
// service command is user to publish, attach and list a service from a container.
|
||||||
func (cli *DockerCli) CmdService(args ...string) error {
|
func (cli *DockerCli) CmdService(args ...string) error {
|
||||||
nCli := nwclient.NewNetworkCli(cli.out, cli.err, nwclient.CallFunc(cli.callWrapper))
|
nCli := nwclient.NewNetworkCli(cli.out, cli.err, nwclient.CallFunc(cli.callWrapper))
|
||||||
args = append([]string{"service"}, args...)
|
args = append([]string{"service"}, args...)
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"github.com/docker/docker/utils"
|
"github.com/docker/docker/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var VersionTemplate = `Client:
|
var versionTemplate = `Client:
|
||||||
Version: {{.Client.Version}}
|
Version: {{.Client.Version}}
|
||||||
API version: {{.Client.ApiVersion}}
|
API version: {{.Client.ApiVersion}}
|
||||||
Go version: {{.Client.GoVersion}}
|
Go version: {{.Client.GoVersion}}
|
||||||
|
@ -31,7 +31,7 @@ Server:
|
||||||
OS/Arch: {{.Server.Os}}/{{.Server.Arch}}{{if .Server.Experimental}}
|
OS/Arch: {{.Server.Os}}/{{.Server.Arch}}{{if .Server.Experimental}}
|
||||||
Experimental: {{.Server.Experimental}}{{end}}{{end}}`
|
Experimental: {{.Server.Experimental}}{{end}}{{end}}`
|
||||||
|
|
||||||
type VersionData struct {
|
type versionData struct {
|
||||||
Client types.Version
|
Client types.Version
|
||||||
ServerOK bool
|
ServerOK bool
|
||||||
Server types.Version
|
Server types.Version
|
||||||
|
@ -49,7 +49,7 @@ func (cli *DockerCli) CmdVersion(args ...string) (err error) {
|
||||||
|
|
||||||
cmd.ParseFlags(args, true)
|
cmd.ParseFlags(args, true)
|
||||||
if *tmplStr == "" {
|
if *tmplStr == "" {
|
||||||
*tmplStr = VersionTemplate
|
*tmplStr = versionTemplate
|
||||||
}
|
}
|
||||||
|
|
||||||
var tmpl *template.Template
|
var tmpl *template.Template
|
||||||
|
@ -58,7 +58,7 @@ func (cli *DockerCli) CmdVersion(args ...string) (err error) {
|
||||||
Status: "Template parsing error: " + err.Error()}
|
Status: "Template parsing error: " + err.Error()}
|
||||||
}
|
}
|
||||||
|
|
||||||
vd := VersionData{
|
vd := versionData{
|
||||||
Client: types.Version{
|
Client: types.Version{
|
||||||
Version: dockerversion.VERSION,
|
Version: dockerversion.VERSION,
|
||||||
ApiVersion: api.Version,
|
ApiVersion: api.Version,
|
||||||
|
|
|
@ -9,6 +9,8 @@ source "${MAKEDIR}/.validate"
|
||||||
|
|
||||||
packages=(
|
packages=(
|
||||||
api/server
|
api/server
|
||||||
|
api/client
|
||||||
|
api/client/ps
|
||||||
builder
|
builder
|
||||||
builder/command
|
builder/command
|
||||||
builder/parser
|
builder/parser
|
||||||
|
|
Loading…
Reference in New Issue