Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli-plugins/manager/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Plugin struct {
// returned with no error. An error is only returned due to a
// non-recoverable error.
//
// nolint: gocyclo
//nolint:gocyclo
func newPlugin(c Candidate, rootcmd *cobra.Command) (Plugin, error) {
path := c.Path()
if path == "" {
Expand Down
6 changes: 4 additions & 2 deletions cli/command/container/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,12 @@ func copyToContainer(ctx context.Context, dockerCli command.Cli, copyConfig cpCo
// in a valid LOCALPATH, like `file:name.txt`. We can resolve this ambiguity by
// requiring a LOCALPATH with a `:` to be made explicit with a relative or
// absolute path:
// `/path/to/file:name.txt` or `./file:name.txt`
//
// `/path/to/file:name.txt` or `./file:name.txt`
//
// This is apparently how `scp` handles this as well:
// http://www.cyberciti.biz/faq/rsync-scp-file-name-with-colon-punctuation-in-it/
//
// http://www.cyberciti.biz/faq/rsync-scp-file-name-with-colon-punctuation-in-it/
//
// We can't simply check for a filepath separator because container names may
// have a separator, e.g., "host0/cname1" if container is in a Docker cluster,
Expand Down
2 changes: 1 addition & 1 deletion cli/command/container/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func newCIDFile(path string) (*cidFile, error) {
return &cidFile{path: path, file: f}, nil
}

// nolint: gocyclo
//nolint:gocyclo
func createContainer(ctx context.Context, dockerCli command.Cli, containerConfig *containerConfig, opts *createOptions) (*container.CreateResponse, error) {
config := containerConfig.Config
hostConfig := containerConfig.HostConfig
Expand Down
10 changes: 7 additions & 3 deletions cli/command/container/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ type containerConfig struct {
// parse parses the args for the specified command and generates a Config,
// a HostConfig and returns them with the specified command.
// If the specified args are not valid, it will return an error.
// nolint: gocyclo
//
//nolint:gocyclo
func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*containerConfig, error) {
var (
attachStdin = copts.attach.Get("stdin")
Expand Down Expand Up @@ -965,7 +966,8 @@ func parseWindowsDevice(device string) (container.DeviceMapping, error) {

// validateDeviceCgroupRule validates a device cgroup rule string format
// It will make sure 'val' is in the form:
// 'type major:minor mode'
//
// 'type major:minor mode'
func validateDeviceCgroupRule(val string) (string, error) {
if deviceCgroupRuleRegexp.MatchString(val) {
return val, nil
Expand Down Expand Up @@ -1009,7 +1011,9 @@ func validateDevice(val string, serverOS string) (string, error) {
// validateLinuxPath is the implementation of validateDevice knowing that the
// target server operating system is a Linux daemon.
// It will make sure 'val' is in the form:
// [host-dir:]container-path[:mode]
//
// [host-dir:]container-path[:mode]
//
// It also validates the device mode.
func validateLinuxPath(val string, validator func(string) bool) (string, error) {
var containerPath string
Expand Down
2 changes: 1 addition & 1 deletion cli/command/container/opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func TestParseRunWithInvalidArgs(t *testing.T) {
}
}

// nolint: gocyclo
//nolint:gocyclo
func TestParseWithVolumes(t *testing.T) {

// A single volume
Expand Down
2 changes: 1 addition & 1 deletion cli/command/container/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func runRun(dockerCli command.Cli, flags *pflag.FlagSet, ropts *runOptions, copt
return runContainer(dockerCli, ropts, copts, containerConfig)
}

// nolint: gocyclo
//nolint:gocyclo
func runContainer(dockerCli command.Cli, opts *runOptions, copts *containerOptions, containerConfig *containerConfig) error {
config := containerConfig.Config
stdout, stderr := dockerCli.Out(), dockerCli.Err()
Expand Down
3 changes: 2 additions & 1 deletion cli/command/container/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ func NewStartCommand(dockerCli command.Cli) *cobra.Command {
}

// RunStart executes a `start` command
// nolint: gocyclo
//
//nolint:gocyclo
func RunStart(dockerCli command.Cli, opts *StartOptions) error {
ctx, cancelFun := context.WithCancel(context.Background())
defer cancelFun()
Expand Down
3 changes: 2 additions & 1 deletion cli/command/container/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ func NewStatsCommand(dockerCli command.Cli) *cobra.Command {

// runStats displays a live stream of resource usage statistics for one or more containers.
// This shows real-time information on CPU usage, memory usage, and network I/O.
// nolint: gocyclo
//
//nolint:gocyclo
func runStats(dockerCli command.Cli, opts *statsOptions) error {
showAll := len(opts.containers) == 0
closeChan := make(chan error)
Expand Down
2 changes: 1 addition & 1 deletion cli/command/formatter/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ type ports struct {
expected string
}

// nolint: lll
//nolint:lll
func TestDisplayablePorts(t *testing.T) {
cases := []ports{
{
Expand Down
2 changes: 1 addition & 1 deletion cli/command/formatter/reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (d *dummy) Func1() string {
return "Func1"
}

func (d *dummy) func2() string { // nolint: unused
func (d *dummy) func2() string { //nolint:unused
return "func2(should not be marshalled)"
}

Expand Down
3 changes: 2 additions & 1 deletion cli/command/formatter/tabwriter/tabwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
// The text/tabwriter package is frozen and is not accepting new features.

// based on https://github.com/golang/go/blob/master/src/text/tabwriter/tabwriter.go Last modified 690ac40 on 31 Jan
//nolint

//nolint:gocyclo,nakedret,revive,unused // ignore linting errors, so that we can stick close to upstream
package tabwriter

import (
Expand Down
2 changes: 1 addition & 1 deletion cli/command/image/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (out *lastProgressOutput) WriteProgress(prog progress.Progress) error {
return out.output.WriteProgress(prog)
}

// nolint: gocyclo
//nolint:gocyclo
func runBuild(dockerCli command.Cli, options buildOptions) error {
var (
err error
Expand Down
6 changes: 3 additions & 3 deletions cli/command/image/formatter_history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func TestHistoryContext_CreatedSince(t *testing.T) {
}

func TestHistoryContext_CreatedBy(t *testing.T) {
withTabs := `/bin/sh -c apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 && echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list && apt-get update && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates nginx=${NGINX_VERSION} nginx-module-xslt nginx-module-geoip nginx-module-image-filter nginx-module-perl nginx-module-njs gettext-base && rm -rf /var/lib/apt/lists/*` // nolint: lll
expected := `/bin/sh -c apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 && echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list && apt-get update && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates nginx=${NGINX_VERSION} nginx-module-xslt nginx-module-geoip nginx-module-image-filter nginx-module-perl nginx-module-njs gettext-base && rm -rf /var/lib/apt/lists/*` // nolint: lll
withTabs := `/bin/sh -c apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 && echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list && apt-get update && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates nginx=${NGINX_VERSION} nginx-module-xslt nginx-module-geoip nginx-module-image-filter nginx-module-perl nginx-module-njs gettext-base && rm -rf /var/lib/apt/lists/*` //nolint:lll
expected := `/bin/sh -c apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 && echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list && apt-get update && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates nginx=${NGINX_VERSION} nginx-module-xslt nginx-module-geoip nginx-module-image-filter nginx-module-perl nginx-module-njs gettext-base && rm -rf /var/lib/apt/lists/*` //nolint:lll

var ctx historyContext
cases := []historyCase{
Expand Down Expand Up @@ -186,7 +186,7 @@ func TestHistoryContext_Table(t *testing.T) {
{ID: "imageID3", Created: unixTime, CreatedBy: "/bin/bash ls", Size: int64(182964289), Comment: "Hi", Tags: []string{"image:tag2"}},
{ID: "imageID4", Created: unixTime, CreatedBy: "/bin/bash grep", Size: int64(182964289), Comment: "Hi", Tags: []string{"image:tag2"}},
}
// nolint: lll
//nolint:lll
expectedNoTrunc := `IMAGE CREATED CREATED BY SIZE COMMENT
imageID1 24 hours ago /bin/bash ls && npm i && npm run test && karma -c karma.conf.js start && npm start && more commands here && the list goes on 183MB Hi
imageID2 24 hours ago /bin/bash echo 183MB Hi
Expand Down
3 changes: 2 additions & 1 deletion cli/command/image/trust.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func TrustedPush(ctx context.Context, cli command.Cli, repoInfo *registry.Reposi
}

// PushTrustedReference pushes a canonical reference to the trust server.
// nolint: gocyclo
//
//nolint:gocyclo
func PushTrustedReference(streams command.Streams, repoInfo *registry.RepositoryInfo, ref reference.Named, authConfig types.AuthConfig, in io.Reader) error {
// If it is a trusted push we would like to find the target entry which match the
// tag provided in the function and then do an AddTarget later.
Expand Down
2 changes: 1 addition & 1 deletion cli/command/manifest/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func normalizeReference(ref string) (reference.Named, error) {
}

// getManifest from the local store, and fallback to the remote registry if it
// doesn't exist locally
// doesn't exist locally
func getManifest(ctx context.Context, dockerCli command.Cli, listRef, namedRef reference.Named, insecure bool) (types.ImageManifest, error) {
data, err := dockerCli.ManifestStore().Get(listRef, namedRef)
switch {
Expand Down
3 changes: 2 additions & 1 deletion cli/command/network/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ func runCreate(dockerCli command.Cli, options createOptions) error {
// possible to correlate the various related parameters and consolidate them.
// consolidateIpam consolidates subnets, ip-ranges, gateways and auxiliary addresses into
// structured ipam data.
// nolint: gocyclo
//
//nolint:gocyclo
func consolidateIpam(subnets, ranges, gateways []string, auxaddrs map[string]string) ([]network.IPAMConfig, error) {
if len(subnets) < len(ranges) || len(subnets) < len(gateways) {
return nil, errors.Errorf("every ip-range or gateway must have a corresponding subnet")
Expand Down
2 changes: 1 addition & 1 deletion cli/command/registry/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func verifyloginOptions(dockerCli command.Cli, opts *loginOptions) error {
return nil
}

func runLogin(dockerCli command.Cli, opts loginOptions) error { //nolint: gocyclo
func runLogin(dockerCli command.Cli, opts loginOptions) error { //nolint:gocyclo
ctx := context.Background()
clnt := dockerCli.Client()
if err := verifyloginOptions(dockerCli, &opts); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion cli/command/service/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ func runList(dockerCli command.Cli, opts listOptions) error {
// there may be other situations where the client uses the "default" version.
// To take these situations into account, we do a quick check for services
// that don't have ServiceStatus set, and perform a lookup for those.
// nolint: gocyclo
//
//nolint:gocyclo
func AppendServiceStatus(ctx context.Context, c client.APIClient, services []swarm.Service) ([]swarm.Service, error) {
status := map[string]*swarm.ServiceStatus{}
taskFilter := filters.NewArgs()
Expand Down
8 changes: 6 additions & 2 deletions cli/command/service/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,13 @@ func (opts *healthCheckOptions) toHealthConfig() (*container.HealthConfig, error
}

// convertExtraHostsToSwarmHosts converts an array of extra hosts in cli
// <host>:<ip>
//
// <host>:<ip>
//
// into a swarmkit host format:
// IP_address canonical_hostname [aliases...]
//
// IP_address canonical_hostname [aliases...]
//
// This assumes input value (<host>:<ip>) has already been validated
func convertExtraHostsToSwarmHosts(extraHosts []string) []string {
hosts := []string{}
Expand Down
3 changes: 2 additions & 1 deletion cli/command/service/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ func terminalState(state swarm.TaskState) bool {
}

// ServiceProgress outputs progress information for convergence of a service.
// nolint: gocyclo
//
//nolint:gocyclo
func ServiceProgress(ctx context.Context, client client.APIClient, serviceID string, progressWriter io.WriteCloser) error {
defer progressWriter.Close()

Expand Down
67 changes: 33 additions & 34 deletions cli/command/service/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func newListOptsVarWithValidator(validator opts.ValidatorFctType) *opts.ListOpts
return opts.NewListOptsRef(&[]string{}, validator)
}

// nolint: gocyclo
//nolint:gocyclo
func runUpdate(dockerCli command.Cli, flags *pflag.FlagSet, options *serviceOptions, serviceID string) error {
apiClient := dockerCli.Client()
ctx := context.Background()
Expand Down Expand Up @@ -252,7 +252,7 @@ func runUpdate(dockerCli command.Cli, flags *pflag.FlagSet, options *serviceOpti
return waitOnService(ctx, dockerCli, serviceID, options.quiet)
}

// nolint: gocyclo
//nolint:gocyclo
func updateService(ctx context.Context, apiClient client.NetworkAPIClient, flags *pflag.FlagSet, spec *swarm.ServiceSpec) error {
updateBoolPtr := func(flag string, field **bool) {
if flags.Changed(flag) {
Expand Down Expand Up @@ -1139,37 +1139,37 @@ type hostMapping struct {
// Entries can be removed by either a specific `<host-name>:<ip-address>` mapping,
// or by `<host>` alone:
//
// - If both IP-address and host-name is provided, the hostname is removed only
// from entries that match the given IP-address.
// - If only a host-name is provided, the hostname is removed from any entry it
// is part of (either as canonical host-name, or as alias).
// - If, after removing the host-name from an entry, no host-names remain in
// the entry, the entry itself is removed.
// - If both IP-address and host-name is provided, the hostname is removed only
// from entries that match the given IP-address.
// - If only a host-name is provided, the hostname is removed from any entry it
// is part of (either as canonical host-name, or as alias).
// - If, after removing the host-name from an entry, no host-names remain in
// the entry, the entry itself is removed.
//
// For example, the list of host-entries before processing could look like this:
//
// hosts = &[]string{
// "127.0.0.2 host3 host1 host2 host4",
// "127.0.0.1 host1 host4",
// "127.0.0.3 host1",
// "127.0.0.1 host1",
// }
// hosts = &[]string{
// "127.0.0.2 host3 host1 host2 host4",
// "127.0.0.1 host1 host4",
// "127.0.0.3 host1",
// "127.0.0.1 host1",
// }
//
// Removing `host1` removes every occurrence:
//
// hosts = &[]string{
// "127.0.0.2 host3 host2 host4",
// "127.0.0.1 host4",
// }
// hosts = &[]string{
// "127.0.0.2 host3 host2 host4",
// "127.0.0.1 host4",
// }
//
// Removing `host1:127.0.0.1` on the other hand, only remove the host if the
// IP-address matches:
//
// hosts = &[]string{
// "127.0.0.2 host3 host1 host2 host4",
// "127.0.0.1 host4",
// "127.0.0.3 host1",
// }
// hosts = &[]string{
// "127.0.0.2 host3 host1 host2 host4",
// "127.0.0.1 host4",
// "127.0.0.3 host1",
// }
func updateHosts(flags *pflag.FlagSet, hosts *[]string) error {
var toRemove []hostMapping
if flags.Changed(flagHostRemove) {
Expand Down Expand Up @@ -1410,34 +1410,33 @@ func updateCredSpecConfig(flags *pflag.FlagSet, containerSpec *swarm.ContainerSp
//
// Adding/removing capabilities when updating a service is handled as a tri-state;
//
// - if the capability was previously "dropped", then remove it from "CapabilityDrop",
// but NOT added to "CapabilityAdd". However, if the capability was not yet in
// the service's "CapabilityDrop", then it's simply added to the service's "CapabilityAdd"
// - likewise, if the capability was previously "added", then it's removed from
// "CapabilityAdd", but NOT added to "CapabilityDrop". If the capability was
// not yet in the service's "CapabilityAdd", then simply add it to the service's
// "CapabilityDrop".
// - if the capability was previously "dropped", then remove it from "CapabilityDrop",
// but NOT added to "CapabilityAdd". However, if the capability was not yet in
// the service's "CapabilityDrop", then it's simply added to the service's "CapabilityAdd"
// - likewise, if the capability was previously "added", then it's removed from
// "CapabilityAdd", but NOT added to "CapabilityDrop". If the capability was
// not yet in the service's "CapabilityAdd", then simply add it to the service's
// "CapabilityDrop".
//
// In other words, given a service with the following:
//
// | CapDrop | CapAdd |
// | -------------- | ------------- |
// |----------------|---------------|
// | CAP_SOME_CAP | |
//
// When updating the service, and applying `--cap-add CAP_SOME_CAP`, the previously
// dropped capability is removed:
//
// | CapDrop | CapAdd |
// | -------------- | ------------- |
// |----------------|---------------|
// | | |
//
// After updating the service a second time, applying `--cap-add CAP_SOME_CAP`,
// capability is now added:
//
// | CapDrop | CapAdd |
// | -------------- | ------------- |
// |----------------|---------------|
// | | CAP_SOME_CAP |
//
func updateCapabilities(flags *pflag.FlagSet, containerSpec *swarm.ContainerSpec) {
var (
toAdd, toDrop map[string]bool
Expand Down
5 changes: 3 additions & 2 deletions cli/command/service/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,9 @@ func (s secretAPIClientMock) SecretUpdate(ctx context.Context, id string, versio
return nil
}

// TestUpdateSecretUpdateInPlace tests the ability to update the "target" of an secret with "docker service update"
// by combining "--secret-rm" and "--secret-add" for the same secret.
// TestUpdateSecretUpdateInPlace tests the ability to update the "target" of a
// secret with "docker service update" by combining "--secret-rm" and
// "--secret-add" for the same secret.
func TestUpdateSecretUpdateInPlace(t *testing.T) {
apiClient := secretAPIClientMock{
listResult: []swarm.Secret{
Expand Down
2 changes: 1 addition & 1 deletion cli/command/stack/swarm/deploy_composefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func createNetworks(ctx context.Context, dockerCli command.Cli, namespace conver
return nil
}

// nolint: gocyclo
//nolint:gocyclo
func deployServices(ctx context.Context, dockerCli command.Cli, services map[string]swarm.ServiceSpec, namespace convert.Namespace, sendAuth bool, resolveImage string) error {
apiClient := dockerCli.Client()
out := dockerCli.Out()
Expand Down
4 changes: 2 additions & 2 deletions cli/command/system/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func prettyPrintClientInfo(dockerCli command.Cli, info clientInfo) {
}
}

// nolint: gocyclo
//nolint:gocyclo
func prettyPrintServerInfo(dockerCli command.Cli, info types.Info) []error {
var errs []error

Expand Down Expand Up @@ -360,7 +360,7 @@ func prettyPrintServerInfo(dockerCli command.Cli, info types.Info) []error {
return errs
}

// nolint: gocyclo
//nolint:gocyclo
func printSwarmInfo(dockerCli command.Cli, info types.Info) {
if info.Swarm.LocalNodeState == swarm.LocalNodeStateInactive || info.Swarm.LocalNodeState == swarm.LocalNodeStateLocked {
return
Expand Down
Loading