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

add possibility to setup a custom logger for kubectl configuration #1384

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lahabana
Copy link
Contributor

@lahabana lahabana commented Jan 9, 2024

Description

Fixes #1383.

This enables users to not log messages like: "Configuring Kubernetes client using config file"

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Added option ConfigLogger in KubectlOptions to specify a custom logger for configuration

Migration Guide

@lahabana
Copy link
Contributor Author

@denis256 any chance to get that in?

@@ -15,6 +15,8 @@ type KubectlOptions struct {
InClusterAuth bool
RestConfig *rest.Config
Logger *logger.Logger
// ConfigLogger is useful to set a different logger when configuring kubectl with a config. This can significantly reduce verbosity of tests
ConfigLogger *logger.Logger
Copy link
Member

Choose a reason for hiding this comment

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

Hm, what will happen if the logger will not be provided?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logger falls back to the Default logger if it's nil. This also enables backward compatibility

// methods can be called on (typed) nil pointers. In this case, use the Default function to log. This enables the
// caller to do `var l *Logger` and then use the logger already.
if l == nil || l.l == nil {
Default.Logf(t, format, args...)
return
}
l.l.Logf(t, format, args...)

@lahabana
Copy link
Contributor Author

@denis256 sorry I didn't notice you commented on the PR.

This enables users to not log messages like: "Configuring Kubernetes
client using config file"

Fix gruntwork-io#1383

Signed-off-by: Charly Molter <charly.molter@konghq.com>
@lahabana
Copy link
Contributor Author

@denis256 friendly ping on this :) It would greatly help our test logs to be a lot more readable :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reduce logging when configuring kubectl
2 participants