Skip to content

Commit

Permalink
Add kubernetes license to credential manager
Browse files Browse the repository at this point in the history
  • Loading branch information
abrarshivani committed May 17, 2018
1 parent f58cc6c commit 99076ce
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
16 changes: 16 additions & 0 deletions pkg/cloudprovider/providers/vsphere/credentialmanager.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package vsphere

import (
Expand Down
20 changes: 18 additions & 2 deletions pkg/cloudprovider/providers/vsphere/credentialmanager_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package vsphere

import (
Expand Down Expand Up @@ -213,8 +229,8 @@ func TestSecretCredentialManager_GetCredential(t *testing.T) {
if expected.err == nil {
if expected.username != credential.User ||
expected.password != credential.Password {
t.Fatalf("Recieved credentials %v "+
"are diffrent than actual credential user:%s password:%s", credential, expected.username,
t.Fatalf("Received credentials %v "+
"are different than actual credential user:%s password:%s", credential, expected.username,
expected.password)
}
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/cloudprovider/providers/vsphere/vclib/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ func (connection *VSphereConnection) NewClient(ctx context.Context) (*vim25.Clie
return client, nil
}

// UpdateCredentials updates username and password.
// Note: Updated username and password will be used when there is no session active
func (connection *VSphereConnection) UpdateCredentials(username string, password string) {
connection.credentialsLock.Lock()
defer connection.credentialsLock.Unlock()
Expand Down
1 change: 1 addition & 0 deletions pkg/cloudprovider/providers/vsphere/vclib/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ func IsManagedObjectNotFoundError(err error) bool {
return isManagedObjectNotFoundError
}

// IsInvalidCredentialsError returns true if error is of type InvalidLogin
func IsInvalidCredentialsError(err error) bool {
isInvalidCredentialsError := false
if soap.IsSoapFault(err) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloudprovider/providers/vsphere/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,11 @@ func TestSecretVSphereConfig(t *testing.T) {
if !testcase.expectedIsSecretProvided {
for _, vsInstance := range vs.vsphereInstanceMap {
if vsInstance.conn.Username != testcase.expectedUsername {
t.Fatalf("Expected username doesn't match actual username in config %s. error: %s",
t.Fatalf("Expected username %s doesn't match actual username %s in config %s. error: %s",
testcase.expectedUsername, vsInstance.conn.Username, testcase.conf, err)
}
if vsInstance.conn.Password != testcase.expectedPassword {
t.Fatalf("Expected password doesn't match actual password in config %s. error: %s",
t.Fatalf("Expected password %s doesn't match actual password %s in config %s. error: %s",
testcase.expectedPassword, vsInstance.conn.Password, testcase.conf, err)
}

Expand Down

0 comments on commit 99076ce

Please sign in to comment.