Signed-off-by: Doug Davis <dug@us.ibm.com>
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"testing" |
| 13 | 13 |
|
| 14 | 14 |
"github.com/docker/docker/api" |
| 15 |
+ "github.com/docker/docker/api/types" |
|
| 15 | 16 |
"github.com/docker/docker/engine" |
| 16 | 17 |
"github.com/docker/docker/pkg/version" |
| 17 | 18 |
) |
| ... | ... |
@@ -122,7 +123,7 @@ func TestGetImagesJSON(t *testing.T) {
|
| 122 | 122 |
eng.Register("images", func(job *engine.Job) error {
|
| 123 | 123 |
called = true |
| 124 | 124 |
v := createEnvFromGetImagesJSONStruct(sampleImage) |
| 125 |
- if _, err := v.WriteTo(job.Stdout); err != nil {
|
|
| 125 |
+ if err := json.NewEncoder(job.Stdout).Encode(v); err != nil {
|
|
| 126 | 126 |
return err |
| 127 | 127 |
} |
| 128 | 128 |
return nil |
| ... | ... |
@@ -186,9 +187,10 @@ func TestGetImagesJSONLegacyFormat(t *testing.T) {
|
| 186 | 186 |
var called bool |
| 187 | 187 |
eng.Register("images", func(job *engine.Job) error {
|
| 188 | 188 |
called = true |
| 189 |
- outsLegacy := engine.NewTable("Created", 0)
|
|
| 190 |
- outsLegacy.Add(createEnvFromGetImagesJSONStruct(sampleImage)) |
|
| 191 |
- if _, err := outsLegacy.WriteListTo(job.Stdout); err != nil {
|
|
| 189 |
+ images := []types.Image{
|
|
| 190 |
+ createEnvFromGetImagesJSONStruct(sampleImage), |
|
| 191 |
+ } |
|
| 192 |
+ if err := json.NewEncoder(job.Stdout).Encode(images); err != nil {
|
|
| 192 | 193 |
return err |
| 193 | 194 |
} |
| 194 | 195 |
return nil |
| ... | ... |
@@ -526,14 +528,14 @@ func assertHttpNotError(r *httptest.ResponseRecorder, t *testing.T) {
|
| 526 | 526 |
} |
| 527 | 527 |
} |
| 528 | 528 |
|
| 529 |
-func createEnvFromGetImagesJSONStruct(data getImagesJSONStruct) *engine.Env {
|
|
| 530 |
- v := &engine.Env{}
|
|
| 531 |
- v.SetList("RepoTags", data.RepoTags)
|
|
| 532 |
- v.Set("Id", data.Id)
|
|
| 533 |
- v.SetInt64("Created", data.Created)
|
|
| 534 |
- v.SetInt64("Size", data.Size)
|
|
| 535 |
- v.SetInt64("VirtualSize", data.VirtualSize)
|
|
| 536 |
- return v |
|
| 529 |
+func createEnvFromGetImagesJSONStruct(data getImagesJSONStruct) types.Image {
|
|
| 530 |
+ return types.Image{
|
|
| 531 |
+ RepoTags: data.RepoTags, |
|
| 532 |
+ ID: data.Id, |
|
| 533 |
+ Created: int(data.Created), |
|
| 534 |
+ Size: int(data.Size), |
|
| 535 |
+ VirtualSize: int(data.VirtualSize), |
|
| 536 |
+ } |
|
| 537 | 537 |
} |
| 538 | 538 |
|
| 539 | 539 |
type getImagesJSONStruct struct {
|
| ... | ... |
@@ -1,7 +1,6 @@ |
| 1 | 1 |
package daemon |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "github.com/docker/docker/engine" |
|
| 5 | 4 |
"github.com/docker/docker/nat" |
| 6 | 5 |
) |
| 7 | 6 |
|
| ... | ... |
@@ -22,27 +21,3 @@ type NetworkSettings struct {
|
| 22 | 22 |
PortMapping map[string]PortMapping // Deprecated |
| 23 | 23 |
Ports nat.PortMap |
| 24 | 24 |
} |
| 25 |
- |
|
| 26 |
-func (settings *NetworkSettings) PortMappingAPI() *engine.Table {
|
|
| 27 |
- var outs = engine.NewTable("", 0)
|
|
| 28 |
- for port, bindings := range settings.Ports {
|
|
| 29 |
- p, _ := nat.ParsePort(port.Port()) |
|
| 30 |
- if len(bindings) == 0 {
|
|
| 31 |
- out := &engine.Env{}
|
|
| 32 |
- out.SetInt("PrivatePort", p)
|
|
| 33 |
- out.Set("Type", port.Proto())
|
|
| 34 |
- outs.Add(out) |
|
| 35 |
- continue |
|
| 36 |
- } |
|
| 37 |
- for _, binding := range bindings {
|
|
| 38 |
- out := &engine.Env{}
|
|
| 39 |
- h, _ := nat.ParsePort(binding.HostPort) |
|
| 40 |
- out.SetInt("PrivatePort", p)
|
|
| 41 |
- out.SetInt("PublicPort", h)
|
|
| 42 |
- out.Set("Type", port.Proto())
|
|
| 43 |
- out.Set("IP", binding.HostIp)
|
|
| 44 |
- outs.Add(out) |
|
| 45 |
- } |
|
| 46 |
- } |
|
| 47 |
- return outs |
|
| 48 |
-} |
| ... | ... |
@@ -16,6 +16,7 @@ import ( |
| 16 | 16 |
|
| 17 | 17 |
"github.com/docker/docker/api" |
| 18 | 18 |
"github.com/docker/docker/api/server" |
| 19 |
+ "github.com/docker/docker/api/types" |
|
| 19 | 20 |
"github.com/docker/docker/builder" |
| 20 | 21 |
"github.com/docker/docker/engine" |
| 21 | 22 |
"github.com/docker/docker/runconfig" |
| ... | ... |
@@ -793,12 +794,14 @@ func TestDeleteImages(t *testing.T) {
|
| 793 | 793 |
t.Fatalf("%d OK expected, received %d\n", http.StatusOK, r.Code)
|
| 794 | 794 |
} |
| 795 | 795 |
|
| 796 |
- outs := engine.NewTable("Created", 0)
|
|
| 797 |
- if _, err := outs.ReadListFrom(r2.Body.Bytes()); err != nil {
|
|
| 796 |
+ delImages := []types.ImageDelete{}
|
|
| 797 |
+ err = json.Unmarshal(r2.Body.Bytes(), &delImages) |
|
| 798 |
+ if err != nil {
|
|
| 798 | 799 |
t.Fatal(err) |
| 799 | 800 |
} |
| 800 |
- if len(outs.Data) != 1 {
|
|
| 801 |
- t.Fatalf("Expected %d event (untagged), got %d", 1, len(outs.Data))
|
|
| 801 |
+ |
|
| 802 |
+ if len(delImages) != 1 {
|
|
| 803 |
+ t.Fatalf("Expected %d event (untagged), got %d", 1, len(delImages))
|
|
| 802 | 804 |
} |
| 803 | 805 |
images = getImages(eng, t, false, "") |
| 804 | 806 |
|
| ... | ... |
@@ -329,10 +329,6 @@ func fakeTar() (io.ReadCloser, error) {
|
| 329 | 329 |
return ioutil.NopCloser(buf), nil |
| 330 | 330 |
} |
| 331 | 331 |
|
| 332 |
-func getAllImages(eng *engine.Engine, t *testing.T) *engine.Table {
|
|
| 333 |
- return getImages(eng, t, true, "") |
|
| 334 |
-} |
|
| 335 |
- |
|
| 336 | 332 |
func getImages(eng *engine.Engine, t *testing.T, all bool, filter string) *engine.Table {
|
| 337 | 333 |
job := eng.Job("images")
|
| 338 | 334 |
job.SetenvBool("all", all)
|