Merge pull request #43362 from thaJeztah/remove_lcow_setos_getos
Remove LCOW (step 9): layer: remove layerstore.setOS(), layerstore.getOS()
This commit is contained in:
commit
45e1f59dea
|
@ -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
|
|
||||||
}
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"github.com/docker/docker/pkg/idtools"
|
"github.com/docker/docker/pkg/idtools"
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/docker/docker/pkg/system"
|
|
||||||
"github.com/moby/locker"
|
"github.com/moby/locker"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/sirupsen/logrus"
|
"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)
|
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{
|
cl = &roLayer{
|
||||||
chainID: layer,
|
chainID: layer,
|
||||||
diffID: diff,
|
diffID: diff,
|
||||||
|
|
|
@ -3,7 +3,6 @@ package layer // import "github.com/docker/docker/layer"
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"github.com/docker/distribution"
|
"github.com/docker/distribution"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
|
@ -145,7 +144,7 @@ func storeLayer(tx *fileMetadataTransaction, layer *roLayer) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tx.setOS(runtime.GOOS)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newVerifiedReadCloser(rc io.ReadCloser, dgst digest.Digest) (io.ReadCloser, error) {
|
func newVerifiedReadCloser(rc io.ReadCloser, dgst digest.Digest) (io.ReadCloser, error) {
|
||||||
|
|
Loading…
Reference in New Issue