From ca5730aa0315ea982cbb1f6b600040889edf6b89 Mon Sep 17 00:00:00 2001 From: vbadrina Date: Wed, 18 Dec 2024 15:32:14 +0530 Subject: [PATCH] Fix the length of generated OBC bucket name Signed-off-by: vbadrina --- controllers/utils/hash.go | 2 +- controllers/utils/s3.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/utils/hash.go b/controllers/utils/hash.go index 98dd0693..faf488dc 100644 --- a/controllers/utils/hash.go +++ b/controllers/utils/hash.go @@ -77,7 +77,7 @@ func GenerateUniqueIdForMirrorPeer(mirrorPeer multiclusterv1alpha1.MirrorPeer, h checksum = sha1.Sum([]byte(peerAccumulator)) } // truncate to bucketGenerateName + "-" + first 12 (out of 20) byte representations of sha1 checksum - return hex.EncodeToString(checksum[:])[0 : len(BucketGenerateName)+1+12] + return hex.EncodeToString(checksum[:]) } func GetKey(clusterName, clientName string) string { diff --git a/controllers/utils/s3.go b/controllers/utils/s3.go index b1e1e062..fbcd7f3c 100644 --- a/controllers/utils/s3.go +++ b/controllers/utils/s3.go @@ -53,7 +53,7 @@ func GetEnv(key, defaultValue string) string { func GenerateBucketName(mirrorPeer multiclusterv1alpha1.MirrorPeer, hasStorageClientRef bool) string { mirrorPeerId := GenerateUniqueIdForMirrorPeer(mirrorPeer, hasStorageClientRef) bucketGenerateName := BucketGenerateName - return fmt.Sprintf("%s-%s", bucketGenerateName, mirrorPeerId) + return fmt.Sprintf("%s-%s", bucketGenerateName, mirrorPeerId)[0 : len(BucketGenerateName)+1+12] } func CreateOrUpdateObjectBucketClaim(ctx context.Context, c client.Client, bucketName, bucketNamespace string, annotations map[string]string) (controllerutil.OperationResult, error) {