Skip to content

Commit

Permalink
fixing more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AlisonB319 committed Jan 19, 2024
1 parent a8a889d commit 998ec01
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions pkg/client/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,44 +48,32 @@ func isKubeConfigStillValid(kubeConfigPath string, logger *zap.Logger) (bool, er
func isClientConfigStillValid(kubeconfigPath string, logger *zap.Logger) (bool, error) {
bootstrapClientConfig, err := loadRESTClientConfig(kubeconfigPath)
if err != nil {
logger.Error("unable to read existing bootstrap client config from ",
zap.String("kubeconfigPath", kubeconfigPath),
zap.Error(err))
logger.Error("unable to read existing kubeconfig.")
return false, err
}
transportConfig, err := bootstrapClientConfig.TransportConfig()
if err != nil {
logger.Error("unable to load transport configuration from existing bootstrap client config read from ",
zap.String("kubeconfigPath", kubeconfigPath),
zap.Error(err))
logger.Error("unable to load transport configuration from existing kubeconfig.")
return false, err
}
// has side effect of populating transport config data fields
if _, err := transport.TLSConfigFor(transportConfig); err != nil {
logger.Error("unable to load TLS configuration from existing bootstrap client config read from ",
zap.String("kubeconfigPath", kubeconfigPath),
zap.Error(err))
logger.Error("unable to load TLS configuration from existing kubeconfig.")
return false, err
}
certs, err := certutil.ParseCertsPEM(transportConfig.TLS.CertData)
if err != nil {
logger.Error("unable to load TLS certificates from existing bootstrap client config read from ",
zap.String("kubeconfigPath", kubeconfigPath),
zap.Error(err))
logger.Error("unable to load TLS certificates from existing kubeconfig.")
return false, err
}
if len(certs) == 0 {
logger.Error("unable to read TLS certificates from existing bootstrap client config read from ",
zap.String("kubeconfigPath", kubeconfigPath),
zap.Error(err))
logger.Error("unable to read TLS certificates from existing kubeconfig.")
return false, err
}
now := time.Now()
for _, cert := range certs {
if now.After(cert.NotAfter) {
logger.Error("part of the existing bootstrap client certificate in %s is expired: %v",
zap.String("kubeconfigPath", kubeconfigPath),
zap.String("expirationTime", cert.NotAfter.String()))
logger.Error("part of the existing kubeconfig certificate is expire.")
return false, err
}
}
Expand Down

0 comments on commit 998ec01

Please sign in to comment.