Преглед на файлове

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

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn преди 3 години
родител
ревизия
c28a8e9cf7
променени са 4 файла, в които са добавени 1 реда и са изтрити 62 реда
  1. 0 16
      layer/filestore_unix.go
  2. 0 34
      layer/filestore_windows.go
  3. 0 10
      layer/layer_store.go
  4. 1 2
      layer/ro_layer.go

+ 0 - 16
layer/filestore_unix.go

@@ -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
-}

+ 0 - 34
layer/filestore_windows.go

@@ -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
-}

+ 0 - 10
layer/layer_store.go

@@ -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,

+ 1 - 2
layer/ro_layer.go

@@ -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) {