diff --git a/distribution/config.go b/distribution/config.go index 52ed9ddbfc..fa06e3c9c0 100644 --- a/distribution/config.go +++ b/distribution/config.go @@ -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 { diff --git a/distribution/pull_v2.go b/distribution/pull_v2.go index 090ba10f25..0495ab4146 100644 --- a/distribution/pull_v2.go +++ b/distribution/pull_v2.go @@ -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 } diff --git a/distribution/push_v2.go b/distribution/push_v2.go index 372705dc9c..24824709ee 100644 --- a/distribution/push_v2.go +++ b/distribution/push_v2.go @@ -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) }