Add kubernetes license to credential manager
This commit is contained in:
		@@ -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
 | 
					package vsphere
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
					package vsphere
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
@@ -213,8 +229,8 @@ func TestSecretCredentialManager_GetCredential(t *testing.T) {
 | 
				
			|||||||
				if expected.err == nil {
 | 
									if expected.err == nil {
 | 
				
			||||||
					if expected.username != credential.User ||
 | 
										if expected.username != credential.User ||
 | 
				
			||||||
						expected.password != credential.Password {
 | 
											expected.password != credential.Password {
 | 
				
			||||||
						t.Fatalf("Recieved credentials %v "+
 | 
											t.Fatalf("Received credentials %v "+
 | 
				
			||||||
							"are diffrent than actual credential user:%s password:%s", credential, expected.username,
 | 
												"are different than actual credential user:%s password:%s", credential, expected.username,
 | 
				
			||||||
							expected.password)
 | 
												expected.password)
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -167,6 +167,8 @@ func (connection *VSphereConnection) NewClient(ctx context.Context) (*vim25.Clie
 | 
				
			|||||||
	return client, nil
 | 
						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) {
 | 
					func (connection *VSphereConnection) UpdateCredentials(username string, password string) {
 | 
				
			||||||
	connection.credentialsLock.Lock()
 | 
						connection.credentialsLock.Lock()
 | 
				
			||||||
	defer connection.credentialsLock.Unlock()
 | 
						defer connection.credentialsLock.Unlock()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -172,6 +172,7 @@ func IsManagedObjectNotFoundError(err error) bool {
 | 
				
			|||||||
	return isManagedObjectNotFoundError
 | 
						return isManagedObjectNotFoundError
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// IsInvalidCredentialsError returns true if error is of type InvalidLogin
 | 
				
			||||||
func IsInvalidCredentialsError(err error) bool {
 | 
					func IsInvalidCredentialsError(err error) bool {
 | 
				
			||||||
	isInvalidCredentialsError := false
 | 
						isInvalidCredentialsError := false
 | 
				
			||||||
	if soap.IsSoapFault(err) {
 | 
						if soap.IsSoapFault(err) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -557,11 +557,11 @@ func TestSecretVSphereConfig(t *testing.T) {
 | 
				
			|||||||
		if !testcase.expectedIsSecretProvided {
 | 
							if !testcase.expectedIsSecretProvided {
 | 
				
			||||||
			for _, vsInstance := range vs.vsphereInstanceMap {
 | 
								for _, vsInstance := range vs.vsphereInstanceMap {
 | 
				
			||||||
				if vsInstance.conn.Username != testcase.expectedUsername {
 | 
									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)
 | 
											testcase.expectedUsername, vsInstance.conn.Username, testcase.conf, err)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				if vsInstance.conn.Password != testcase.expectedPassword {
 | 
									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)
 | 
											testcase.expectedPassword, vsInstance.conn.Password, testcase.conf, err)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user