Fix staticchecks ST1005,S1002,S1008,S1039 in pkg/kubelet

This commit is contained in:
auxten
2020-09-07 10:53:43 +08:00
parent 1f708f6e62
commit a9c1acc044
5 changed files with 9 additions and 9 deletions

View File

@@ -33,11 +33,11 @@ func GetNodenameForKernel(hostname string, hostDomainName string, setHostnameAsF
kernelHostname := hostname
// FQDN has to be 64 chars to fit in the Linux nodename kernel field (specification 64 chars and the null terminating char).
const fqdnMaxLen = 64
if len(hostDomainName) > 0 && setHostnameAsFQDN != nil && *setHostnameAsFQDN == true {
if len(hostDomainName) > 0 && setHostnameAsFQDN != nil && *setHostnameAsFQDN {
fqdn := fmt.Sprintf("%s.%s", hostname, hostDomainName)
// FQDN has to be shorter than hostnameMaxLen characters.
if len(fqdn) > fqdnMaxLen {
return "", fmt.Errorf("Failed to construct FQDN from pod hostname and cluster domain, FQDN %s is too long (%d characters is the max, %d characters requested)", fqdn, fqdnMaxLen, len(fqdn))
return "", fmt.Errorf("failed to construct FQDN from pod hostname and cluster domain, FQDN %s is too long (%d characters is the max, %d characters requested)", fqdn, fqdnMaxLen, len(fqdn))
}
kernelHostname = fqdn
}