From 82427d1a078e89d9bd10dd397e5ee7736a8086f9 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 13 Jul 2022 12:29:49 +0200 Subject: [PATCH] format (GoDoc) comments with Go 1.19 to prepare for go updates Older versions of Go do not format these comments, so we can already reformat them ahead of time to prevent gofmt linting failing once we update to Go 1.19 or up. Result of: gofmt -s -w $(find . -type f -name '*.go' | grep -v "/vendor/") With some manual adjusting. Signed-off-by: Sebastiaan van Stijn --- cli-plugins/manager/plugin.go | 2 +- cli/command/container/cp.go | 6 +- cli/command/container/create.go | 2 +- cli/command/container/opts.go | 10 ++- cli/command/container/opts_test.go | 2 +- cli/command/container/run.go | 2 +- cli/command/container/start.go | 3 +- cli/command/container/stats.go | 3 +- cli/command/formatter/container_test.go | 2 +- cli/command/formatter/reflect_test.go | 2 +- cli/command/formatter/tabwriter/tabwriter.go | 3 +- cli/command/image/build.go | 2 +- cli/command/image/formatter_history_test.go | 6 +- cli/command/image/trust.go | 3 +- cli/command/manifest/util.go | 2 +- cli/command/network/create.go | 3 +- cli/command/registry/login.go | 2 +- cli/command/service/list.go | 3 +- cli/command/service/opts.go | 8 ++- cli/command/service/progress/progress.go | 3 +- cli/command/service/update.go | 67 +++++++++---------- cli/command/service/update_test.go | 5 +- cli/command/stack/swarm/deploy_composefile.go | 2 +- cli/command/system/info.go | 4 +- cli/compose/loader/merge.go | 6 +- cli/compose/loader/windows_path.go | 3 +- cli/connhelper/commandconn/commandconn.go | 14 ++-- cli/context/docker/load.go | 2 +- cli/context/store/doc.go | 40 +++++++---- cli/context/store/tlsstore.go | 2 +- cli/required.go | 2 +- e2e/image/push_test.go | 2 +- internal/test/builders/doc.go | 1 - internal/test/doc.go | 1 - opts/envfile.go | 4 +- opts/gpus.go | 3 +- opts/mount.go | 3 +- opts/opts_test.go | 2 +- opts/parse.go | 4 +- opts/port.go | 3 +- 40 files changed, 136 insertions(+), 103 deletions(-) diff --git a/cli-plugins/manager/plugin.go b/cli-plugins/manager/plugin.go index 4b32a4fde6..e501af7228 100644 --- a/cli-plugins/manager/plugin.go +++ b/cli-plugins/manager/plugin.go @@ -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 == "" { diff --git a/cli/command/container/cp.go b/cli/command/container/cp.go index 82e46e198c..525866f2a9 100644 --- a/cli/command/container/cp.go +++ b/cli/command/container/cp.go @@ -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, diff --git a/cli/command/container/create.go b/cli/command/container/create.go index 40cff76c66..17d868e420 100644 --- a/cli/command/container/create.go +++ b/cli/command/container/create.go @@ -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 diff --git a/cli/command/container/opts.go b/cli/command/container/opts.go index c449955717..4d21783d7c 100644 --- a/cli/command/container/opts.go +++ b/cli/command/container/opts.go @@ -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") @@ -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 @@ -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 diff --git a/cli/command/container/opts_test.go b/cli/command/container/opts_test.go index 56b0f07f9d..b5672a186c 100644 --- a/cli/command/container/opts_test.go +++ b/cli/command/container/opts_test.go @@ -182,7 +182,7 @@ func TestParseRunWithInvalidArgs(t *testing.T) { } } -// nolint: gocyclo +//nolint:gocyclo func TestParseWithVolumes(t *testing.T) { // A single volume diff --git a/cli/command/container/run.go b/cli/command/container/run.go index e4db79373d..5efcf61ecd 100644 --- a/cli/command/container/run.go +++ b/cli/command/container/run.go @@ -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() diff --git a/cli/command/container/start.go b/cli/command/container/start.go index 2ecc0f97ef..9a8a083e6b 100644 --- a/cli/command/container/start.go +++ b/cli/command/container/start.go @@ -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() diff --git a/cli/command/container/stats.go b/cli/command/container/stats.go index 70d6e1640a..c0c4f0e0e5 100644 --- a/cli/command/container/stats.go +++ b/cli/command/container/stats.go @@ -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) diff --git a/cli/command/formatter/container_test.go b/cli/command/formatter/container_test.go index 42dc0a3cda..bc59447708 100644 --- a/cli/command/formatter/container_test.go +++ b/cli/command/formatter/container_test.go @@ -436,7 +436,7 @@ type ports struct { expected string } -// nolint: lll +//nolint:lll func TestDisplayablePorts(t *testing.T) { cases := []ports{ { diff --git a/cli/command/formatter/reflect_test.go b/cli/command/formatter/reflect_test.go index ffda51b858..58bd7fe42b 100644 --- a/cli/command/formatter/reflect_test.go +++ b/cli/command/formatter/reflect_test.go @@ -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)" } diff --git a/cli/command/formatter/tabwriter/tabwriter.go b/cli/command/formatter/tabwriter/tabwriter.go index f1ea77cc1a..2dcbcd0eb8 100644 --- a/cli/command/formatter/tabwriter/tabwriter.go +++ b/cli/command/formatter/tabwriter/tabwriter.go @@ -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 ( diff --git a/cli/command/image/build.go b/cli/command/image/build.go index f7c7e062d1..40b246c5c4 100644 --- a/cli/command/image/build.go +++ b/cli/command/image/build.go @@ -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 diff --git a/cli/command/image/formatter_history_test.go b/cli/command/image/formatter_history_test.go index 067e421ad1..2facc0c90f 100644 --- a/cli/command/image/formatter_history_test.go +++ b/cli/command/image/formatter_history_test.go @@ -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{ @@ -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 diff --git a/cli/command/image/trust.go b/cli/command/image/trust.go index 13b87afe3a..8bbf28acb9 100644 --- a/cli/command/image/trust.go +++ b/cli/command/image/trust.go @@ -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. diff --git a/cli/command/manifest/util.go b/cli/command/manifest/util.go index 26de5bf663..1d530d9f2f 100644 --- a/cli/command/manifest/util.go +++ b/cli/command/manifest/util.go @@ -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 { diff --git a/cli/command/network/create.go b/cli/command/network/create.go index 6c32753265..6b47bd3907 100644 --- a/cli/command/network/create.go +++ b/cli/command/network/create.go @@ -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") diff --git a/cli/command/registry/login.go b/cli/command/registry/login.go index c60e60b8f8..0e0a8465fd 100644 --- a/cli/command/registry/login.go +++ b/cli/command/registry/login.go @@ -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 { diff --git a/cli/command/service/list.go b/cli/command/service/list.go index ce6d1dc9e7..efaa8a193b 100644 --- a/cli/command/service/list.go +++ b/cli/command/service/list.go @@ -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() diff --git a/cli/command/service/opts.go b/cli/command/service/opts.go index 5680ec3eb5..05b3b8055d 100644 --- a/cli/command/service/opts.go +++ b/cli/command/service/opts.go @@ -466,9 +466,13 @@ func (opts *healthCheckOptions) toHealthConfig() (*container.HealthConfig, error } // convertExtraHostsToSwarmHosts converts an array of extra hosts in cli -// : +// +// : +// // into a swarmkit host format: -// IP_address canonical_hostname [aliases...] +// +// IP_address canonical_hostname [aliases...] +// // This assumes input value (:) has already been validated func convertExtraHostsToSwarmHosts(extraHosts []string) []string { hosts := []string{} diff --git a/cli/command/service/progress/progress.go b/cli/command/service/progress/progress.go index dc95a02a6a..aa8a293d21 100644 --- a/cli/command/service/progress/progress.go +++ b/cli/command/service/progress/progress.go @@ -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() diff --git a/cli/command/service/update.go b/cli/command/service/update.go index 47d3b20cf0..aa59cb7d7e 100644 --- a/cli/command/service/update.go +++ b/cli/command/service/update.go @@ -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() @@ -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) { @@ -1139,37 +1139,37 @@ type hostMapping struct { // Entries can be removed by either a specific `:` mapping, // or by `` 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) { @@ -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 diff --git a/cli/command/service/update_test.go b/cli/command/service/update_test.go index 269cd396b4..117c2d80cc 100644 --- a/cli/command/service/update_test.go +++ b/cli/command/service/update_test.go @@ -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{ diff --git a/cli/command/stack/swarm/deploy_composefile.go b/cli/command/stack/swarm/deploy_composefile.go index 2ab9be8a4f..8c77ca92f7 100644 --- a/cli/command/stack/swarm/deploy_composefile.go +++ b/cli/command/stack/swarm/deploy_composefile.go @@ -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() diff --git a/cli/command/system/info.go b/cli/command/system/info.go index 0e71b4bf77..c51e56bd2c 100644 --- a/cli/command/system/info.go +++ b/cli/command/system/info.go @@ -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 @@ -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 diff --git a/cli/compose/loader/merge.go b/cli/compose/loader/merge.go index 97d55ea6b8..13ac877b8d 100644 --- a/cli/compose/loader/merge.go +++ b/cli/compose/loader/merge.go @@ -227,7 +227,7 @@ func mergeLoggingConfig(dst, src reflect.Value) error { return nil } -//nolint: unparam +//nolint:unparam func mergeUlimitsConfig(dst, src reflect.Value) error { if src.Interface() != reflect.Zero(reflect.TypeOf(src.Interface())).Interface() { dst.Elem().Set(src.Elem()) @@ -235,7 +235,7 @@ func mergeUlimitsConfig(dst, src reflect.Value) error { return nil } -//nolint: unparam +//nolint:unparam func mergeShellCommand(dst, src reflect.Value) error { if src.Len() != 0 { dst.Set(src) @@ -243,7 +243,7 @@ func mergeShellCommand(dst, src reflect.Value) error { return nil } -//nolint: unparam +//nolint:unparam func mergeServiceNetworkConfig(dst, src reflect.Value) error { if src.Interface() != reflect.Zero(reflect.TypeOf(src.Interface())).Interface() { dst.Elem().FieldByName("Aliases").Set(src.Elem().FieldByName("Aliases")) diff --git a/cli/compose/loader/windows_path.go b/cli/compose/loader/windows_path.go index eaf41bf72a..3070bf8843 100644 --- a/cli/compose/loader/windows_path.go +++ b/cli/compose/loader/windows_path.go @@ -28,7 +28,8 @@ func isAbs(path string) (b bool) { // volumeNameLen returns length of the leading volume name on Windows. // It returns 0 elsewhere. -// nolint: gocyclo +// +//nolint:gocyclo func volumeNameLen(path string) int { if len(path) < 2 { return 0 diff --git a/cli/connhelper/commandconn/commandconn.go b/cli/connhelper/commandconn/commandconn.go index 128da447b5..b9c8ae5f40 100644 --- a/cli/connhelper/commandconn/commandconn.go +++ b/cli/connhelper/commandconn/commandconn.go @@ -4,13 +4,13 @@ // For example, to provide an http.Client that can connect to a Docker daemon // running in a Docker container ("DIND"): // -// httpClient := &http.Client{ -// Transport: &http.Transport{ -// DialContext: func(ctx context.Context, _network, _addr string) (net.Conn, error) { -// return commandconn.New(ctx, "docker", "exec", "-it", containerID, "docker", "system", "dial-stdio") -// }, -// }, -// } +// httpClient := &http.Client{ +// Transport: &http.Transport{ +// DialContext: func(ctx context.Context, _network, _addr string) (net.Conn, error) { +// return commandconn.New(ctx, "docker", "exec", "-it", containerID, "docker", "system", "dial-stdio") +// }, +// }, +// } package commandconn import ( diff --git a/cli/context/docker/load.go b/cli/context/docker/load.go index e4016440b8..09ec40505a 100644 --- a/cli/context/docker/load.go +++ b/cli/context/docker/load.go @@ -67,7 +67,7 @@ func (c *Endpoint) tlsConfig() (*tls.Config, error) { if pemBlock == nil { return nil, errors.New("no valid private key found") } - if x509.IsEncryptedPEMBlock(pemBlock) { //nolint: staticcheck // SA1019: x509.IsEncryptedPEMBlock is deprecated, and insecure by design + if x509.IsEncryptedPEMBlock(pemBlock) { //nolint:staticcheck // SA1019: x509.IsEncryptedPEMBlock is deprecated, and insecure by design return nil, errors.New("private key is encrypted - support for encrypted private keys has been removed, see https://docs.docker.com/go/deprecated/") } diff --git a/cli/context/store/doc.go b/cli/context/store/doc.go index f84c023839..705982ae41 100644 --- a/cli/context/store/doc.go +++ b/cli/context/store/doc.go @@ -1,20 +1,32 @@ -// Package store provides a generic way to store credentials to connect to virtually any kind of remote system. -// The term `context` comes from the similar feature in Kubernetes kubectl config files. +// Package store provides a generic way to store credentials to connect to +// virtually any kind of remote system. +// The term `context` comes from the similar feature in Kubernetes kubectl +// config files. // -// Conceptually, a context is a set of metadata and TLS data, that can be used to connect to various endpoints -// of a remote system. TLS data and metadata are stored separately, so that in the future, we will be able to store sensitive -// information in a more secure way, depending on the os we are running on (e.g.: on Windows we could use the user Certificate Store, on Mac OS the user Keychain...). +// Conceptually, a context is a set of metadata and TLS data, that can be used +// to connect to various endpoints of a remote system. TLS data and metadata +// are stored separately, so that in the future, we will be able to store +// sensitive information in a more secure way, depending on the os we are running +// on (e.g.: on Windows we could use the user Certificate Store, on macOS the +// user Keychain...). // // Current implementation is purely file based with the following structure: -// ${CONTEXT_ROOT} -// - meta/ -// - /meta.json: contains context medata (key/value pairs) as well as a list of endpoints (themselves containing key/value pair metadata) -// - tls/ -// - /endpoint1/: directory containing TLS data for the endpoint1 in the corresponding context // -// The context store itself has absolutely no knowledge about what a docker endpoint should contain in term of metadata or TLS config. -// Client code is responsible for generating and parsing endpoint metadata and TLS files. -// The multi-endpoints approach of this package allows to combine many different endpoints in the same "context". +// ${CONTEXT_ROOT} +// meta/ +// /meta.json: contains context medata (key/value pairs) as +// well as a list of endpoints (themselves containing +// key/value pair metadata). +// tls/ +// /endpoint1/: directory containing TLS data for the endpoint1 +// in the corresponding context. // -// Context IDs are actually SHA256 hashes of the context name, and are there only to avoid dealing with special characters in context names. +// The context store itself has absolutely no knowledge about what a docker +// endpoint should contain in term of metadata or TLS config. Client code is +// responsible for generating and parsing endpoint metadata and TLS files. The +// multi-endpoints approach of this package allows to combine many different +// endpoints in the same "context". +// +// Context IDs are actually SHA256 hashes of the context name, and are there +// only to avoid dealing with special characters in context names. package store diff --git a/cli/context/store/tlsstore.go b/cli/context/store/tlsstore.go index 4a8dc7f4ff..797fbaf51f 100644 --- a/cli/context/store/tlsstore.go +++ b/cli/context/store/tlsstore.go @@ -43,7 +43,7 @@ func (s *tlsStore) getData(contextID contextdir, endpointName, filename string) return data, nil } -func (s *tlsStore) remove(contextID contextdir, endpointName, filename string) error { // nolint:unused +func (s *tlsStore) remove(contextID contextdir, endpointName, filename string) error { //nolint:unused err := os.Remove(s.filePath(contextID, endpointName, filename)) if os.IsNotExist(err) { return nil diff --git a/cli/required.go b/cli/required.go index cce81c86ab..454e247613 100644 --- a/cli/required.go +++ b/cli/required.go @@ -99,7 +99,7 @@ func ExactArgs(number int) cobra.PositionalArgs { } } -//nolint: unparam +//nolint:unparam func pluralize(word string, number int) string { if number == 1 { return word diff --git a/e2e/image/push_test.go b/e2e/image/push_test.go index 48029d9a32..fbc5095f3d 100644 --- a/e2e/image/push_test.go +++ b/e2e/image/push_test.go @@ -325,7 +325,7 @@ func createImage(t *testing.T, repo string, tags ...string) string { return fmt.Sprintf("%s/%s:%s", registryPrefix, repo, tags[0]) } -//nolint: unparam +//nolint:unparam func withNotaryPassphrase(pwd string) func(*icmd.Cmd) { return func(c *icmd.Cmd) { c.Env = append(c.Env, []string{ diff --git a/internal/test/builders/doc.go b/internal/test/builders/doc.go index eac991c2e4..01fa86e41d 100644 --- a/internal/test/builders/doc.go +++ b/internal/test/builders/doc.go @@ -1,3 +1,2 @@ // Package builders helps you create struct for your unit test while keeping them expressive. -// package builders diff --git a/internal/test/doc.go b/internal/test/doc.go index 342441d533..401f02facf 100644 --- a/internal/test/doc.go +++ b/internal/test/doc.go @@ -1,5 +1,4 @@ // Package test is a test-only package that can be used by other cli package to write unit test. // // It as an internal package and cannot be used outside of github.com/docker/cli package. -// package test diff --git a/opts/envfile.go b/opts/envfile.go index 69d3ca6f60..26aa3c3a90 100644 --- a/opts/envfile.go +++ b/opts/envfile.go @@ -6,12 +6,12 @@ import ( // ParseEnvFile reads a file with environment variables enumerated by lines // -// ``Environment variable names used by the utilities in the Shell and +// “Environment variable names used by the utilities in the Shell and // Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase // letters, digits, and the '_' (underscore) from the characters defined in // Portable Character Set and do not begin with a digit. *But*, other // characters may be permitted by an implementation; applications shall -// tolerate the presence of such names.'' +// tolerate the presence of such names.” // -- http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html // // As of #16585, it's up to application inside docker to validate or not diff --git a/opts/gpus.go b/opts/gpus.go index e110a4771e..8796a805d4 100644 --- a/opts/gpus.go +++ b/opts/gpus.go @@ -24,7 +24,8 @@ func parseCount(s string) (int, error) { } // Set a new mount value -// nolint: gocyclo +// +//nolint:gocyclo func (o *GpuOpts) Set(value string) error { csvReader := csv.NewReader(strings.NewReader(value)) fields, err := csvReader.Read() diff --git a/opts/mount.go b/opts/mount.go index fd010d66a4..7ffc3acc93 100644 --- a/opts/mount.go +++ b/opts/mount.go @@ -18,7 +18,8 @@ type MountOpt struct { } // Set a new mount value -// nolint: gocyclo +// +//nolint:gocyclo func (m *MountOpt) Set(value string) error { csvReader := csv.NewReader(strings.NewReader(value)) fields, err := csvReader.Read() diff --git a/opts/opts_test.go b/opts/opts_test.go index a1be7b5147..4ef3e19b6f 100644 --- a/opts/opts_test.go +++ b/opts/opts_test.go @@ -118,7 +118,7 @@ func TestListOptsWithValidator(t *testing.T) { } } -// nolint: lll +//nolint:lll func TestValidateDNSSearch(t *testing.T) { valid := []string{ `.`, diff --git a/opts/parse.go b/opts/parse.go index 327c2775f6..4012c461fb 100644 --- a/opts/parse.go +++ b/opts/parse.go @@ -55,7 +55,9 @@ func ConvertKVStringsToMap(values []string) map[string]string { // ConvertKVStringsToMapWithNil converts ["key=value"] to {"key":"value"} // but set unset keys to nil - meaning the ones with no "=" in them. // We use this in cases where we need to distinguish between -// FOO= and FOO +// +// FOO= and FOO +// // where the latter case just means FOO was mentioned but not given a value func ConvertKVStringsToMapWithNil(values []string) map[string]*string { result := make(map[string]*string, len(values)) diff --git a/opts/port.go b/opts/port.go index e0c5389930..c0814dbd9a 100644 --- a/opts/port.go +++ b/opts/port.go @@ -26,7 +26,8 @@ type PortOpt struct { } // Set a new port value -// nolint: gocyclo +// +//nolint:gocyclo func (p *PortOpt) Set(value string) error { longSyntax, err := regexp.MatchString(`\w+=\w+(,\w+=\w+)*`, value) if err != nil {