| ... | ... |
@@ -384,7 +384,7 @@ func (srv *Server) CmdImport(stdin io.ReadCloser, stdout io.Writer, args ...stri |
| 384 | 384 |
} |
| 385 | 385 |
archive = ProgressReader(resp.Body, int(resp.ContentLength), stdout) |
| 386 | 386 |
} |
| 387 |
- img, err := srv.runtime.graph.Create(archive, "", "Imported from "+src) |
|
| 387 |
+ img, err := srv.runtime.graph.Create(archive, nil, "Imported from "+src) |
|
| 388 | 388 |
if err != nil {
|
| 389 | 389 |
return err |
| 390 | 390 |
} |
| ... | ... |
@@ -46,7 +46,7 @@ func TestCommitRun(t *testing.T) {
|
| 46 | 46 |
if err != nil {
|
| 47 | 47 |
t.Error(err) |
| 48 | 48 |
} |
| 49 |
- img, err := runtime.graph.Create(rwTar, container1.Image, "unit test commited image") |
|
| 49 |
+ img, err := runtime.graph.Create(rwTar, container1, "unit test commited image") |
|
| 50 | 50 |
if err != nil {
|
| 51 | 51 |
t.Error(err) |
| 52 | 52 |
} |
| ... | ... |
@@ -47,13 +47,17 @@ func (graph *Graph) Get(id string) (*Image, error) {
|
| 47 | 47 |
return img, nil |
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 |
-func (graph *Graph) Create(layerData Archive, parent, comment string) (*Image, error) {
|
|
| 50 |
+func (graph *Graph) Create(layerData Archive, container *Container, comment string) (*Image, error) {
|
|
| 51 | 51 |
img := &Image{
|
| 52 | 52 |
Id: GenerateId(), |
| 53 |
- Parent: parent, |
|
| 54 | 53 |
Comment: comment, |
| 55 | 54 |
Created: time.Now(), |
| 56 | 55 |
} |
| 56 |
+ if container != nil {
|
|
| 57 |
+ img.Parent = container.Image |
|
| 58 |
+ img.ParentContainer = container.Id |
|
| 59 |
+ img.ParentCommand = append([]string{container.Path}, container.Args...)
|
|
| 60 |
+ } |
|
| 57 | 61 |
if err := graph.Register(layerData, img); err != nil {
|
| 58 | 62 |
return nil, err |
| 59 | 63 |
} |
| ... | ... |
@@ -35,7 +35,7 @@ func TestGraphCreate(t *testing.T) {
|
| 35 | 35 |
if err != nil {
|
| 36 | 36 |
t.Fatal(err) |
| 37 | 37 |
} |
| 38 |
- image, err := graph.Create(archive, "", "Testing") |
|
| 38 |
+ image, err := graph.Create(archive, nil, "Testing") |
|
| 39 | 39 |
if err != nil {
|
| 40 | 40 |
t.Fatal(err) |
| 41 | 41 |
} |
| ... | ... |
@@ -92,7 +92,7 @@ func TestMount(t *testing.T) {
|
| 92 | 92 |
if err != nil {
|
| 93 | 93 |
t.Fatal(err) |
| 94 | 94 |
} |
| 95 |
- image, err := graph.Create(archive, "", "Testing") |
|
| 95 |
+ image, err := graph.Create(archive, nil, "Testing") |
|
| 96 | 96 |
if err != nil {
|
| 97 | 97 |
t.Fatal(err) |
| 98 | 98 |
} |
| ... | ... |
@@ -128,7 +128,7 @@ func TestDelete(t *testing.T) {
|
| 128 | 128 |
t.Fatal(err) |
| 129 | 129 |
} |
| 130 | 130 |
assertNImages(graph, t, 0) |
| 131 |
- img, err := graph.Create(archive, "", "Bla bla") |
|
| 131 |
+ img, err := graph.Create(archive, nil, "Bla bla") |
|
| 132 | 132 |
if err != nil {
|
| 133 | 133 |
t.Fatal(err) |
| 134 | 134 |
} |
| ... | ... |
@@ -139,11 +139,11 @@ func TestDelete(t *testing.T) {
|
| 139 | 139 |
assertNImages(graph, t, 0) |
| 140 | 140 |
|
| 141 | 141 |
// Test 2 create (same name) / 1 delete |
| 142 |
- img1, err := graph.Create(archive, "foo", "Testing") |
|
| 142 |
+ img1, err := graph.Create(archive, nil, "Testing") |
|
| 143 | 143 |
if err != nil {
|
| 144 | 144 |
t.Fatal(err) |
| 145 | 145 |
} |
| 146 |
- if _, err = graph.Create(archive, "foo", "Testing"); err != nil {
|
|
| 146 |
+ if _, err = graph.Create(archive, nil, "Testing"); err != nil {
|
|
| 147 | 147 |
t.Fatal(err) |
| 148 | 148 |
} |
| 149 | 149 |
assertNImages(graph, t, 2) |
| ... | ... |
@@ -15,11 +15,13 @@ import ( |
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 | 17 |
type Image struct {
|
| 18 |
- Id string |
|
| 19 |
- Parent string |
|
| 20 |
- Comment string |
|
| 21 |
- Created time.Time |
|
| 22 |
- graph *Graph |
|
| 18 |
+ Id string |
|
| 19 |
+ Parent string |
|
| 20 |
+ Comment string |
|
| 21 |
+ Created time.Time |
|
| 22 |
+ ParentContainer string |
|
| 23 |
+ ParentCommand []string |
|
| 24 |
+ graph *Graph |
|
| 23 | 25 |
} |
| 24 | 26 |
|
| 25 | 27 |
func LoadImage(root string) (*Image, error) {
|
| ... | ... |
@@ -214,7 +214,7 @@ func (runtime *Runtime) Commit(id, repository, tag string) (*Image, error) {
|
| 214 | 214 |
return nil, err |
| 215 | 215 |
} |
| 216 | 216 |
// Create a new image from the container's base layers + a new layer from container changes |
| 217 |
- img, err := runtime.graph.Create(rwTar, container.Image, "") |
|
| 217 |
+ img, err := runtime.graph.Create(rwTar, container, "") |
|
| 218 | 218 |
if err != nil {
|
| 219 | 219 |
return nil, err |
| 220 | 220 |
} |