Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/sigs.k8s.io/controller…
Browse files Browse the repository at this point in the history
…-runtime-0.20.0
  • Loading branch information
m00g3n authored Jan 22, 2025
2 parents 38ddb66 + 626aace commit 873660c
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions internal/webhook/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"sync"
"time"

"github.com/go-logr/logr"
"github.com/kyma-project/kim-snatch/internal/httpserver"
logf "github.com/kyma-project/kim-snatch/internal/log"
"github.com/kyma-project/kim-snatch/internal/metrics"
Expand Down Expand Up @@ -178,22 +177,27 @@ func (s *DefaultServer) Start(ctx context.Context) error {
}

if cfg.GetCertificate == nil {
go func(certPath, keyPath string, callback func(tls.Certificate), log logr.Logger, ctx context.Context) {
// Create the certificate watcher and
// set the config's GetCertificate on the TLSConfig
certWatcher, err := certwatcher.New(certPath, keyPath)
if err != nil {
log.Error(err, "failed to create cert watcher")
return
}
cfg.GetCertificate = certWatcher.GetCertificate
certWatcher.RegisterCallback(callback)
certPath := filepath.Join(s.Options.CertDir, s.Options.CertName)
keyPath := filepath.Join(s.Options.CertDir, s.Options.KeyName)

// Create the certificate watcher and
// set the config's GetCertificate on the TLSConfig
certWatcher, err := certwatcher.New(certPath, keyPath)
if err != nil {
return err
}

cfg.GetCertificate = certWatcher.GetCertificate
certWatcher.RegisterCallback(s.Options.Callback)

startWatcher := func() {
if err := certWatcher.Start(ctx); err != nil {
log.Error(err, "failed to start cert watcher")
return
}
}(filepath.Join(s.Options.CertDir, s.Options.CertName), filepath.Join(s.Options.CertDir, s.Options.KeyName), s.Options.Callback, log, ctx)
}

go startWatcher()
}

// Load CA to verify client certificate, if configured.
Expand Down

0 comments on commit 873660c

Please sign in to comment.