Browse code

Add versioning to docker image format. IMPORTANT: the format versioning is pegged to docker's versioning, so changes to the format MUST trigger an increment in version number.

Solomon Hykes authored on 2013/04/05 10:38:43
Showing 3 changed files
... ...
@@ -85,9 +85,10 @@ func (graph *Graph) Get(name string) (*Image, error) {
85 85
 // Create creates a new image and registers it in the graph.
86 86
 func (graph *Graph) Create(layerData Archive, container *Container, comment string) (*Image, error) {
87 87
 	img := &Image{
88
-		Id:      GenerateId(),
89
-		Comment: comment,
90
-		Created: time.Now(),
88
+		Id:            GenerateId(),
89
+		Comment:       comment,
90
+		Created:       time.Now(),
91
+		DockerVersion: VERSION,
91 92
 	}
92 93
 	if container != nil {
93 94
 		img.Parent = container.Image
... ...
@@ -45,6 +45,9 @@ func TestGraphCreate(t *testing.T) {
45 45
 	if image.Comment != "Testing" {
46 46
 		t.Fatalf("Wrong comment: should be '%s', not '%s'", "Testing", image.Comment)
47 47
 	}
48
+	if image.DockerVersion != VERSION {
49
+		t.Fatalf("Wrong docker_version: should be '%s', not '%s'", VERSION, image.DockerVersion)
50
+	}
48 51
 	if images, err := graph.All(); err != nil {
49 52
 		t.Fatal(err)
50 53
 	} else if l := len(images); l != 1 {
... ...
@@ -20,6 +20,7 @@ type Image struct {
20 20
 	Created         time.Time `json:"created"`
21 21
 	Container       string    `json:"container,omitempty"`
22 22
 	ContainerConfig Config    `json:"container_config,omitempty"`
23
+	DockerVersion   string    `json:"docker_version,omitempty"`
23 24
 	graph           *Graph
24 25
 }
25 26