diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index c77b21ef0c..f7ade82dd7 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -12,4 +12,4 @@ on: jobs: backport: - uses: upbound/uptest/.github/workflows/provider-backport.yml@main + uses: upbound/uptest/.github/workflows/provider-backport.yml@standard-runners diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7bd469415..5b53f0e751 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,9 +10,9 @@ on: jobs: ci: - uses: upbound/uptest/.github/workflows/provider-ci.yml@main + uses: upbound/uptest/.github/workflows/provider-ci.yml@standard-runners with: - go-version: 1.21 + go-version: "1.21" cleanup-disk: true secrets: UPBOUND_MARKETPLACE_PUSH_ROBOT_USR: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} diff --git a/.github/workflows/commands.yml b/.github/workflows/commands.yml index cbbd0db78f..5564ecee22 100644 --- a/.github/workflows/commands.yml +++ b/.github/workflows/commands.yml @@ -4,4 +4,4 @@ on: issue_comment jobs: comment-commands: - uses: upbound/uptest/.github/workflows/provider-commands.yml@main + uses: upbound/uptest/.github/workflows/provider-commands.yml@standard-runners diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 6792312404..a7b10fbdb9 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -6,9 +6,10 @@ on: jobs: e2e: - uses: upbound/uptest/.github/workflows/pr-comment-trigger.yml@main + uses: upbound/uptest/.github/workflows/pr-comment-trigger.yml@standard-runners with: go-version: 1.21 + cleanup-disk: true secrets: UPTEST_CLOUD_CREDENTIALS: ${{ secrets.UPTEST_CLOUD_CREDENTIALS }} UPTEST_DATASOURCE: ${{ secrets.UPTEST_DATASOURCE }} diff --git a/.github/workflows/issue-triage.yml b/.github/workflows/issue-triage.yml index 3ace073495..bfa7000f24 100644 --- a/.github/workflows/issue-triage.yml +++ b/.github/workflows/issue-triage.yml @@ -8,6 +8,6 @@ on: jobs: community-issue-triage: - uses: upbound/uptest/.github/workflows/issue-triage.yml@main + uses: upbound/uptest/.github/workflows/issue-triage.yml@standard-runners secrets: UPBOUND_BOT_GITHUB_TOKEN: ${{ secrets.UPBOUND_COMMUNITY_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/native-provider-bump.yml b/.github/workflows/native-provider-bump.yml index 2420436c30..6444718a67 100644 --- a/.github/workflows/native-provider-bump.yml +++ b/.github/workflows/native-provider-bump.yml @@ -5,7 +5,7 @@ on: jobs: open-bump-pr: - uses: upbound/uptest/.github/workflows/native-provider-bump.yml@main + uses: upbound/uptest/.github/workflows/native-provider-bump.yml@standard-runners with: provider-source: hashicorp/aws go-version: 1.21 diff --git a/.github/workflows/publish-service-artifacts.yml b/.github/workflows/publish-service-artifacts.yml index 0b7fd8b3b8..dfc713e628 100644 --- a/.github/workflows/publish-service-artifacts.yml +++ b/.github/workflows/publish-service-artifacts.yml @@ -30,7 +30,7 @@ on: jobs: publish-service-artifacts: - uses: upbound/uptest/.github/workflows/provider-publish-service-artifacts.yml@main + uses: upbound/uptest/.github/workflows/provider-publish-service-artifacts.yml@standard-runners with: subpackages: ${{ github.event.inputs.subpackages }} size: ${{ github.event.inputs.size }} @@ -39,6 +39,7 @@ jobs: branch_name: ${{ github.event.inputs.branch_name }} version: ${{ github.event.inputs.version }} go-version: 1.21 + cleanup-disk: true secrets: UPBOUND_MARKETPLACE_PUSH_ROBOT_USR: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR_RC }} UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW_RC }} diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml index 3b0963a7e4..971ffc2423 100644 --- a/.github/workflows/scan.yml +++ b/.github/workflows/scan.yml @@ -40,7 +40,7 @@ jobs: echo "We are going to scan the last ${supported_releases_number} releases for: ${images}" scan: - uses: upbound/uptest/.github/workflows/scan.yml@main + uses: upbound/uptest/.github/workflows/scan.yml@standard-runners needs: - setup-vars with: diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml index 2a93895ad8..086c6f4dcd 100644 --- a/.github/workflows/tag.yaml +++ b/.github/workflows/tag.yaml @@ -12,7 +12,7 @@ on: jobs: tag: - uses: upbound/uptest/.github/workflows/provider-tag.yml@main + uses: upbound/uptest/.github/workflows/provider-tag.yml@standard-runners with: version: ${{ github.event.inputs.version }} message: ${{ github.event.inputs.message }} diff --git a/.github/workflows/updoc.yml b/.github/workflows/updoc.yml index 7674953490..a8487b7132 100644 --- a/.github/workflows/updoc.yml +++ b/.github/workflows/updoc.yml @@ -5,7 +5,7 @@ on: jobs: publish-docs: - uses: upbound/uptest/.github/workflows/provider-updoc.yml@main + uses: upbound/uptest/.github/workflows/provider-updoc.yml@standard-runners with: providers: "monolith config" go-version: 1.21 diff --git a/cmd/provider/accessanalyzer/zz_main.go b/cmd/provider/accessanalyzer/zz_main.go index 52d230ca57..1d6ab6d106 100644 --- a/cmd/provider/accessanalyzer/zz_main.go +++ b/cmd/provider/accessanalyzer/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/account/zz_main.go b/cmd/provider/account/zz_main.go index 5302358865..3ddcf906f6 100644 --- a/cmd/provider/account/zz_main.go +++ b/cmd/provider/account/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/acm/zz_main.go b/cmd/provider/acm/zz_main.go index 7516ae215b..250c253aa9 100644 --- a/cmd/provider/acm/zz_main.go +++ b/cmd/provider/acm/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/acmpca/zz_main.go b/cmd/provider/acmpca/zz_main.go index c04fb793e6..f916f9cd7e 100644 --- a/cmd/provider/acmpca/zz_main.go +++ b/cmd/provider/acmpca/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/amp/zz_main.go b/cmd/provider/amp/zz_main.go index dfc7308af8..0179ef1ea1 100644 --- a/cmd/provider/amp/zz_main.go +++ b/cmd/provider/amp/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/amplify/zz_main.go b/cmd/provider/amplify/zz_main.go index 22c5ea2701..785d240416 100644 --- a/cmd/provider/amplify/zz_main.go +++ b/cmd/provider/amplify/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/apigateway/zz_main.go b/cmd/provider/apigateway/zz_main.go index 259efd8218..56e1afdcf0 100644 --- a/cmd/provider/apigateway/zz_main.go +++ b/cmd/provider/apigateway/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/apigatewayv2/zz_main.go b/cmd/provider/apigatewayv2/zz_main.go index d37b47a556..1602c8b604 100644 --- a/cmd/provider/apigatewayv2/zz_main.go +++ b/cmd/provider/apigatewayv2/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/appautoscaling/zz_main.go b/cmd/provider/appautoscaling/zz_main.go index 878a02b702..a82d513849 100644 --- a/cmd/provider/appautoscaling/zz_main.go +++ b/cmd/provider/appautoscaling/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/appconfig/zz_main.go b/cmd/provider/appconfig/zz_main.go index e261ce64a5..41621e17e9 100644 --- a/cmd/provider/appconfig/zz_main.go +++ b/cmd/provider/appconfig/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/appflow/zz_main.go b/cmd/provider/appflow/zz_main.go index b993754f11..728c6f3e88 100644 --- a/cmd/provider/appflow/zz_main.go +++ b/cmd/provider/appflow/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/appintegrations/zz_main.go b/cmd/provider/appintegrations/zz_main.go index a39b0f8544..16bbf99df2 100644 --- a/cmd/provider/appintegrations/zz_main.go +++ b/cmd/provider/appintegrations/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/applicationinsights/zz_main.go b/cmd/provider/applicationinsights/zz_main.go index da7096803d..7ea922ba7e 100644 --- a/cmd/provider/applicationinsights/zz_main.go +++ b/cmd/provider/applicationinsights/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/appmesh/zz_main.go b/cmd/provider/appmesh/zz_main.go index 4716d739d4..803ac697ed 100644 --- a/cmd/provider/appmesh/zz_main.go +++ b/cmd/provider/appmesh/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/apprunner/zz_main.go b/cmd/provider/apprunner/zz_main.go index 62675123b7..43d1af30dc 100644 --- a/cmd/provider/apprunner/zz_main.go +++ b/cmd/provider/apprunner/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/appstream/zz_main.go b/cmd/provider/appstream/zz_main.go index d19f35f660..761caf0f77 100644 --- a/cmd/provider/appstream/zz_main.go +++ b/cmd/provider/appstream/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/appsync/zz_main.go b/cmd/provider/appsync/zz_main.go index 283948a6b2..d2d81cf6d7 100644 --- a/cmd/provider/appsync/zz_main.go +++ b/cmd/provider/appsync/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/athena/zz_main.go b/cmd/provider/athena/zz_main.go index ec6a6270bc..79ae6c6566 100644 --- a/cmd/provider/athena/zz_main.go +++ b/cmd/provider/athena/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/autoscaling/zz_main.go b/cmd/provider/autoscaling/zz_main.go index 4b349b1c23..e5fa680ec8 100644 --- a/cmd/provider/autoscaling/zz_main.go +++ b/cmd/provider/autoscaling/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/autoscalingplans/zz_main.go b/cmd/provider/autoscalingplans/zz_main.go index 7bbd876c9b..b8f121d6a0 100644 --- a/cmd/provider/autoscalingplans/zz_main.go +++ b/cmd/provider/autoscalingplans/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/backup/zz_main.go b/cmd/provider/backup/zz_main.go index 3338cc000a..ecbfe9fc86 100644 --- a/cmd/provider/backup/zz_main.go +++ b/cmd/provider/backup/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/batch/zz_main.go b/cmd/provider/batch/zz_main.go index 1036689228..445a81f34e 100644 --- a/cmd/provider/batch/zz_main.go +++ b/cmd/provider/batch/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/budgets/zz_main.go b/cmd/provider/budgets/zz_main.go index 80c5154f87..144e2ae20c 100644 --- a/cmd/provider/budgets/zz_main.go +++ b/cmd/provider/budgets/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/ce/zz_main.go b/cmd/provider/ce/zz_main.go index 6b8d471bd0..ebad609152 100644 --- a/cmd/provider/ce/zz_main.go +++ b/cmd/provider/ce/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/chime/zz_main.go b/cmd/provider/chime/zz_main.go index fb92d4efa1..8428de241f 100644 --- a/cmd/provider/chime/zz_main.go +++ b/cmd/provider/chime/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/cloud9/zz_main.go b/cmd/provider/cloud9/zz_main.go index b2fc9cc1d9..9171e3d60f 100644 --- a/cmd/provider/cloud9/zz_main.go +++ b/cmd/provider/cloud9/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/cloudcontrol/zz_main.go b/cmd/provider/cloudcontrol/zz_main.go index 9ff5e710e0..b5d0fb6ba7 100644 --- a/cmd/provider/cloudcontrol/zz_main.go +++ b/cmd/provider/cloudcontrol/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/cloudformation/zz_main.go b/cmd/provider/cloudformation/zz_main.go index ab3859da0d..1a97dbae9f 100644 --- a/cmd/provider/cloudformation/zz_main.go +++ b/cmd/provider/cloudformation/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/cloudfront/zz_main.go b/cmd/provider/cloudfront/zz_main.go index db47f17d5a..6e2f5a7039 100644 --- a/cmd/provider/cloudfront/zz_main.go +++ b/cmd/provider/cloudfront/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/cloudsearch/zz_main.go b/cmd/provider/cloudsearch/zz_main.go index c79a2fc45c..d6a4356197 100644 --- a/cmd/provider/cloudsearch/zz_main.go +++ b/cmd/provider/cloudsearch/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/cloudtrail/zz_main.go b/cmd/provider/cloudtrail/zz_main.go index 00003e77dd..8e4b38d62e 100644 --- a/cmd/provider/cloudtrail/zz_main.go +++ b/cmd/provider/cloudtrail/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/cloudwatch/zz_main.go b/cmd/provider/cloudwatch/zz_main.go index 03789a4ed9..3d58b80f0f 100644 --- a/cmd/provider/cloudwatch/zz_main.go +++ b/cmd/provider/cloudwatch/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/cloudwatchevents/zz_main.go b/cmd/provider/cloudwatchevents/zz_main.go index cd4cbf82ad..ef1598cfbe 100644 --- a/cmd/provider/cloudwatchevents/zz_main.go +++ b/cmd/provider/cloudwatchevents/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/cloudwatchlogs/zz_main.go b/cmd/provider/cloudwatchlogs/zz_main.go index 2ba4347e6d..d1bbc66732 100644 --- a/cmd/provider/cloudwatchlogs/zz_main.go +++ b/cmd/provider/cloudwatchlogs/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/codecommit/zz_main.go b/cmd/provider/codecommit/zz_main.go index d715213e87..01a400b890 100644 --- a/cmd/provider/codecommit/zz_main.go +++ b/cmd/provider/codecommit/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/codepipeline/zz_main.go b/cmd/provider/codepipeline/zz_main.go index e6328c94da..c69232c6db 100644 --- a/cmd/provider/codepipeline/zz_main.go +++ b/cmd/provider/codepipeline/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/codestarconnections/zz_main.go b/cmd/provider/codestarconnections/zz_main.go index 5f48bff04d..7b8dec70f2 100644 --- a/cmd/provider/codestarconnections/zz_main.go +++ b/cmd/provider/codestarconnections/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/codestarnotifications/zz_main.go b/cmd/provider/codestarnotifications/zz_main.go index 183a878361..aa9b9aa7c9 100644 --- a/cmd/provider/codestarnotifications/zz_main.go +++ b/cmd/provider/codestarnotifications/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/cognitoidentity/zz_main.go b/cmd/provider/cognitoidentity/zz_main.go index a0cf5551d7..a209370577 100644 --- a/cmd/provider/cognitoidentity/zz_main.go +++ b/cmd/provider/cognitoidentity/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/cognitoidp/zz_main.go b/cmd/provider/cognitoidp/zz_main.go index 6751cafbd4..f4cd66c712 100644 --- a/cmd/provider/cognitoidp/zz_main.go +++ b/cmd/provider/cognitoidp/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/config/zz_main.go b/cmd/provider/config/zz_main.go index 956498c959..962b0a7ae6 100644 --- a/cmd/provider/config/zz_main.go +++ b/cmd/provider/config/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/configservice/zz_main.go b/cmd/provider/configservice/zz_main.go index 900a97657b..5a4d74a3c0 100644 --- a/cmd/provider/configservice/zz_main.go +++ b/cmd/provider/configservice/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/connect/zz_main.go b/cmd/provider/connect/zz_main.go index 1d3c34677b..22cc212298 100644 --- a/cmd/provider/connect/zz_main.go +++ b/cmd/provider/connect/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/cur/zz_main.go b/cmd/provider/cur/zz_main.go index 6e3ad6630a..529cced8fa 100644 --- a/cmd/provider/cur/zz_main.go +++ b/cmd/provider/cur/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/dataexchange/zz_main.go b/cmd/provider/dataexchange/zz_main.go index 96c10617a9..897c3ce0d7 100644 --- a/cmd/provider/dataexchange/zz_main.go +++ b/cmd/provider/dataexchange/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/datapipeline/zz_main.go b/cmd/provider/datapipeline/zz_main.go index eda59afa42..9a4b3f7ed2 100644 --- a/cmd/provider/datapipeline/zz_main.go +++ b/cmd/provider/datapipeline/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/datasync/zz_main.go b/cmd/provider/datasync/zz_main.go index 743a31293e..024d80aa67 100644 --- a/cmd/provider/datasync/zz_main.go +++ b/cmd/provider/datasync/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/dax/zz_main.go b/cmd/provider/dax/zz_main.go index 85e0d779f1..a301ac2ff3 100644 --- a/cmd/provider/dax/zz_main.go +++ b/cmd/provider/dax/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/deploy/zz_main.go b/cmd/provider/deploy/zz_main.go index 07d934d090..8e6bd4c84b 100644 --- a/cmd/provider/deploy/zz_main.go +++ b/cmd/provider/deploy/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/detective/zz_main.go b/cmd/provider/detective/zz_main.go index bf815fb223..fa3cdfa292 100644 --- a/cmd/provider/detective/zz_main.go +++ b/cmd/provider/detective/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/devicefarm/zz_main.go b/cmd/provider/devicefarm/zz_main.go index 37242ad949..ce2610cd48 100644 --- a/cmd/provider/devicefarm/zz_main.go +++ b/cmd/provider/devicefarm/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/directconnect/zz_main.go b/cmd/provider/directconnect/zz_main.go index c378005df6..054860659d 100644 --- a/cmd/provider/directconnect/zz_main.go +++ b/cmd/provider/directconnect/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/dlm/zz_main.go b/cmd/provider/dlm/zz_main.go index ae9525083b..f3f7795348 100644 --- a/cmd/provider/dlm/zz_main.go +++ b/cmd/provider/dlm/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/dms/zz_main.go b/cmd/provider/dms/zz_main.go index f2c8ac7af5..a5b5c2f1f3 100644 --- a/cmd/provider/dms/zz_main.go +++ b/cmd/provider/dms/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/docdb/zz_main.go b/cmd/provider/docdb/zz_main.go index afbe2f0a67..706c0ea52d 100644 --- a/cmd/provider/docdb/zz_main.go +++ b/cmd/provider/docdb/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/ds/zz_main.go b/cmd/provider/ds/zz_main.go index d089095faf..816242d6b5 100644 --- a/cmd/provider/ds/zz_main.go +++ b/cmd/provider/ds/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/dynamodb/zz_main.go b/cmd/provider/dynamodb/zz_main.go index 8239829a54..af05926335 100644 --- a/cmd/provider/dynamodb/zz_main.go +++ b/cmd/provider/dynamodb/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/ec2/zz_main.go b/cmd/provider/ec2/zz_main.go index 9539e4f970..a586762fdc 100644 --- a/cmd/provider/ec2/zz_main.go +++ b/cmd/provider/ec2/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/ecr/zz_main.go b/cmd/provider/ecr/zz_main.go index e5fab75620..bfb412d0e1 100644 --- a/cmd/provider/ecr/zz_main.go +++ b/cmd/provider/ecr/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/ecrpublic/zz_main.go b/cmd/provider/ecrpublic/zz_main.go index e3d2b437b5..2991a2dd4e 100644 --- a/cmd/provider/ecrpublic/zz_main.go +++ b/cmd/provider/ecrpublic/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/ecs/zz_main.go b/cmd/provider/ecs/zz_main.go index 8f77f38b51..190fef70e8 100644 --- a/cmd/provider/ecs/zz_main.go +++ b/cmd/provider/ecs/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/efs/zz_main.go b/cmd/provider/efs/zz_main.go index f4c9e90e11..000e5ce350 100644 --- a/cmd/provider/efs/zz_main.go +++ b/cmd/provider/efs/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/eks/zz_main.go b/cmd/provider/eks/zz_main.go index 2cc803badb..7c7244e116 100644 --- a/cmd/provider/eks/zz_main.go +++ b/cmd/provider/eks/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/elasticache/zz_main.go b/cmd/provider/elasticache/zz_main.go index 005bac0f63..83a3b46e5a 100644 --- a/cmd/provider/elasticache/zz_main.go +++ b/cmd/provider/elasticache/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/elasticbeanstalk/zz_main.go b/cmd/provider/elasticbeanstalk/zz_main.go index 70dfb36c4a..9e9464d207 100644 --- a/cmd/provider/elasticbeanstalk/zz_main.go +++ b/cmd/provider/elasticbeanstalk/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/elasticsearch/zz_main.go b/cmd/provider/elasticsearch/zz_main.go index fb46e52c67..f0203e3680 100644 --- a/cmd/provider/elasticsearch/zz_main.go +++ b/cmd/provider/elasticsearch/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/elastictranscoder/zz_main.go b/cmd/provider/elastictranscoder/zz_main.go index be309860ee..b3a5f0bee9 100644 --- a/cmd/provider/elastictranscoder/zz_main.go +++ b/cmd/provider/elastictranscoder/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/elb/zz_main.go b/cmd/provider/elb/zz_main.go index 3129b7df69..36150a95e0 100644 --- a/cmd/provider/elb/zz_main.go +++ b/cmd/provider/elb/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/elbv2/zz_main.go b/cmd/provider/elbv2/zz_main.go index 5230b80f6e..7069a74867 100644 --- a/cmd/provider/elbv2/zz_main.go +++ b/cmd/provider/elbv2/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/emr/zz_main.go b/cmd/provider/emr/zz_main.go index 931c1e7304..b2f07f55da 100644 --- a/cmd/provider/emr/zz_main.go +++ b/cmd/provider/emr/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/emrserverless/zz_main.go b/cmd/provider/emrserverless/zz_main.go index 74832ae576..bf83c98201 100644 --- a/cmd/provider/emrserverless/zz_main.go +++ b/cmd/provider/emrserverless/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/evidently/zz_main.go b/cmd/provider/evidently/zz_main.go index b2408f9cd1..a6696e942f 100644 --- a/cmd/provider/evidently/zz_main.go +++ b/cmd/provider/evidently/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/firehose/zz_main.go b/cmd/provider/firehose/zz_main.go index d39e9547fa..6ce5ef31fc 100644 --- a/cmd/provider/firehose/zz_main.go +++ b/cmd/provider/firehose/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/fis/zz_main.go b/cmd/provider/fis/zz_main.go index 4a13a096da..357a43a055 100644 --- a/cmd/provider/fis/zz_main.go +++ b/cmd/provider/fis/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/fsx/zz_main.go b/cmd/provider/fsx/zz_main.go index f6782cd065..6daa591418 100644 --- a/cmd/provider/fsx/zz_main.go +++ b/cmd/provider/fsx/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/gamelift/zz_main.go b/cmd/provider/gamelift/zz_main.go index b19f82c08a..874ee29bdd 100644 --- a/cmd/provider/gamelift/zz_main.go +++ b/cmd/provider/gamelift/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/glacier/zz_main.go b/cmd/provider/glacier/zz_main.go index 893f54f636..459d443179 100644 --- a/cmd/provider/glacier/zz_main.go +++ b/cmd/provider/glacier/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/globalaccelerator/zz_main.go b/cmd/provider/globalaccelerator/zz_main.go index 4eabcc5d17..afa418bd62 100644 --- a/cmd/provider/globalaccelerator/zz_main.go +++ b/cmd/provider/globalaccelerator/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/glue/zz_main.go b/cmd/provider/glue/zz_main.go index 5d98ccf503..7833f8420d 100644 --- a/cmd/provider/glue/zz_main.go +++ b/cmd/provider/glue/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/grafana/zz_main.go b/cmd/provider/grafana/zz_main.go index 5726adec19..65a48b1e75 100644 --- a/cmd/provider/grafana/zz_main.go +++ b/cmd/provider/grafana/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/guardduty/zz_main.go b/cmd/provider/guardduty/zz_main.go index f18384f8b3..cda67f5d22 100644 --- a/cmd/provider/guardduty/zz_main.go +++ b/cmd/provider/guardduty/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/iam/zz_main.go b/cmd/provider/iam/zz_main.go index c853be6c85..baec9dd2fb 100644 --- a/cmd/provider/iam/zz_main.go +++ b/cmd/provider/iam/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/identitystore/zz_main.go b/cmd/provider/identitystore/zz_main.go index 4e52e1ab6d..f970ffde03 100644 --- a/cmd/provider/identitystore/zz_main.go +++ b/cmd/provider/identitystore/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/imagebuilder/zz_main.go b/cmd/provider/imagebuilder/zz_main.go index 81bf132b7e..b8d73cb51b 100644 --- a/cmd/provider/imagebuilder/zz_main.go +++ b/cmd/provider/imagebuilder/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/inspector/zz_main.go b/cmd/provider/inspector/zz_main.go index d65900250c..fdda46749e 100644 --- a/cmd/provider/inspector/zz_main.go +++ b/cmd/provider/inspector/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/inspector2/zz_main.go b/cmd/provider/inspector2/zz_main.go index 05afd88640..fcd8aa7ff9 100644 --- a/cmd/provider/inspector2/zz_main.go +++ b/cmd/provider/inspector2/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/iot/zz_main.go b/cmd/provider/iot/zz_main.go index 7677d5ad5a..f964454fa3 100644 --- a/cmd/provider/iot/zz_main.go +++ b/cmd/provider/iot/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/ivs/zz_main.go b/cmd/provider/ivs/zz_main.go index 9de2fbd3d5..427a60aff6 100644 --- a/cmd/provider/ivs/zz_main.go +++ b/cmd/provider/ivs/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/kafka/zz_main.go b/cmd/provider/kafka/zz_main.go index 3bd20fb74e..63a6a2eeca 100644 --- a/cmd/provider/kafka/zz_main.go +++ b/cmd/provider/kafka/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/kendra/zz_main.go b/cmd/provider/kendra/zz_main.go index 204a3e3185..4002cdfc0e 100644 --- a/cmd/provider/kendra/zz_main.go +++ b/cmd/provider/kendra/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/keyspaces/zz_main.go b/cmd/provider/keyspaces/zz_main.go index 08dcb3f689..f28c22a873 100644 --- a/cmd/provider/keyspaces/zz_main.go +++ b/cmd/provider/keyspaces/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/kinesis/zz_main.go b/cmd/provider/kinesis/zz_main.go index 746fabcabb..e6a1b8bdf5 100644 --- a/cmd/provider/kinesis/zz_main.go +++ b/cmd/provider/kinesis/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/kinesisanalytics/zz_main.go b/cmd/provider/kinesisanalytics/zz_main.go index abdcd2298c..c1fbaadaa7 100644 --- a/cmd/provider/kinesisanalytics/zz_main.go +++ b/cmd/provider/kinesisanalytics/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/kinesisanalyticsv2/zz_main.go b/cmd/provider/kinesisanalyticsv2/zz_main.go index da73371b0b..1bc7108535 100644 --- a/cmd/provider/kinesisanalyticsv2/zz_main.go +++ b/cmd/provider/kinesisanalyticsv2/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/kinesisvideo/zz_main.go b/cmd/provider/kinesisvideo/zz_main.go index da31d270bd..58f798f3eb 100644 --- a/cmd/provider/kinesisvideo/zz_main.go +++ b/cmd/provider/kinesisvideo/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/kms/zz_main.go b/cmd/provider/kms/zz_main.go index 61181d4fe3..771aacddb7 100644 --- a/cmd/provider/kms/zz_main.go +++ b/cmd/provider/kms/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/lakeformation/zz_main.go b/cmd/provider/lakeformation/zz_main.go index 86ee4e4482..5b6a5423d0 100644 --- a/cmd/provider/lakeformation/zz_main.go +++ b/cmd/provider/lakeformation/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/lambda/zz_main.go b/cmd/provider/lambda/zz_main.go index 36a19ca828..f4898674de 100644 --- a/cmd/provider/lambda/zz_main.go +++ b/cmd/provider/lambda/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/lexmodels/zz_main.go b/cmd/provider/lexmodels/zz_main.go index a8a7e84b7d..d627667b18 100644 --- a/cmd/provider/lexmodels/zz_main.go +++ b/cmd/provider/lexmodels/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/licensemanager/zz_main.go b/cmd/provider/licensemanager/zz_main.go index 1b46e486a8..0fbda0f106 100644 --- a/cmd/provider/licensemanager/zz_main.go +++ b/cmd/provider/licensemanager/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/lightsail/zz_main.go b/cmd/provider/lightsail/zz_main.go index 0f8bb97b5c..80ee1af709 100644 --- a/cmd/provider/lightsail/zz_main.go +++ b/cmd/provider/lightsail/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/location/zz_main.go b/cmd/provider/location/zz_main.go index c1f4ac71ef..cc79e8aa23 100644 --- a/cmd/provider/location/zz_main.go +++ b/cmd/provider/location/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/macie2/zz_main.go b/cmd/provider/macie2/zz_main.go index f639965bfd..63d04f4a9e 100644 --- a/cmd/provider/macie2/zz_main.go +++ b/cmd/provider/macie2/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/mediaconvert/zz_main.go b/cmd/provider/mediaconvert/zz_main.go index 8c38da7cde..023a21d920 100644 --- a/cmd/provider/mediaconvert/zz_main.go +++ b/cmd/provider/mediaconvert/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/medialive/zz_main.go b/cmd/provider/medialive/zz_main.go index 17107f61c8..5c5dfc3cf3 100644 --- a/cmd/provider/medialive/zz_main.go +++ b/cmd/provider/medialive/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/mediapackage/zz_main.go b/cmd/provider/mediapackage/zz_main.go index 680b1cde91..13b4598260 100644 --- a/cmd/provider/mediapackage/zz_main.go +++ b/cmd/provider/mediapackage/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/mediastore/zz_main.go b/cmd/provider/mediastore/zz_main.go index aa22273607..c3346aaf44 100644 --- a/cmd/provider/mediastore/zz_main.go +++ b/cmd/provider/mediastore/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/memorydb/zz_main.go b/cmd/provider/memorydb/zz_main.go index 7119b07c12..852465c484 100644 --- a/cmd/provider/memorydb/zz_main.go +++ b/cmd/provider/memorydb/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/monolith/zz_main.go b/cmd/provider/monolith/zz_main.go index e17b7191d4..b869cf8082 100644 --- a/cmd/provider/monolith/zz_main.go +++ b/cmd/provider/monolith/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/mq/zz_main.go b/cmd/provider/mq/zz_main.go index 3865edcef5..9bee854df5 100644 --- a/cmd/provider/mq/zz_main.go +++ b/cmd/provider/mq/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/neptune/zz_main.go b/cmd/provider/neptune/zz_main.go index b22798b87d..d56142ec06 100644 --- a/cmd/provider/neptune/zz_main.go +++ b/cmd/provider/neptune/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/networkfirewall/zz_main.go b/cmd/provider/networkfirewall/zz_main.go index 65fee01c0f..651c24c73a 100644 --- a/cmd/provider/networkfirewall/zz_main.go +++ b/cmd/provider/networkfirewall/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/networkmanager/zz_main.go b/cmd/provider/networkmanager/zz_main.go index f2935eebc0..7050772136 100644 --- a/cmd/provider/networkmanager/zz_main.go +++ b/cmd/provider/networkmanager/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/opensearch/zz_main.go b/cmd/provider/opensearch/zz_main.go index 5106f3437f..a09ba7d39e 100644 --- a/cmd/provider/opensearch/zz_main.go +++ b/cmd/provider/opensearch/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/opsworks/zz_main.go b/cmd/provider/opsworks/zz_main.go index 83c50eb23c..17e97d30e2 100644 --- a/cmd/provider/opsworks/zz_main.go +++ b/cmd/provider/opsworks/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/organizations/zz_main.go b/cmd/provider/organizations/zz_main.go index db5f953a50..7de5b46f9a 100644 --- a/cmd/provider/organizations/zz_main.go +++ b/cmd/provider/organizations/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/pinpoint/zz_main.go b/cmd/provider/pinpoint/zz_main.go index deb39a009e..4fd6a0b613 100644 --- a/cmd/provider/pinpoint/zz_main.go +++ b/cmd/provider/pinpoint/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/qldb/zz_main.go b/cmd/provider/qldb/zz_main.go index dc53416ccc..adc5bace8e 100644 --- a/cmd/provider/qldb/zz_main.go +++ b/cmd/provider/qldb/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/quicksight/zz_main.go b/cmd/provider/quicksight/zz_main.go index ad25a181a5..d7e725cd2c 100644 --- a/cmd/provider/quicksight/zz_main.go +++ b/cmd/provider/quicksight/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/ram/zz_main.go b/cmd/provider/ram/zz_main.go index b205c46757..33f104f532 100644 --- a/cmd/provider/ram/zz_main.go +++ b/cmd/provider/ram/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/rds/zz_main.go b/cmd/provider/rds/zz_main.go index 57ed6a3316..c7c918140f 100644 --- a/cmd/provider/rds/zz_main.go +++ b/cmd/provider/rds/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/redshift/zz_main.go b/cmd/provider/redshift/zz_main.go index 2c1f39f3f1..ef6a08b348 100644 --- a/cmd/provider/redshift/zz_main.go +++ b/cmd/provider/redshift/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/redshiftserverless/zz_main.go b/cmd/provider/redshiftserverless/zz_main.go index 26903222cc..0887dcf6d5 100644 --- a/cmd/provider/redshiftserverless/zz_main.go +++ b/cmd/provider/redshiftserverless/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/resourcegroups/zz_main.go b/cmd/provider/resourcegroups/zz_main.go index 7cdb2c8c54..b1fe57eb2e 100644 --- a/cmd/provider/resourcegroups/zz_main.go +++ b/cmd/provider/resourcegroups/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/rolesanywhere/zz_main.go b/cmd/provider/rolesanywhere/zz_main.go index 37146d900f..f96ce80ea8 100644 --- a/cmd/provider/rolesanywhere/zz_main.go +++ b/cmd/provider/rolesanywhere/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/route53/zz_main.go b/cmd/provider/route53/zz_main.go index 49efe8a686..fd995d3318 100644 --- a/cmd/provider/route53/zz_main.go +++ b/cmd/provider/route53/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/route53recoverycontrolconfig/zz_main.go b/cmd/provider/route53recoverycontrolconfig/zz_main.go index 8735029046..924c71c7be 100644 --- a/cmd/provider/route53recoverycontrolconfig/zz_main.go +++ b/cmd/provider/route53recoverycontrolconfig/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/route53recoveryreadiness/zz_main.go b/cmd/provider/route53recoveryreadiness/zz_main.go index 807e47a190..3d9c994541 100644 --- a/cmd/provider/route53recoveryreadiness/zz_main.go +++ b/cmd/provider/route53recoveryreadiness/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/route53resolver/zz_main.go b/cmd/provider/route53resolver/zz_main.go index 2e3e7ff657..d82755cd87 100644 --- a/cmd/provider/route53resolver/zz_main.go +++ b/cmd/provider/route53resolver/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/rum/zz_main.go b/cmd/provider/rum/zz_main.go index bdc4b78dc4..eb2c01e6c1 100644 --- a/cmd/provider/rum/zz_main.go +++ b/cmd/provider/rum/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/s3/zz_main.go b/cmd/provider/s3/zz_main.go index fddd54aefe..daf1ea3b24 100644 --- a/cmd/provider/s3/zz_main.go +++ b/cmd/provider/s3/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/s3control/zz_main.go b/cmd/provider/s3control/zz_main.go index 6f865b82d1..d3fd067b25 100644 --- a/cmd/provider/s3control/zz_main.go +++ b/cmd/provider/s3control/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/sagemaker/zz_main.go b/cmd/provider/sagemaker/zz_main.go index db502ac1cf..c295e85c64 100644 --- a/cmd/provider/sagemaker/zz_main.go +++ b/cmd/provider/sagemaker/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/scheduler/zz_main.go b/cmd/provider/scheduler/zz_main.go index 65e16efc7c..01450e63d3 100644 --- a/cmd/provider/scheduler/zz_main.go +++ b/cmd/provider/scheduler/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/schemas/zz_main.go b/cmd/provider/schemas/zz_main.go index 35e1d95b2b..76242e723f 100644 --- a/cmd/provider/schemas/zz_main.go +++ b/cmd/provider/schemas/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/secretsmanager/zz_main.go b/cmd/provider/secretsmanager/zz_main.go index 958f710b49..cfe727c4b9 100644 --- a/cmd/provider/secretsmanager/zz_main.go +++ b/cmd/provider/secretsmanager/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/securityhub/zz_main.go b/cmd/provider/securityhub/zz_main.go index 5879a90fb5..90beb542f6 100644 --- a/cmd/provider/securityhub/zz_main.go +++ b/cmd/provider/securityhub/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/serverlessrepo/zz_main.go b/cmd/provider/serverlessrepo/zz_main.go index 976b39a0bb..f42a5223b7 100644 --- a/cmd/provider/serverlessrepo/zz_main.go +++ b/cmd/provider/serverlessrepo/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/servicecatalog/zz_main.go b/cmd/provider/servicecatalog/zz_main.go index 206fef4ac9..47ec39db14 100644 --- a/cmd/provider/servicecatalog/zz_main.go +++ b/cmd/provider/servicecatalog/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/servicediscovery/zz_main.go b/cmd/provider/servicediscovery/zz_main.go index 8839e7e63f..bd829d59df 100644 --- a/cmd/provider/servicediscovery/zz_main.go +++ b/cmd/provider/servicediscovery/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/servicequotas/zz_main.go b/cmd/provider/servicequotas/zz_main.go index fe44d4a622..cd100eb2b2 100644 --- a/cmd/provider/servicequotas/zz_main.go +++ b/cmd/provider/servicequotas/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/ses/zz_main.go b/cmd/provider/ses/zz_main.go index 9abb5fb73b..29d53dd9f3 100644 --- a/cmd/provider/ses/zz_main.go +++ b/cmd/provider/ses/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/sesv2/zz_main.go b/cmd/provider/sesv2/zz_main.go index fc6934bdfa..cd43b6ff64 100644 --- a/cmd/provider/sesv2/zz_main.go +++ b/cmd/provider/sesv2/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/sfn/zz_main.go b/cmd/provider/sfn/zz_main.go index 6d5dacfa2f..285ab04a54 100644 --- a/cmd/provider/sfn/zz_main.go +++ b/cmd/provider/sfn/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/signer/zz_main.go b/cmd/provider/signer/zz_main.go index 528b17e904..f5bdb43ae1 100644 --- a/cmd/provider/signer/zz_main.go +++ b/cmd/provider/signer/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/simpledb/zz_main.go b/cmd/provider/simpledb/zz_main.go index f9634009ff..631ea4a668 100644 --- a/cmd/provider/simpledb/zz_main.go +++ b/cmd/provider/simpledb/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/sns/zz_main.go b/cmd/provider/sns/zz_main.go index bdd760012a..897552b3b8 100644 --- a/cmd/provider/sns/zz_main.go +++ b/cmd/provider/sns/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/sqs/zz_main.go b/cmd/provider/sqs/zz_main.go index 60490385b5..0828a90927 100644 --- a/cmd/provider/sqs/zz_main.go +++ b/cmd/provider/sqs/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/ssm/zz_main.go b/cmd/provider/ssm/zz_main.go index dcf525c2de..40c86742bb 100644 --- a/cmd/provider/ssm/zz_main.go +++ b/cmd/provider/ssm/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/ssoadmin/zz_main.go b/cmd/provider/ssoadmin/zz_main.go index 9cec0a3d05..cb8b55f348 100644 --- a/cmd/provider/ssoadmin/zz_main.go +++ b/cmd/provider/ssoadmin/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/swf/zz_main.go b/cmd/provider/swf/zz_main.go index f68119b76b..631005f35a 100644 --- a/cmd/provider/swf/zz_main.go +++ b/cmd/provider/swf/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/timestreamwrite/zz_main.go b/cmd/provider/timestreamwrite/zz_main.go index 2c65f8782c..32b2376bd4 100644 --- a/cmd/provider/timestreamwrite/zz_main.go +++ b/cmd/provider/timestreamwrite/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/transcribe/zz_main.go b/cmd/provider/transcribe/zz_main.go index 845b3b5dfa..ab2508a903 100644 --- a/cmd/provider/transcribe/zz_main.go +++ b/cmd/provider/transcribe/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/transfer/zz_main.go b/cmd/provider/transfer/zz_main.go index e9f84cee25..ba1c622327 100644 --- a/cmd/provider/transfer/zz_main.go +++ b/cmd/provider/transfer/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/vpc/zz_main.go b/cmd/provider/vpc/zz_main.go index 8991d62ee6..d3bd42e46a 100644 --- a/cmd/provider/vpc/zz_main.go +++ b/cmd/provider/vpc/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/waf/zz_main.go b/cmd/provider/waf/zz_main.go index 30deff61bd..92a447c4bc 100644 --- a/cmd/provider/waf/zz_main.go +++ b/cmd/provider/waf/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/wafregional/zz_main.go b/cmd/provider/wafregional/zz_main.go index fc72b64954..576bf0edb2 100644 --- a/cmd/provider/wafregional/zz_main.go +++ b/cmd/provider/wafregional/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/wafv2/zz_main.go b/cmd/provider/wafv2/zz_main.go index 58b3858967..6998872ded 100644 --- a/cmd/provider/wafv2/zz_main.go +++ b/cmd/provider/wafv2/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/workspaces/zz_main.go b/cmd/provider/workspaces/zz_main.go index 374a67ab70..8ee851c8fa 100644 --- a/cmd/provider/workspaces/zz_main.go +++ b/cmd/provider/workspaces/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/cmd/provider/xray/zz_main.go b/cmd/provider/xray/zz_main.go index 9962a3af21..5235101dc5 100644 --- a/cmd/provider/xray/zz_main.go +++ b/cmd/provider/xray/zz_main.go @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.") diff --git a/hack/main.go.tmpl b/hack/main.go.tmpl index fe66e8ffbc..38ed2d7b25 100644 --- a/hack/main.go.tmpl +++ b/hack/main.go.tmpl @@ -6,6 +6,8 @@ package main import ( "context" + "io" + "log" "os" "path/filepath" "time" @@ -57,9 +59,11 @@ func main() { setupConfig.NativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String() 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-aws")) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) 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 @@ -69,7 +73,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-interval", syncInterval.String(), + logr.Debug("Starting", "sync-interval", syncInterval.String(), "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) cfg, err := ctrl.GetConfig() @@ -96,7 +100,7 @@ func main() { // This removes some complexity for setting up development environments. setupConfig.DefaultScheduler = terraform.NewNoOpProviderScheduler() if len(*setupConfig.NativeProviderPath) != 0 { - setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(log, *pluginProcessTTL, + setupConfig.DefaultScheduler = terraform.NewSharedProviderScheduler(logr, *pluginProcessTTL, terraform.WithSharedProviderOptions(terraform.WithNativeProviderPath(*setupConfig.NativeProviderPath), terraform.WithNativeProviderName("registry.terraform.io/"+*setupConfig.NativeProviderSource))) } @@ -107,32 +111,32 @@ func main() { setupConfig.AWSClient = awsClient o := tjcontroller.Options{ Options: xpcontroller.Options{ - Logger: log, + Logger: logr, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, }, Provider: provider, - SetupFn: clients.SelectTerraformSetup(log, setupConfig), + SetupFn: clients.SelectTerraformSetup(logr, setupConfig), 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) } - o.WorkspaceStore = terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) + o.WorkspaceStore = terraform.NewWorkspaceStore(logr, terraform.WithDisableInit(len(*setupConfig.NativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(o.Features)) 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.")