Skip to content

Commit 0afc842

Browse files
authored
Merge pull request kubernetes#84992 from yutedz/openstack-passwd
Move password retrieval to openstack_test.go
2 parents a18303d + e304975 commit 0afc842

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

staging/src/k8s.io/legacy-cloud-providers/openstack/openstack.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ func (cfg Config) toAuth3Options() tokens3.AuthOptions {
221221
func configFromEnv() (cfg Config, ok bool) {
222222
cfg.Global.AuthURL = os.Getenv("OS_AUTH_URL")
223223
cfg.Global.Username = os.Getenv("OS_USERNAME")
224-
cfg.Global.Password = os.Getenv("OS_PASSWORD")
225224
cfg.Global.Region = os.Getenv("OS_REGION_NAME")
226225
cfg.Global.UserID = os.Getenv("OS_USER_ID")
227226
cfg.Global.TrustID = os.Getenv("OS_TRUST_ID")

staging/src/k8s.io/legacy-cloud-providers/openstack/openstack_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ func TestReadConfig(t *testing.T) {
119119
[Metadata]
120120
search-order = configDrive, metadataService
121121
`))
122+
cfg.Global.Password = os.Getenv("OS_PASSWORD")
123+
122124
if err != nil {
123125
t.Fatalf("Should succeed when a valid config is provided: %s", err)
124126
}
@@ -476,8 +478,17 @@ func TestNodeAddresses(t *testing.T) {
476478
}
477479
}
478480

481+
func configFromEnvWithPasswd() (cfg Config, ok bool) {
482+
cfg, ok = configFromEnv()
483+
if !ok {
484+
return cfg, ok
485+
}
486+
cfg.Global.Password = os.Getenv("OS_PASSWORD")
487+
return cfg, ok
488+
}
489+
479490
func TestNewOpenStack(t *testing.T) {
480-
cfg, ok := configFromEnv()
491+
cfg, ok := configFromEnvWithPasswd()
481492
if !ok {
482493
t.Skip("No config found in environment")
483494
}
@@ -489,7 +500,7 @@ func TestNewOpenStack(t *testing.T) {
489500
}
490501

491502
func TestLoadBalancer(t *testing.T) {
492-
cfg, ok := configFromEnv()
503+
cfg, ok := configFromEnvWithPasswd()
493504
if !ok {
494505
t.Skip("No config found in environment")
495506
}
@@ -553,7 +564,7 @@ func TestZones(t *testing.T) {
553564
var diskPathRegexp = regexp.MustCompile("/dev/disk/(?:by-id|by-path)/")
554565

555566
func TestVolumes(t *testing.T) {
556-
cfg, ok := configFromEnv()
567+
cfg, ok := configFromEnvWithPasswd()
557568
if !ok {
558569
t.Skip("No config found in environment")
559570
}

0 commit comments

Comments
 (0)