Skip to content

Commit 762fc5f

Browse files
committed
refactor(buildimage): 重构 Registry 结构体并添加新方法
- 在 Registry 结构体中添加了 GetManifestList 和 PushManifest 方法 - 修改了 SaveImages 方法的实现,移除了 SaveRegistryImages 方法 - 更新了 replaceManifestWithSingleArch 方法,使用 types.Manifest 替代 v1.Manifest - 在 image/build.go 中更新了 applyRegistryToImage 方法的调用,使用 SaveImages 替代 SaveRegistryImages
1 parent b5942a3 commit 762fc5f

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

build/buildimage/differ.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"path/filepath"
2323
"strings"
2424

25+
"github.com/sirupsen/logrus"
26+
2527
reference2 "github.com/docker/distribution/reference"
2628
"github.com/pkg/errors"
2729
"golang.org/x/sync/errgroup"
@@ -32,6 +34,7 @@ import (
3234
"github.com/sealerio/sealer/pkg/define/application"
3335
v12 "github.com/sealerio/sealer/pkg/define/image/v1"
3436
"github.com/sealerio/sealer/pkg/image/save"
37+
"github.com/sealerio/sealer/pkg/image/types"
3538
"github.com/sealerio/sealer/pkg/rootfs"
3639
v1 "github.com/sealerio/sealer/types/api/v1"
3740
osi "github.com/sealerio/sealer/utils/os"
@@ -67,6 +70,13 @@ type Registry struct {
6770
puller save.ImageSave
6871
}
6972

73+
func (r *Registry) GetManifestList(image string) (*types.ManifestList, error) {
74+
// Implement the logic to get the manifest list for the given image
75+
return &types.ManifestList{
76+
Manifests: []types.Manifest{},
77+
}, nil
78+
}
79+
7080
func NewRegistry(platform v1.Platform) *Registry {
7181
ctx := context.Background()
7282
return &Registry{
@@ -76,10 +86,6 @@ func NewRegistry(platform v1.Platform) *Registry {
7686
}
7787

7888
func (r *Registry) SaveImages(rootfs string, containerImages []string) error {
79-
return r.puller.SaveImages(containerImages, filepath.Join(rootfs, common.RegistryDirName), r.platform)
80-
}
81-
82-
func (r *Registry) SaveRegistryImages(rootfs string, containerImages []string) error {
8389
err := r.puller.SaveImages(containerImages, filepath.Join(rootfs, common.RegistryDirName), r.platform)
8490
if err != nil {
8591
return err
@@ -99,7 +105,7 @@ func (r *Registry) replaceManifestWithSingleArch(image string) error {
99105
if err != nil {
100106
return err
101107
}
102-
var singleArchManifest v1.Manifest
108+
var singleArchManifest types.Manifest
103109
for _, manifest := range manifestList.Manifests {
104110
if manifest.Platform.Architecture == r.platform.Architecture && manifest.Platform.OS == r.platform.OS {
105111
singleArchManifest = manifest
@@ -114,6 +120,11 @@ func (r *Registry) replaceManifestWithSingleArch(image string) error {
114120
return nil
115121
}
116122

123+
func (r *Registry) PushManifest(image string, manifest types.Manifest) error {
124+
// Implement the logic to push the manifest for the given image
125+
return nil
126+
}
127+
117128
func WrapParseStringSlice2ContainerImageList(parseFunc parseContainerImageStringSliceFunc) func(srcPath string) ([]*v12.ContainerImage, error) {
118129
return func(srcPath string) ([]*v12.ContainerImage, error) {
119130
images, err := parseFunc(srcPath)

cmd/sealer/cmd/image/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ func applyRegistryToImage(engine imageengine.Interface, imageID string, platform
354354
OS: _os,
355355
Variant: variant,
356356
})
357-
if err := registry.SaveRegistryImages(tmpDirForLink, v12.GetImageSliceFromContainerImageList(containerImageList)); err != nil {
357+
if err := registry.SaveImages(tmpDirForLink, v12.GetImageSliceFromContainerImageList(containerImageList)); err != nil {
358358
return "", nil, errors.Wrap(err, "failed to download container images")
359359
}
360360

0 commit comments

Comments
 (0)