Skip to content

Commit c94d34f

Browse files
author
John Howard
committed
Remove OS() from layer interface
Signed-off-by: John Howard <[email protected]>
1 parent 0cba774 commit c94d34f

File tree

8 files changed

+8
-36
lines changed

8 files changed

+8
-36
lines changed

distribution/xfer/download_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ func (ml *mockLayer) DiffSize() (size int64, err error) {
5757
return 0, nil
5858
}
5959

60-
func (ml *mockLayer) OS() string {
61-
return ml.os
62-
}
63-
6460
func (ml *mockLayer) Metadata() (map[string]string, error) {
6561
return make(map[string]string), nil
6662
}
@@ -158,10 +154,6 @@ func (ls *mockLayerStore) DriverName() string {
158154
return "mock"
159155
}
160156

161-
func (ls *mockLayerStore) OS() string {
162-
return runtime.GOOS
163-
}
164-
165157
type mockDownloadDescriptor struct {
166158
currentDownloads *int32
167159
id string

image/store.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ func (is *store) Delete(id ID) ([]layer.Metadata, error) {
224224
if imageMeta == nil {
225225
return nil, fmt.Errorf("unrecognized image ID %s", id.String())
226226
}
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+
}
227234
for id := range imageMeta.children {
228235
is.fs.DeleteMetadata(id.Digest(), "parent")
229236
}
@@ -238,7 +245,7 @@ func (is *store) Delete(id ID) ([]layer.Metadata, error) {
238245
is.fs.Delete(id.Digest())
239246

240247
if imageMeta.layer != nil {
241-
return is.lss[imageMeta.layer.OS()].Release(imageMeta.layer)
248+
return is.lss[img.OperatingSystem()].Release(imageMeta.layer)
242249
}
243250
return nil, nil
244251
}

layer/empty.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ func (el *emptyLayer) Parent() Layer {
4343
return nil
4444
}
4545

46-
func (el *emptyLayer) OS() string {
47-
return ""
48-
}
49-
5046
func (el *emptyLayer) Size() (size int64, err error) {
5147
return 0, nil
5248
}

layer/layer.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ type Layer interface {
100100
// Parent returns the next layer in the layer chain.
101101
Parent() Layer
102102

103-
// OS returns the operating system of the layer
104-
OS() string
105-
106103
// Size returns the size of the entire layer chain. The size
107104
// is calculated from the total size of all files in the layers.
108105
Size() (int64, error)
@@ -148,9 +145,6 @@ type RWLayer interface {
148145

149146
// Metadata returns the low level metadata for the mutable layer
150147
Metadata() (map[string]string, error)
151-
152-
// OS returns the operating system of the writable layer
153-
OS() string
154148
}
155149

156150
// Metadata holds information about a
@@ -199,7 +193,6 @@ type Store interface {
199193
Cleanup() error
200194
DriverStatus() [][2]string
201195
DriverName() string
202-
OS() string
203196
}
204197

205198
// DescribableStore represents a layer store capable of storing

layer/layer_store.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,10 +725,6 @@ func (ls *layerStore) DriverName() string {
725725
return ls.driver.String()
726726
}
727727

728-
func (ls *layerStore) OS() string {
729-
return ls.os
730-
}
731-
732728
type naiveDiffPathDriver struct {
733729
graphdriver.Driver
734730
}

layer/mounted_layer.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ func (ml *mountedLayer) Parent() Layer {
4646
return nil
4747
}
4848

49-
func (ml *mountedLayer) OS() string {
50-
return ml.layerStore.os
51-
}
52-
5349
func (ml *mountedLayer) Size() (int64, error) {
5450
return ml.layerStore.driver.DiffSize(ml.mountID, ml.cacheParent())
5551
}

layer/ro_layer.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ func (rl *roLayer) Parent() Layer {
6969
return rl.parent
7070
}
7171

72-
func (rl *roLayer) OS() string {
73-
return rl.layerStore.os
74-
}
75-
7672
func (rl *roLayer) Size() (size int64, err error) {
7773
if rl.parent != nil {
7874
size, err = rl.parent.Size()

migrate/v1/migratev1_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,6 @@ func (l *mockLayer) DiffSize() (int64, error) {
432432
return 0, nil
433433
}
434434

435-
func (l *mockLayer) OS() string {
436-
return ""
437-
}
438-
439435
func (l *mockLayer) Metadata() (map[string]string, error) {
440436
return nil, nil
441437
}

0 commit comments

Comments
 (0)