Bladeren bron

Move Change to the archive package, and fix a leftover merge in
Container.Inject()

Solomon Hykes 11 jaren geleden
bovenliggende
commit
9ae4bcaaf8
7 gewijzigde bestanden met toevoegingen van 16 en 14 verwijderingen
  1. 1 1
      archive/changes.go
  2. 2 3
      container.go
  3. 1 1
      devmapper/driver.go
  4. 2 6
      graphdriver/driver.go
  5. 2 1
      runtime.go
  6. 1 2
      server.go
  7. 7 0
      utils.go

+ 1 - 1
changes.go → archive/changes.go

@@ -1,4 +1,4 @@
-package docker
+package archive
 
 import (
 	"fmt"

+ 2 - 3
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)
 }
 

+ 1 - 1
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")
 }
 

+ 2 - 6
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
 }

+ 2 - 1
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)
 }
 

+ 1 - 2
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()
 	}

+ 7 - 0
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 {