From a1dc197d1cb84ca01b18abb69f122ca2b1e124e6 Mon Sep 17 00:00:00 2001 From: Anca Iordache Date: Tue, 17 Sep 2019 09:49:03 +0200 Subject: [PATCH 1/2] app-214 Enabled validate only for experimental mode Signed-off-by: Anca Iordache --- internal/commands/root.go | 17 ++++++++++++++--- internal/commands/validate.go | 9 +++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/internal/commands/root.go b/internal/commands/root.go index 7abfc328c..11574c4ad 100644 --- a/internal/commands/root.go +++ b/internal/commands/root.go @@ -48,7 +48,7 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command { } func addCommands(cmd *cobra.Command, dockerCli command.Cli) { - cmd.AddCommand( + listOfCommands := []*cobra.Command{ runCmd(dockerCli), updateCmd(dockerCli), removeCmd(dockerCli), @@ -59,8 +59,19 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) { pullCmd(dockerCli), image.Cmd(dockerCli), build.Cmd(dockerCli), - inspectCmd(dockerCli), - ) + } + + isExperimentalMode := dockerCli.ClientInfo().HasExperimental + for _, ccmd := range listOfCommands { + switch ccmd.Annotations["experimental"] { + case "true": + if isExperimentalMode { + cmd.AddCommand(ccmd) + } + default: + cmd.AddCommand(ccmd) + } + } } func firstOrEmpty(list []string) string { diff --git a/internal/commands/validate.go b/internal/commands/validate.go index d4e82016b..1b39de399 100644 --- a/internal/commands/validate.go +++ b/internal/commands/validate.go @@ -22,10 +22,11 @@ type validateOptions struct { func validateCmd() *cobra.Command { var opts validateOptions cmd := &cobra.Command{ - Use: "validate [OPTIONS] APP_DEFINITION", - Short: "Check that an App definition (.dockerapp) is syntactically correct", - Example: `$ docker app validate myapp.dockerapp --set key=value --parameters-file myparam.yml`, - Args: cli.RequiresMaxArgs(1), + Use: "validate [OPTIONS] APP_DEFINITION", + Short: "Check that an App definition (.dockerapp) is syntactically correct", + Example: `$ docker app validate myapp.dockerapp --set key=value --parameters-file myparam.yml`, + Args: cli.RequiresMaxArgs(1), + Annotations: map[string]string{"experimental": "true"}, RunE: func(cmd *cobra.Command, args []string) error { return runValidate(args, opts) }, From ed930a804155dcaa0165e507a2f0d79230f13d07 Mon Sep 17 00:00:00 2001 From: Anca Iordache Date: Fri, 8 Nov 2019 14:23:39 +0100 Subject: [PATCH 2/2] vendor update Signed-off-by: Anca Iordache --- Gopkg.lock | 8 +-- Gopkg.toml | 5 +- internal/commands/root.go | 1 + .../github.com/docker/cli/cli/command/cli.go | 56 ++++++++++++++----- .../docker/cli/cli/command/formatter/image.go | 9 ++- .../cli/cli/command/stack/kubernetes/list.go | 2 +- .../docker/cli/cli/command/utils.go | 2 +- .../docker/cli/cli/compose/convert/compose.go | 6 +- .../docker/cli/cli/compose/convert/service.go | 21 +++---- .../compose/interpolation/interpolation.go | 2 - .../cli/cli/compose/loader/interpolate.go | 1 + .../docker/cli/cli/compose/loader/loader.go | 35 ++++++------ .../docker/cli/cli/compose/loader/merge.go | 1 + .../docker/cli/cli/compose/types/types.go | 2 +- .../docker/cli/cli/registry/client/fetcher.go | 6 +- vendor/github.com/docker/cli/cli/required.go | 1 + .../internal/containerizedengine/progress.go | 1 - .../internal/containerizedengine/update.go | 2 +- .../docker/cli/internal/versions/versions.go | 1 - .../docker/cli/opts/throttledevice.go | 3 - .../api/types/container/container_changes.go | 3 +- .../api/types/container/container_create.go | 3 +- .../api/types/container/container_top.go | 3 +- .../api/types/container/container_update.go | 3 +- .../api/types/container/container_wait.go | 3 +- .../docker/api/types/image/image_history.go | 3 +- .../docker/api/types/volume/volume_create.go | 3 +- .../docker/api/types/volume/volume_list.go | 3 +- .../docker/docker/registry/session.go | 2 + 29 files changed, 103 insertions(+), 88 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index e0ca13238..0b35835a5 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -231,7 +231,7 @@ version = "v0.3.1" [[projects]] - digest = "1:995dbc119304c3b7edd6fadbaf77200b75bbba47ed7a9a6d3ff1268cf53ce437" + digest = "1:70c71dd9f1dc81872e11415441714469cd8231c85f26b709a4f48c0c3f81d4ae" name = "github.com/docker/cli" packages = [ "cli", @@ -286,7 +286,7 @@ "types", ] pruneopts = "UT" - revision = "6318939f30e01585b34eb6a68a54b890a8d54eb0" + revision = "37f9a88c696ae81be14c1697bd083d6421b4933c" [[projects]] digest = "1:3314fe819a33c59d1d8c25b35297da7d3137dadef098699e087c50be3ecdd867" @@ -347,7 +347,7 @@ [[projects]] branch = "master" - digest = "1:5b5820e4dbabe9742d8e6de338060fe555aaade0d608fc6f632a4ab2a98851a5" + digest = "1:61d8f5998565a7c687a03d7f93845975651a0e0a87a079b824a2905c125d9bd0" name = "github.com/docker/docker" packages = [ "api", @@ -391,7 +391,7 @@ "registry/resumable", ] pruneopts = "NUT" - revision = "7cb46617fcc1071963ab59d81082eab3e3ef8f9d" + revision = "1a88e0255496ca8a5ffa70e845da43381c7fc8ea" [[projects]] digest = "1:8866486038791fe65ea1abf660041423954b1f3fb99ea6a0ad8424422e943458" diff --git a/Gopkg.toml b/Gopkg.toml index cd42ca659..0e2112fda 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -50,7 +50,7 @@ required = ["github.com/wadey/gocovmerge"] [[override]] name = "github.com/docker/cli" - revision = "6318939f30e01585b34eb6a68a54b890a8d54eb0" + revision = "37f9a88c696ae81be14c1697bd083d6421b4933c" [[override]] name = "github.com/deislabs/cnab-go" @@ -71,7 +71,7 @@ required = ["github.com/wadey/gocovmerge"] [[override]] name = "github.com/xeipuuv/gojsonschema" version = "v1.2.0" - + [[override]] name = "github.com/docker/go-metrics" revision = "d466d4f6fd960e01820085bd7e1a24426ee7ef18" @@ -117,6 +117,7 @@ required = ["github.com/wadey/gocovmerge"] name = "github.com/Microsoft/hcsshim" revision = "2226e083fc390003ae5aa8325c3c92789afa0e7a" + [[constraint]] name = "github.com/spf13/pflag" branch = "master" diff --git a/internal/commands/root.go b/internal/commands/root.go index 11574c4ad..4eac33e36 100644 --- a/internal/commands/root.go +++ b/internal/commands/root.go @@ -59,6 +59,7 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) { pullCmd(dockerCli), image.Cmd(dockerCli), build.Cmd(dockerCli), + inspectCmd(dockerCli), } isExperimentalMode := dockerCli.ClientInfo().HasExperimental diff --git a/vendor/github.com/docker/cli/cli/command/cli.go b/vendor/github.com/docker/cli/cli/command/cli.go index 186854f86..c2f601d86 100644 --- a/vendor/github.com/docker/cli/cli/command/cli.go +++ b/vendor/github.com/docker/cli/cli/command/cli.go @@ -25,6 +25,7 @@ import ( "github.com/docker/cli/internal/containerizedengine" dopts "github.com/docker/cli/opts" clitypes "github.com/docker/cli/types" + "github.com/docker/docker/api" "github.com/docker/docker/api/types" registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/client" @@ -76,7 +77,7 @@ type DockerCli struct { err io.Writer client client.APIClient serverInfo ServerInfo - clientInfo ClientInfo + clientInfo *ClientInfo contentTrust bool newContainerizeClient func(string) (clitypes.ContainerizedClient, error) contextStore store.Store @@ -87,7 +88,7 @@ type DockerCli struct { // DefaultVersion returns api.defaultVersion or DOCKER_API_VERSION if specified. func (cli *DockerCli) DefaultVersion() string { - return cli.clientInfo.DefaultVersion + return cli.ClientInfo().DefaultVersion } // Client returns the APIClient @@ -126,9 +127,16 @@ func ShowHelp(err io.Writer) func(*cobra.Command, []string) error { // ConfigFile returns the ConfigFile func (cli *DockerCli) ConfigFile() *configfile.ConfigFile { + if cli.configFile == nil { + cli.loadConfigFile() + } return cli.configFile } +func (cli *DockerCli) loadConfigFile() { + cli.configFile = cliconfig.LoadDefaultConfigFile(cli.err) +} + // ServerInfo returns the server version details for the host this client is // connected to func (cli *DockerCli) ServerInfo() ServerInfo { @@ -137,7 +145,34 @@ func (cli *DockerCli) ServerInfo() ServerInfo { // ClientInfo returns the client details for the cli func (cli *DockerCli) ClientInfo() ClientInfo { - return cli.clientInfo + if cli.clientInfo == nil { + _ = cli.loadClientInfo() + } + return *cli.clientInfo +} + +func (cli *DockerCli) loadClientInfo() error { + var experimentalValue string + // Environment variable always overrides configuration + if experimentalValue = os.Getenv("DOCKER_CLI_EXPERIMENTAL"); experimentalValue == "" { + experimentalValue = cli.ConfigFile().Experimental + } + hasExperimental, err := isEnabled(experimentalValue) + if err != nil { + return errors.Wrap(err, "Experimental field") + } + + var v string + if cli.client != nil { + v = cli.client.ClientVersion() + } else { + v = api.DefaultVersion + } + cli.clientInfo = &ClientInfo{ + DefaultVersion: v, + HasExperimental: hasExperimental, + } + return nil } // ContentTrustEnabled returns whether content trust has been enabled by an @@ -207,7 +242,7 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...Initialize debug.Enable() } - cli.configFile = cliconfig.LoadDefaultConfigFile(cli.err) + cli.loadConfigFile() baseContextStore := store.New(cliconfig.ContextStoreDir(), cli.contextStoreConfig) cli.contextStore = &ContextStoreWithDefault{ @@ -239,18 +274,9 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...Initialize return err } } - var experimentalValue string - // Environment variable always overrides configuration - if experimentalValue = os.Getenv("DOCKER_CLI_EXPERIMENTAL"); experimentalValue == "" { - experimentalValue = cli.configFile.Experimental - } - hasExperimental, err := isEnabled(experimentalValue) + err = cli.loadClientInfo() if err != nil { - return errors.Wrap(err, "Experimental field") - } - cli.clientInfo = ClientInfo{ - DefaultVersion: cli.client.ClientVersion(), - HasExperimental: hasExperimental, + return err } cli.initializeFromClient() return nil diff --git a/vendor/github.com/docker/cli/cli/command/formatter/image.go b/vendor/github.com/docker/cli/cli/command/formatter/image.go index 91893e8f9..384b35dc1 100644 --- a/vendor/github.com/docker/cli/cli/command/formatter/image.go +++ b/vendor/github.com/docker/cli/cli/command/formatter/image.go @@ -11,8 +11,8 @@ import ( ) const ( - defaultImageTableFormat = "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedSince}}\t{{.Size}}" - defaultImageTableFormatWithDigest = "table {{.Repository}}\t{{.Tag}}\t{{.Digest}}\t{{.ID}}\t{{.CreatedSince}}\t{{.Size}}" + defaultImageTableFormat = "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{if .CreatedSince }}{{.CreatedSince}}{{else}}N/A{{end}}\t{{.Size}}" + defaultImageTableFormatWithDigest = "table {{.Repository}}\t{{.Tag}}\t{{.Digest}}\t{{.ID}}\t{{if .CreatedSince }}{{.CreatedSince}}{{else}}N/A{{end}}\t{{.Size}}" imageIDHeader = "IMAGE ID" repositoryHeader = "REPOSITORY" @@ -235,6 +235,11 @@ func (c *imageContext) Digest() string { func (c *imageContext) CreatedSince() string { createdAt := time.Unix(c.i.Created, 0) + + if createdAt.IsZero() { + return "" + } + return units.HumanDuration(time.Now().UTC().Sub(createdAt)) + " ago" } diff --git a/vendor/github.com/docker/cli/cli/command/stack/kubernetes/list.go b/vendor/github.com/docker/cli/cli/command/stack/kubernetes/list.go index 9706f4be5..facd401bb 100644 --- a/vendor/github.com/docker/cli/cli/command/stack/kubernetes/list.go +++ b/vendor/github.com/docker/cli/cli/command/stack/kubernetes/list.go @@ -29,7 +29,7 @@ func GetStacks(kubeCli *KubeCli, opts options.List) ([]*formatter.Stack, error) } func isAllNamespacesDisabled(kubeCliConfig *configfile.KubernetesConfig) bool { - return kubeCliConfig == nil || kubeCliConfig != nil && kubeCliConfig.AllNamespaces != "disabled" + return kubeCliConfig == nil || kubeCliConfig.AllNamespaces != "disabled" } func getStacks(kubeCli *KubeCli, opts options.List) ([]*formatter.Stack, error) { diff --git a/vendor/github.com/docker/cli/cli/command/utils.go b/vendor/github.com/docker/cli/cli/command/utils.go index 21e702eb3..72503f5d0 100644 --- a/vendor/github.com/docker/cli/cli/command/utils.go +++ b/vendor/github.com/docker/cli/cli/command/utils.go @@ -78,7 +78,7 @@ func PromptForConfirmation(ins io.Reader, outs io.Writer, message string) bool { } message += " [y/N] " - fmt.Fprintf(outs, message) + _, _ = fmt.Fprint(outs, message) // On Windows, force the use of the regular OS stdin stream. if runtime.GOOS == "windows" { diff --git a/vendor/github.com/docker/cli/cli/compose/convert/compose.go b/vendor/github.com/docker/cli/cli/compose/convert/compose.go index 983e7b52e..189a90962 100644 --- a/vendor/github.com/docker/cli/cli/compose/convert/compose.go +++ b/vendor/github.com/docker/cli/cli/compose/convert/compose.go @@ -109,7 +109,7 @@ func Secrets(namespace Namespace, secrets map[string]composetypes.SecretConfig) var obj swarmFileObject var err error if secret.Driver != "" { - obj, err = driverObjectConfig(namespace, name, composetypes.FileObjectConfig(secret)) + obj = driverObjectConfig(namespace, name, composetypes.FileObjectConfig(secret)) } else { obj, err = fileObjectConfig(namespace, name, composetypes.FileObjectConfig(secret)) } @@ -161,7 +161,7 @@ type swarmFileObject struct { Data []byte } -func driverObjectConfig(namespace Namespace, name string, obj composetypes.FileObjectConfig) (swarmFileObject, error) { +func driverObjectConfig(namespace Namespace, name string, obj composetypes.FileObjectConfig) swarmFileObject { if obj.Name != "" { name = obj.Name } else { @@ -174,7 +174,7 @@ func driverObjectConfig(namespace Namespace, name string, obj composetypes.FileO Labels: AddStackLabel(namespace, obj.Labels), }, Data: []byte{}, - }, nil + } } func fileObjectConfig(namespace Namespace, name string, obj composetypes.FileObjectConfig) (swarmFileObject, error) { diff --git a/vendor/github.com/docker/cli/cli/compose/convert/service.go b/vendor/github.com/docker/cli/cli/compose/convert/service.go index 2da8c6dc5..da182bbfe 100644 --- a/vendor/github.com/docker/cli/cli/compose/convert/service.go +++ b/vendor/github.com/docker/cli/cli/compose/convert/service.go @@ -66,11 +66,7 @@ func Service( configs []*swarm.ConfigReference, ) (swarm.ServiceSpec, error) { name := namespace.Scope(service.Name) - - endpoint, err := convertEndpointSpec(service.Deploy.EndpointMode, service.Ports) - if err != nil { - return swarm.ServiceSpec{}, err - } + endpoint := convertEndpointSpec(service.Deploy.EndpointMode, service.Ports) mode, err := convertDeployMode(service.Deploy.Mode, service.Deploy.Replicas) if err != nil { @@ -103,10 +99,7 @@ func Service( return swarm.ServiceSpec{}, err } - dnsConfig, err := convertDNSConfig(service.DNS, service.DNSSearch) - if err != nil { - return swarm.ServiceSpec{}, err - } + dnsConfig := convertDNSConfig(service.DNS, service.DNSSearch) var privileges swarm.Privileges privileges.CredentialSpec, err = convertCredentialSpec( @@ -575,7 +568,7 @@ func convertResources(source composetypes.Resources) (*swarm.ResourceRequirement return resources, nil } -func convertEndpointSpec(endpointMode string, source []composetypes.ServicePortConfig) (*swarm.EndpointSpec, error) { +func convertEndpointSpec(endpointMode string, source []composetypes.ServicePortConfig) *swarm.EndpointSpec { portConfigs := []swarm.PortConfig{} for _, port := range source { portConfig := swarm.PortConfig{ @@ -594,7 +587,7 @@ func convertEndpointSpec(endpointMode string, source []composetypes.ServicePortC return &swarm.EndpointSpec{ Mode: swarm.ResolutionMode(strings.ToLower(endpointMode)), Ports: portConfigs, - }, nil + } } func convertEnvironment(source map[string]*string) []string { @@ -629,14 +622,14 @@ func convertDeployMode(mode string, replicas *uint64) (swarm.ServiceMode, error) return serviceMode, nil } -func convertDNSConfig(DNS []string, DNSSearch []string) (*swarm.DNSConfig, error) { +func convertDNSConfig(DNS []string, DNSSearch []string) *swarm.DNSConfig { if DNS != nil || DNSSearch != nil { return &swarm.DNSConfig{ Nameservers: DNS, Search: DNSSearch, - }, nil + } } - return nil, nil + return nil } func convertCredentialSpec(namespace Namespace, spec composetypes.CredentialSpecConfig, refs []*swarm.ConfigReference) (*swarm.CredentialSpec, error) { diff --git a/vendor/github.com/docker/cli/cli/compose/interpolation/interpolation.go b/vendor/github.com/docker/cli/cli/compose/interpolation/interpolation.go index d4f5c4a43..fd34ca82e 100644 --- a/vendor/github.com/docker/cli/cli/compose/interpolation/interpolation.go +++ b/vendor/github.com/docker/cli/cli/compose/interpolation/interpolation.go @@ -54,7 +54,6 @@ func Interpolate(config map[string]interface{}, opts Options) (map[string]interf func recursiveInterpolate(value interface{}, path Path, opts Options) (interface{}, error) { switch value := value.(type) { - case string: newValue, err := opts.Substitute(value, template.Mapping(opts.LookupValue)) if err != nil || newValue == value { @@ -91,7 +90,6 @@ func recursiveInterpolate(value interface{}, path Path, opts Options) (interface default: return value, nil - } } diff --git a/vendor/github.com/docker/cli/cli/compose/loader/interpolate.go b/vendor/github.com/docker/cli/cli/compose/loader/interpolate.go index f0a321fc4..d25936be8 100644 --- a/vendor/github.com/docker/cli/cli/compose/loader/interpolate.go +++ b/vendor/github.com/docker/cli/cli/compose/loader/interpolate.go @@ -19,6 +19,7 @@ var interpolateTypeCastMapping = map[interp.Path]interp.Cast{ servicePath("deploy", "rollback_config", "parallelism"): toInt, servicePath("deploy", "rollback_config", "max_failure_ratio"): toFloat, servicePath("deploy", "restart_policy", "max_attempts"): toInt, + servicePath("deploy", "placement", "max_replicas_per_node"): toInt, servicePath("ports", interp.PathMatchList, "target"): toInt, servicePath("ports", interp.PathMatchList, "published"): toInt, servicePath("ulimits", interp.PathMatchAll): toInt, diff --git a/vendor/github.com/docker/cli/cli/compose/loader/loader.go b/vendor/github.com/docker/cli/cli/compose/loader/loader.go index a17105f08..28573dc4d 100644 --- a/vendor/github.com/docker/cli/cli/compose/loader/loader.go +++ b/vendor/github.com/docker/cli/cli/compose/loader/loader.go @@ -297,10 +297,13 @@ func Transform(source interface{}, target interface{}, additionalTransformers .. return decoder.Decode(source) } +// TransformerFunc defines a function to perform the actual transformation +type TransformerFunc func(interface{}) (interface{}, error) + // Transformer defines a map to type transformer type Transformer struct { TypeOf reflect.Type - Func func(interface{}) (interface{}, error) + Func TransformerFunc } func createTransformHook(additionalTransformers ...Transformer) mapstructure.DecodeHookFuncType { @@ -684,7 +687,7 @@ func absPath(workingDir string, filePath string) string { return filepath.Join(workingDir, filePath) } -func transformMapStringString(data interface{}) (interface{}, error) { +var transformMapStringString TransformerFunc = func(data interface{}) (interface{}, error) { switch value := data.(type) { case map[string]interface{}: return toMapStringString(value, false), nil @@ -695,7 +698,7 @@ func transformMapStringString(data interface{}) (interface{}, error) { } } -func transformExternal(data interface{}) (interface{}, error) { +var transformExternal TransformerFunc = func(data interface{}) (interface{}, error) { switch value := data.(type) { case bool: return map[string]interface{}{"external": value}, nil @@ -706,7 +709,7 @@ func transformExternal(data interface{}) (interface{}, error) { } } -func transformServicePort(data interface{}) (interface{}, error) { +var transformServicePort TransformerFunc = func(data interface{}) (interface{}, error) { switch entries := data.(type) { case []interface{}: // We process the list instead of individual items here. @@ -739,7 +742,7 @@ func transformServicePort(data interface{}) (interface{}, error) { } } -func transformStringSourceMap(data interface{}) (interface{}, error) { +var transformStringSourceMap TransformerFunc = func(data interface{}) (interface{}, error) { switch value := data.(type) { case string: return map[string]interface{}{"source": value}, nil @@ -750,7 +753,7 @@ func transformStringSourceMap(data interface{}) (interface{}, error) { } } -func transformBuildConfig(data interface{}) (interface{}, error) { +var transformBuildConfig TransformerFunc = func(data interface{}) (interface{}, error) { switch value := data.(type) { case string: return map[string]interface{}{"context": value}, nil @@ -761,7 +764,7 @@ func transformBuildConfig(data interface{}) (interface{}, error) { } } -func transformServiceVolumeConfig(data interface{}) (interface{}, error) { +var transformServiceVolumeConfig TransformerFunc = func(data interface{}) (interface{}, error) { switch value := data.(type) { case string: return ParseVolume(value) @@ -772,7 +775,7 @@ func transformServiceVolumeConfig(data interface{}) (interface{}, error) { } } -func transformServiceNetworkMap(value interface{}) (interface{}, error) { +var transformServiceNetworkMap TransformerFunc = func(value interface{}) (interface{}, error) { if list, ok := value.([]interface{}); ok { mapValue := map[interface{}]interface{}{} for _, name := range list { @@ -783,7 +786,7 @@ func transformServiceNetworkMap(value interface{}) (interface{}, error) { return value, nil } -func transformStringOrNumberList(value interface{}) (interface{}, error) { +var transformStringOrNumberList TransformerFunc = func(value interface{}) (interface{}, error) { list := value.([]interface{}) result := make([]string, len(list)) for i, item := range list { @@ -792,7 +795,7 @@ func transformStringOrNumberList(value interface{}) (interface{}, error) { return result, nil } -func transformStringList(data interface{}) (interface{}, error) { +var transformStringList TransformerFunc = func(data interface{}) (interface{}, error) { switch value := data.(type) { case string: return []string{value}, nil @@ -803,13 +806,13 @@ func transformStringList(data interface{}) (interface{}, error) { } } -func transformMappingOrListFunc(sep string, allowNil bool) func(interface{}) (interface{}, error) { +func transformMappingOrListFunc(sep string, allowNil bool) TransformerFunc { return func(data interface{}) (interface{}, error) { return transformMappingOrList(data, sep, allowNil), nil } } -func transformListOrMappingFunc(sep string, allowNil bool) func(interface{}) (interface{}, error) { +func transformListOrMappingFunc(sep string, allowNil bool) TransformerFunc { return func(data interface{}) (interface{}, error) { return transformListOrMapping(data, sep, allowNil), nil } @@ -848,14 +851,14 @@ func transformMappingOrList(mappingOrList interface{}, sep string, allowNil bool panic(errors.Errorf("expected a map or a list, got %T: %#v", mappingOrList, mappingOrList)) } -func transformShellCommand(value interface{}) (interface{}, error) { +var transformShellCommand TransformerFunc = func(value interface{}) (interface{}, error) { if str, ok := value.(string); ok { return shellwords.Parse(str) } return value, nil } -func transformHealthCheckTest(data interface{}) (interface{}, error) { +var transformHealthCheckTest TransformerFunc = func(data interface{}) (interface{}, error) { switch value := data.(type) { case string: return append([]string{"CMD-SHELL"}, value), nil @@ -866,7 +869,7 @@ func transformHealthCheckTest(data interface{}) (interface{}, error) { } } -func transformSize(value interface{}) (interface{}, error) { +var transformSize TransformerFunc = func(value interface{}) (interface{}, error) { switch value := value.(type) { case int: return int64(value), nil @@ -876,7 +879,7 @@ func transformSize(value interface{}) (interface{}, error) { panic(errors.Errorf("invalid type for size %T", value)) } -func transformStringToDuration(value interface{}) (interface{}, error) { +var transformStringToDuration TransformerFunc = func(value interface{}) (interface{}, error) { switch value := value.(type) { case string: d, err := time.ParseDuration(value) diff --git a/vendor/github.com/docker/cli/cli/compose/loader/merge.go b/vendor/github.com/docker/cli/cli/compose/loader/merge.go index 24b74ffbc..015b1f5a5 100644 --- a/vendor/github.com/docker/cli/cli/compose/loader/merge.go +++ b/vendor/github.com/docker/cli/cli/compose/loader/merge.go @@ -60,6 +60,7 @@ func mergeServices(base, override []types.ServiceConfig) ([]types.ServiceConfig, }, } for name, overrideService := range overrideServices { + overrideService := overrideService if baseService, ok := baseServices[name]; ok { if err := mergo.Merge(&baseService, &overrideService, mergo.WithAppendSlice, mergo.WithOverride, mergo.WithTransformers(specials)); err != nil { return base, errors.Wrapf(err, "cannot merge service %s", name) diff --git a/vendor/github.com/docker/cli/cli/compose/types/types.go b/vendor/github.com/docker/cli/cli/compose/types/types.go index d77c1b63d..2578b8cf0 100644 --- a/vendor/github.com/docker/cli/cli/compose/types/types.go +++ b/vendor/github.com/docker/cli/cli/compose/types/types.go @@ -103,7 +103,7 @@ type Config struct { Volumes map[string]VolumeConfig `yaml:",omitempty" json:"volumes,omitempty"` Secrets map[string]SecretConfig `yaml:",omitempty" json:"secrets,omitempty"` Configs map[string]ConfigObjConfig `yaml:",omitempty" json:"configs,omitempty"` - Extras map[string]interface{} `yaml:",inline", json:"-"` + Extras map[string]interface{} `yaml:",inline" json:"-"` } // MarshalJSON makes Config implement json.Marshaler diff --git a/vendor/github.com/docker/cli/cli/registry/client/fetcher.go b/vendor/github.com/docker/cli/cli/registry/client/fetcher.go index e3d6cd606..678ea2649 100644 --- a/vendor/github.com/docker/cli/cli/registry/client/fetcher.go +++ b/vendor/github.com/docker/cli/cli/registry/client/fetcher.go @@ -11,7 +11,7 @@ import ( "github.com/docker/distribution/manifest/schema2" "github.com/docker/distribution/reference" "github.com/docker/distribution/registry/api/errcode" - "github.com/docker/distribution/registry/api/v2" + v2 "github.com/docker/distribution/registry/api/v2" distclient "github.com/docker/distribution/registry/client" "github.com/docker/docker/registry" digest "github.com/opencontainers/go-digest" @@ -103,9 +103,6 @@ func pullManifestSchemaV2ImageConfig(ctx context.Context, dgst digest.Digest, re } verifier := dgst.Verifier() - if err != nil { - return nil, err - } if _, err := verifier.Write(configJSON); err != nil { return nil, err } @@ -212,7 +209,6 @@ func (c *client) iterateEndpoints(ctx context.Context, namedRef reference.Named, confirmedTLSRegistries := make(map[string]bool) for _, endpoint := range endpoints { - if endpoint.Version == registry.APIVersion1 { logrus.Debugf("skipping v1 endpoint %s", endpoint.URL) continue diff --git a/vendor/github.com/docker/cli/cli/required.go b/vendor/github.com/docker/cli/cli/required.go index 33a467354..cce81c86a 100644 --- a/vendor/github.com/docker/cli/cli/required.go +++ b/vendor/github.com/docker/cli/cli/required.go @@ -99,6 +99,7 @@ func ExactArgs(number int) cobra.PositionalArgs { } } +//nolint: unparam func pluralize(word string, number int) string { if number == 1 { return word diff --git a/vendor/github.com/docker/cli/internal/containerizedengine/progress.go b/vendor/github.com/docker/cli/internal/containerizedengine/progress.go index 9ff2be52a..e40b5a45d 100644 --- a/vendor/github.com/docker/cli/internal/containerizedengine/progress.go +++ b/vendor/github.com/docker/cli/internal/containerizedengine/progress.go @@ -93,7 +93,6 @@ outer: } func updateNonActive(ctx context.Context, ongoing *jobs, cs content.Store, statuses map[string]statusInfo, keys *[]string, activeSeen map[string]struct{}, done *bool, start time.Time) error { - for _, j := range ongoing.jobs() { key := remotes.MakeRefKey(ctx, j) *keys = append(*keys, key) diff --git a/vendor/github.com/docker/cli/internal/containerizedengine/update.go b/vendor/github.com/docker/cli/internal/containerizedengine/update.go index 3cd7b3108..7c71da19e 100644 --- a/vendor/github.com/docker/cli/internal/containerizedengine/update.go +++ b/vendor/github.com/docker/cli/internal/containerizedengine/update.go @@ -16,7 +16,7 @@ import ( "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" ver "github.com/hashicorp/go-version" - "github.com/opencontainers/image-spec/specs-go/v1" + v1 "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" ) diff --git a/vendor/github.com/docker/cli/internal/versions/versions.go b/vendor/github.com/docker/cli/internal/versions/versions.go index 9e83bb371..5e09eb65f 100644 --- a/vendor/github.com/docker/cli/internal/versions/versions.go +++ b/vendor/github.com/docker/cli/internal/versions/versions.go @@ -24,7 +24,6 @@ const ( // GetEngineVersions reports the versions of the engine that are available func GetEngineVersions(ctx context.Context, registryClient registryclient.RegistryClient, registryPrefix, imageName, versionString string) (clitypes.AvailableVersions, error) { - if imageName == "" { var err error localMetadata, err := GetCurrentRuntimeMetadata("") diff --git a/vendor/github.com/docker/cli/opts/throttledevice.go b/vendor/github.com/docker/cli/opts/throttledevice.go index 0959efae3..0bf5dd666 100644 --- a/vendor/github.com/docker/cli/opts/throttledevice.go +++ b/vendor/github.com/docker/cli/opts/throttledevice.go @@ -48,9 +48,6 @@ func ValidateThrottleIOpsDevice(val string) (*blkiodev.ThrottleDevice, error) { if err != nil { return nil, fmt.Errorf("invalid rate for device: %s. The correct format is :. Number must be a positive integer", val) } - if rate < 0 { - return nil, fmt.Errorf("invalid rate for device: %s. The correct format is :. Number must be a positive integer", val) - } return &blkiodev.ThrottleDevice{Path: split[0], Rate: rate}, nil } diff --git a/vendor/github.com/docker/docker/api/types/container/container_changes.go b/vendor/github.com/docker/docker/api/types/container/container_changes.go index 222d14100..16dd5019e 100644 --- a/vendor/github.com/docker/docker/api/types/container/container_changes.go +++ b/vendor/github.com/docker/docker/api/types/container/container_changes.go @@ -1,8 +1,7 @@ package container // import "github.com/docker/docker/api/types/container" // ---------------------------------------------------------------------------- -// DO NOT EDIT THIS FILE -// This file was generated by `swagger generate operation` +// Code generated by `swagger generate operation`. DO NOT EDIT. // // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- diff --git a/vendor/github.com/docker/docker/api/types/container/container_create.go b/vendor/github.com/docker/docker/api/types/container/container_create.go index 1ec9c3728..d0c852f84 100644 --- a/vendor/github.com/docker/docker/api/types/container/container_create.go +++ b/vendor/github.com/docker/docker/api/types/container/container_create.go @@ -1,8 +1,7 @@ package container // import "github.com/docker/docker/api/types/container" // ---------------------------------------------------------------------------- -// DO NOT EDIT THIS FILE -// This file was generated by `swagger generate operation` +// Code generated by `swagger generate operation`. DO NOT EDIT. // // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- diff --git a/vendor/github.com/docker/docker/api/types/container/container_top.go b/vendor/github.com/docker/docker/api/types/container/container_top.go index f8a606687..f0ee9dde7 100644 --- a/vendor/github.com/docker/docker/api/types/container/container_top.go +++ b/vendor/github.com/docker/docker/api/types/container/container_top.go @@ -1,8 +1,7 @@ package container // import "github.com/docker/docker/api/types/container" // ---------------------------------------------------------------------------- -// DO NOT EDIT THIS FILE -// This file was generated by `swagger generate operation` +// Code generated by `swagger generate operation`. DO NOT EDIT. // // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- diff --git a/vendor/github.com/docker/docker/api/types/container/container_update.go b/vendor/github.com/docker/docker/api/types/container/container_update.go index 33addedf7..c10f175ea 100644 --- a/vendor/github.com/docker/docker/api/types/container/container_update.go +++ b/vendor/github.com/docker/docker/api/types/container/container_update.go @@ -1,8 +1,7 @@ package container // import "github.com/docker/docker/api/types/container" // ---------------------------------------------------------------------------- -// DO NOT EDIT THIS FILE -// This file was generated by `swagger generate operation` +// Code generated by `swagger generate operation`. DO NOT EDIT. // // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- diff --git a/vendor/github.com/docker/docker/api/types/container/container_wait.go b/vendor/github.com/docker/docker/api/types/container/container_wait.go index 94b6a20e1..49e05ae66 100644 --- a/vendor/github.com/docker/docker/api/types/container/container_wait.go +++ b/vendor/github.com/docker/docker/api/types/container/container_wait.go @@ -1,8 +1,7 @@ package container // import "github.com/docker/docker/api/types/container" // ---------------------------------------------------------------------------- -// DO NOT EDIT THIS FILE -// This file was generated by `swagger generate operation` +// Code generated by `swagger generate operation`. DO NOT EDIT. // // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- diff --git a/vendor/github.com/docker/docker/api/types/image/image_history.go b/vendor/github.com/docker/docker/api/types/image/image_history.go index b5a7a0c49..e302bb0ae 100644 --- a/vendor/github.com/docker/docker/api/types/image/image_history.go +++ b/vendor/github.com/docker/docker/api/types/image/image_history.go @@ -1,8 +1,7 @@ package image // import "github.com/docker/docker/api/types/image" // ---------------------------------------------------------------------------- -// DO NOT EDIT THIS FILE -// This file was generated by `swagger generate operation` +// Code generated by `swagger generate operation`. DO NOT EDIT. // // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- diff --git a/vendor/github.com/docker/docker/api/types/volume/volume_create.go b/vendor/github.com/docker/docker/api/types/volume/volume_create.go index 0c3772d3a..0d4f46a84 100644 --- a/vendor/github.com/docker/docker/api/types/volume/volume_create.go +++ b/vendor/github.com/docker/docker/api/types/volume/volume_create.go @@ -1,8 +1,7 @@ package volume // import "github.com/docker/docker/api/types/volume" // ---------------------------------------------------------------------------- -// DO NOT EDIT THIS FILE -// This file was generated by `swagger generate operation` +// Code generated by `swagger generate operation`. DO NOT EDIT. // // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- diff --git a/vendor/github.com/docker/docker/api/types/volume/volume_list.go b/vendor/github.com/docker/docker/api/types/volume/volume_list.go index 45c3c1c9a..8e685d51c 100644 --- a/vendor/github.com/docker/docker/api/types/volume/volume_list.go +++ b/vendor/github.com/docker/docker/api/types/volume/volume_list.go @@ -1,8 +1,7 @@ package volume // import "github.com/docker/docker/api/types/volume" // ---------------------------------------------------------------------------- -// DO NOT EDIT THIS FILE -// This file was generated by `swagger generate operation` +// Code generated by `swagger generate operation`. DO NOT EDIT. // // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- diff --git a/vendor/github.com/docker/docker/registry/session.go b/vendor/github.com/docker/docker/registry/session.go index f11a8847b..14825c5f9 100644 --- a/vendor/github.com/docker/docker/registry/session.go +++ b/vendor/github.com/docker/docker/registry/session.go @@ -133,7 +133,9 @@ func (tr *authTransport) RoundTrip(orig *http.Request) (*http.Response, error) { } resp, err := tr.RoundTripper.RoundTrip(req) if err != nil { + tr.mu.Lock() delete(tr.modReq, orig) + tr.mu.Unlock() return nil, err } if len(resp.Header["X-Docker-Token"]) > 0 {