crypto.go: Rename ShouldGenSelfSignedCerts() to FoundCertOrKey().

Since the function only tests whether the files are on the disk,
the original name is a little bit misleading.
This commit is contained in:
Yifan Gu 2016-08-19 13:50:07 -07:00
parent 26babd4eba
commit 2e631d811c
3 changed files with 7 additions and 7 deletions

View File

@ -699,7 +699,7 @@ func InitializeTLS(s *options.KubeletServer) (*server.TLSOptions, error) {
if s.TLSCertFile == "" && s.TLSPrivateKeyFile == "" { if s.TLSCertFile == "" && s.TLSPrivateKeyFile == "" {
s.TLSCertFile = path.Join(s.CertDirectory, "kubelet.crt") s.TLSCertFile = path.Join(s.CertDirectory, "kubelet.crt")
s.TLSPrivateKeyFile = path.Join(s.CertDirectory, "kubelet.key") s.TLSPrivateKeyFile = path.Join(s.CertDirectory, "kubelet.key")
if crypto.ShouldGenSelfSignedCerts(s.TLSCertFile, s.TLSPrivateKeyFile) { if !crypto.FoundCertOrKey(s.TLSCertFile, s.TLSPrivateKeyFile) {
if err := crypto.GenerateSelfSignedCert(nodeutil.GetHostname(s.HostnameOverride), s.TLSCertFile, s.TLSPrivateKeyFile, nil, nil); err != nil { if err := crypto.GenerateSelfSignedCert(nodeutil.GetHostname(s.HostnameOverride), s.TLSCertFile, s.TLSPrivateKeyFile, nil, nil); err != nil {
return nil, fmt.Errorf("unable to generate self signed cert: %v", err) return nil, fmt.Errorf("unable to generate self signed cert: %v", err)
} }

View File

@ -689,7 +689,7 @@ func (s *GenericAPIServer) Run(options *options.ServerRunOptions) {
alternateDNS := []string{"kubernetes.default.svc", "kubernetes.default", "kubernetes"} alternateDNS := []string{"kubernetes.default.svc", "kubernetes.default", "kubernetes"}
// It would be nice to set a fqdn subject alt name, but only the kubelets know, the apiserver is clueless // It would be nice to set a fqdn subject alt name, but only the kubelets know, the apiserver is clueless
// alternateDNS = append(alternateDNS, "kubernetes.default.svc.CLUSTER.DNS.NAME") // alternateDNS = append(alternateDNS, "kubernetes.default.svc.CLUSTER.DNS.NAME")
if crypto.ShouldGenSelfSignedCerts(options.TLSCertFile, options.TLSPrivateKeyFile) { if !crypto.FoundCertOrKey(options.TLSCertFile, options.TLSPrivateKeyFile) {
if err := crypto.GenerateSelfSignedCert(s.ClusterIP.String(), options.TLSCertFile, options.TLSPrivateKeyFile, alternateIPs, alternateDNS); err != nil { if err := crypto.GenerateSelfSignedCert(s.ClusterIP.String(), options.TLSCertFile, options.TLSPrivateKeyFile, alternateIPs, alternateDNS); err != nil {
glog.Errorf("Unable to generate self signed cert: %v", err) glog.Errorf("Unable to generate self signed cert: %v", err)
} else { } else {

View File

@ -33,14 +33,14 @@ import (
"time" "time"
) )
// ShouldGenSelfSignedCerts returns false if the certificate or key files already exists, // FoundCertOrKey returns true if the certificate or key files already exists,
// otherwise returns true. // otherwise returns false.
func ShouldGenSelfSignedCerts(certPath, keyPath string) bool { func FoundCertOrKey(certPath, keyPath string) bool {
if canReadFile(certPath) || canReadFile(keyPath) { if canReadFile(certPath) || canReadFile(keyPath) {
return false return true
} }
return true return false
} }
// If the file represented by path exists and // If the file represented by path exists and