|
@@ -5,6 +5,8 @@ import (
|
|
"fmt"
|
|
"fmt"
|
|
"io"
|
|
"io"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
|
|
+ "runtime"
|
|
|
|
+ "strings"
|
|
"sync"
|
|
"sync"
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
"github.com/Sirupsen/logrus"
|
|
@@ -13,6 +15,7 @@ import (
|
|
"github.com/docker/docker/pkg/idtools"
|
|
"github.com/docker/docker/pkg/idtools"
|
|
"github.com/docker/docker/pkg/plugingetter"
|
|
"github.com/docker/docker/pkg/plugingetter"
|
|
"github.com/docker/docker/pkg/stringid"
|
|
"github.com/docker/docker/pkg/stringid"
|
|
|
|
+ "github.com/docker/docker/pkg/system"
|
|
"github.com/opencontainers/go-digest"
|
|
"github.com/opencontainers/go-digest"
|
|
"github.com/vbatts/tar-split/tar/asm"
|
|
"github.com/vbatts/tar-split/tar/asm"
|
|
"github.com/vbatts/tar-split/tar/storage"
|
|
"github.com/vbatts/tar-split/tar/storage"
|
|
@@ -36,6 +39,8 @@ type layerStore struct {
|
|
mountL sync.Mutex
|
|
mountL sync.Mutex
|
|
|
|
|
|
useTarSplit bool
|
|
useTarSplit bool
|
|
|
|
+
|
|
|
|
+ platform string
|
|
}
|
|
}
|
|
|
|
|
|
// StoreOptions are the options used to create a new Store instance
|
|
// StoreOptions are the options used to create a new Store instance
|
|
@@ -47,6 +52,7 @@ type StoreOptions struct {
|
|
IDMappings *idtools.IDMappings
|
|
IDMappings *idtools.IDMappings
|
|
PluginGetter plugingetter.PluginGetter
|
|
PluginGetter plugingetter.PluginGetter
|
|
ExperimentalEnabled bool
|
|
ExperimentalEnabled bool
|
|
|
|
+ Platform string
|
|
}
|
|
}
|
|
|
|
|
|
// NewStoreFromOptions creates a new Store instance
|
|
// NewStoreFromOptions creates a new Store instance
|
|
@@ -68,13 +74,13 @@ func NewStoreFromOptions(options StoreOptions) (Store, error) {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
|
|
- return NewStoreFromGraphDriver(fms, driver)
|
|
|
|
|
|
+ return NewStoreFromGraphDriver(fms, driver, options.Platform)
|
|
}
|
|
}
|
|
|
|
|
|
// NewStoreFromGraphDriver creates a new Store instance using the provided
|
|
// NewStoreFromGraphDriver creates a new Store instance using the provided
|
|
// metadata store and graph driver. The metadata store will be used to restore
|
|
// metadata store and graph driver. The metadata store will be used to restore
|
|
// the Store.
|
|
// the Store.
|
|
-func NewStoreFromGraphDriver(store MetadataStore, driver graphdriver.Driver) (Store, error) {
|
|
|
|
|
|
+func NewStoreFromGraphDriver(store MetadataStore, driver graphdriver.Driver, platform string) (Store, error) {
|
|
caps := graphdriver.Capabilities{}
|
|
caps := graphdriver.Capabilities{}
|
|
if capDriver, ok := driver.(graphdriver.CapabilityDriver); ok {
|
|
if capDriver, ok := driver.(graphdriver.CapabilityDriver); ok {
|
|
caps = capDriver.Capabilities()
|
|
caps = capDriver.Capabilities()
|
|
@@ -86,6 +92,7 @@ func NewStoreFromGraphDriver(store MetadataStore, driver graphdriver.Driver) (St
|
|
layerMap: map[ChainID]*roLayer{},
|
|
layerMap: map[ChainID]*roLayer{},
|
|
mounts: map[string]*mountedLayer{},
|
|
mounts: map[string]*mountedLayer{},
|
|
useTarSplit: !caps.ReproducesExactDiffs,
|
|
useTarSplit: !caps.ReproducesExactDiffs,
|
|
|
|
+ platform: platform,
|
|
}
|
|
}
|
|
|
|
|
|
ids, mounts, err := store.List()
|
|
ids, mounts, err := store.List()
|
|
@@ -264,6 +271,14 @@ func (ls *layerStore) registerWithDescriptor(ts io.Reader, parent ChainID, platf
|
|
var err error
|
|
var err error
|
|
var pid string
|
|
var pid string
|
|
var p *roLayer
|
|
var p *roLayer
|
|
|
|
+
|
|
|
|
+ // Integrity check - ensure we are creating something for the correct platform
|
|
|
|
+ if runtime.GOOS == "windows" && system.LCOWSupported() {
|
|
|
|
+ if strings.ToLower(ls.platform) != strings.ToLower(string(platform)) {
|
|
|
|
+ return nil, fmt.Errorf("cannot create entry for platform %q in layer store for platform %q", platform, ls.platform)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if string(parent) != "" {
|
|
if string(parent) != "" {
|
|
p = ls.get(parent)
|
|
p = ls.get(parent)
|
|
if p == nil {
|
|
if p == nil {
|