Browse code

Remove OS() from layer interface

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2018/01/19 05:56:28
Showing 8 changed files
... ...
@@ -57,10 +57,6 @@ func (ml *mockLayer) DiffSize() (size int64, err error) {
57 57
 	return 0, nil
58 58
 }
59 59
 
60
-func (ml *mockLayer) OS() string {
61
-	return ml.os
62
-}
63
-
64 60
 func (ml *mockLayer) Metadata() (map[string]string, error) {
65 61
 	return make(map[string]string), nil
66 62
 }
... ...
@@ -158,10 +154,6 @@ func (ls *mockLayerStore) DriverName() string {
158 158
 	return "mock"
159 159
 }
160 160
 
161
-func (ls *mockLayerStore) OS() string {
162
-	return runtime.GOOS
163
-}
164
-
165 161
 type mockDownloadDescriptor struct {
166 162
 	currentDownloads *int32
167 163
 	id               string
... ...
@@ -224,6 +224,13 @@ func (is *store) Delete(id ID) ([]layer.Metadata, error) {
224 224
 	if imageMeta == nil {
225 225
 		return nil, fmt.Errorf("unrecognized image ID %s", id.String())
226 226
 	}
227
+	img, err := is.Get(id)
228
+	if err != nil {
229
+		return nil, fmt.Errorf("unrecognized image %s, %v", id.String(), err)
230
+	}
231
+	if !system.IsOSSupported(img.OperatingSystem()) {
232
+		return nil, fmt.Errorf("unsupported image operating system %q", img.OperatingSystem())
233
+	}
227 234
 	for id := range imageMeta.children {
228 235
 		is.fs.DeleteMetadata(id.Digest(), "parent")
229 236
 	}
... ...
@@ -238,7 +245,7 @@ func (is *store) Delete(id ID) ([]layer.Metadata, error) {
238 238
 	is.fs.Delete(id.Digest())
239 239
 
240 240
 	if imageMeta.layer != nil {
241
-		return is.lss[imageMeta.layer.OS()].Release(imageMeta.layer)
241
+		return is.lss[img.OperatingSystem()].Release(imageMeta.layer)
242 242
 	}
243 243
 	return nil, nil
244 244
 }
... ...
@@ -43,10 +43,6 @@ func (el *emptyLayer) Parent() Layer {
43 43
 	return nil
44 44
 }
45 45
 
46
-func (el *emptyLayer) OS() string {
47
-	return ""
48
-}
49
-
50 46
 func (el *emptyLayer) Size() (size int64, err error) {
51 47
 	return 0, nil
52 48
 }
... ...
@@ -100,9 +100,6 @@ type Layer interface {
100 100
 	// Parent returns the next layer in the layer chain.
101 101
 	Parent() Layer
102 102
 
103
-	// OS returns the operating system of the layer
104
-	OS() string
105
-
106 103
 	// Size returns the size of the entire layer chain. The size
107 104
 	// is calculated from the total size of all files in the layers.
108 105
 	Size() (int64, error)
... ...
@@ -148,9 +145,6 @@ type RWLayer interface {
148 148
 
149 149
 	// Metadata returns the low level metadata for the mutable layer
150 150
 	Metadata() (map[string]string, error)
151
-
152
-	// OS returns the operating system of the writable layer
153
-	OS() string
154 151
 }
155 152
 
156 153
 // Metadata holds information about a
... ...
@@ -199,7 +193,6 @@ type Store interface {
199 199
 	Cleanup() error
200 200
 	DriverStatus() [][2]string
201 201
 	DriverName() string
202
-	OS() string
203 202
 }
204 203
 
205 204
 // DescribableStore represents a layer store capable of storing
... ...
@@ -725,10 +725,6 @@ func (ls *layerStore) DriverName() string {
725 725
 	return ls.driver.String()
726 726
 }
727 727
 
728
-func (ls *layerStore) OS() string {
729
-	return ls.os
730
-}
731
-
732 728
 type naiveDiffPathDriver struct {
733 729
 	graphdriver.Driver
734 730
 }
... ...
@@ -46,10 +46,6 @@ func (ml *mountedLayer) Parent() Layer {
46 46
 	return nil
47 47
 }
48 48
 
49
-func (ml *mountedLayer) OS() string {
50
-	return ml.layerStore.os
51
-}
52
-
53 49
 func (ml *mountedLayer) Size() (int64, error) {
54 50
 	return ml.layerStore.driver.DiffSize(ml.mountID, ml.cacheParent())
55 51
 }
... ...
@@ -69,10 +69,6 @@ func (rl *roLayer) Parent() Layer {
69 69
 	return rl.parent
70 70
 }
71 71
 
72
-func (rl *roLayer) OS() string {
73
-	return rl.layerStore.os
74
-}
75
-
76 72
 func (rl *roLayer) Size() (size int64, err error) {
77 73
 	if rl.parent != nil {
78 74
 		size, err = rl.parent.Size()
... ...
@@ -432,10 +432,6 @@ func (l *mockLayer) DiffSize() (int64, error) {
432 432
 	return 0, nil
433 433
 }
434 434
 
435
-func (l *mockLayer) OS() string {
436
-	return ""
437
-}
438
-
439 435
 func (l *mockLayer) Metadata() (map[string]string, error) {
440 436
 	return nil, nil
441 437
 }