diff --git a/CHANGELOG.md b/CHANGELOG.md index 892b099e51..3e35d539ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ IMPROVEMENTS: * `kube-system` and `local-path-storage` namespaces are now excluded from connect injection by default on Kubernetes versions >= 1.21. This prevents deadlock issues when `kube-system` components go down and allows Kind to work without changing the failure policy of the mutating webhook. [[GH-726](https://github.com/hashicorp/consul-k8s/pull/726)] * CLI * Add `status` command. [[GH-768](https://github.com/hashicorp/consul-k8s/pull/768)] + * Add `-verbose`, `-v` flag to the `consul-k8s install` command, which outputs all logs emitted from the installation. By default, verbose is set to `false` to hide logs that show resources are not ready. [[GH-810](https://github.com/hashicorp/consul-k8s/pull/810)] * Add Prometheus deployment and Consul K8s metrics integration with demo preset when installing via `-preset=demo`. [[GH-809](https://github.com/hashicorp/consul-k8s/pull/809)] ## 0.35.0 (October 19, 2021) diff --git a/cli/cmd/install/install.go b/cli/cmd/install/install.go index 7b5e68d34a..689fbbcc3e 100644 --- a/cli/cmd/install/install.go +++ b/cli/cmd/install/install.go @@ -44,6 +44,9 @@ const ( flagNameTimeout = "timeout" defaultTimeout = "10m" + flagNameVerbose = "verbose" + defaultVerbose = false + flagNameWait = "wait" defaultWait = true ) @@ -65,6 +68,7 @@ type Command struct { flagFileValues []string flagTimeout string timeoutDuration time.Duration + flagVerbose bool flagWait bool flagKubeConfig string @@ -135,6 +139,13 @@ func (c *Command) init() { Default: defaultTimeout, Usage: "Timeout to wait for installation to be ready.", }) + f.BoolVar(&flag.BoolVar{ + Name: flagNameVerbose, + Aliases: []string{"v"}, + Target: &c.flagVerbose, + Default: defaultVerbose, + Usage: "Output verbose logs from the install command with the status of resources being installed.", + }) f.BoolVar(&flag.BoolVar{ Name: flagNameWait, Target: &c.flagWait, @@ -192,7 +203,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 for resources + if !strings.Contains(logMsg, "not ready") { + c.UI.Output(logMsg, terminal.WithLibraryStyle()) + } + } } // Set up the kubernetes client to use for non Helm SDK calls to the Kubernetes API