@@ -3,8 +3,10 @@ package runner
33import (
44 "context"
55 "fmt"
6+ "io"
67 "reflect"
78
9+ "github.com/hashicorp/terraform-exec/tfexec"
810 infrav1 "github.com/weaveworks/tf-controller/api/v1alpha2"
911 corev1 "k8s.io/api/core/v1"
1012 apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -13,6 +15,18 @@ import (
1315 ctrl "sigs.k8s.io/controller-runtime"
1416)
1517
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+
1630func (r * TerraformRunnerServer ) Output (ctx context.Context , req * OutputRequest ) (* OutputReply , error ) {
1731 log := ctrl .LoggerFrom (ctx , "instance-id" , r .InstanceID ).WithName (loggerName )
1832 log .Info ("creating outputs" )
@@ -22,7 +36,7 @@ func (r *TerraformRunnerServer) Output(ctx context.Context, req *OutputRequest)
2236 return nil , err
2337 }
2438
25- outputs , err := r .tf . Output (ctx )
39+ outputs , err := r .tfOutput (ctx )
2640 if err != nil {
2741 log .Error (err , "unable to get outputs" )
2842 return nil , err
0 commit comments