diff --git a/cmd/provider/main.go b/cmd/provider/main.go index 6bb9cfe..4fcc5a1 100644 --- a/cmd/provider/main.go +++ b/cmd/provider/main.go @@ -66,7 +66,7 @@ func main() { ) kingpin.MustParse(app.Parse(os.Args[1:])) - zl := zap.New(zap.UseDevMode(*debug), UseJSONencoder()) + zl := zap.New(zap.UseDevMode(*debug), UseISO8601()) log := logging.NewLogrLogger(zl.WithName("provider-terraform")) if *debug { // The controller-runtime runs with a no-op logger by default. It is @@ -150,11 +150,9 @@ func main() { kingpin.FatalIfError(mgr.Start(ctrl.SetupSignalHandler()), "Cannot start controller manager") } -// UseJSONencoder sets the logger to use json format for log records -func UseJSONencoder() zap.Opts { +// UseISO8601 sets the logger to use ISO8601 timestamp format +func UseISO8601() zap.Opts { return func(o *zap.Options) { - encoderConfig := zapuber.NewProductionEncoderConfig() - encoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder - o.Encoder = zapcore.NewJSONEncoder(encoderConfig) + o.TimeEncoder = zapcore.ISO8601TimeEncoder } } diff --git a/examples/workspace-random-generator.yaml b/examples/workspace-random-generator.yaml index 77bac11..696d3d9 100644 --- a/examples/workspace-random-generator.yaml +++ b/examples/workspace-random-generator.yaml @@ -1,7 +1,7 @@ apiVersion: tf.upbound.io/v1beta1 kind: Workspace metadata: - name: example-random-generator + name: example-random-generator-no-logging annotations: meta.upbound.io/example-id: tf/v1beta1/workspace # The terraform workspace will be named 'random'. If you omit this diff --git a/internal/controller/workspace/workspace.go b/internal/controller/workspace/workspace.go index 3ffc87a..7993d70 100644 --- a/internal/controller/workspace/workspace.go +++ b/internal/controller/workspace/workspace.go @@ -319,8 +319,8 @@ func (c *connector) Connect(ctx context.Context, mg resource.Managed) (managed.E } envs[idx] = strings.Join([]string{env.Name, runtimeVal}, "=") } - - tf := c.terraform(dir, *pc.Spec.PluginCache, cr.Spec.ForProvider.EnableTerraformCLILogging, l, envs...) + + tf := c.terraform(dir, *pc.Spec.PluginCache, cr.Spec.EnableLogging, c.logger, envs...) if cr.Status.AtProvider.Checksum != "" { checksum, err := tf.GenerateChecksum(ctx) if err != nil { diff --git a/internal/terraform/terraform.go b/internal/terraform/terraform.go index 1077ace..5f7834c 100644 --- a/internal/terraform/terraform.go +++ b/internal/terraform/terraform.go @@ -32,9 +32,10 @@ import ( "sort" "strconv" "strings" - "sync" "syscall" + "sync" + "github.com/crossplane/crossplane-runtime/pkg/logging" "github.com/pkg/errors" )