Skip to content

Commit

Permalink
Merge pull request #115 from ulucinar/fix-logs
Browse files Browse the repository at this point in the history
Set log.Default's output to io.Discard
  • Loading branch information
ulucinar authored Mar 21, 2024
2 parents 1cf91b3 + 2d5f0ec commit b5c5d4b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions cmd/provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package main
import (
"context"
"fmt"
"io"
"log"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -64,9 +66,11 @@ func main() {
)

kingpin.MustParse(app.Parse(os.Args[1:]))
log.Default().SetOutput(io.Discard)
ctrl.SetLogger(zap.New(zap.WriteTo(io.Discard)))

zl := zap.New(zap.UseDevMode(*debug))
log := logging.NewLogrLogger(zl.WithName("provider-azuread"))
logr := logging.NewLogrLogger(zl.WithName("provider-azuread"))
if *debug {
// The controller-runtime runs with a no-op logger by default. It is
// *very* verbose even at info level, so we only provide it a real
Expand All @@ -76,7 +80,7 @@ func main() {

// currently, we configure the jitter to be the 5% of the poll interval
pollJitter := time.Duration(float64(*pollInterval) * 0.05)
log.Debug("Starting", "sync-period", syncPeriod.String(),
logr.Debug("Starting", "sync-period", syncPeriod.String(),
"poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate)

cfg, err := ctrl.GetConfig()
Expand All @@ -100,32 +104,30 @@ func main() {
kingpin.FatalIfError(err, "Cannot initialize the provider configuration")
o := tjcontroller.Options{
Options: xpcontroller.Options{
Logger: log,
Logger: logr,
GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate),
PollInterval: *pollInterval,
MaxConcurrentReconciles: *maxReconcileRate,
Features: &feature.Flags{},
},
Provider: provider,
// use the following WorkspaceStoreOption to enable the shared gRPC mode
// terraform.WithProviderRunner(terraform.NewSharedProvider(log, os.Getenv("TERRAFORM_NATIVE_PROVIDER_PATH"), terraform.WithNativeProviderArgs("-debuggable")))
Provider: provider,
SetupFn: clients.TerraformSetupBuilder(provider.TerraformProvider),
PollJitter: pollJitter,
OperationTrackerStore: tjcontroller.NewOperationStore(log),
OperationTrackerStore: tjcontroller.NewOperationStore(logr),
}

if *enableManagementPolicies {
o.Features.Enable(features.EnableBetaManagementPolicies)
log.Info("Beta feature enabled", "flag", features.EnableBetaManagementPolicies)
logr.Info("Beta feature enabled", "flag", features.EnableBetaManagementPolicies)
}

if *enableExternalSecretStores {
o.SecretStoreConfigGVK = &v1alpha1.StoreConfigGroupVersionKind
log.Info("Alpha feature enabled", "flag", features.EnableAlphaExternalSecretStores)
logr.Info("Alpha feature enabled", "flag", features.EnableAlphaExternalSecretStores)

o.ESSOptions = &tjcontroller.ESSOptions{}
if *essTLSCertsPath != "" {
log.Info("ESS TLS certificates path is set. Loading mTLS configuration.")
logr.Info("ESS TLS certificates path is set. Loading mTLS configuration.")
tCfg, err := certificates.LoadMTLSConfig(filepath.Join(*essTLSCertsPath, "ca.crt"), filepath.Join(*essTLSCertsPath, "tls.crt"), filepath.Join(*essTLSCertsPath, "tls.key"), false)
kingpin.FatalIfError(err, "Cannot load ESS TLS config.")

Expand Down

0 comments on commit b5c5d4b

Please sign in to comment.