image: remove leftover LCOW platform checks

This removes some of the checks that were added in 0cba7740d4,
but should no longer be needed.

- `image/store.Delete()`: no need to validate image platform to delete it.
- `image/tarexporter/takeLayerReference()`: use `image.OperatingSystem()` and
  fail early to prevent constructing the `ChainID()`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-01-25 12:18:44 +01:00
parent b2ef2e8c83
commit 1ef0a5bb91
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
2 changed files with 4 additions and 12 deletions

View file

@ -229,13 +229,10 @@ func (is *store) Delete(id ID) ([]layer.Metadata, error) {
if imageMeta == nil {
return nil, fmt.Errorf("unrecognized image ID %s", id.String())
}
img, err := is.Get(id)
_, 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 {
is.fs.DeleteMetadata(id.Digest(), "parent")
}

View file

@ -7,7 +7,6 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"time"
"github.com/docker/distribution"
@ -149,18 +148,14 @@ func (l *tarexporter) takeLayerReference(id image.ID, imgDescr *imageDescriptor)
if err != nil {
return err
}
if os := img.OperatingSystem(); !system.IsOSSupported(os) {
return fmt.Errorf("os %q is not supported", os)
}
imgDescr.image = img
topLayerID := img.RootFS.ChainID()
if topLayerID == "" {
return nil
}
os := img.OS
if os == "" {
os = runtime.GOOS
}
if !system.IsOSSupported(os) {
return fmt.Errorf("os %q is not supported", os)
}
layer, err := l.lss.Get(topLayerID)
if err != nil {
return err