1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Added 'author' field to the image format

This commit is contained in:
Solomon Hykes 2013-04-17 19:58:17 -07:00
parent e34e44e8e6
commit 4ef2d5c1e6
6 changed files with 14 additions and 12 deletions

View file

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

View file

@ -182,7 +182,7 @@ func TestCommitRun(t *testing.T) {
if err != nil { if err != nil {
t.Error(err) 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 { if err != nil {
t.Error(err) t.Error(err)
} }

View file

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

View file

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

View file

@ -23,6 +23,7 @@ type Image struct {
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"` DockerVersion string `json:"docker_version,omitempty"`
Author string `json:"author,omitempty"`
graph *Graph graph *Graph
} }

View file

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