From f52242e7fac7e0d5695c5a6b4ea97eb3d5f16dba Mon Sep 17 00:00:00 2001 From: Anne Macedo Date: Mon, 24 Jul 2023 09:38:49 -0300 Subject: [PATCH] adds custom logger to kubectl options This commit adds the custom logging facility to kubectl options and to the Kubectl Run with output that can be used to suppress stdout from Kubectl run if needed. The logging facility was introduced on #510 but it missed kubectl options. Fixes #358 since @blame19 recalled that the behavior was missing on the k8s module. Signed-off-by: Anne Macedo --- modules/k8s/kubectl.go | 1 + modules/k8s/kubectl_options.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/modules/k8s/kubectl.go b/modules/k8s/kubectl.go index 1aeca2eb9..9ed5601e2 100644 --- a/modules/k8s/kubectl.go +++ b/modules/k8s/kubectl.go @@ -40,6 +40,7 @@ func RunKubectlAndGetOutputE(t testing.TestingT, options *KubectlOptions, args . Command: "kubectl", Args: cmdArgs, Env: options.Env, + Logger: options.Logger, } return shell.RunCommandAndGetOutputE(t, command) } diff --git a/modules/k8s/kubectl_options.go b/modules/k8s/kubectl_options.go index 693f63159..afcb60241 100644 --- a/modules/k8s/kubectl_options.go +++ b/modules/k8s/kubectl_options.go @@ -1,6 +1,7 @@ package k8s import ( + "github.com/gruntwork-io/terratest/modules/logger" "github.com/gruntwork-io/terratest/modules/testing" ) @@ -11,6 +12,7 @@ type KubectlOptions struct { Namespace string Env map[string]string InClusterAuth bool + Logger *logger.Logger } // NewKubectlOptions will return a pointer to new instance of KubectlOptions with the configured options