Skip to content

Commit 140ebad

Browse files
Merge pull request #2799 from 2uasimojo/HIVE-3017/trimspace-vsphere-creds
HIVE-3017: Trim whitespace from vsphere credentials
2 parents 941efca + 9e73153 commit 140ebad

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pkg/controller/utils/credentials.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ func ValidateCredentialsForClusterDeployment(kubeClient client.Client, cd *hivev
6161
}
6262

6363
return validateVSphereCredentials(cd.Spec.Platform.VSphere.VCenter,
64-
string(secret.Data[constants.UsernameSecretKey]),
65-
string(secret.Data[constants.PasswordSecretKey]),
64+
strings.TrimSpace(string(secret.Data[constants.UsernameSecretKey])),
65+
strings.TrimSpace(string(secret.Data[constants.PasswordSecretKey])),
6666
rootCAFiles,
6767
logger)
6868
default:

pkg/creds/vsphere/vsphere.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package vsphere
22

33
import (
44
"os"
5+
"strings"
56

67
"sigs.k8s.io/controller-runtime/pkg/client"
78

@@ -26,10 +27,10 @@ func ConfigureCreds(c client.Client, metadata *installertypes.ClusterMetadata) {
2627
}
2728
if credsSecret := utils.LoadSecretOrDie(c, "CREDS_SECRET_NAME"); credsSecret != nil {
2829
var username, password string
29-
if username = string(credsSecret.Data[constants.UsernameSecretKey]); username != "" {
30+
if username = strings.TrimSpace(string(credsSecret.Data[constants.UsernameSecretKey])); username != "" {
3031
os.Setenv(constants.VSphereUsernameEnvVar, username)
3132
}
32-
if password = string(credsSecret.Data[constants.PasswordSecretKey]); password != "" {
33+
if password = strings.TrimSpace(string(credsSecret.Data[constants.PasswordSecretKey])); password != "" {
3334
os.Setenv(constants.VSpherePasswordEnvVar, password)
3435
}
3536
// Snowflake! We need to (re)inject the creds into the metadata.

0 commit comments

Comments
 (0)