From d199f78d180b55febede2357b06b66580e3360c6 Mon Sep 17 00:00:00 2001 From: Nishant Totla Date: Thu, 16 Jun 2016 19:09:44 -0700 Subject: [PATCH] Updating header name and executor Signed-off-by: Nishant Totla (cherry picked from commit af5df117a805c8df661c7efa58c57680019b5752) --- api/client/service/create.go | 2 +- api/client/service/scale.go | 4 +--- api/client/service/update.go | 4 +--- api/client/stack/deploy.go | 5 ++++- api/server/router/swarm/cluster_routes.go | 10 ++-------- daemon/cluster/executor/container/adapter.go | 1 - hack/vendor.sh | 2 +- 7 files changed, 10 insertions(+), 18 deletions(-) diff --git a/api/client/service/create.go b/api/client/service/create.go index 9333ec411f..d169f32c79 100644 --- a/api/client/service/create.go +++ b/api/client/service/create.go @@ -47,7 +47,7 @@ func runCreate(dockerCli *client.DockerCli, opts *serviceOptions) error { } headers := map[string][]string{ - "x-registry-auth": {encodedAuth}, + "X-Registry-Auth": {encodedAuth}, } response, err := apiClient.ServiceCreate(ctx, service, headers) diff --git a/api/client/service/scale.go b/api/client/service/scale.go index d272b557cf..b0583e79a0 100644 --- a/api/client/service/scale.go +++ b/api/client/service/scale.go @@ -76,9 +76,7 @@ func runServiceScale(dockerCli *client.DockerCli, serviceID string, scale string if err != nil { return err } - headers = map[string][]string{ - "x-registry-auth": {encodedAuth}, - } + headers["X-Registry-Auth"] = []string{encodedAuth} } serviceMode := &service.Spec.Mode diff --git a/api/client/service/update.go b/api/client/service/update.go index 1fa514b2a3..8b51bd2ed2 100644 --- a/api/client/service/update.go +++ b/api/client/service/update.go @@ -53,9 +53,7 @@ func runUpdate(dockerCli *client.DockerCli, flags *pflag.FlagSet, serviceID stri if err != nil { return err } - headers = map[string][]string{ - "x-registry-auth": {encodedAuth}, - } + headers["X-Registry-Auth"] = []string{encodedAuth} } service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID) diff --git a/api/client/stack/deploy.go b/api/client/stack/deploy.go index 4bd8eb8eb9..4dcd19dc4d 100644 --- a/api/client/stack/deploy.go +++ b/api/client/stack/deploy.go @@ -184,18 +184,21 @@ func deployServices( if service, exists := existingServiceMap[name]; exists { fmt.Fprintf(out, "Updating service %s (id: %s)\n", name, service.ID) + // TODO(nishanttotla): Pass headers with X-Registry-Auth if err := apiClient.ServiceUpdate( ctx, service.ID, service.Version, serviceSpec, + nil, ); err != nil { return err } } else { fmt.Fprintf(out, "Creating service %s\n", name) - if _, err := apiClient.ServiceCreate(ctx, serviceSpec); err != nil { + // TODO(nishanttotla): Pass headers with X-Registry-Auth + if _, err := apiClient.ServiceCreate(ctx, serviceSpec, nil); err != nil { return err } } diff --git a/api/server/router/swarm/cluster_routes.go b/api/server/router/swarm/cluster_routes.go index 7744de2d2b..a8be21cd87 100644 --- a/api/server/router/swarm/cluster_routes.go +++ b/api/server/router/swarm/cluster_routes.go @@ -107,10 +107,7 @@ func (sr *swarmRouter) createService(ctx context.Context, w http.ResponseWriter, return err } - encodedAuth := "" - if auth, ok := r.Header["x-registry-auth"]; ok { - encodedAuth = auth[0] - } + encodedAuth := r.Header.Get("X-Registry-Auth") id, err := sr.backend.CreateService(service, encodedAuth) if err != nil { @@ -135,10 +132,7 @@ func (sr *swarmRouter) updateService(ctx context.Context, w http.ResponseWriter, return fmt.Errorf("Invalid service version '%s': %s", rawVersion, err.Error()) } - encodedAuth := "" - if auth, ok := r.Header["x-registry-auth"]; ok { - encodedAuth = auth[0] - } + encodedAuth := r.Header.Get("X-Registry-Auth") if err := sr.backend.UpdateService(vars["id"], version, service, encodedAuth); err != nil { logrus.Errorf("Error updating service %s: %v", vars["id"], err) diff --git a/daemon/cluster/executor/container/adapter.go b/daemon/cluster/executor/container/adapter.go index 50718fd3d2..9a959ae4cc 100644 --- a/daemon/cluster/executor/container/adapter.go +++ b/daemon/cluster/executor/container/adapter.go @@ -44,7 +44,6 @@ func (c *containerAdapter) pullImage(ctx context.Context) error { var encodedAuthConfig string if spec.PullOptions != nil { encodedAuthConfig = spec.PullOptions.RegistryAuth - } authConfig := &types.AuthConfig{} diff --git a/hack/vendor.sh b/hack/vendor.sh index 73abb1a213..6d4d304f2e 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -60,7 +60,7 @@ clone git golang.org/x/net 2beffdc2e92c8a3027590f898fe88f69af48a3f8 https://gith clone git golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://github.com/golang/sys.git clone git github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3 clone git github.com/docker/go-connections fa2850ff103453a9ad190da0df0af134f0314b3d -clone git github.com/docker/engine-api c57d0447ea1ae71f6dad83c8d8a1215a89869a0c +clone git github.com/docker/engine-api 19b4fb48a86c3318e610e156ec06b684f79ac31d clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837 clone git github.com/imdario/mergo 0.2.1