Skip to content

Commit

Permalink
Use logger that always write on describe command
Browse files Browse the repository at this point in the history
Signed-off-by: Joao Pereira <[email protected]>
  • Loading branch information
joaopapereira committed Nov 1, 2023
1 parent 4a96555 commit aa249af
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pkg/imgpkg/bundle/bundlefakes/fake_images_lock_reader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/imgpkg/bundle/bundlefakes/fake_images_metadata_writer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions pkg/imgpkg/cmd/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/imgpkg/registry/registryfakes/fake_images_reader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/imgpkg/signature/signaturefakes/fake_finder.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions test/e2e/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
)

Expand Down Expand Up @@ -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),
},
)

Expand Down Expand Up @@ -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",
},
)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -557,15 +557,15 @@ 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",
},
)

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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit aa249af

Please sign in to comment.