Browse Source

Remove OS() from layer interface

Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard 7 years ago
parent
commit
c94d34f783

+ 0 - 8
distribution/xfer/download_test.go

@@ -57,10 +57,6 @@ func (ml *mockLayer) DiffSize() (size int64, err error) {
 	return 0, nil
 	return 0, nil
 }
 }
 
 
-func (ml *mockLayer) OS() string {
-	return ml.os
-}
-
 func (ml *mockLayer) Metadata() (map[string]string, error) {
 func (ml *mockLayer) Metadata() (map[string]string, error) {
 	return make(map[string]string), nil
 	return make(map[string]string), nil
 }
 }
@@ -158,10 +154,6 @@ func (ls *mockLayerStore) DriverName() string {
 	return "mock"
 	return "mock"
 }
 }
 
 
-func (ls *mockLayerStore) OS() string {
-	return runtime.GOOS
-}
-
 type mockDownloadDescriptor struct {
 type mockDownloadDescriptor struct {
 	currentDownloads *int32
 	currentDownloads *int32
 	id               string
 	id               string

+ 8 - 1
image/store.go

@@ -224,6 +224,13 @@ func (is *store) Delete(id ID) ([]layer.Metadata, error) {
 	if imageMeta == nil {
 	if imageMeta == nil {
 		return nil, fmt.Errorf("unrecognized image ID %s", id.String())
 		return nil, fmt.Errorf("unrecognized image ID %s", id.String())
 	}
 	}
+	img, err := is.Get(id)
+	if err != nil {
+		return nil, fmt.Errorf("unrecognized image %s, %v", id.String(), err)
+	}
+	if !system.IsOSSupported(img.OperatingSystem()) {
+		return nil, fmt.Errorf("unsupported image operating system %q", img.OperatingSystem())
+	}
 	for id := range imageMeta.children {
 	for id := range imageMeta.children {
 		is.fs.DeleteMetadata(id.Digest(), "parent")
 		is.fs.DeleteMetadata(id.Digest(), "parent")
 	}
 	}
@@ -238,7 +245,7 @@ func (is *store) Delete(id ID) ([]layer.Metadata, error) {
 	is.fs.Delete(id.Digest())
 	is.fs.Delete(id.Digest())
 
 
 	if imageMeta.layer != nil {
 	if imageMeta.layer != nil {
-		return is.lss[imageMeta.layer.OS()].Release(imageMeta.layer)
+		return is.lss[img.OperatingSystem()].Release(imageMeta.layer)
 	}
 	}
 	return nil, nil
 	return nil, nil
 }
 }

+ 0 - 4
layer/empty.go

@@ -43,10 +43,6 @@ func (el *emptyLayer) Parent() Layer {
 	return nil
 	return nil
 }
 }
 
 
-func (el *emptyLayer) OS() string {
-	return ""
-}
-
 func (el *emptyLayer) Size() (size int64, err error) {
 func (el *emptyLayer) Size() (size int64, err error) {
 	return 0, nil
 	return 0, nil
 }
 }

+ 0 - 7
layer/layer.go

@@ -100,9 +100,6 @@ type Layer interface {
 	// Parent returns the next layer in the layer chain.
 	// Parent returns the next layer in the layer chain.
 	Parent() Layer
 	Parent() Layer
 
 
-	// OS returns the operating system of the layer
-	OS() string
-
 	// Size returns the size of the entire layer chain. The size
 	// Size returns the size of the entire layer chain. The size
 	// is calculated from the total size of all files in the layers.
 	// is calculated from the total size of all files in the layers.
 	Size() (int64, error)
 	Size() (int64, error)
@@ -148,9 +145,6 @@ type RWLayer interface {
 
 
 	// Metadata returns the low level metadata for the mutable layer
 	// Metadata returns the low level metadata for the mutable layer
 	Metadata() (map[string]string, error)
 	Metadata() (map[string]string, error)
-
-	// OS returns the operating system of the writable layer
-	OS() string
 }
 }
 
 
 // Metadata holds information about a
 // Metadata holds information about a
@@ -199,7 +193,6 @@ type Store interface {
 	Cleanup() error
 	Cleanup() error
 	DriverStatus() [][2]string
 	DriverStatus() [][2]string
 	DriverName() string
 	DriverName() string
-	OS() string
 }
 }
 
 
 // DescribableStore represents a layer store capable of storing
 // DescribableStore represents a layer store capable of storing

+ 0 - 4
layer/layer_store.go

@@ -725,10 +725,6 @@ func (ls *layerStore) DriverName() string {
 	return ls.driver.String()
 	return ls.driver.String()
 }
 }
 
 
-func (ls *layerStore) OS() string {
-	return ls.os
-}
-
 type naiveDiffPathDriver struct {
 type naiveDiffPathDriver struct {
 	graphdriver.Driver
 	graphdriver.Driver
 }
 }

+ 0 - 4
layer/mounted_layer.go

@@ -46,10 +46,6 @@ func (ml *mountedLayer) Parent() Layer {
 	return nil
 	return nil
 }
 }
 
 
-func (ml *mountedLayer) OS() string {
-	return ml.layerStore.os
-}
-
 func (ml *mountedLayer) Size() (int64, error) {
 func (ml *mountedLayer) Size() (int64, error) {
 	return ml.layerStore.driver.DiffSize(ml.mountID, ml.cacheParent())
 	return ml.layerStore.driver.DiffSize(ml.mountID, ml.cacheParent())
 }
 }

+ 0 - 4
layer/ro_layer.go

@@ -69,10 +69,6 @@ func (rl *roLayer) Parent() Layer {
 	return rl.parent
 	return rl.parent
 }
 }
 
 
-func (rl *roLayer) OS() string {
-	return rl.layerStore.os
-}
-
 func (rl *roLayer) Size() (size int64, err error) {
 func (rl *roLayer) Size() (size int64, err error) {
 	if rl.parent != nil {
 	if rl.parent != nil {
 		size, err = rl.parent.Size()
 		size, err = rl.parent.Size()

+ 0 - 4
migrate/v1/migratev1_test.go

@@ -432,10 +432,6 @@ func (l *mockLayer) DiffSize() (int64, error) {
 	return 0, nil
 	return 0, nil
 }
 }
 
 
-func (l *mockLayer) OS() string {
-	return ""
-}
-
 func (l *mockLayer) Metadata() (map[string]string, error) {
 func (l *mockLayer) Metadata() (map[string]string, error) {
 	return nil, nil
 	return nil, nil
 }
 }