1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

api/client fix golint errors/warnings

Addresses #14756

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
This commit is contained in:
root 2015-07-21 00:55:30 +00:00 committed by Srini Brahmaroutu
parent dfcdde4d98
commit 929f2c2f40
10 changed files with 34 additions and 19 deletions

View file

@ -59,8 +59,8 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
flMemoryString := cmd.String([]string{"m", "-memory"}, "", "Memory limit")
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)")
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")
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")
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)")
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("cpusetmems", *flCPUSetMems)
v.Set("cpushares", strconv.FormatInt(*flCPUShares, 10))
v.Set("cpuquota", strconv.FormatInt(*flCpuQuota, 10))
v.Set("cpuperiod", strconv.FormatInt(*flCpuPeriod, 10))
v.Set("cpuquota", strconv.FormatInt(*flCPUQuota, 10))
v.Set("cpuperiod", strconv.FormatInt(*flCPUPeriod, 10))
v.Set("memory", strconv.FormatInt(memory, 10))
v.Set("memswap", strconv.FormatInt(memorySwap, 10))
v.Set("cgroupparent", *flCgroupParent)
@ -250,11 +250,11 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
v.Set("dockerfile", relDockerfile)
ulimitsVar := flUlimits.GetList()
ulimitsJson, err := json.Marshal(ulimitsVar)
ulimitsJSON, err := json.Marshal(ulimitsVar)
if err != nil {
return err
}
v.Set("ulimits", string(ulimitsJson))
v.Set("ulimits", string(ulimitsJSON))
headers := http.Header(make(map[string][]string))
buf, err := json.Marshal(cli.configFile.AuthConfigs)

View file

@ -58,6 +58,8 @@ type DockerCli struct {
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 {
if cli.init == nil {
return nil
@ -77,6 +79,8 @@ func (cli *DockerCli) CheckTtyInput(attachStdin, ttyMode bool) error {
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 {
return cli.configFile.PsFormat
}

View file

@ -2,7 +2,6 @@ package client
import (
"errors"
"io"
"os"
Cli "github.com/docker/docker/cli"
@ -22,7 +21,7 @@ func (cli *DockerCli) CmdExport(args ...string) error {
cmd.ParseFlags(args, true)
var (
output io.Writer = cli.out
output = cli.out
err error
)
if *outfile != "" {

View file

@ -8,6 +8,7 @@ import (
nwclient "github.com/docker/libnetwork/client"
)
// CmdNetwork is used to create, display and configure network endpoints.
func (cli *DockerCli) CmdNetwork(args ...string) error {
nCli := nwclient.NewNetworkCli(cli.out, cli.err, nwclient.CallFunc(cli.callWrapper))
args = append([]string{"network"}, args...)

View file

@ -11,7 +11,7 @@ import (
)
func TestContainerContextID(t *testing.T) {
containerId := stringid.GenerateNonCryptoID()
containerID := stringid.GenerateRandomID()
unix := time.Now().Unix()
var ctx containerContext
@ -22,7 +22,7 @@ func TestContainerContextID(t *testing.T) {
expHeader 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{Image: "ubuntu"}, true, "ubuntu", imageHeader, ctx.Image},
{types.Container{Image: ""}, true, "<no image>", imageHeader, ctx.Image},

View file

@ -14,14 +14,22 @@ const (
defaultQuietFormat = "{{.ID}}"
)
// Context contains information required by the formatter to print the output as desired.
type Context struct {
// Output is the output stream to which the formatted string is written.
Output io.Writer
// Format is used to choose raw, table or custom format for the output.
Format string
Size bool
Quiet bool
Trunc bool
// Size when set to true will display the size of the output.
Size bool
// Quiet when set to true will simply print minimal information.
Quiet bool
// Trunc when set to true will truncate the output of certain fields such as Container ID.
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) {
switch ctx.Format {
case tableFormatKey:

View file

@ -2,7 +2,6 @@ package client
import (
"errors"
"io"
"net/url"
"os"
@ -23,7 +22,7 @@ func (cli *DockerCli) CmdSave(args ...string) error {
cmd.ParseFlags(args, true)
var (
output io.Writer = cli.out
output = cli.out
err error
)
if *outfile != "" {

View file

@ -8,6 +8,8 @@ import (
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 {
nCli := nwclient.NewNetworkCli(cli.out, cli.err, nwclient.CallFunc(cli.callWrapper))
args = append([]string{"service"}, args...)

View file

@ -13,7 +13,7 @@ import (
"github.com/docker/docker/utils"
)
var VersionTemplate = `Client:
var versionTemplate = `Client:
Version: {{.Client.Version}}
API version: {{.Client.ApiVersion}}
Go version: {{.Client.GoVersion}}
@ -31,7 +31,7 @@ Server:
OS/Arch: {{.Server.Os}}/{{.Server.Arch}}{{if .Server.Experimental}}
Experimental: {{.Server.Experimental}}{{end}}{{end}}`
type VersionData struct {
type versionData struct {
Client types.Version
ServerOK bool
Server types.Version
@ -49,7 +49,7 @@ func (cli *DockerCli) CmdVersion(args ...string) (err error) {
cmd.ParseFlags(args, true)
if *tmplStr == "" {
*tmplStr = VersionTemplate
*tmplStr = versionTemplate
}
var tmpl *template.Template
@ -58,7 +58,7 @@ func (cli *DockerCli) CmdVersion(args ...string) (err error) {
Status: "Template parsing error: " + err.Error()}
}
vd := VersionData{
vd := versionData{
Client: types.Version{
Version: dockerversion.VERSION,
ApiVersion: api.Version,

View file

@ -9,6 +9,8 @@ source "${MAKEDIR}/.validate"
packages=(
api/server
api/client
api/client/ps
builder
builder/command
builder/parser