Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
| ... | ... |
@@ -275,6 +275,12 @@ type ServiceCreateResponse struct {
|
| 275 | 275 |
ID string |
| 276 | 276 |
} |
| 277 | 277 |
|
| 278 |
+// Values for RegistryAuthFrom in ServiceUpdateOptions |
|
| 279 |
+const ( |
|
| 280 |
+ RegistryAuthFromSpec = "spec" |
|
| 281 |
+ RegistryAuthFromPreviousSpec = "previous-spec" |
|
| 282 |
+) |
|
| 283 |
+ |
|
| 278 | 284 |
// ServiceUpdateOptions contains the options to be used for updating services. |
| 279 | 285 |
type ServiceUpdateOptions struct {
|
| 280 | 286 |
// EncodedRegistryAuth is the encoded registry authorization credentials to |
| ... | ... |
@@ -286,6 +292,11 @@ type ServiceUpdateOptions struct {
|
| 286 | 286 |
// TODO(stevvooe): Consider moving the version parameter of ServiceUpdate |
| 287 | 287 |
// into this field. While it does open API users up to racy writes, most |
| 288 | 288 |
// users may not need that level of consistency in practice. |
| 289 |
+ |
|
| 290 |
+ // RegistryAuthFrom specifies where to find the registry authorization |
|
| 291 |
+ // credentials if they are not given in EncodedRegistryAuth. Valid |
|
| 292 |
+ // values are "spec" and "previous-spec". |
|
| 293 |
+ RegistryAuthFrom string |
|
| 289 | 294 |
} |
| 290 | 295 |
|
| 291 | 296 |
// ServiceListOptions holds parameters to list services with. |
| ... | ... |
@@ -7,6 +7,7 @@ type Service struct {
|
| 7 | 7 |
ID string |
| 8 | 8 |
Meta |
| 9 | 9 |
Spec ServiceSpec `json:",omitempty"` |
| 10 |
+ PreviousSpec *ServiceSpec `json:",omitempty"` |
|
| 10 | 11 |
Endpoint Endpoint `json:",omitempty"` |
| 11 | 12 |
UpdateStatus UpdateStatus `json:",omitempty"` |
| 12 | 13 |
} |
| ... | ... |
@@ -71,7 +72,34 @@ const ( |
| 71 | 71 |
|
| 72 | 72 |
// UpdateConfig represents the update configuration. |
| 73 | 73 |
type UpdateConfig struct {
|
| 74 |
- Parallelism uint64 `json:",omitempty"` |
|
| 75 |
- Delay time.Duration `json:",omitempty"` |
|
| 76 |
- FailureAction string `json:",omitempty"` |
|
| 74 |
+ // Maximum number of tasks to be updated in one iteration. |
|
| 75 |
+ // 0 means unlimited parallelism. |
|
| 76 |
+ Parallelism uint64 `json:",omitempty"` |
|
| 77 |
+ |
|
| 78 |
+ // Amount of time between updates. |
|
| 79 |
+ Delay time.Duration `json:",omitempty"` |
|
| 80 |
+ |
|
| 81 |
+ // FailureAction is the action to take when an update failures. |
|
| 82 |
+ FailureAction string `json:",omitempty"` |
|
| 83 |
+ |
|
| 84 |
+ // Monitor indicates how long to monitor a task for failure after it is |
|
| 85 |
+ // created. If the task fails by ending up in one of the states |
|
| 86 |
+ // REJECTED, COMPLETED, or FAILED, within Monitor from its creation, |
|
| 87 |
+ // this counts as a failure. If it fails after Monitor, it does not |
|
| 88 |
+ // count as a failure. If Monitor is unspecified, a default value will |
|
| 89 |
+ // be used. |
|
| 90 |
+ Monitor time.Duration `json:",omitempty"` |
|
| 91 |
+ |
|
| 92 |
+ // AllowedFailureFraction is the fraction of tasks that may fail during |
|
| 93 |
+ // an update before the failure action is invoked. Any task created by |
|
| 94 |
+ // the current update which ends up in one of the states REJECTED, |
|
| 95 |
+ // COMPLETED or FAILED within Monitor from its creation counts as a |
|
| 96 |
+ // failure. The number of failures is divided by the number of tasks |
|
| 97 |
+ // being updated, and if this fraction is greater than |
|
| 98 |
+ // AllowedFailureFraction, the failure action is invoked. |
|
| 99 |
+ // |
|
| 100 |
+ // If the failure action is CONTINUE, there is no effect. |
|
| 101 |
+ // If the failure action is PAUSE, no more tasks will be updated until |
|
| 102 |
+ // another update is started. |
|
| 103 |
+ AllowedFailureFraction float32 |
|
| 77 | 104 |
} |
| ... | ... |
@@ -22,6 +22,10 @@ func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version |
| 22 | 22 |
} |
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 |
+ if options.RegistryAuthFrom != "" {
|
|
| 26 |
+ query.Set("registryAuthFrom", options.RegistryAuthFrom)
|
|
| 27 |
+ } |
|
| 28 |
+ |
|
| 25 | 29 |
query.Set("version", strconv.FormatUint(version.Index, 10))
|
| 26 | 30 |
|
| 27 | 31 |
resp, err := cli.post(ctx, "/services/"+serviceID+"/update", query, service, headers) |