From c3c0da3938e8cf312cd409eb34b9dff25277c0aa Mon Sep 17 00:00:00 2001 From: David Yu Date: Thu, 28 Oct 2021 00:01:18 -0700 Subject: [PATCH 1/6] cli: remove not ready library log messages --- cli/cmd/install/install.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cli/cmd/install/install.go b/cli/cmd/install/install.go index dbb481c0ea..673c300563 100644 --- a/cli/cmd/install/install.go +++ b/cli/cmd/install/install.go @@ -192,7 +192,9 @@ 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 !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 From b80b0a830eaff9e89430c977be5649e1b31ec7e8 Mon Sep 17 00:00:00 2001 From: David Yu Date: Thu, 28 Oct 2021 10:11:08 -0700 Subject: [PATCH 2/6] adding verbose flag and selectively output logs when verbose is not set --- cli/cmd/install/install.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cli/cmd/install/install.go b/cli/cmd/install/install.go index 673c300563..5f78c4307f 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,12 @@ func (c *Command) init() { Default: defaultTimeout, Usage: "Timeout to wait for installation to be ready.", }) + f.BoolVar(&flag.BoolVar{ + Name: flagNameVerbose, + Target: &c.flagVerbose, + Default: defaultVerbose, + Usage: "Output verbose logs from the install command to understand status of resources being installed.", + }) f.BoolVar(&flag.BoolVar{ Name: flagNameWait, Target: &c.flagWait, @@ -192,8 +202,15 @@ 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...) - if !strings.Contains(logMsg, "not ready") { + + 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") { + c.UI.Output(logMsg, terminal.WithLibraryStyle()) + } } } From b91ecaaa2e39bff949aa1da5e14a32e5493465dd Mon Sep 17 00:00:00 2001 From: David Yu Date: Thu, 28 Oct 2021 11:42:26 -0700 Subject: [PATCH 3/6] Update cli/cmd/install/install.go adding -v alias Co-authored-by: Nitya Dhanushkodi --- cli/cmd/install/install.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/cmd/install/install.go b/cli/cmd/install/install.go index 5f78c4307f..98a2a8befa 100644 --- a/cli/cmd/install/install.go +++ b/cli/cmd/install/install.go @@ -141,6 +141,7 @@ func (c *Command) init() { }) f.BoolVar(&flag.BoolVar{ Name: flagNameVerbose, + Aliases: []string{"v"}, Target: &c.flagVerbose, Default: defaultVerbose, Usage: "Output verbose logs from the install command to understand status of resources being installed.", From 373e08332d4c66fe7e7dcf91e690aa1f0c5c8ff8 Mon Sep 17 00:00:00 2001 From: David Yu Date: Thu, 28 Oct 2021 11:43:56 -0700 Subject: [PATCH 4/6] small comment change --- cli/cmd/install/install.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/cmd/install/install.go b/cli/cmd/install/install.go index 98a2a8befa..57020900a1 100644 --- a/cli/cmd/install/install.go +++ b/cli/cmd/install/install.go @@ -208,7 +208,7 @@ func (c *Command) Run(args []string) int { // 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 + // 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()) } From 3fa9964a01b64b478f69c593cf8046fafac4863a Mon Sep 17 00:00:00 2001 From: David Yu Date: Thu, 28 Oct 2021 11:48:34 -0700 Subject: [PATCH 5/6] adding changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a224794a64..57806e9c32 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)] ## 0.35.0 (October 19, 2021) From 4e3518356c2b5b1ead8bbb5d37f22b941d8f7ae8 Mon Sep 17 00:00:00 2001 From: David Yu Date: Thu, 28 Oct 2021 13:00:15 -0700 Subject: [PATCH 6/6] Update cli/cmd/install/install.go Co-authored-by: Thomas Eckert --- cli/cmd/install/install.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/cmd/install/install.go b/cli/cmd/install/install.go index c4a8ffc8b6..689fbbcc3e 100644 --- a/cli/cmd/install/install.go +++ b/cli/cmd/install/install.go @@ -144,7 +144,7 @@ func (c *Command) init() { Aliases: []string{"v"}, Target: &c.flagVerbose, Default: defaultVerbose, - Usage: "Output verbose logs from the install command to understand status of resources being installed.", + Usage: "Output verbose logs from the install command with the status of resources being installed.", }) f.BoolVar(&flag.BoolVar{ Name: flagNameWait,