From aa249af5b901afcf92dbd2bd2d1be6201a1f701c Mon Sep 17 00:00:00 2001 From: Joao Pereira Date: Tue, 24 Oct 2023 10:21:17 -0500 Subject: [PATCH] Use logger that always write on describe command Signed-off-by: Joao Pereira --- .../bundlefakes/fake_images_lock_reader.go | 2 +- .../bundlefakes/fake_images_metadata_writer.go | 6 +++--- pkg/imgpkg/cmd/describe.go | 7 ++++--- .../registryfakes/fake_images_reader.go | 2 +- .../registryfakes/fake_images_reader_writer.go | 4 ++-- .../signature/signaturefakes/fake_finder.go | 2 +- test/e2e/describe_test.go | 18 +++++++++--------- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/pkg/imgpkg/bundle/bundlefakes/fake_images_lock_reader.go b/pkg/imgpkg/bundle/bundlefakes/fake_images_lock_reader.go index 8e15d9a2b..97883b620 100644 --- a/pkg/imgpkg/bundle/bundlefakes/fake_images_lock_reader.go +++ b/pkg/imgpkg/bundle/bundlefakes/fake_images_lock_reader.go @@ -4,9 +4,9 @@ package bundlefakes import ( "sync" - v1 "github.com/google/go-containerregistry/pkg/v1" "carvel.dev/imgpkg/pkg/imgpkg/bundle" "carvel.dev/imgpkg/pkg/imgpkg/lockconfig" + v1 "github.com/google/go-containerregistry/pkg/v1" ) type FakeImagesLockReader struct { diff --git a/pkg/imgpkg/bundle/bundlefakes/fake_images_metadata_writer.go b/pkg/imgpkg/bundle/bundlefakes/fake_images_metadata_writer.go index b9cc2e5c1..b9b859162 100644 --- a/pkg/imgpkg/bundle/bundlefakes/fake_images_metadata_writer.go +++ b/pkg/imgpkg/bundle/bundlefakes/fake_images_metadata_writer.go @@ -4,12 +4,12 @@ package bundlefakes import ( "sync" - "github.com/google/go-containerregistry/pkg/name" - v1 "github.com/google/go-containerregistry/pkg/v1" - "github.com/google/go-containerregistry/pkg/v1/remote" "carvel.dev/imgpkg/pkg/imgpkg/bundle" "carvel.dev/imgpkg/pkg/imgpkg/internal/util" "carvel.dev/imgpkg/pkg/imgpkg/registry" + "github.com/google/go-containerregistry/pkg/name" + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/remote" ) type FakeImagesMetadataWriter struct { diff --git a/pkg/imgpkg/cmd/describe.go b/pkg/imgpkg/cmd/describe.go index 28466f2fb..b7da3a83e 100644 --- a/pkg/imgpkg/cmd/describe.go +++ b/pkg/imgpkg/cmd/describe.go @@ -9,7 +9,7 @@ import ( "carvel.dev/imgpkg/pkg/imgpkg/bundle" "carvel.dev/imgpkg/pkg/imgpkg/internal/util" - "carvel.dev/imgpkg/pkg/imgpkg/v1" + v1 "carvel.dev/imgpkg/pkg/imgpkg/v1" goui "github.com/cppforlife/go-cli-ui/ui" regname "github.com/google/go-containerregistry/pkg/name" "github.com/spf13/cobra" @@ -78,11 +78,12 @@ func (d *DescribeOptions) Run() error { return err } + ttyEnabledLogger := util.NewUILevelLogger(logLevel, util.NewLoggerNoTTY(d.ui)) if d.OutputType == "text" { - p := bundleTextPrinter{logger: levelLogger} + p := bundleTextPrinter{logger: ttyEnabledLogger} p.Print(description) } else if d.OutputType == "yaml" { - p := bundleYAMLPrinter{logger: util.NewUILevelLogger(logLevel, util.NewLoggerNoTTY(d.ui))} + p := bundleYAMLPrinter{logger: ttyEnabledLogger} return p.Print(description) } return nil diff --git a/pkg/imgpkg/registry/registryfakes/fake_images_reader.go b/pkg/imgpkg/registry/registryfakes/fake_images_reader.go index 1af18b790..6f735d347 100644 --- a/pkg/imgpkg/registry/registryfakes/fake_images_reader.go +++ b/pkg/imgpkg/registry/registryfakes/fake_images_reader.go @@ -4,10 +4,10 @@ package registryfakes import ( "sync" + "carvel.dev/imgpkg/pkg/imgpkg/registry" "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/remote" - "carvel.dev/imgpkg/pkg/imgpkg/registry" ) type FakeImagesReader struct { diff --git a/pkg/imgpkg/registry/registryfakes/fake_images_reader_writer.go b/pkg/imgpkg/registry/registryfakes/fake_images_reader_writer.go index 5bf5d098c..67e599cb9 100644 --- a/pkg/imgpkg/registry/registryfakes/fake_images_reader_writer.go +++ b/pkg/imgpkg/registry/registryfakes/fake_images_reader_writer.go @@ -4,11 +4,11 @@ package registryfakes import ( "sync" + "carvel.dev/imgpkg/pkg/imgpkg/internal/util" + "carvel.dev/imgpkg/pkg/imgpkg/registry" "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/remote" - "carvel.dev/imgpkg/pkg/imgpkg/internal/util" - "carvel.dev/imgpkg/pkg/imgpkg/registry" ) type FakeImagesReaderWriter struct { diff --git a/pkg/imgpkg/signature/signaturefakes/fake_finder.go b/pkg/imgpkg/signature/signaturefakes/fake_finder.go index 4c13ccfbc..9452e6608 100644 --- a/pkg/imgpkg/signature/signaturefakes/fake_finder.go +++ b/pkg/imgpkg/signature/signaturefakes/fake_finder.go @@ -4,9 +4,9 @@ package signaturefakes import ( "sync" - "github.com/google/go-containerregistry/pkg/name" "carvel.dev/imgpkg/pkg/imgpkg/imageset" "carvel.dev/imgpkg/pkg/imgpkg/signature" + "github.com/google/go-containerregistry/pkg/name" ) type FakeFinder struct { diff --git a/test/e2e/describe_test.go b/test/e2e/describe_test.go index 35516635e..d838f9db2 100644 --- a/test/e2e/describe_test.go +++ b/test/e2e/describe_test.go @@ -64,7 +64,7 @@ images: logger.Section("executes describe command", func() { stdout := imgpkg.Run( []string{"describe", - "--tty", "--bundle", fmt.Sprintf("%s%s", env.RelocationRepo, bundleDigest), + "--bundle", fmt.Sprintf("%s%s", env.RelocationRepo, bundleDigest), }, ) @@ -158,7 +158,7 @@ images: logger.Section("executes describe command", func() { stdout := imgpkg.Run( []string{"describe", - "--tty", "--bundle", fmt.Sprintf("%s%s", env.RelocationRepo, outerBundleDigest), + "--bundle", fmt.Sprintf("%s%s", env.RelocationRepo, outerBundleDigest), }, ) @@ -258,7 +258,7 @@ images: logger.Section("executes describe command", func() { stdout := imgpkg.Run( []string{"describe", - "--tty", "--bundle", fmt.Sprintf("%s%s", outerBundle, outerBundleDigest), + "--bundle", fmt.Sprintf("%s%s", outerBundle, outerBundleDigest), "-o", "text", }, ) @@ -341,14 +341,14 @@ images: logger.Section("executes describe command", func() { stdout := imgpkg.Run( []string{"describe", - "--tty", "--bundle", fmt.Sprintf("%s%s", env.RelocationRepo, bundleDigest), + "--bundle", fmt.Sprintf("%s%s", env.RelocationRepo, bundleDigest), "-o", "yaml", }, ) locationsImgDigest := env.ImageFactory.ImageDigest(fmt.Sprintf("%s:%s.image-locations.imgpkg", env.RelocationRepo, strings.ReplaceAll(bundleDigest[1:], ":", "-"))) stdoutLines := strings.Split(stdout, "\n") - stdout = strings.Join(stdoutLines[:len(stdoutLines)-2], "\n") + stdout = strings.Join(stdoutLines[:len(stdoutLines)-1], "\n") require.YAMLEq(t, fmt.Sprintf(`sha: %s content: images: @@ -557,7 +557,7 @@ images: logger.Section("executes describe command", func() { stdout := imgpkg.Run( []string{"describe", - "--tty", "--bundle", fmt.Sprintf("%s%s", env.RelocationRepo, outerBundleDigest), + "--bundle", fmt.Sprintf("%s%s", env.RelocationRepo, outerBundleDigest), "-o", "yaml", }, ) @@ -565,7 +565,7 @@ images: locationsNestedBundleImgDigest := env.ImageFactory.ImageDigest(fmt.Sprintf("%s:%s.image-locations.imgpkg", env.RelocationRepo, strings.ReplaceAll(nestedBundleDigest[1:], ":", "-"))) locationsOuterBundleImgDigest := env.ImageFactory.ImageDigest(fmt.Sprintf("%s:%s.image-locations.imgpkg", env.RelocationRepo, strings.ReplaceAll(outerBundleDigest[1:], ":", "-"))) stdoutLines := strings.Split(stdout, "\n") - stdout = strings.Join(stdoutLines[:len(stdoutLines)-2], "\n") + stdout = strings.Join(stdoutLines[:len(stdoutLines)-1], "\n") require.YAMLEq(t, fmt.Sprintf(`sha: %s content: bundles: @@ -679,13 +679,13 @@ images: logger.Section("executes describe command", func() { stdout := imgpkg.Run( []string{"describe", - "--tty", "--bundle", fmt.Sprintf("%s%s", outerBundle, outerBundleDigest), + "--bundle", fmt.Sprintf("%s%s", outerBundle, outerBundleDigest), "--output-type", "yaml", }, ) stdoutLines := strings.Split(stdout, "\n") - stdout = strings.Join(stdoutLines[:len(stdoutLines)-2], "\n") + stdout = strings.Join(stdoutLines[:len(stdoutLines)-1], "\n") require.YAMLEq(t, fmt.Sprintf(`sha: %s content: bundles: