Skip to content

Commit

Permalink
changed exported type to unexported
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutosji committed Jan 17, 2024
1 parent 1c99845 commit c4f2ab7
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions pkg/util/https/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ type tls interface {
ListenAndServeTLS(certFile, keyFile string) error
}

// CertServer holds the Server certificate
type CertServer struct {
Certs *cryptotls.Certificate
CertMu sync.Mutex
// certServer holds the Server certificate
type certServer struct {
certs *cryptotls.Certificate
certMu sync.Mutex
}

// Server is a HTTPs server that conforms to the runner interface
// we use in /cmd/controller, and has a public Mux that can be updated
// has a default 404 handler, to make discovery of k8s services a bit easier.
type Server struct {
CertServer CertServer
certServer certServer
logger *logrus.Entry
Mux *http.ServeMux
tls tls
Expand Down Expand Up @@ -86,16 +86,16 @@ func (s *Server) setupServer() {
return
}

s.CertServer.CertMu.Lock()
defer s.CertServer.CertMu.Unlock()
s.CertServer.Certs = &tlsCert
s.certServer.certMu.Lock()
defer s.certServer.certMu.Unlock()
s.certServer.certs = &tlsCert
}

// getCertificate returns the current TLS certificate
func (s *Server) getCertificate(hello *cryptotls.ClientHelloInfo) (*cryptotls.Certificate, error) {
s.CertServer.CertMu.Lock()
defer s.CertServer.CertMu.Unlock()
return s.CertServer.Certs, nil
s.certServer.certMu.Lock()
defer s.certServer.certMu.Unlock()
return s.certServer.certs, nil
}

// WatchForCertificateChanges watches for changes in the certificate files
Expand All @@ -109,9 +109,9 @@ func (s *Server) WatchForCertificateChanges() (func(), error) {
s.logger.WithError(err).Error("could not load TLS certs; keeping old one")
return
}
s.CertServer.CertMu.Lock()
defer s.CertServer.CertMu.Unlock()
s.CertServer.Certs = &tlsCert
s.certServer.certMu.Lock()
defer s.certServer.certMu.Unlock()
s.certServer.certs = &tlsCert
s.logger.Info("TLS certs updated")
})
if err != nil {
Expand Down

0 comments on commit c4f2ab7

Please sign in to comment.