Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: install - move not ready library log messages behind -verbose flag #810

Merged
merged 7 commits into from
Oct 28, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion cli/cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const (
flagNameTimeout = "timeout"
defaultTimeout = "10m"

flagNameVerbose = "verbose"
defaultVerbose = false

flagNameWait = "wait"
defaultWait = true
)
Expand All @@ -65,6 +68,7 @@ type Command struct {
flagFileValues []string
flagTimeout string
timeoutDuration time.Duration
flagVerbose bool
flagWait bool

flagKubeConfig string
Expand Down Expand Up @@ -135,6 +139,12 @@ func (c *Command) init() {
Default: defaultTimeout,
Usage: "Timeout to wait for installation to be ready.",
})
f.BoolVar(&flag.BoolVar{
Name: flagNameVerbose,
david-yu marked this conversation as resolved.
Show resolved Hide resolved
Target: &c.flagVerbose,
Default: defaultVerbose,
Usage: "Output verbose logs from the install command to understand status of resources being installed.",
david-yu marked this conversation as resolved.
Show resolved Hide resolved
})
f.BoolVar(&flag.BoolVar{
Name: flagNameWait,
Target: &c.flagWait,
Expand Down Expand Up @@ -192,7 +202,16 @@ func (c *Command) Run(args []string) int {
// Setup logger to stream Helm library logs
var uiLogger = func(s string, args ...interface{}) {
logMsg := fmt.Sprintf(s, args...)
c.UI.Output(logMsg, terminal.WithLibraryStyle())

if c.flagVerbose {
// Only output all logs when verbose is enabled
c.UI.Output(logMsg, terminal.WithLibraryStyle())
} else {
// When verbose is not enabled, output all logs except not ready messages from logs
if !strings.Contains(logMsg, "not ready") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely works for now. Might be worth revisiting in the future. I might look into refactoring this later to have a generalized logger that can have a verbose setting. This is totally good for now though.

c.UI.Output(logMsg, terminal.WithLibraryStyle())
}
}
}

// Set up the kubernetes client to use for non Helm SDK calls to the Kubernetes API
Expand Down