mirror of https://github.com/docker/cli.git
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 <github@gone.nl>
(cherry picked from commit 82427d1a07
)
Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
parent
e501531b5f
commit
0573ec2b01
|
@ -285,9 +285,11 @@ func copyToContainer(ctx context.Context, dockerCli command.Cli, copyConfig cpCo
|
||||||
// in a valid LOCALPATH, like `file:name.txt`. We can resolve this ambiguity by
|
// 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
|
// requiring a LOCALPATH with a `:` to be made explicit with a relative or
|
||||||
// absolute path:
|
// 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:
|
// 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
|
// We can't simply check for a filepath separator because container names may
|
||||||
|
|
|
@ -310,6 +310,7 @@ type containerConfig struct {
|
||||||
// parse parses the args for the specified command and generates a Config,
|
// parse parses the args for the specified command and generates a Config,
|
||||||
// a HostConfig and returns them with the specified command.
|
// a HostConfig and returns them with the specified command.
|
||||||
// If the specified args are not valid, it will return an error.
|
// 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) {
|
func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*containerConfig, error) {
|
||||||
var (
|
var (
|
||||||
|
@ -951,6 +952,7 @@ func parseWindowsDevice(device string) (container.DeviceMapping, error) {
|
||||||
|
|
||||||
// validateDeviceCgroupRule validates a device cgroup rule string format
|
// validateDeviceCgroupRule validates a device cgroup rule string format
|
||||||
// It will make sure 'val' is in the form:
|
// It will make sure 'val' is in the form:
|
||||||
|
//
|
||||||
// 'type major:minor mode'
|
// 'type major:minor mode'
|
||||||
func validateDeviceCgroupRule(val string) (string, error) {
|
func validateDeviceCgroupRule(val string) (string, error) {
|
||||||
if deviceCgroupRuleRegexp.MatchString(val) {
|
if deviceCgroupRuleRegexp.MatchString(val) {
|
||||||
|
@ -995,7 +997,9 @@ func validateDevice(val string, serverOS string) (string, error) {
|
||||||
// validateLinuxPath is the implementation of validateDevice knowing that the
|
// validateLinuxPath is the implementation of validateDevice knowing that the
|
||||||
// target server operating system is a Linux daemon.
|
// target server operating system is a Linux daemon.
|
||||||
// It will make sure 'val' is in the form:
|
// 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.
|
// It also validates the device mode.
|
||||||
func validateLinuxPath(val string, validator func(string) bool) (string, error) {
|
func validateLinuxPath(val string, validator func(string) bool) (string, error) {
|
||||||
var containerPath string
|
var containerPath string
|
||||||
|
|
|
@ -50,6 +50,7 @@ func NewStatsCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
|
|
||||||
// runStats displays a live stream of resource usage statistics for one or more containers.
|
// 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.
|
// 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 {
|
func runStats(dockerCli command.Cli, opts *statsOptions) error {
|
||||||
showAll := len(opts.containers) == 0
|
showAll := len(opts.containers) == 0
|
||||||
|
|
|
@ -42,6 +42,7 @@ func TrustedPush(ctx context.Context, cli command.Cli, repoInfo *registry.Reposi
|
||||||
}
|
}
|
||||||
|
|
||||||
// PushTrustedReference pushes a canonical reference to the trust server.
|
// 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 {
|
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
|
// If it is a trusted push we would like to find the target entry which match the
|
||||||
|
|
|
@ -128,6 +128,7 @@ func runCreate(dockerCli command.Cli, options createOptions) error {
|
||||||
// possible to correlate the various related parameters and consolidate them.
|
// possible to correlate the various related parameters and consolidate them.
|
||||||
// consolidateIpam consolidates subnets, ip-ranges, gateways and auxiliary addresses into
|
// consolidateIpam consolidates subnets, ip-ranges, gateways and auxiliary addresses into
|
||||||
// structured ipam data.
|
// structured ipam data.
|
||||||
|
//
|
||||||
//nolint:gocyclo
|
//nolint:gocyclo
|
||||||
func consolidateIpam(subnets, ranges, gateways []string, auxaddrs map[string]string) ([]network.IPAMConfig, error) {
|
func consolidateIpam(subnets, ranges, gateways []string, auxaddrs map[string]string) ([]network.IPAMConfig, error) {
|
||||||
if len(subnets) < len(ranges) || len(subnets) < len(gateways) {
|
if len(subnets) < len(ranges) || len(subnets) < len(gateways) {
|
||||||
|
|
|
@ -106,6 +106,7 @@ func runList(dockerCli command.Cli, opts listOptions) error {
|
||||||
// there may be other situations where the client uses the "default" version.
|
// 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
|
// 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.
|
// 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) {
|
func AppendServiceStatus(ctx context.Context, c client.APIClient, services []swarm.Service) ([]swarm.Service, error) {
|
||||||
status := map[string]*swarm.ServiceStatus{}
|
status := map[string]*swarm.ServiceStatus{}
|
||||||
|
|
|
@ -466,9 +466,13 @@ func (opts *healthCheckOptions) toHealthConfig() (*container.HealthConfig, error
|
||||||
}
|
}
|
||||||
|
|
||||||
// convertExtraHostsToSwarmHosts converts an array of extra hosts in cli
|
// convertExtraHostsToSwarmHosts converts an array of extra hosts in cli
|
||||||
|
//
|
||||||
// <host>:<ip>
|
// <host>:<ip>
|
||||||
|
//
|
||||||
// into a swarmkit host format:
|
// 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
|
// This assumes input value (<host>:<ip>) has already been validated
|
||||||
func convertExtraHostsToSwarmHosts(extraHosts []string) []string {
|
func convertExtraHostsToSwarmHosts(extraHosts []string) []string {
|
||||||
hosts := []string{}
|
hosts := []string{}
|
||||||
|
|
|
@ -75,6 +75,7 @@ func stateToProgress(state swarm.TaskState, rollback bool) int64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServiceProgress outputs progress information for convergence of a service.
|
// 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 {
|
func ServiceProgress(ctx context.Context, client client.APIClient, serviceID string, progressWriter io.WriteCloser) error {
|
||||||
defer progressWriter.Close()
|
defer progressWriter.Close()
|
||||||
|
|
|
@ -1418,23 +1418,22 @@ func updateCredSpecConfig(flags *pflag.FlagSet, containerSpec *swarm.ContainerSp
|
||||||
// In other words, given a service with the following:
|
// In other words, given a service with the following:
|
||||||
//
|
//
|
||||||
// | CapDrop | CapAdd |
|
// | CapDrop | CapAdd |
|
||||||
// | -------------- | ------------- |
|
// |----------------|---------------|
|
||||||
// | CAP_SOME_CAP | |
|
// | CAP_SOME_CAP | |
|
||||||
//
|
//
|
||||||
// When updating the service, and applying `--cap-add CAP_SOME_CAP`, the previously
|
// When updating the service, and applying `--cap-add CAP_SOME_CAP`, the previously
|
||||||
// dropped capability is removed:
|
// dropped capability is removed:
|
||||||
//
|
//
|
||||||
// | CapDrop | CapAdd |
|
// | CapDrop | CapAdd |
|
||||||
// | -------------- | ------------- |
|
// |----------------|---------------|
|
||||||
// | | |
|
// | | |
|
||||||
//
|
//
|
||||||
// After updating the service a second time, applying `--cap-add CAP_SOME_CAP`,
|
// After updating the service a second time, applying `--cap-add CAP_SOME_CAP`,
|
||||||
// capability is now added:
|
// capability is now added:
|
||||||
//
|
//
|
||||||
// | CapDrop | CapAdd |
|
// | CapDrop | CapAdd |
|
||||||
// | -------------- | ------------- |
|
// |----------------|---------------|
|
||||||
// | | CAP_SOME_CAP |
|
// | | CAP_SOME_CAP |
|
||||||
//
|
|
||||||
func updateCapabilities(flags *pflag.FlagSet, containerSpec *swarm.ContainerSpec) {
|
func updateCapabilities(flags *pflag.FlagSet, containerSpec *swarm.ContainerSpec) {
|
||||||
var (
|
var (
|
||||||
toAdd, toDrop map[string]bool
|
toAdd, toDrop map[string]bool
|
||||||
|
|
|
@ -520,8 +520,9 @@ func (s secretAPIClientMock) SecretUpdate(ctx context.Context, id string, versio
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestUpdateSecretUpdateInPlace tests the ability to update the "target" of an secret with "docker service update"
|
// TestUpdateSecretUpdateInPlace tests the ability to update the "target" of a
|
||||||
// by combining "--secret-rm" and "--secret-add" for the same secret.
|
// secret with "docker service update" by combining "--secret-rm" and
|
||||||
|
// "--secret-add" for the same secret.
|
||||||
func TestUpdateSecretUpdateInPlace(t *testing.T) {
|
func TestUpdateSecretUpdateInPlace(t *testing.T) {
|
||||||
apiClient := secretAPIClientMock{
|
apiClient := secretAPIClientMock{
|
||||||
listResult: []swarm.Secret{
|
listResult: []swarm.Secret{
|
||||||
|
|
|
@ -28,6 +28,7 @@ func isAbs(path string) (b bool) {
|
||||||
|
|
||||||
// volumeNameLen returns length of the leading volume name on Windows.
|
// volumeNameLen returns length of the leading volume name on Windows.
|
||||||
// It returns 0 elsewhere.
|
// It returns 0 elsewhere.
|
||||||
|
//
|
||||||
//nolint:gocyclo
|
//nolint:gocyclo
|
||||||
func volumeNameLen(path string) int {
|
func volumeNameLen(path string) int {
|
||||||
if len(path) < 2 {
|
if len(path) < 2 {
|
||||||
|
|
|
@ -1,22 +1,32 @@
|
||||||
// Package store provides a generic way to store credentials to connect to virtually any kind of remote system.
|
// Package store provides a generic way to store credentials to connect to
|
||||||
// The term `context` comes from the similar feature in Kubernetes kubectl config files.
|
// 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
|
// Conceptually, a context is a set of metadata and TLS data, that can be used
|
||||||
// of a remote system. TLS data and metadata are stored separately, so that in the future, we will be able to store sensitive
|
// to connect to various endpoints of a remote system. TLS data and metadata
|
||||||
// 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...).
|
// 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:
|
// Current implementation is purely file based with the following structure:
|
||||||
|
//
|
||||||
// ${CONTEXT_ROOT}
|
// ${CONTEXT_ROOT}
|
||||||
// - meta/
|
// meta/
|
||||||
// - <context id>/meta.json: contains context medata (key/value pairs) as well as a list of endpoints (themselves containing key/value pair metadata)
|
// <context id>/meta.json: contains context medata (key/value pairs) as
|
||||||
// - tls/
|
// well as a list of endpoints (themselves containing
|
||||||
// - <context id>/endpoint1/: directory containing TLS data for the endpoint1 in the corresponding context
|
// key/value pair metadata).
|
||||||
|
// tls/
|
||||||
|
// <context id>/endpoint1/: directory containing TLS data for the endpoint1
|
||||||
|
// in the corresponding context.
|
||||||
//
|
//
|
||||||
// The context store itself has absolutely no knowledge about what a docker or a kubernetes endpoint should contain in term of metadata or TLS config.
|
// The context store itself has absolutely no knowledge about what a docker
|
||||||
// Client code is responsible for generating and parsing endpoint metadata and TLS files.
|
// endpoint should contain in term of metadata or TLS config. Client code is
|
||||||
// The multi-endpoints approach of this package allows to combine many different endpoints in the same "context" (e.g., the Docker CLI
|
// responsible for generating and parsing endpoint metadata and TLS files. The
|
||||||
// is able for a single context to define both a docker endpoint and a Kubernetes endpoint for the same cluster, and also specify which
|
// multi-endpoints approach of this package allows to combine many different
|
||||||
// orchestrator to use by default when deploying a compose stack on this cluster).
|
// 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.
|
// 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
|
package store
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
/*Package winresources is used to embed Windows resources into docker.exe.
|
/*
|
||||||
|
Package winresources is used to embed Windows resources into docker.exe.
|
||||||
These resources are used to provide
|
These resources are used to provide
|
||||||
|
|
||||||
* Version information
|
- Version information
|
||||||
* An icon
|
- An icon
|
||||||
* A Windows manifest declaring Windows version support
|
- A Windows manifest declaring Windows version support
|
||||||
|
|
||||||
The resource object files are generated when building with scripts/build/binary .
|
The resource object files are generated when building with scripts/build/binary .
|
||||||
The resource source files are located in scripts/winresources.
|
The resource source files are located in scripts/winresources.
|
||||||
|
@ -11,6 +12,5 @@ This occurs automatically when you run scripts/build/windows.
|
||||||
|
|
||||||
These object files are picked up automatically by go build when this package
|
These object files are picked up automatically by go build when this package
|
||||||
is included.
|
is included.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package winresources
|
package winresources
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
// Package builders helps you create struct for your unit test while keeping them expressive.
|
// Package builders helps you create struct for your unit test while keeping them expressive.
|
||||||
//
|
|
||||||
package builders
|
package builders
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// Package test is a test-only package that can be used by other cli package to write unit test.
|
// 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.
|
// It as an internal package and cannot be used outside of github.com/docker/cli package.
|
||||||
//
|
|
||||||
package test
|
package test
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build never
|
||||||
// +build never
|
// +build never
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
|
@ -6,12 +6,12 @@ import (
|
||||||
|
|
||||||
// ParseEnvFile reads a file with environment variables enumerated by lines
|
// 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
|
// Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase
|
||||||
// letters, digits, and the '_' (underscore) from the characters defined in
|
// letters, digits, and the '_' (underscore) from the characters defined in
|
||||||
// Portable Character Set and do not begin with a digit. *But*, other
|
// Portable Character Set and do not begin with a digit. *But*, other
|
||||||
// characters may be permitted by an implementation; applications shall
|
// 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
|
// -- http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html
|
||||||
//
|
//
|
||||||
// As of #16585, it's up to application inside docker to validate or not
|
// As of #16585, it's up to application inside docker to validate or not
|
||||||
|
|
|
@ -24,6 +24,7 @@ func parseCount(s string) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set a new mount value
|
// Set a new mount value
|
||||||
|
//
|
||||||
//nolint:gocyclo
|
//nolint:gocyclo
|
||||||
func (o *GpuOpts) Set(value string) error {
|
func (o *GpuOpts) Set(value string) error {
|
||||||
csvReader := csv.NewReader(strings.NewReader(value))
|
csvReader := csv.NewReader(strings.NewReader(value))
|
||||||
|
|
|
@ -17,6 +17,7 @@ type MountOpt struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set a new mount value
|
// Set a new mount value
|
||||||
|
//
|
||||||
//nolint:gocyclo
|
//nolint:gocyclo
|
||||||
func (m *MountOpt) Set(value string) error {
|
func (m *MountOpt) Set(value string) error {
|
||||||
csvReader := csv.NewReader(strings.NewReader(value))
|
csvReader := csv.NewReader(strings.NewReader(value))
|
||||||
|
|
|
@ -55,7 +55,9 @@ func ConvertKVStringsToMap(values []string) map[string]string {
|
||||||
// ConvertKVStringsToMapWithNil converts ["key=value"] to {"key":"value"}
|
// ConvertKVStringsToMapWithNil converts ["key=value"] to {"key":"value"}
|
||||||
// but set unset keys to nil - meaning the ones with no "=" in them.
|
// but set unset keys to nil - meaning the ones with no "=" in them.
|
||||||
// We use this in cases where we need to distinguish between
|
// 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
|
// where the latter case just means FOO was mentioned but not given a value
|
||||||
func ConvertKVStringsToMapWithNil(values []string) map[string]*string {
|
func ConvertKVStringsToMapWithNil(values []string) map[string]*string {
|
||||||
result := make(map[string]*string, len(values))
|
result := make(map[string]*string, len(values))
|
||||||
|
|
|
@ -25,6 +25,7 @@ type PortOpt struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set a new port value
|
// Set a new port value
|
||||||
|
//
|
||||||
//nolint:gocyclo
|
//nolint:gocyclo
|
||||||
func (p *PortOpt) Set(value string) error {
|
func (p *PortOpt) Set(value string) error {
|
||||||
longSyntax, err := regexp.MatchString(`\w+=\w+(,\w+=\w+)*`, value)
|
longSyntax, err := regexp.MatchString(`\w+=\w+(,\w+=\w+)*`, value)
|
||||||
|
|
Loading…
Reference in New Issue