diff --git a/pkg/imgpkg/cmd/copy.go b/pkg/imgpkg/cmd/copy.go index 3e98bdb8c..5e947494b 100644 --- a/pkg/imgpkg/cmd/copy.go +++ b/pkg/imgpkg/cmd/copy.go @@ -7,6 +7,7 @@ import ( "fmt" "carvel.dev/imgpkg/pkg/imgpkg/bundle" + "carvel.dev/imgpkg/pkg/imgpkg/image" ctlimgset "carvel.dev/imgpkg/pkg/imgpkg/imageset" "carvel.dev/imgpkg/pkg/imgpkg/internal/util" "carvel.dev/imgpkg/pkg/imgpkg/lockconfig" @@ -106,10 +107,10 @@ func (c *CopyOptions) Run() error { levelLogger := util.NewUILevelLogger(util.LogWarn, prefixedLogger) imagesUploaderLogger := util.NewProgressBar(levelLogger, "done uploading images", "Error uploading images") - var tagGen util.TagGenerator - tagGen = util.DefaultTagGenerator{} + var tagGen ctlimgset.TagGenerator + tagGen = image.DefaultTagGenerator{} if c.UseRepoBasedTags { - tagGen = util.RepoBasedTagGenerator{} + tagGen = image.RepoBasedTagGenerator{} } imageSet := ctlimgset.NewImageSet(c.Concurrency, prefixedLogger, tagGen) diff --git a/pkg/imgpkg/internal/util/repo_based_tag_generator_test.go b/pkg/imgpkg/image/repo_based_tag_generator_test.go similarity index 98% rename from pkg/imgpkg/internal/util/repo_based_tag_generator_test.go rename to pkg/imgpkg/image/repo_based_tag_generator_test.go index 7914424b5..34a9e90dd 100644 --- a/pkg/imgpkg/internal/util/repo_based_tag_generator_test.go +++ b/pkg/imgpkg/image/repo_based_tag_generator_test.go @@ -1,13 +1,13 @@ // Copyright 2024 The Carvel Authors. // SPDX-License-Identifier: Apache-2.0 -package util_test +package image_test import ( "testing" + "carvel.dev/imgpkg/pkg/imgpkg/image" "carvel.dev/imgpkg/pkg/imgpkg/imagedigest" - util "carvel.dev/imgpkg/pkg/imgpkg/internal/util" regname "github.com/google/go-containerregistry/pkg/name" "github.com/stretchr/testify/require" ) @@ -89,7 +89,7 @@ func TestGenerateTagRepobasedgenerator(t *testing.T) { digestWrap.DigestWrap(imgIdxRef, test.origRef) importRepo, err := regname.NewRepository("import-registry/dst-repo") require.NoError(t, err) - tagGen := util.RepoBasedTagGenerator{} + tagGen := image.RepoBasedTagGenerator{} tag, err := tagGen.GenerateTag(digestWrap, importRepo) require.NoError(t, err) require.Equal(t, test.expectedTag, tag.TagStr()) diff --git a/pkg/imgpkg/internal/util/tag.go b/pkg/imgpkg/image/tag.go similarity index 94% rename from pkg/imgpkg/internal/util/tag.go rename to pkg/imgpkg/image/tag.go index 896aa2899..b394b94ce 100644 --- a/pkg/imgpkg/internal/util/tag.go +++ b/pkg/imgpkg/image/tag.go @@ -1,7 +1,7 @@ // Copyright 2024 The Carvel Authors. // SPDX-License-Identifier: Apache-2.0 -package util +package image import ( "fmt" @@ -32,11 +32,6 @@ func (t TagGenDigest) Digest() (regv1.Hash, error) { }, nil } -// TagGenerator interface -type TagGenerator interface { - GenerateTag(item imagedigest.DigestWrap, destinationRepo regname.Repository) (regname.Tag, error) -} - // DefaultTagGenerator implements GenerateTag // and generates default tag type DefaultTagGenerator struct{} diff --git a/pkg/imgpkg/imageset/image_set.go b/pkg/imgpkg/imageset/image_set.go index c3faa3d75..07da7f199 100644 --- a/pkg/imgpkg/imageset/image_set.go +++ b/pkg/imgpkg/imageset/image_set.go @@ -20,14 +20,19 @@ type Logger interface { Logf(str string, args ...interface{}) } +// TagGenerator interface +type TagGenerator interface { + GenerateTag(item imagedigest.DigestWrap, destinationRepo regname.Repository) (regname.Tag, error) +} + type ImageSet struct { concurrency int logger Logger - tagGen util.TagGenerator + tagGen TagGenerator } // NewImageSet constructor for creating an ImageSet -func NewImageSet(concurrency int, logger Logger, tagGen util.TagGenerator) ImageSet { +func NewImageSet(concurrency int, logger Logger, tagGen TagGenerator) ImageSet { return ImageSet{concurrency, logger, tagGen} } diff --git a/pkg/imgpkg/plainimage/contents.go b/pkg/imgpkg/plainimage/contents.go index ff3754635..e692fa345 100644 --- a/pkg/imgpkg/plainimage/contents.go +++ b/pkg/imgpkg/plainimage/contents.go @@ -10,7 +10,6 @@ import ( "strings" ctlimg "carvel.dev/imgpkg/pkg/imgpkg/image" - "carvel.dev/imgpkg/pkg/imgpkg/internal/util" regname "github.com/google/go-containerregistry/pkg/name" regv1 "github.com/google/go-containerregistry/pkg/v1" regremote "github.com/google/go-containerregistry/pkg/v1/remote" @@ -61,7 +60,7 @@ func (i Contents) Push(uploadRef regname.Tag, labels map[string]string, writer I return "", err } - uploadTagRef, err := util.BuildDefaultUploadTagRef(img, uploadRef.Repository) + uploadTagRef, err := ctlimg.BuildDefaultUploadTagRef(img, uploadRef.Repository) if err != nil { return "", fmt.Errorf("Building default upload tag image ref: %s", err) } diff --git a/pkg/imgpkg/v1/copy_test.go b/pkg/imgpkg/v1/copy_test.go index e3979b073..be41e195f 100644 --- a/pkg/imgpkg/v1/copy_test.go +++ b/pkg/imgpkg/v1/copy_test.go @@ -38,7 +38,7 @@ var stdOut *bytes.Buffer func testSetup(registryBuild *helpers.FakeTestRegistryBuilder, imageName string, bundleName string, tarPath string, lockfilePath string) (v1.CopyOrigin, v1.CopyOpts, registry.Registry) { stdOut = bytes.NewBufferString("") uiLogger := util.NewUILevelLogger(util.LogWarn, util.NewBufferLogger(stdOut)) - tagGen := util.DefaultTagGenerator{} + tagGen := ctlimg.DefaultTagGenerator{} imageSet := imageset.NewImageSet(1, uiLogger, tagGen) opts := v1.CopyOpts{