Browse code

Add a specific config for the update command

This allows to define clearly what is mutable or not in a container
and remove the use of the internal HostConfig struct to be used.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Vincent Demeester authored on 2016/01/12 16:33:41
Showing 3 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 package container
2 2
 
3 3
 import (
4
+	"encoding/json"
4 5
 	"fmt"
5 6
 	"io"
6 7
 	"net/http"
... ...
@@ -332,11 +333,17 @@ func (s *containerRouter) postContainerUpdate(ctx context.Context, w http.Respon
332 332
 		return err
333 333
 	}
334 334
 
335
-	_, hostConfig, _, err := runconfig.DecodeContainerConfig(r.Body)
336
-	if err != nil {
335
+	var updateConfig container.UpdateConfig
336
+
337
+	decoder := json.NewDecoder(r.Body)
338
+	if err := decoder.Decode(&updateConfig); err != nil {
337 339
 		return err
338 340
 	}
339 341
 
342
+	hostConfig := &container.HostConfig{
343
+		Resources: updateConfig.Resources,
344
+	}
345
+
340 346
 	name := vars["name"]
341 347
 	warnings, err := s.backend.ContainerUpdate(name, hostConfig)
342 348
 	if err != nil {
... ...
@@ -95,6 +95,7 @@ This section lists each version from latest to oldest.  Each listing includes a
95 95
 
96 96
 [Docker Remote API v1.22](docker_remote_api_v1.22.md) documentation
97 97
 
98
+* `POST /container/(name)/update` updates the resources of a container.
98 99
 * `GET /containers/json` supports filter `isolation` on Windows.
99 100
 * `GET /containers/json` now returns the list of networks of containers.
100 101
 * `GET /info` Now returns `Architecture` and `OSType` fields, providing information
... ...
@@ -120,7 +121,7 @@ This section lists each version from latest to oldest.  Each listing includes a
120 120
 * `GET /volumes` lists volumes from all volume drivers.
121 121
 * `POST /volumes/create` to create a volume.
122 122
 * `GET /volumes/(name)` get low-level information about a volume.
123
-* `DELETE /volumes/(name)`remove a volume with the specified name.
123
+* `DELETE /volumes/(name)` remove a volume with the specified name.
124 124
 * `VolumeDriver` was moved from `config` to `HostConfig` to make the configuration portable.
125 125
 * `GET /images/(name)/json` now returns information about an image's `RepoTags` and `RepoDigests`.
126 126
 * The `config` option now accepts the field `StopSignal`, which specifies the signal to use to kill a container.
... ...
@@ -1023,7 +1023,7 @@ Update resource configs of one or more containers.
1023 1023
        Content-Type: application/json
1024 1024
 
1025 1025
        {
1026
-           "HostConfig": {
1026
+           "UpdateConfig": {
1027 1027
                "Resources": {
1028 1028
                    "BlkioWeight": 300,
1029 1029
                    "CpuShares": 512,