Skip to content

Commit 3aeb806

Browse files
committed
Fix duplicated base64 encoding of secrets
Signed-off-by: Jannik Hollenbach <jannik.hollenbach@iteratec.com>
1 parent 9b60e9d commit 3aeb806

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

auto-discovery/kubernetes/pull-secret-extractor/internal/secret_extraction/secret_extraction.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ func extractCredentials(auth *AuthEntry) (*Credentials, error) {
161161
}
162162

163163
return &Credentials{
164-
Username: base64.StdEncoding.EncodeToString([]byte(parts[0])),
165-
Password: base64.StdEncoding.EncodeToString([]byte(parts[1])),
164+
Username: parts[0],
165+
Password: parts[1],
166166
}, nil
167167
}
168168

@@ -190,9 +190,9 @@ func buildSecret(ctx context.Context, k8sClient client.Client, secretName, names
190190
},
191191
},
192192
},
193-
Data: map[string][]byte{
194-
"username": []byte(creds.Username),
195-
"password": []byte(creds.Password),
193+
StringData: map[string]string{
194+
"username": creds.Username,
195+
"password": creds.Password,
196196
},
197197
Type: v1.SecretTypeOpaque,
198198
}, nil

auto-discovery/kubernetes/pull-secret-extractor/internal/secret_extraction/secret_extraction_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ func TestCreateTemporarySecret(t *testing.T) {
6464
t.Fatalf("Secret was not created: %v", err)
6565
}
6666

67-
expectedUsername := base64.StdEncoding.EncodeToString([]byte("testuser"))
68-
expectedPassword := base64.StdEncoding.EncodeToString([]byte("testpass"))
67+
expectedUsername := "testuser"
68+
expectedPassword := "testpass"
6969

70-
if string(secret.Data["username"]) != expectedUsername {
71-
t.Errorf("Expected username %s, got %s", expectedUsername, string(secret.Data["username"]))
70+
if secret.StringData["username"] != expectedUsername {
71+
t.Errorf("Expected username %s, got %s", expectedUsername, string(secret.StringData["username"]))
7272
}
7373

74-
if string(secret.Data["password"]) != expectedPassword {
75-
t.Errorf("Expected password %s, got %s", expectedPassword, string(secret.Data["password"]))
74+
if secret.StringData["password"] != expectedPassword {
75+
t.Errorf("Expected password %s, got %s", expectedPassword, string(secret.StringData["password"]))
7676
}
7777

7878
if len(secret.OwnerReferences) != 1 {

0 commit comments

Comments
 (0)