mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Allow driver to provide changes if it impl the Changer interface
This commit is contained in:
		
							parent
							
								
									f512049c8f
								
							
						
					
					
						commit
						9514767587
					
				
					 5 changed files with 9 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -170,11 +170,11 @@ func TestDiff(t *testing.T) {
 | 
			
		|||
	// Commit the container
 | 
			
		||||
	rwTar, err := container1.ExportRw()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Error(err)
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
	img, err := runtime.graph.Create(rwTar, container1, "unit test commited image - diff", "", nil)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Error(err)
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Create a new container from the commited image
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -65,10 +65,6 @@ func (d *Driver) DiffSize(id string) (int64, error) {
 | 
			
		|||
	return -1, fmt.Errorf("Not implemented")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (d *Driver) Changes(id string) ([]archive.Change, error) {
 | 
			
		||||
	return nil, fmt.Errorf("Not implemented")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (d *Driver) mount(id, mp string) error {
 | 
			
		||||
	// Create the target directories if they don't exist
 | 
			
		||||
	if err := os.MkdirAll(mp, 0755); err != nil && !os.IsExist(err) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,11 +18,14 @@ type Driver interface {
 | 
			
		|||
 | 
			
		||||
	Diff(id string) (archive.Archive, error)
 | 
			
		||||
	DiffSize(id string) (bytes int64, err error)
 | 
			
		||||
	Changes(id string) ([]archive.Change, error)
 | 
			
		||||
 | 
			
		||||
	Cleanup() error
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Changer interface {
 | 
			
		||||
	Changes(id string) ([]archive.Change, error)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	// All registred drivers
 | 
			
		||||
	drivers map[string]InitFunc
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,7 +80,3 @@ func (d *Driver) Diff(id string) (archive.Archive, error) {
 | 
			
		|||
func (d *Driver) DiffSize(id string) (int64, error) {
 | 
			
		||||
	return -1, fmt.Errorf("Not implemented")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (d *Driver) Changes(id string) ([]archive.Change, error) {
 | 
			
		||||
	return nil, fmt.Errorf("Not implemented")
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -733,6 +733,9 @@ func (runtime *Runtime) Unmount(container *Container) error {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func (runtime *Runtime) Changes(container *Container) ([]archive.Change, error) {
 | 
			
		||||
	if changer, ok := runtime.driver.(graphdriver.Changer); ok {
 | 
			
		||||
		return changer.Changes(container.ID)
 | 
			
		||||
	}
 | 
			
		||||
	cDir, err := runtime.driver.Get(container.ID)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("Error getting container rootfs %s from driver %s: %s", container.ID, container.runtime.driver, err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue