diff --git a/cmd/provider/main.go b/cmd/provider/main.go index dc3e5a84..d24e03bc 100644 --- a/cmd/provider/main.go +++ b/cmd/provider/main.go @@ -7,6 +7,8 @@ package main import ( "context" "fmt" + "io" + "log" "os" "path/filepath" "time" @@ -64,9 +66,11 @@ func main() { ) kingpin.MustParse(app.Parse(os.Args[1:])) + log.Default().SetOutput(io.Discard) + ctrl.SetLogger(zap.New(zap.WriteTo(io.Discard))) zl := zap.New(zap.UseDevMode(*debug)) - log := logging.NewLogrLogger(zl.WithName("provider-azuread")) + logr := logging.NewLogrLogger(zl.WithName("provider-azuread")) if *debug { // The controller-runtime runs with a no-op logger by default. It is // *very* verbose even at info level, so we only provide it a real @@ -76,7 +80,7 @@ func main() { // currently, we configure the jitter to be the 5% of the poll interval pollJitter := time.Duration(float64(*pollInterval) * 0.05) - log.Debug("Starting", "sync-period", syncPeriod.String(), + logr.Debug("Starting", "sync-period", syncPeriod.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -100,32 +104,30 @@ func main() { kingpin.FatalIfError(err, "Cannot initialize the provider configuration") o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, - Provider: provider, - // use the following WorkspaceStoreOption to enable the shared gRPC mode - // terraform.WithProviderRunner(terraform.NewSharedProvider(log, os.Getenv("TERRAFORM_NATIVE_PROVIDER_PATH"), terraform.WithNativeProviderArgs("-debuggable"))) + Provider: provider, SetupFn: clients.TerraformSetupBuilder(provider.TerraformProvider), PollJitter: pollJitter, - OperationTrackerStore: tjcontroller.NewOperationStore(log), + OperationTrackerStore: tjcontroller.NewOperationStore(logr), } if *enableManagementPolicies { o.Features.Enable(features.EnableBetaManagementPolicies) - log.Info("Beta feature enabled", "flag", features.EnableBetaManagementPolicies) + logr.Info("Beta feature enabled", "flag", features.EnableBetaManagementPolicies) } if *enableExternalSecretStores { o.SecretStoreConfigGVK = &v1alpha1.StoreConfigGroupVersionKind - log.Info("Alpha feature enabled", "flag", features.EnableAlphaExternalSecretStores) + logr.Info("Alpha feature enabled", "flag", features.EnableAlphaExternalSecretStores) o.ESSOptions = &tjcontroller.ESSOptions{} if *essTLSCertsPath != "" { - log.Info("ESS TLS certificates path is set. Loading mTLS configuration.") + logr.Info("ESS TLS certificates path is set. Loading mTLS configuration.") tCfg, err := certificates.LoadMTLSConfig(filepath.Join(*essTLSCertsPath, "ca.crt"), filepath.Join(*essTLSCertsPath, "tls.crt"), filepath.Join(*essTLSCertsPath, "tls.key"), false) kingpin.FatalIfError(err, "Cannot load ESS TLS config.")