mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Add update credentials function in vclib
This commit is contained in:
parent
b3837d004a
commit
1fb9ababbd
@ -40,6 +40,7 @@ type VSphereConnection struct {
|
||||
Port string
|
||||
Insecure bool
|
||||
RoundTripperCount uint
|
||||
credentialsLock sync.Mutex
|
||||
}
|
||||
|
||||
var (
|
||||
@ -85,6 +86,8 @@ func (connection *VSphereConnection) Connect(ctx context.Context) error {
|
||||
// otherwise calls SessionManager.Login with user and password.
|
||||
func (connection *VSphereConnection) login(ctx context.Context, client *vim25.Client) error {
|
||||
m := session.NewManager(client)
|
||||
connection.credentialsLock.Lock()
|
||||
defer connection.credentialsLock.Unlock()
|
||||
|
||||
// TODO: Add separate fields for certificate and private-key.
|
||||
// For now we can leave the config structs and validation as-is and
|
||||
@ -163,3 +166,10 @@ func (connection *VSphereConnection) NewClient(ctx context.Context) (*vim25.Clie
|
||||
client.RoundTripper = vim25.Retry(client.RoundTripper, vim25.TemporaryNetworkError(int(connection.RoundTripperCount)))
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func (connection *VSphereConnection) UpdateCredentials(username string, password string) {
|
||||
connection.credentialsLock.Lock()
|
||||
defer connection.credentialsLock.Unlock()
|
||||
connection.Username = username
|
||||
connection.Password = password
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user