From 9ae4bcaaf8aa01da340341e47f99f83a59ce91dc Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Fri, 8 Nov 2013 00:35:26 +0000 Subject: [PATCH] Move Change to the archive package, and fix a leftover merge in Container.Inject() --- changes.go => archive/changes.go | 2 +- container.go | 5 ++--- devmapper/driver.go | 2 +- graphdriver/driver.go | 8 ++------ runtime.go | 3 ++- server.go | 3 +-- utils.go | 7 +++++++ 7 files changed, 16 insertions(+), 14 deletions(-) rename changes.go => archive/changes.go (99%) diff --git a/changes.go b/archive/changes.go similarity index 99% rename from changes.go rename to archive/changes.go index 7a88ef0d01..504f4a2cf2 100644 --- a/changes.go +++ b/archive/changes.go @@ -1,4 +1,4 @@ -package docker +package archive import ( "fmt" diff --git a/container.go b/container.go index a39b91c10d..7b79cabbfb 100644 --- a/container.go +++ b/container.go @@ -7,7 +7,6 @@ import ( "flag" "fmt" "github.com/dotcloud/docker/archive" - "github.com/dotcloud/docker/graphdriver" // FIXME: graphdriver.Change is a placeholder for archive.Change "github.com/dotcloud/docker/term" "github.com/dotcloud/docker/utils" "github.com/kr/pty" @@ -397,7 +396,7 @@ func (container *Container) Inject(file io.Reader, pth string) error { } // Return error if path exists - if _, err := os.Stat(path.Join(container.rwPath(), pth)); err == nil { + if _, err := os.Stat(path.Join(container.RootfsPath(), pth)); err == nil { // Since err is nil, the path could be stat'd and it exists return fmt.Errorf("%s exists", pth) } else if !os.IsNotExist(err) { @@ -1402,7 +1401,7 @@ func (container *Container) Mount() error { return container.runtime.Mount(container) } -func (container *Container) Changes() ([]graphdriver.Change, error) { +func (container *Container) Changes() ([]archive.Change, error) { return container.runtime.Changes(container) } diff --git a/devmapper/driver.go b/devmapper/driver.go index 7a594db623..909f3cf974 100644 --- a/devmapper/driver.go +++ b/devmapper/driver.go @@ -61,7 +61,7 @@ func (d *Driver) DiffSize(id string) (int64, error) { return -1, fmt.Errorf("Not implemented") } -func (d *Driver) Changes(id string) ([]graphdriver.Change, error) { +func (d *Driver) Changes(id string) ([]archive.Change, error) { return nil, fmt.Errorf("Not implemented") } diff --git a/graphdriver/driver.go b/graphdriver/driver.go index 5a83259324..9165065f27 100644 --- a/graphdriver/driver.go +++ b/graphdriver/driver.go @@ -5,12 +5,8 @@ import ( "github.com/dotcloud/docker/archive" ) -type InitFunc func(root string) (Driver, error) -// FIXME: this is a temporary placeholder for archive.Change -// (to be merged from master) -type Change interface { -} +type InitFunc func(root string) (Driver, error) type Driver interface { Create(id, parent string) error @@ -20,7 +16,7 @@ type Driver interface { Diff(id string) (archive.Archive, error) DiffSize(id string) (bytes int64, err error) - Changes(id string) ([]Change, error) + Changes(id string) ([]archive.Change, error) Cleanup() error } diff --git a/runtime.go b/runtime.go index 60c2bb7cc8..75bae02934 100644 --- a/runtime.go +++ b/runtime.go @@ -5,6 +5,7 @@ import ( "container/list" "database/sql" "fmt" + "github.com/dotcloud/docker/archive" _ "github.com/dotcloud/docker/devmapper" "github.com/dotcloud/docker/gograph" "github.com/dotcloud/docker/graphdriver" @@ -728,7 +729,7 @@ func (runtime *Runtime) Unmount(container *Container) error { return nil } -func (runtime *Runtime) Changes(container *Container) ([]graphdriver.Change, error) { +func (runtime *Runtime) Changes(container *Container) ([]archive.Change, error) { return runtime.driver.Changes(container.ID) } diff --git a/server.go b/server.go index 08ce22afcf..6a94c8ae2c 100644 --- a/server.go +++ b/server.go @@ -9,7 +9,6 @@ import ( "github.com/dotcloud/docker/auth" "github.com/dotcloud/docker/engine" "github.com/dotcloud/docker/gograph" - "github.com/dotcloud/docker/graphdriver" // FIXME: graphdriver.Change is a placeholder for archive.Change "github.com/dotcloud/docker/registry" "github.com/dotcloud/docker/utils" "io" @@ -449,7 +448,7 @@ func (srv *Server) ContainerTop(name, ps_args string) (*APITop, error) { return nil, fmt.Errorf("No such container: %s", name) } -func (srv *Server) ContainerChanges(name string) ([]graphdriver.Change, error) { +func (srv *Server) ContainerChanges(name string) ([]archive.Change, error) { if container := srv.runtime.Get(name); container != nil { return container.Changes() } diff --git a/utils.go b/utils.go index 643187b847..a5df3d59a3 100644 --- a/utils.go +++ b/utils.go @@ -23,6 +23,7 @@ btrfs_reflink(int fd_out, int fd_in) import "C" import ( "fmt" + "github.com/dotcloud/docker/archive" "github.com/dotcloud/docker/namesgenerator" "github.com/dotcloud/docker/utils" "io" @@ -33,6 +34,12 @@ import ( "syscall" ) + +type Change struct { + archive.Change +} + + // Compare two Config struct. Do not compare the "Image" nor "Hostname" fields // If OpenStdin is set, then it differs func CompareConfig(a, b *Config) bool {