distribution: remove RootFSFromConfig(), PlatformFromConfig() from ImageConfigStore
These functions did not require the ImageConfigStore, so could just be local utilities. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
1e75ab0ab9
commit
572c7e0184
3 changed files with 14 additions and 11 deletions
|
@ -87,8 +87,6 @@ type ImagePushConfig struct {
|
|||
type ImageConfigStore interface {
|
||||
Put(context.Context, []byte) (digest.Digest, error)
|
||||
Get(context.Context, digest.Digest) ([]byte, error)
|
||||
RootFSFromConfig([]byte) (*image.RootFS, error)
|
||||
PlatformFromConfig([]byte) (*specs.Platform, error)
|
||||
}
|
||||
|
||||
// PushLayerProvider provides layers to be pushed by ChainID.
|
||||
|
@ -133,7 +131,7 @@ func (s *imageConfigStore) Get(_ context.Context, d digest.Digest) ([]byte, erro
|
|||
return img.RawJSON(), nil
|
||||
}
|
||||
|
||||
func (s *imageConfigStore) RootFSFromConfig(c []byte) (*image.RootFS, error) {
|
||||
func rootFSFromConfig(c []byte) (*image.RootFS, error) {
|
||||
var unmarshalledConfig image.Image
|
||||
if err := json.Unmarshal(c, &unmarshalledConfig); err != nil {
|
||||
return nil, err
|
||||
|
@ -141,7 +139,7 @@ func (s *imageConfigStore) RootFSFromConfig(c []byte) (*image.RootFS, error) {
|
|||
return unmarshalledConfig.RootFS, nil
|
||||
}
|
||||
|
||||
func (s *imageConfigStore) PlatformFromConfig(c []byte) (*specs.Platform, error) {
|
||||
func platformFromConfig(c []byte) (*specs.Platform, error) {
|
||||
var unmarshalledConfig image.Image
|
||||
if err := json.Unmarshal(c, &unmarshalledConfig); err != nil {
|
||||
return nil, err
|
||||
|
@ -154,7 +152,12 @@ func (s *imageConfigStore) PlatformFromConfig(c []byte) (*specs.Platform, error)
|
|||
if !system.IsOSSupported(os) {
|
||||
return nil, errors.Wrapf(system.ErrNotSupportedOperatingSystem, "image operating system %q cannot be used on this platform", os)
|
||||
}
|
||||
return &specs.Platform{OS: os, Architecture: unmarshalledConfig.Architecture, Variant: unmarshalledConfig.Variant, OSVersion: unmarshalledConfig.OSVersion}, nil
|
||||
return &specs.Platform{
|
||||
OS: os,
|
||||
Architecture: unmarshalledConfig.Architecture,
|
||||
Variant: unmarshalledConfig.Variant,
|
||||
OSVersion: unmarshalledConfig.OSVersion,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type storeLayerProvider struct {
|
||||
|
|
|
@ -647,7 +647,7 @@ func (p *puller) pullSchema2Layers(ctx context.Context, target distribution.Desc
|
|||
// check to block Windows images being pulled on Linux is implemented, it
|
||||
// may be necessary to perform the same type of serialisation.
|
||||
if runtime.GOOS == "windows" {
|
||||
configJSON, configRootFS, configPlatform, err = receiveConfig(p.config.ImageStore, configChan, configErrChan)
|
||||
configJSON, configRootFS, configPlatform, err = receiveConfig(configChan, configErrChan)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -708,7 +708,7 @@ func (p *puller) pullSchema2Layers(ctx context.Context, target distribution.Desc
|
|||
}
|
||||
|
||||
if configJSON == nil {
|
||||
configJSON, configRootFS, _, err = receiveConfig(p.config.ImageStore, configChan, configErrChan)
|
||||
configJSON, configRootFS, _, err = receiveConfig(configChan, configErrChan)
|
||||
if err == nil && configRootFS == nil {
|
||||
err = errRootFSInvalid
|
||||
}
|
||||
|
@ -773,14 +773,14 @@ func (p *puller) pullOCI(ctx context.Context, ref reference.Named, mfst *ocische
|
|||
return id, manifestDigest, err
|
||||
}
|
||||
|
||||
func receiveConfig(s ImageConfigStore, configChan <-chan []byte, errChan <-chan error) ([]byte, *image.RootFS, *specs.Platform, error) {
|
||||
func receiveConfig(configChan <-chan []byte, errChan <-chan error) ([]byte, *image.RootFS, *specs.Platform, error) {
|
||||
select {
|
||||
case configJSON := <-configChan:
|
||||
rootfs, err := s.RootFSFromConfig(configJSON)
|
||||
rootfs, err := rootFSFromConfig(configJSON)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
platform, err := s.PlatformFromConfig(configJSON)
|
||||
platform, err := platformFromConfig(configJSON)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ func (p *pusher) pushTag(ctx context.Context, ref reference.NamedTagged, id dige
|
|||
return fmt.Errorf("could not find image from tag %s: %v", reference.FamiliarString(ref), err)
|
||||
}
|
||||
|
||||
rootfs, err := p.config.ImageStore.RootFSFromConfig(imgConfig)
|
||||
rootfs, err := rootFSFromConfig(imgConfig)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get rootfs for image %s: %s", reference.FamiliarString(ref), err)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue