mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 02:08:13 +00:00 
			
		
		
		
	replace bytes.Compare() with bytes.Equal()
This commit is contained in:
		| @@ -216,7 +216,7 @@ func (e *CombinedEtcdClient) AttachLease(leaseDuration time.Duration) error { | ||||
| 		if err != nil { | ||||
| 			klog.Errorf("Error while attaching lease to: %s", string(kv.Key)) | ||||
| 		} | ||||
| 		if bytes.Compare(putResp.PrevKv.Value, kv.Value) != 0 { | ||||
| 		if !bytes.Equal(putResp.PrevKv.Value, kv.Value) { | ||||
| 			return fmt.Errorf("concurrent access to key detected when setting lease on %s, expected previous value of %s but got %s", | ||||
| 				kv.Key, kv.Value, putResp.PrevKv.Value) | ||||
| 		} | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -393,7 +393,7 @@ func TestEncryptionProviderConfigCorrect(t *testing.T) { | ||||
| 			if stale != (transformer.Name != testCase.Name) { | ||||
| 				t.Fatalf("%s: wrong stale information on reading using %s transformer, should be %v", testCase.Name, transformer.Name, testCase.Name == transformer.Name) | ||||
| 			} | ||||
| 			if bytes.Compare(untransformedData, originalText) != 0 { | ||||
| 			if !bytes.Equal(untransformedData, originalText) { | ||||
| 				t.Fatalf("%s: %s transformer transformed data incorrectly. Expected: %v, got %v", testCase.Name, transformer.Name, originalText, untransformedData) | ||||
| 			} | ||||
| 		} | ||||
|   | ||||
| @@ -94,7 +94,7 @@ func TestEnvelopeCaching(t *testing.T) { | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("could not decrypt Envelope transformer's encrypted data even once: %v", err) | ||||
| 	} | ||||
| 	if bytes.Compare(untransformedData, originalText) != 0 { | ||||
| 	if !bytes.Equal(untransformedData, originalText) { | ||||
| 		t.Fatalf("envelopeTransformer transformed data incorrectly. Expected: %v, got %v", originalText, untransformedData) | ||||
| 	} | ||||
|  | ||||
| @@ -104,7 +104,7 @@ func TestEnvelopeCaching(t *testing.T) { | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("could not decrypt Envelope transformer's encrypted data using just cache: %v", err) | ||||
| 	} | ||||
| 	if bytes.Compare(untransformedData, originalText) != 0 { | ||||
| 	if !bytes.Equal(untransformedData, originalText) { | ||||
| 		t.Fatalf("envelopeTransformer transformed data incorrectly using cache. Expected: %v, got %v", originalText, untransformedData) | ||||
| 	} | ||||
| } | ||||
| @@ -139,7 +139,7 @@ func TestEnvelopeCacheLimit(t *testing.T) { | ||||
| 			t.Fatalf("envelopeTransformer: error while transforming data (%v) from storage: %s", transformedOutputs[i], err) | ||||
| 		} | ||||
|  | ||||
| 		if bytes.Compare(numberText, output) != 0 { | ||||
| 		if !bytes.Equal(numberText, output) { | ||||
| 			t.Fatalf("envelopeTransformer transformed data incorrectly using cache. Expected: %v, got %v", numberText, output) | ||||
| 		} | ||||
| 	} | ||||
| @@ -221,7 +221,7 @@ func TestBackwardsCompatibility(t *testing.T) { | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("could not decrypt Envelope transformer's encrypted data even once: %v", err) | ||||
| 	} | ||||
| 	if bytes.Compare(untransformedData, originalText) != 0 { | ||||
| 	if !bytes.Equal(untransformedData, originalText) { | ||||
| 		t.Fatalf("envelopeTransformer transformed data incorrectly. Expected: %v, got %v", originalText, untransformedData) | ||||
| 	} | ||||
|  | ||||
| @@ -231,7 +231,7 @@ func TestBackwardsCompatibility(t *testing.T) { | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("could not decrypt Envelope transformer's encrypted data using just cache: %v", err) | ||||
| 	} | ||||
| 	if bytes.Compare(untransformedData, originalText) != 0 { | ||||
| 	if !bytes.Equal(untransformedData, originalText) { | ||||
| 		t.Fatalf("envelopeTransformer transformed data incorrectly using cache. Expected: %v, got %v", originalText, untransformedData) | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -341,7 +341,7 @@ func (le *LeaderElector) tryAcquireOrRenew() bool { | ||||
| 	} | ||||
|  | ||||
| 	// 2. Record obtained, check the Identity & Time | ||||
| 	if bytes.Compare(le.observedRawRecord, oldLeaderElectionRawRecord) != 0 { | ||||
| 	if !bytes.Equal(le.observedRawRecord, oldLeaderElectionRawRecord) { | ||||
| 		le.observedRecord = *oldLeaderElectionRecord | ||||
| 		le.observedRawRecord = oldLeaderElectionRawRecord | ||||
| 		le.observedTime = le.clock.Now() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 chenyaqi01
					chenyaqi01