Skip to content

Commit

Permalink
Merge pull request #599 from carvel-dev/issue-596
Browse files Browse the repository at this point in the history
Use logger that always write on describe command
  • Loading branch information
joaopapereira authored Nov 6, 2023
2 parents e9bf543 + aa249af commit 2a82dee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
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
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 2a82dee

Please sign in to comment.