@@ -3,8 +3,10 @@ package runner
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "io"
6
7
"reflect"
7
8
9
+ "github.com/hashicorp/terraform-exec/tfexec"
8
10
infrav1 "github.com/weaveworks/tf-controller/api/v1alpha2"
9
11
corev1 "k8s.io/api/core/v1"
10
12
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -13,6 +15,18 @@ import (
13
15
ctrl "sigs.k8s.io/controller-runtime"
14
16
)
15
17
18
+ func (r * TerraformRunnerServer ) tfOutput (ctx context.Context , opts ... tfexec.OutputOption ) (map [string ]tfexec.OutputMeta , error ) {
19
+ log := ctrl .LoggerFrom (ctx , "instance-id" , r .InstanceID ).WithName (loggerName )
20
+
21
+ // This is the only place where we disable the logger
22
+ r .tf .SetStdout (io .Discard )
23
+ r .tf .SetStderr (io .Discard )
24
+
25
+ defer r .initLogger (log )
26
+
27
+ return r .tf .Output (ctx , opts ... )
28
+ }
29
+
16
30
func (r * TerraformRunnerServer ) Output (ctx context.Context , req * OutputRequest ) (* OutputReply , error ) {
17
31
log := ctrl .LoggerFrom (ctx , "instance-id" , r .InstanceID ).WithName (loggerName )
18
32
log .Info ("creating outputs" )
@@ -22,7 +36,7 @@ func (r *TerraformRunnerServer) Output(ctx context.Context, req *OutputRequest)
22
36
return nil , err
23
37
}
24
38
25
- outputs , err := r .tf . Output (ctx )
39
+ outputs , err := r .tfOutput (ctx )
26
40
if err != nil {
27
41
log .Error (err , "unable to get outputs" )
28
42
return nil , err
0 commit comments