From 140ec59db6e413de5025fb8686b97bf80b66c519 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Tue, 5 Jul 2016 11:20:49 -0400 Subject: [PATCH] re-vendor engine-api Signed-off-by: Brian Goff --- api/client/service/create.go | 7 +++--- api/client/service/inspect.go | 2 +- api/client/service/scale.go | 3 ++- api/client/service/update.go | 7 +++--- api/client/stack/deploy.go | 6 ++--- hack/vendor.sh | 2 +- .../docker/engine-api/client/interface.go | 4 ++-- .../engine-api/client/service_create.go | 10 ++++++++- .../engine-api/client/service_update.go | 16 ++++++++++++-- .../docker/engine-api/types/client.go | 22 +++++++++++++++++++ .../engine-api/types/swarm/container.go | 4 ++-- 11 files changed, 64 insertions(+), 19 deletions(-) diff --git a/api/client/service/create.go b/api/client/service/create.go index 10fcb20f9a..be707c5f5d 100644 --- a/api/client/service/create.go +++ b/api/client/service/create.go @@ -5,6 +5,7 @@ import ( "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/engine-api/types" "github.com/spf13/cobra" "golang.org/x/net/context" ) @@ -33,7 +34,7 @@ func newCreateCommand(dockerCli *client.DockerCli) *cobra.Command { func runCreate(dockerCli *client.DockerCli, opts *serviceOptions) error { apiClient := dockerCli.Client() - headers := map[string][]string{} + createOpts := types.ServiceCreateOptions{} service, err := opts.ToService() if err != nil { @@ -49,10 +50,10 @@ func runCreate(dockerCli *client.DockerCli, opts *serviceOptions) error { if err != nil { return err } - headers["X-Registry-Auth"] = []string{encodedAuth} + createOpts.EncodedRegistryAuth = encodedAuth } - response, err := apiClient.ServiceCreate(ctx, service, headers) + response, err := apiClient.ServiceCreate(ctx, service, createOpts) if err != nil { return err } diff --git a/api/client/service/inspect.go b/api/client/service/inspect.go index 8df91ceace..4b17ce837d 100644 --- a/api/client/service/inspect.go +++ b/api/client/service/inspect.go @@ -169,7 +169,7 @@ func printContainerSpec(out io.Writer, containerSpec swarm.ContainerSpec) { for _, v := range containerSpec.Mounts { fmt.Fprintf(out, " Target = %s\n", v.Target) fmt.Fprintf(out, " Source = %s\n", v.Source) - fmt.Fprintf(out, " Writable = %v\n", v.Writable) + fmt.Fprintf(out, " ReadOnly = %v\n", v.ReadOnly) fmt.Fprintf(out, " Type = %v\n", v.Type) } } diff --git a/api/client/service/scale.go b/api/client/service/scale.go index 2643fdcf27..1a3ea80eaf 100644 --- a/api/client/service/scale.go +++ b/api/client/service/scale.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/client" "github.com/docker/docker/cli" + "github.com/docker/engine-api/types" "github.com/spf13/cobra" ) @@ -77,7 +78,7 @@ func runServiceScale(dockerCli *client.DockerCli, serviceID string, scale string } serviceMode.Replicated.Replicas = &uintScale - err = client.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, nil) + err = client.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, types.ServiceUpdateOptions{}) if err != nil { return err } diff --git a/api/client/service/update.go b/api/client/service/update.go index cd6f1537db..78f98a3283 100644 --- a/api/client/service/update.go +++ b/api/client/service/update.go @@ -10,6 +10,7 @@ import ( "github.com/docker/docker/cli" "github.com/docker/docker/opts" runconfigopts "github.com/docker/docker/runconfig/opts" + "github.com/docker/engine-api/types" "github.com/docker/engine-api/types/swarm" "github.com/docker/go-connections/nat" "github.com/spf13/cobra" @@ -39,7 +40,7 @@ func newUpdateCommand(dockerCli *client.DockerCli) *cobra.Command { func runUpdate(dockerCli *client.DockerCli, flags *pflag.FlagSet, serviceID string) error { apiClient := dockerCli.Client() ctx := context.Background() - headers := map[string][]string{} + updateOpts := types.ServiceUpdateOptions{} service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID) if err != nil { @@ -64,10 +65,10 @@ func runUpdate(dockerCli *client.DockerCli, flags *pflag.FlagSet, serviceID stri if err != nil { return err } - headers["X-Registry-Auth"] = []string{encodedAuth} + updateOpts.EncodedRegistryAuth = encodedAuth } - err = apiClient.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, headers) + err = apiClient.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, updateOpts) if err != nil { return err } diff --git a/api/client/stack/deploy.go b/api/client/stack/deploy.go index 4dcd19dc4d..745b568427 100644 --- a/api/client/stack/deploy.go +++ b/api/client/stack/deploy.go @@ -184,13 +184,13 @@ 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 + // TODO(nishanttotla): Pass auth token if err := apiClient.ServiceUpdate( ctx, service.ID, service.Version, serviceSpec, - nil, + types.ServiceUpdateOptions{}, ); err != nil { return err } @@ -198,7 +198,7 @@ func deployServices( fmt.Fprintf(out, "Creating service %s\n", name) // TODO(nishanttotla): Pass headers with X-Registry-Auth - if _, err := apiClient.ServiceCreate(ctx, serviceSpec, nil); err != nil { + if _, err := apiClient.ServiceCreate(ctx, serviceSpec, types.ServiceCreateOptions{}); err != nil { return err } } diff --git a/hack/vendor.sh b/hack/vendor.sh index 09f6209222..ce27ffbd69 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 62043eb79d581a32ea849645277023c550732e52 +clone git github.com/docker/engine-api 139c221fcbe6e67dfac3c8807870e7136884a45b clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837 clone git github.com/imdario/mergo 0.2.1 diff --git a/vendor/src/github.com/docker/engine-api/client/interface.go b/vendor/src/github.com/docker/engine-api/client/interface.go index 4ad2a5c399..1cadaef56b 100644 --- a/vendor/src/github.com/docker/engine-api/client/interface.go +++ b/vendor/src/github.com/docker/engine-api/client/interface.go @@ -100,11 +100,11 @@ type NodeAPIClient interface { // ServiceAPIClient defines API client methods for the services type ServiceAPIClient interface { - ServiceCreate(ctx context.Context, service swarm.ServiceSpec, headers map[string][]string) (types.ServiceCreateResponse, error) + ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error) ServiceInspectWithRaw(ctx context.Context, serviceID string) (swarm.Service, []byte, error) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) ServiceRemove(ctx context.Context, serviceID string) error - ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, headers map[string][]string) error + ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) error TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) } diff --git a/vendor/src/github.com/docker/engine-api/client/service_create.go b/vendor/src/github.com/docker/engine-api/client/service_create.go index 4153e04d57..7349a984e7 100644 --- a/vendor/src/github.com/docker/engine-api/client/service_create.go +++ b/vendor/src/github.com/docker/engine-api/client/service_create.go @@ -9,7 +9,15 @@ import ( ) // ServiceCreate creates a new Service. -func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, headers map[string][]string) (types.ServiceCreateResponse, error) { +func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error) { + var headers map[string][]string + + if options.EncodedRegistryAuth != "" { + headers = map[string][]string{ + "X-Registry-Auth": []string{options.EncodedRegistryAuth}, + } + } + var response types.ServiceCreateResponse resp, err := cli.post(ctx, "/services/create", nil, service, headers) if err != nil { diff --git a/vendor/src/github.com/docker/engine-api/client/service_update.go b/vendor/src/github.com/docker/engine-api/client/service_update.go index 4281b1e2c1..ee8b46126b 100644 --- a/vendor/src/github.com/docker/engine-api/client/service_update.go +++ b/vendor/src/github.com/docker/engine-api/client/service_update.go @@ -4,14 +4,26 @@ import ( "net/url" "strconv" + "github.com/docker/engine-api/types" "github.com/docker/engine-api/types/swarm" "golang.org/x/net/context" ) // ServiceUpdate updates a Service. -func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, headers map[string][]string) error { - query := url.Values{} +func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) error { + var ( + headers map[string][]string + query = url.Values{} + ) + + if options.EncodedRegistryAuth != "" { + headers = map[string][]string{ + "X-Registry-Auth": []string{options.EncodedRegistryAuth}, + } + } + query.Set("version", strconv.FormatUint(version.Index, 10)) + resp, err := cli.post(ctx, "/services/"+serviceID+"/update", query, service, headers) ensureReaderClosed(resp) return err diff --git a/vendor/src/github.com/docker/engine-api/types/client.go b/vendor/src/github.com/docker/engine-api/types/client.go index b7993b74f0..def3f06197 100644 --- a/vendor/src/github.com/docker/engine-api/types/client.go +++ b/vendor/src/github.com/docker/engine-api/types/client.go @@ -246,6 +246,15 @@ type NodeListOptions struct { Filter filters.Args } +// ServiceCreateOptions contains the options to use when creating a service. +type ServiceCreateOptions struct { + // EncodedRegistryAuth is the encoded registry authorization credentials to + // use when updating the service. + // + // This field follows the format of the X-Registry-Auth header. + EncodedRegistryAuth string +} + // ServiceCreateResponse contains the information returned to a client // on the creation of a new service. type ServiceCreateResponse struct { @@ -253,6 +262,19 @@ type ServiceCreateResponse struct { ID string } +// ServiceUpdateOptions contains the options to be used for updating services. +type ServiceUpdateOptions struct { + // EncodedRegistryAuth is the encoded registry authorization credentials to + // use when updating the service. + // + // This field follows the format of the X-Registry-Auth header. + EncodedRegistryAuth string + + // TODO(stevvooe): Consider moving the version parameter of ServiceUpdate + // into this field. While it does open API users up to racy writes, most + // users may not need that level of consistency in practice. +} + // ServiceListOptions holds parameters to list services with. type ServiceListOptions struct { Filter filters.Args diff --git a/vendor/src/github.com/docker/engine-api/types/swarm/container.go b/vendor/src/github.com/docker/engine-api/types/swarm/container.go index 40718b247b..29f2e8a647 100644 --- a/vendor/src/github.com/docker/engine-api/types/swarm/container.go +++ b/vendor/src/github.com/docker/engine-api/types/swarm/container.go @@ -30,7 +30,7 @@ type Mount struct { Type MountType `json:",omitempty"` Source string `json:",omitempty"` Target string `json:",omitempty"` - Writable bool `json:",omitempty"` + ReadOnly bool `json:",omitempty"` BindOptions *BindOptions `json:",omitempty"` VolumeOptions *VolumeOptions `json:",omitempty"` @@ -61,7 +61,7 @@ type BindOptions struct { // VolumeOptions represents the options for a mount of type volume. type VolumeOptions struct { - Populate bool `json:",omitempty"` + NoCopy bool `json:",omitempty"` Labels map[string]string `json:",omitempty"` DriverConfig *Driver `json:",omitempty"` }