@@ -16,6 +16,7 @@ import (
1616 "github.com/werf/logboek/pkg/types"
1717 "github.com/werf/werf/pkg/build/stage"
1818 "github.com/werf/werf/pkg/container_backend"
19+ "github.com/werf/werf/pkg/docker_registry"
1920 "github.com/werf/werf/pkg/image"
2021 "github.com/werf/werf/pkg/storage"
2122 "github.com/werf/werf/pkg/storage/lrumeta"
@@ -47,6 +48,11 @@ type ForEachDeleteStageOptions struct {
4748 storage.FilterStagesAndProcessRelatedDataOptions
4849}
4950
51+ type StorageOptions struct {
52+ ContainerBackend container_backend.ContainerBackend
53+ DockerRegistry docker_registry.ApiInterface
54+ }
55+
5056type StorageManagerInterface interface {
5157 InitCache (ctx context.Context ) error
5258
@@ -59,6 +65,8 @@ type StorageManagerInterface interface {
5965 MaxNumberOfWorkers () int
6066 GenerateStageUniqueID (digest string , stages []* image.StageDescription ) (string , int64 )
6167
68+ GetImageInfo (ctx context.Context , ref string , opts StorageOptions ) (* image.Info , error )
69+
6270 LockStageImage (ctx context.Context , imageName string ) error
6371 GetStagesByDigest (ctx context.Context , stageName , stageDigest string ) ([]* image.StageDescription , error )
6472 GetStagesByDigestWithCache (ctx context.Context , stageName , stageDigest string ) ([]* image.StageDescription , error )
@@ -342,6 +350,29 @@ func (m *StorageManager) ForEachDeleteStage(ctx context.Context, options ForEach
342350 })
343351}
344352
353+ func (m * StorageManager ) GetImageInfo (ctx context.Context , ref string , opts StorageOptions ) (* image.Info , error ) {
354+ info , err := m .getImageInfoFromContainerBackend (ctx , ref , opts .ContainerBackend )
355+ if err != nil {
356+ return nil , err
357+ }
358+ if info != nil {
359+ return info , err
360+ }
361+ return m .getImageInfoFromRegistry (ctx , ref , opts .DockerRegistry )
362+ }
363+
364+ func (m * StorageManager ) getImageInfoFromContainerBackend (ctx context.Context , ref string , containerBackend container_backend.ContainerBackend ) (* image.Info , error ) {
365+ return containerBackend .GetImageInfo (ctx , ref , container_backend.GetImageInfoOpts {})
366+ }
367+
368+ func (m * StorageManager ) getImageInfoFromRegistry (ctx context.Context , ref string , dockerRegistry docker_registry.ApiInterface ) (* image.Info , error ) {
369+ cfg , err := dockerRegistry .GetRepoImageConfigFile (ctx , ref )
370+ if err != nil {
371+ return nil , err
372+ }
373+ return image .NewImageInfoFromRegistryConfig (ref , cfg ), nil
374+ }
375+
345376func (m * StorageManager ) LockStageImage (ctx context.Context , imageName string ) error {
346377 imageLockName := container_backend .ImageLockName (imageName )
347378
0 commit comments