Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit 140ec59db6e413de5025fb8686b97bf80b66c519)
Signed-off-by: Tibor Vass <tibor@docker.com>
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
|
| 6 | 6 |
"github.com/docker/docker/api/client" |
| 7 | 7 |
"github.com/docker/docker/cli" |
| 8 |
+ "github.com/docker/engine-api/types" |
|
| 8 | 9 |
"github.com/spf13/cobra" |
| 9 | 10 |
"golang.org/x/net/context" |
| 10 | 11 |
) |
| ... | ... |
@@ -33,7 +34,7 @@ func newCreateCommand(dockerCli *client.DockerCli) *cobra.Command {
|
| 33 | 33 |
|
| 34 | 34 |
func runCreate(dockerCli *client.DockerCli, opts *serviceOptions) error {
|
| 35 | 35 |
apiClient := dockerCli.Client() |
| 36 |
- headers := map[string][]string{}
|
|
| 36 |
+ createOpts := types.ServiceCreateOptions{}
|
|
| 37 | 37 |
|
| 38 | 38 |
service, err := opts.ToService() |
| 39 | 39 |
if err != nil {
|
| ... | ... |
@@ -49,10 +50,10 @@ func runCreate(dockerCli *client.DockerCli, opts *serviceOptions) error {
|
| 49 | 49 |
if err != nil {
|
| 50 | 50 |
return err |
| 51 | 51 |
} |
| 52 |
- headers["X-Registry-Auth"] = []string{encodedAuth}
|
|
| 52 |
+ createOpts.EncodedRegistryAuth = encodedAuth |
|
| 53 | 53 |
} |
| 54 | 54 |
|
| 55 |
- response, err := apiClient.ServiceCreate(ctx, service, headers) |
|
| 55 |
+ response, err := apiClient.ServiceCreate(ctx, service, createOpts) |
|
| 56 | 56 |
if err != nil {
|
| 57 | 57 |
return err |
| 58 | 58 |
} |
| ... | ... |
@@ -169,7 +169,7 @@ func printContainerSpec(out io.Writer, containerSpec swarm.ContainerSpec) {
|
| 169 | 169 |
for _, v := range containerSpec.Mounts {
|
| 170 | 170 |
fmt.Fprintf(out, " Target = %s\n", v.Target) |
| 171 | 171 |
fmt.Fprintf(out, " Source = %s\n", v.Source) |
| 172 |
- fmt.Fprintf(out, " Writable = %v\n", v.Writable) |
|
| 172 |
+ fmt.Fprintf(out, " ReadOnly = %v\n", v.ReadOnly) |
|
| 173 | 173 |
fmt.Fprintf(out, " Type = %v\n", v.Type) |
| 174 | 174 |
} |
| 175 | 175 |
} |
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
"github.com/docker/docker/api/client" |
| 11 | 11 |
"github.com/docker/docker/cli" |
| 12 |
+ "github.com/docker/engine-api/types" |
|
| 12 | 13 |
"github.com/spf13/cobra" |
| 13 | 14 |
) |
| 14 | 15 |
|
| ... | ... |
@@ -77,7 +78,7 @@ func runServiceScale(dockerCli *client.DockerCli, serviceID string, scale string |
| 77 | 77 |
} |
| 78 | 78 |
serviceMode.Replicated.Replicas = &uintScale |
| 79 | 79 |
|
| 80 |
- err = client.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, nil) |
|
| 80 |
+ err = client.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, types.ServiceUpdateOptions{})
|
|
| 81 | 81 |
if err != nil {
|
| 82 | 82 |
return err |
| 83 | 83 |
} |
| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
"github.com/docker/docker/cli" |
| 11 | 11 |
"github.com/docker/docker/opts" |
| 12 | 12 |
runconfigopts "github.com/docker/docker/runconfig/opts" |
| 13 |
+ "github.com/docker/engine-api/types" |
|
| 13 | 14 |
"github.com/docker/engine-api/types/swarm" |
| 14 | 15 |
"github.com/docker/go-connections/nat" |
| 15 | 16 |
"github.com/spf13/cobra" |
| ... | ... |
@@ -39,7 +40,7 @@ func newUpdateCommand(dockerCli *client.DockerCli) *cobra.Command {
|
| 39 | 39 |
func runUpdate(dockerCli *client.DockerCli, flags *pflag.FlagSet, serviceID string) error {
|
| 40 | 40 |
apiClient := dockerCli.Client() |
| 41 | 41 |
ctx := context.Background() |
| 42 |
- headers := map[string][]string{}
|
|
| 42 |
+ updateOpts := types.ServiceUpdateOptions{}
|
|
| 43 | 43 |
|
| 44 | 44 |
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID) |
| 45 | 45 |
if err != nil {
|
| ... | ... |
@@ -64,10 +65,10 @@ func runUpdate(dockerCli *client.DockerCli, flags *pflag.FlagSet, serviceID stri |
| 64 | 64 |
if err != nil {
|
| 65 | 65 |
return err |
| 66 | 66 |
} |
| 67 |
- headers["X-Registry-Auth"] = []string{encodedAuth}
|
|
| 67 |
+ updateOpts.EncodedRegistryAuth = encodedAuth |
|
| 68 | 68 |
} |
| 69 | 69 |
|
| 70 |
- err = apiClient.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, headers) |
|
| 70 |
+ err = apiClient.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, updateOpts) |
|
| 71 | 71 |
if err != nil {
|
| 72 | 72 |
return err |
| 73 | 73 |
} |
| ... | ... |
@@ -184,13 +184,13 @@ func deployServices( |
| 184 | 184 |
if service, exists := existingServiceMap[name]; exists {
|
| 185 | 185 |
fmt.Fprintf(out, "Updating service %s (id: %s)\n", name, service.ID) |
| 186 | 186 |
|
| 187 |
- // TODO(nishanttotla): Pass headers with X-Registry-Auth |
|
| 187 |
+ // TODO(nishanttotla): Pass auth token |
|
| 188 | 188 |
if err := apiClient.ServiceUpdate( |
| 189 | 189 |
ctx, |
| 190 | 190 |
service.ID, |
| 191 | 191 |
service.Version, |
| 192 | 192 |
serviceSpec, |
| 193 |
- nil, |
|
| 193 |
+ types.ServiceUpdateOptions{},
|
|
| 194 | 194 |
); err != nil {
|
| 195 | 195 |
return err |
| 196 | 196 |
} |
| ... | ... |
@@ -198,7 +198,7 @@ func deployServices( |
| 198 | 198 |
fmt.Fprintf(out, "Creating service %s\n", name) |
| 199 | 199 |
|
| 200 | 200 |
// TODO(nishanttotla): Pass headers with X-Registry-Auth |
| 201 |
- if _, err := apiClient.ServiceCreate(ctx, serviceSpec, nil); err != nil {
|
|
| 201 |
+ if _, err := apiClient.ServiceCreate(ctx, serviceSpec, types.ServiceCreateOptions{}); err != nil {
|
|
| 202 | 202 |
return err |
| 203 | 203 |
} |
| 204 | 204 |
} |
| ... | ... |
@@ -60,7 +60,7 @@ clone git golang.org/x/net 2beffdc2e92c8a3027590f898fe88f69af48a3f8 https://gith |
| 60 | 60 |
clone git golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://github.com/golang/sys.git |
| 61 | 61 |
clone git github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3 |
| 62 | 62 |
clone git github.com/docker/go-connections fa2850ff103453a9ad190da0df0af134f0314b3d |
| 63 |
-clone git github.com/docker/engine-api 62043eb79d581a32ea849645277023c550732e52 |
|
| 63 |
+clone git github.com/docker/engine-api 139c221fcbe6e67dfac3c8807870e7136884a45b |
|
| 64 | 64 |
clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837 |
| 65 | 65 |
clone git github.com/imdario/mergo 0.2.1 |
| 66 | 66 |
|
| ... | ... |
@@ -100,11 +100,11 @@ type NodeAPIClient interface {
|
| 100 | 100 |
|
| 101 | 101 |
// ServiceAPIClient defines API client methods for the services |
| 102 | 102 |
type ServiceAPIClient interface {
|
| 103 |
- ServiceCreate(ctx context.Context, service swarm.ServiceSpec, headers map[string][]string) (types.ServiceCreateResponse, error) |
|
| 103 |
+ ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error) |
|
| 104 | 104 |
ServiceInspectWithRaw(ctx context.Context, serviceID string) (swarm.Service, []byte, error) |
| 105 | 105 |
ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) |
| 106 | 106 |
ServiceRemove(ctx context.Context, serviceID string) error |
| 107 |
- ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, headers map[string][]string) error |
|
| 107 |
+ ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) error |
|
| 108 | 108 |
TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) |
| 109 | 109 |
TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) |
| 110 | 110 |
} |
| ... | ... |
@@ -9,7 +9,15 @@ import ( |
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 | 11 |
// ServiceCreate creates a new Service. |
| 12 |
-func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, headers map[string][]string) (types.ServiceCreateResponse, error) {
|
|
| 12 |
+func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error) {
|
|
| 13 |
+ var headers map[string][]string |
|
| 14 |
+ |
|
| 15 |
+ if options.EncodedRegistryAuth != "" {
|
|
| 16 |
+ headers = map[string][]string{
|
|
| 17 |
+ "X-Registry-Auth": []string{options.EncodedRegistryAuth},
|
|
| 18 |
+ } |
|
| 19 |
+ } |
|
| 20 |
+ |
|
| 13 | 21 |
var response types.ServiceCreateResponse |
| 14 | 22 |
resp, err := cli.post(ctx, "/services/create", nil, service, headers) |
| 15 | 23 |
if err != nil {
|
| ... | ... |
@@ -4,14 +4,26 @@ import ( |
| 4 | 4 |
"net/url" |
| 5 | 5 |
"strconv" |
| 6 | 6 |
|
| 7 |
+ "github.com/docker/engine-api/types" |
|
| 7 | 8 |
"github.com/docker/engine-api/types/swarm" |
| 8 | 9 |
"golang.org/x/net/context" |
| 9 | 10 |
) |
| 10 | 11 |
|
| 11 | 12 |
// ServiceUpdate updates a Service. |
| 12 |
-func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, headers map[string][]string) error {
|
|
| 13 |
- query := url.Values{}
|
|
| 13 |
+func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) error {
|
|
| 14 |
+ var ( |
|
| 15 |
+ headers map[string][]string |
|
| 16 |
+ query = url.Values{}
|
|
| 17 |
+ ) |
|
| 18 |
+ |
|
| 19 |
+ if options.EncodedRegistryAuth != "" {
|
|
| 20 |
+ headers = map[string][]string{
|
|
| 21 |
+ "X-Registry-Auth": []string{options.EncodedRegistryAuth},
|
|
| 22 |
+ } |
|
| 23 |
+ } |
|
| 24 |
+ |
|
| 14 | 25 |
query.Set("version", strconv.FormatUint(version.Index, 10))
|
| 26 |
+ |
|
| 15 | 27 |
resp, err := cli.post(ctx, "/services/"+serviceID+"/update", query, service, headers) |
| 16 | 28 |
ensureReaderClosed(resp) |
| 17 | 29 |
return err |
| ... | ... |
@@ -246,6 +246,15 @@ type NodeListOptions struct {
|
| 246 | 246 |
Filter filters.Args |
| 247 | 247 |
} |
| 248 | 248 |
|
| 249 |
+// ServiceCreateOptions contains the options to use when creating a service. |
|
| 250 |
+type ServiceCreateOptions struct {
|
|
| 251 |
+ // EncodedRegistryAuth is the encoded registry authorization credentials to |
|
| 252 |
+ // use when updating the service. |
|
| 253 |
+ // |
|
| 254 |
+ // This field follows the format of the X-Registry-Auth header. |
|
| 255 |
+ EncodedRegistryAuth string |
|
| 256 |
+} |
|
| 257 |
+ |
|
| 249 | 258 |
// ServiceCreateResponse contains the information returned to a client |
| 250 | 259 |
// on the creation of a new service. |
| 251 | 260 |
type ServiceCreateResponse struct {
|
| ... | ... |
@@ -253,6 +262,19 @@ type ServiceCreateResponse struct {
|
| 253 | 253 |
ID string |
| 254 | 254 |
} |
| 255 | 255 |
|
| 256 |
+// ServiceUpdateOptions contains the options to be used for updating services. |
|
| 257 |
+type ServiceUpdateOptions struct {
|
|
| 258 |
+ // EncodedRegistryAuth is the encoded registry authorization credentials to |
|
| 259 |
+ // use when updating the service. |
|
| 260 |
+ // |
|
| 261 |
+ // This field follows the format of the X-Registry-Auth header. |
|
| 262 |
+ EncodedRegistryAuth string |
|
| 263 |
+ |
|
| 264 |
+ // TODO(stevvooe): Consider moving the version parameter of ServiceUpdate |
|
| 265 |
+ // into this field. While it does open API users up to racy writes, most |
|
| 266 |
+ // users may not need that level of consistency in practice. |
|
| 267 |
+} |
|
| 268 |
+ |
|
| 256 | 269 |
// ServiceListOptions holds parameters to list services with. |
| 257 | 270 |
type ServiceListOptions struct {
|
| 258 | 271 |
Filter filters.Args |
| ... | ... |
@@ -30,7 +30,7 @@ type Mount struct {
|
| 30 | 30 |
Type MountType `json:",omitempty"` |
| 31 | 31 |
Source string `json:",omitempty"` |
| 32 | 32 |
Target string `json:",omitempty"` |
| 33 |
- Writable bool `json:",omitempty"` |
|
| 33 |
+ ReadOnly bool `json:",omitempty"` |
|
| 34 | 34 |
|
| 35 | 35 |
BindOptions *BindOptions `json:",omitempty"` |
| 36 | 36 |
VolumeOptions *VolumeOptions `json:",omitempty"` |
| ... | ... |
@@ -61,7 +61,7 @@ type BindOptions struct {
|
| 61 | 61 |
|
| 62 | 62 |
// VolumeOptions represents the options for a mount of type volume. |
| 63 | 63 |
type VolumeOptions struct {
|
| 64 |
- Populate bool `json:",omitempty"` |
|
| 64 |
+ NoCopy bool `json:",omitempty"` |
|
| 65 | 65 |
Labels map[string]string `json:",omitempty"` |
| 66 | 66 |
DriverConfig *Driver `json:",omitempty"` |
| 67 | 67 |
} |