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:
		@@ -699,7 +699,7 @@ func InitializeTLS(s *options.KubeletServer) (*server.TLSOptions, error) {
 | 
			
		||||
	if s.TLSCertFile == "" && s.TLSPrivateKeyFile == "" {
 | 
			
		||||
		s.TLSCertFile = path.Join(s.CertDirectory, "kubelet.crt")
 | 
			
		||||
		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 {
 | 
			
		||||
				return nil, fmt.Errorf("unable to generate self signed cert: %v", err)
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
@@ -689,7 +689,7 @@ func (s *GenericAPIServer) Run(options *options.ServerRunOptions) {
 | 
			
		||||
			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
 | 
			
		||||
			// 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 {
 | 
			
		||||
					glog.Errorf("Unable to generate self signed cert: %v", err)
 | 
			
		||||
				} else {
 | 
			
		||||
 
 | 
			
		||||
@@ -33,14 +33,14 @@ import (
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ShouldGenSelfSignedCerts returns false if the certificate or key files already exists,
 | 
			
		||||
// otherwise returns true.
 | 
			
		||||
func ShouldGenSelfSignedCerts(certPath, keyPath string) bool {
 | 
			
		||||
// FoundCertOrKey returns true if the certificate or key files already exists,
 | 
			
		||||
// otherwise returns false.
 | 
			
		||||
func FoundCertOrKey(certPath, keyPath string) bool {
 | 
			
		||||
	if canReadFile(certPath) || canReadFile(keyPath) {
 | 
			
		||||
		return false
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return true
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// If the file represented by path exists and
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user