1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-31 14:36:32 +00:00

Optimize strings operations

At 5000+ nodes these small string optimizations make a difference
This commit is contained in:
Darren Shepherd
2020-03-06 08:47:37 -07:00
parent 1e34d2b464
commit 5e5ccacb58

View File

@@ -259,31 +259,31 @@ func GetCrtNameForHost(host *hosts.Host, prefix string) string {
} else {
newAddress = strings.Replace(host.Address, ".", "-", -1)
}
return fmt.Sprintf("%s-%s", prefix, newAddress)
return prefix + "-" + newAddress
}
func GetCertPath(name string) string {
return fmt.Sprintf("%s%s.pem", CertPathPrefix, name)
return CertPathPrefix + name + ".pem"
}
func GetKeyPath(name string) string {
return fmt.Sprintf("%s%s-key.pem", CertPathPrefix, name)
return CertPathPrefix + name + "-key.pem"
}
func GetConfigPath(name string) string {
return fmt.Sprintf("%skubecfg-%s.yaml", CertPathPrefix, name)
return CertPathPrefix + "kubecfg-" + name + ".yaml"
}
func GetCertTempPath(name string) string {
return fmt.Sprintf("%s%s.pem", TempCertPath, name)
return TempCertPath + name + ".pem"
}
func GetKeyTempPath(name string) string {
return fmt.Sprintf("%s%s-key.pem", TempCertPath, name)
return TempCertPath + name + ".pem"
}
func GetConfigTempPath(name string) string {
return fmt.Sprintf("%skubecfg-%s.yaml", TempCertPath, name)
return TempCertPath + "kubecfg-" + name + ".yaml"
}
func ToCertObject(componentName, commonName, ouName string, certificate *x509.Certificate, key *rsa.PrivateKey, csrASN1 []byte) CertificatePKI {