mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-08-08 23:37:11 +00:00
Merge pull request #83071 from chendotjs/bytes-equal
replace bytes.Compare() with bytes.Equal()
This commit is contained in:
@@ -495,7 +495,7 @@ func (e *TokensController) hasReferencedToken(serviceAccount *v1.ServiceAccount)
|
||||
|
||||
func (e *TokensController) secretUpdateNeeded(secret *v1.Secret) (bool, bool, bool) {
|
||||
caData := secret.Data[v1.ServiceAccountRootCAKey]
|
||||
needsCA := len(e.rootCA) > 0 && bytes.Compare(caData, e.rootCA) != 0
|
||||
needsCA := len(e.rootCA) > 0 && !bytes.Equal(caData, e.rootCA)
|
||||
|
||||
needsNamespace := len(secret.Data[v1.ServiceAccountNamespaceKey]) == 0
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ func (v *legacyValidator) Validate(tokenData string, public *jwt.Claims, private
|
||||
klog.V(4).Infof("Token is deleted and awaiting removal: %s/%s for service account %s/%s", namespace, secretName, namespace, serviceAccountName)
|
||||
return nil, errors.New("Token has been invalidated")
|
||||
}
|
||||
if bytes.Compare(secret.Data[v1.ServiceAccountTokenKey], []byte(tokenData)) != 0 {
|
||||
if !bytes.Equal(secret.Data[v1.ServiceAccountTokenKey], []byte(tokenData)) {
|
||||
klog.V(4).Infof("Token contents no longer matches %s/%s for service account %s/%s", namespace, secretName, namespace, serviceAccountName)
|
||||
return nil, errors.New("Token does not match server's copy")
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ func shouldWriteFile(path string, content []byte) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return (bytes.Compare(content, contentOnFs) != 0), nil
|
||||
return !bytes.Equal(content, contentOnFs), nil
|
||||
}
|
||||
|
||||
// pathsToRemove walks the current version of the data directory and
|
||||
|
||||
Reference in New Issue
Block a user