Browse Source

Added 'author' field to the image format

Solomon Hykes 12 years ago
parent
commit
4ef2d5c1e6
6 changed files with 14 additions and 12 deletions
  1. 2 2
      commands.go
  2. 1 1
      container_test.go
  3. 2 1
      graph.go
  4. 6 6
      graph_test.go
  5. 1 0
      image.go
  6. 2 2
      runtime.go

+ 2 - 2
commands.go

@@ -472,7 +472,7 @@ func (srv *Server) CmdImport(stdin io.ReadCloser, stdout rcli.DockerConn, args .
 		}
 		archive = ProgressReader(resp.Body, int(resp.ContentLength), stdout)
 	}
-	img, err := srv.runtime.graph.Create(archive, nil, "Imported from "+src)
+	img, err := srv.runtime.graph.Create(archive, nil, "Imported from "+src, "")
 	if err != nil {
 		return err
 	}
@@ -727,7 +727,7 @@ func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri
 		cmd.Usage()
 		return nil
 	}
-	img, err := srv.runtime.Commit(containerName, repository, tag, *flComment)
+	img, err := srv.runtime.Commit(containerName, repository, tag, *flComment, "")
 	if err != nil {
 		return err
 	}

+ 1 - 1
container_test.go

@@ -182,7 +182,7 @@ func TestCommitRun(t *testing.T) {
 	if err != nil {
 		t.Error(err)
 	}
-	img, err := runtime.graph.Create(rwTar, container1, "unit test commited image")
+	img, err := runtime.graph.Create(rwTar, container1, "unit test commited image", "")
 	if err != nil {
 		t.Error(err)
 	}

+ 2 - 1
graph.go

@@ -83,12 +83,13 @@ func (graph *Graph) Get(name string) (*Image, error) {
 }
 
 // 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, author string) (*Image, error) {
 	img := &Image{
 		Id:            GenerateId(),
 		Comment:       comment,
 		Created:       time.Now(),
 		DockerVersion: VERSION,
+		Author:        author,
 	}
 	if container != nil {
 		img.Parent = container.Image

+ 6 - 6
graph_test.go

@@ -62,7 +62,7 @@ func TestGraphCreate(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	image, err := graph.Create(archive, nil, "Testing")
+	image, err := graph.Create(archive, nil, "Testing", "")
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -122,7 +122,7 @@ func TestMount(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	image, err := graph.Create(archive, nil, "Testing")
+	image, err := graph.Create(archive, nil, "Testing", "")
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -166,7 +166,7 @@ func createTestImage(graph *Graph, t *testing.T) *Image {
 	if err != nil {
 		t.Fatal(err)
 	}
-	img, err := graph.Create(archive, nil, "Test image")
+	img, err := graph.Create(archive, nil, "Test image", "")
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -181,7 +181,7 @@ func TestDelete(t *testing.T) {
 		t.Fatal(err)
 	}
 	assertNImages(graph, t, 0)
-	img, err := graph.Create(archive, nil, "Bla bla")
+	img, err := graph.Create(archive, nil, "Bla bla", "")
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -192,11 +192,11 @@ func TestDelete(t *testing.T) {
 	assertNImages(graph, t, 0)
 
 	// Test 2 create (same name) / 1 delete
-	img1, err := graph.Create(archive, nil, "Testing")
+	img1, err := graph.Create(archive, nil, "Testing", "")
 	if err != nil {
 		t.Fatal(err)
 	}
-	if _, err = graph.Create(archive, nil, "Testing"); err != nil {
+	if _, err = graph.Create(archive, nil, "Testing", ""); err != nil {
 		t.Fatal(err)
 	}
 	assertNImages(graph, t, 2)

+ 1 - 0
image.go

@@ -23,6 +23,7 @@ type Image struct {
 	Container       string    `json:"container,omitempty"`
 	ContainerConfig Config    `json:"container_config,omitempty"`
 	DockerVersion   string    `json:"docker_version,omitempty"`
+	Author          string    `json:"author,omitempty"`
 	graph           *Graph
 }
 

+ 2 - 2
runtime.go

@@ -238,7 +238,7 @@ func (runtime *Runtime) Destroy(container *Container) error {
 
 // Commit creates a new filesystem image from the current state of a container.
 // The image can optionally be tagged into a repository
-func (runtime *Runtime) Commit(id, repository, tag, comment string) (*Image, error) {
+func (runtime *Runtime) Commit(id, repository, tag, comment, author string) (*Image, error) {
 	container := runtime.Get(id)
 	if container == nil {
 		return nil, fmt.Errorf("No such container: %s", id)
@@ -250,7 +250,7 @@ func (runtime *Runtime) Commit(id, repository, tag, comment string) (*Image, err
 		return nil, err
 	}
 	// Create a new image from the container's base layers + a new layer from container changes
-	img, err := runtime.graph.Create(rwTar, container, comment)
+	img, err := runtime.graph.Create(rwTar, container, comment, author)
 	if err != nil {
 		return nil, err
 	}