From 997ed7b9b46e39c602bd71a56df3b1ee80cef552 Mon Sep 17 00:00:00 2001 From: galal-hussein Date: Wed, 21 Jul 2021 19:56:12 +0200 Subject: [PATCH] simplifying the code Signed-off-by: galal-hussein --- pkg/cluster/storage.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/cluster/storage.go b/pkg/cluster/storage.go index 1b6031a8ed..2751515d43 100644 --- a/pkg/cluster/storage.go +++ b/pkg/cluster/storage.go @@ -143,8 +143,7 @@ func (c *Cluster) getBootstrapKeyFromStorage(ctx context.Context, storageClient } for _, bootstrapKV := range bootstrapList { // checking for empty string bootstrap key - switch string(bootstrapKV.Key) { - case tokenKey: + if string(bootstrapKV.Key) == tokenKey { return &bootstrapKV, nil } } @@ -189,7 +188,7 @@ func (c *Cluster) migrateEmptyStringToken(ctx context.Context, bootstrapList []c // checking for empty string bootstrap key if string(bootstrapKV.Key) == emptyStringKey { logrus.Warn("bootstrap data encrypted with empty string, deleting and resaving with token") - // making sure that the process is autonmous by decrypting and rencrypting the data first + // make sure that the process is non-destructive by decrypting/re-encrypting/storing the data before deleting the old key data, err := decrypt("", bootstrapKV.Data) if err != nil { return err @@ -210,10 +209,7 @@ func (c *Cluster) migrateEmptyStringToken(ctx context.Context, bootstrapList []c return err } // deleting the empty string key - if err := storageClient.Delete(ctx, emptyStringKey, bootstrapKV.Modified); err != nil { - return err - } - return nil + return storageClient.Delete(ctx, emptyStringKey, bootstrapKV.Modified) } }