diff --git a/integration/image/remove_unix_test.go b/integration/image/remove_unix_test.go index aad281bc6e522..6f16f2d8eec31 100644 --- a/integration/image/remove_unix_test.go +++ b/integration/image/remove_unix_test.go @@ -7,6 +7,8 @@ import ( "io" "io/ioutil" "os" + "path/filepath" + "runtime" "strconv" "strings" "syscall" @@ -14,6 +16,10 @@ import ( "unsafe" "github.com/docker/docker/api/types" + _ "github.com/docker/docker/daemon/graphdriver/register" // register graph drivers + "github.com/docker/docker/daemon/images" + "github.com/docker/docker/layer" + "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/testutil/daemon" "github.com/docker/docker/testutil/fakecontext" "gotest.tools/assert" @@ -31,13 +37,27 @@ func TestRemoveImageGarbageCollector(t *testing.T) { // Create daemon with overlay2 graphdriver because vfs uses disk differently // and this test case would not work with it. - d := daemon.New(t, daemon.WithStorageDriver("overlay2"), daemon.WithImageService) + d := daemon.New(t, daemon.WithStorageDriver("overlay2")) d.Start(t) defer d.Stop(t) ctx := context.Background() client := d.NewClientT(t) - i := d.ImageService() + + layerStores := make(map[string]layer.Store) + layerStores[runtime.GOOS], _ = layer.NewStoreFromOptions(layer.StoreOptions{ + Root: d.Root, + MetadataStorePathTemplate: filepath.Join(d.RootDir(), "image", "%s", "layerdb"), + GraphDriver: d.StorageDriver(), + GraphDriverOptions: nil, + IDMapping: &idtools.IdentityMapping{}, + PluginGetter: nil, + ExperimentalEnabled: false, + OS: runtime.GOOS, + }) + i := images.NewImageService(images.ImageServiceConfig{ + LayerStores: layerStores, + }) img := "test-garbage-collector" diff --git a/testutil/daemon/daemon.go b/testutil/daemon/daemon.go index 3dd8659f50491..de948ecdc2a22 100644 --- a/testutil/daemon/daemon.go +++ b/testutil/daemon/daemon.go @@ -17,7 +17,6 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/events" "github.com/docker/docker/client" - "github.com/docker/docker/daemon/images" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/stringid" @@ -72,7 +71,6 @@ type Daemon struct { init bool dockerdBinary string log logT - imageService *images.ImageService // swarm related field swarmListenAddr string @@ -721,8 +719,3 @@ func cleanupRaftDir(t testing.TB, rootPath string) { } } } - -// ImageService returns the Daemon's ImageService -func (d *Daemon) ImageService() *images.ImageService { - return d.imageService -} diff --git a/testutil/daemon/ops_unix.go b/testutil/daemon/ops_unix.go deleted file mode 100644 index 41011e87c5c09..0000000000000 --- a/testutil/daemon/ops_unix.go +++ /dev/null @@ -1,34 +0,0 @@ -// +build !windows - -package daemon - -import ( - "path/filepath" - "runtime" - - "github.com/docker/docker/daemon/images" - "github.com/docker/docker/layer" - - // register graph drivers - _ "github.com/docker/docker/daemon/graphdriver/register" - "github.com/docker/docker/pkg/idtools" -) - -// WithImageService sets imageService options -func WithImageService(d *Daemon) { - layerStores := make(map[string]layer.Store) - os := runtime.GOOS - layerStores[os], _ = layer.NewStoreFromOptions(layer.StoreOptions{ - Root: d.Root, - MetadataStorePathTemplate: filepath.Join(d.RootDir(), "image", "%s", "layerdb"), - GraphDriver: d.storageDriver, - GraphDriverOptions: nil, - IDMapping: &idtools.IdentityMapping{}, - PluginGetter: nil, - ExperimentalEnabled: false, - OS: os, - }) - d.imageService = images.NewImageService(images.ImageServiceConfig{ - LayerStores: layerStores, - }) -}