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.
This commit is contained in:
parent
3de51b7bfe
commit
8bfbdd7afa
7
graph.go
7
graph.go
|
@ -85,9 +85,10 @@ func (graph *Graph) Get(name string) (*Image, error) {
|
||||||
// Create creates a new image and registers it in the graph.
|
// Create creates a new image and registers it in the graph.
|
||||||
func (graph *Graph) Create(layerData Archive, container *Container, comment string) (*Image, error) {
|
func (graph *Graph) Create(layerData Archive, container *Container, comment string) (*Image, error) {
|
||||||
img := &Image{
|
img := &Image{
|
||||||
Id: GenerateId(),
|
Id: GenerateId(),
|
||||||
Comment: comment,
|
Comment: comment,
|
||||||
Created: time.Now(),
|
Created: time.Now(),
|
||||||
|
DockerVersion: VERSION,
|
||||||
}
|
}
|
||||||
if container != nil {
|
if container != nil {
|
||||||
img.Parent = container.Image
|
img.Parent = container.Image
|
||||||
|
|
|
@ -45,6 +45,9 @@ func TestGraphCreate(t *testing.T) {
|
||||||
if image.Comment != "Testing" {
|
if image.Comment != "Testing" {
|
||||||
t.Fatalf("Wrong comment: should be '%s', not '%s'", "Testing", image.Comment)
|
t.Fatalf("Wrong comment: should be '%s', not '%s'", "Testing", image.Comment)
|
||||||
}
|
}
|
||||||
|
if image.DockerVersion != VERSION {
|
||||||
|
t.Fatalf("Wrong docker_version: should be '%s', not '%s'", VERSION, image.DockerVersion)
|
||||||
|
}
|
||||||
if images, err := graph.All(); err != nil {
|
if images, err := graph.All(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else if l := len(images); l != 1 {
|
} else if l := len(images); l != 1 {
|
||||||
|
|
1
image.go
1
image.go
|
@ -20,6 +20,7 @@ type Image struct {
|
||||||
Created time.Time `json:"created"`
|
Created time.Time `json:"created"`
|
||||||
Container string `json:"container,omitempty"`
|
Container string `json:"container,omitempty"`
|
||||||
ContainerConfig Config `json:"container_config,omitempty"`
|
ContainerConfig Config `json:"container_config,omitempty"`
|
||||||
|
DockerVersion string `json:"docker_version,omitempty"`
|
||||||
graph *Graph
|
graph *Graph
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue