layer: remove layerstore.setOS(), layerstore.getOS()

This removes the `setOS()` / `getOS()` functions from the layer store, which were
added in fc21bf280b and 0380fbff37
in support of LCOW.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-01-25 14:25:04 +01:00
parent a583434ebc
commit c28a8e9cf7
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
4 changed files with 1 additions and 62 deletions

View File

@ -1,16 +0,0 @@
//go:build !windows
// +build !windows
package layer // import "github.com/docker/docker/layer"
import "runtime"
// setOS writes the "os" file to the layer filestore
func (fm *fileMetadataTransaction) setOS(os string) error {
return nil
}
// getOS reads the "os" file from the layer filestore
func (fms *fileMetadataStore) getOS(layer ChainID) (string, error) {
return runtime.GOOS, nil
}

View File

@ -1,34 +0,0 @@
package layer // import "github.com/docker/docker/layer"
import (
"fmt"
"os"
"strings"
)
// setOS writes the "os" file to the layer filestore
func (fm *fileMetadataTransaction) setOS(os string) error {
if os == "" {
return nil
}
return fm.ws.WriteFile("os", []byte(os), 0644)
}
// getOS reads the "os" file from the layer filestore
func (fms *fileMetadataStore) getOS(layer ChainID) (string, error) {
contentBytes, err := os.ReadFile(fms.getLayerFilename(layer, "os"))
if err != nil {
// For backwards compatibility, the os file may not exist. Default to "windows" if missing.
if os.IsNotExist(err) {
return "windows", nil
}
return "", err
}
content := strings.TrimSpace(string(contentBytes))
if content != "windows" && content != "linux" {
return "", fmt.Errorf("invalid operating system value: %s", content)
}
return content, nil
}

View File

@ -13,7 +13,6 @@ import (
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/plugingetter"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/pkg/system"
"github.com/moby/locker"
"github.com/opencontainers/go-digest"
"github.com/sirupsen/logrus"
@ -156,15 +155,6 @@ func (ls *layerStore) loadLayer(layer ChainID) (*roLayer, error) {
return nil, fmt.Errorf("failed to get descriptor for %s: %s", layer, err)
}
os, err := ls.store.getOS(layer)
if err != nil {
return nil, fmt.Errorf("failed to get operating system for %s: %s", layer, err)
}
if !system.IsOSSupported(os) {
return nil, fmt.Errorf("failed to load layer with os %s into layerstore: %w", os, system.ErrNotSupportedOperatingSystem)
}
cl = &roLayer{
chainID: layer,
diffID: diff,

View File

@ -3,7 +3,6 @@ package layer // import "github.com/docker/docker/layer"
import (
"fmt"
"io"
"runtime"
"github.com/docker/distribution"
"github.com/opencontainers/go-digest"
@ -145,7 +144,7 @@ func storeLayer(tx *fileMetadataTransaction, layer *roLayer) error {
return err
}
}
return tx.setOS(runtime.GOOS)
return nil
}
func newVerifiedReadCloser(rc io.ReadCloser, dgst digest.Digest) (io.ReadCloser, error) {