mirror of
https://github.com/docker/cli.git
synced 2026-09-24 07:25:07 -05:00
Remove Differ and Changer interfaces
Add the methods to the Driver interface to force the drivers to implement the methods Upstream-commit: 4d1a537433ede2bbc75b0a4817e8121f9e03fd86 Component: engine
This commit is contained in:
@@ -18,7 +18,6 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -734,49 +733,13 @@ 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)
|
||||
}
|
||||
initDir, err := runtime.driver.Get(container.ID + "-init")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error getting container init rootfs %s from driver %s: %s", container.ID, container.runtime.driver, err)
|
||||
}
|
||||
return archive.ChangesDirs(cDir, initDir)
|
||||
// FIXME: Remove Changes method from runtime
|
||||
return runtime.driver.Changes(container.ID)
|
||||
}
|
||||
|
||||
func (runtime *Runtime) Diff(container *Container) (archive.Archive, error) {
|
||||
if differ, ok := runtime.driver.(graphdriver.Differ); ok {
|
||||
return differ.Diff(container.ID)
|
||||
}
|
||||
|
||||
changes, err := runtime.Changes(container)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
files := make([]string, 0)
|
||||
deletions := make([]string, 0)
|
||||
for _, change := range changes {
|
||||
if change.Kind == archive.ChangeModify || change.Kind == archive.ChangeAdd {
|
||||
files = append(files, change.Path)
|
||||
}
|
||||
if change.Kind == archive.ChangeDelete {
|
||||
base := filepath.Base(change.Path)
|
||||
dir := filepath.Dir(change.Path)
|
||||
deletions = append(deletions, filepath.Join(dir, ".wh."+base))
|
||||
}
|
||||
}
|
||||
|
||||
return archive.TarFilter(cDir, archive.Uncompressed, files, false, deletions)
|
||||
// FIXME: Remove Diff method from runtime
|
||||
return runtime.driver.Diff(container.ID)
|
||||
}
|
||||
|
||||
func linkLxcStart(root string) error {
|
||||
|
||||
Reference in New Issue
Block a user