From 39d03bb2bd24f69073dfe30de2d9fc2898e6df9e Mon Sep 17 00:00:00 2001 From: Nishant Totla Date: Mon, 15 May 2017 16:01:48 -0700 Subject: [PATCH] Adding a flag to allow disabling registry lookup Signed-off-by: Nishant Totla --- cli/command/service/create.go | 6 +++++- cli/command/service/opts.go | 6 +++++- cli/command/service/update.go | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cli/command/service/create.go b/cli/command/service/create.go index 7dadb6ba77..ef73ec19ed 100644 --- a/cli/command/service/create.go +++ b/cli/command/service/create.go @@ -6,6 +6,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/versions" "github.com/spf13/cobra" "github.com/spf13/pflag" "golang.org/x/net/context" @@ -106,7 +107,10 @@ func runCreate(dockerCli *command.DockerCli, flags *pflag.FlagSet, opts *service createOpts.EncodedRegistryAuth = encodedAuth } - createOpts.QueryRegistry = true + // query registry if flag disabling it was not set + if !opts.noResolveImage && versions.GreaterThanOrEqualTo(apiClient.ClientVersion(), "1.30") { + createOpts.QueryRegistry = true + } response, err := apiClient.ServiceCreate(ctx, service, createOpts) if err != nil { diff --git a/cli/command/service/opts.go b/cli/command/service/opts.go index e1d328c487..dfa0eedb74 100644 --- a/cli/command/service/opts.go +++ b/cli/command/service/opts.go @@ -542,7 +542,8 @@ type serviceOptions struct { networks opts.ListOpts endpoint endpointOptions - registryAuth bool + registryAuth bool + noResolveImage bool logDriver logDriverOptions @@ -797,6 +798,8 @@ func addServiceFlags(flags *pflag.FlagSet, opts *serviceOptions, defaultFlagValu flags.StringVar(&opts.endpoint.mode, flagEndpointMode, defaultFlagValues.getString(flagEndpointMode), "Endpoint mode (vip or dnsrr)") flags.BoolVar(&opts.registryAuth, flagRegistryAuth, false, "Send registry authentication details to swarm agents") + flags.BoolVar(&opts.noResolveImage, flagNoResolveImage, false, "Do not query the registry to resolve image digest and supported platforms") + flags.SetAnnotation(flagNoResolveImage, "version", []string{"1.30"}) flags.StringVar(&opts.logDriver.name, flagLogDriver, "", "Logging driver for service") flags.Var(&opts.logDriver.opts, flagLogOpt, "Logging driver options") @@ -899,6 +902,7 @@ const ( flagUser = "user" flagWorkdir = "workdir" flagRegistryAuth = "with-registry-auth" + flagNoResolveImage = "no-resolve-image" flagLogDriver = "log-driver" flagLogOpt = "log-opt" flagHealthCmd = "health-cmd" diff --git a/cli/command/service/update.go b/cli/command/service/update.go index a57145afa6..88529e0d0a 100644 --- a/cli/command/service/update.go +++ b/cli/command/service/update.go @@ -167,7 +167,9 @@ func runUpdate(dockerCli *command.DockerCli, flags *pflag.FlagSet, options *serv if err := resolveServiceImageDigestContentTrust(dockerCli, spec); err != nil { return err } - updateOpts.QueryRegistry = true + if !options.noResolveImage && versions.GreaterThanOrEqualTo(apiClient.ClientVersion(), "1.30") { + updateOpts.QueryRegistry = true + } } updatedSecrets, err := getUpdatedSecrets(apiClient, flags, spec.TaskTemplate.ContainerSpec.Secrets)