mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +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
|
Port string
|
||||||
Insecure bool
|
Insecure bool
|
||||||
RoundTripperCount uint
|
RoundTripperCount uint
|
||||||
|
credentialsLock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -85,6 +86,8 @@ func (connection *VSphereConnection) Connect(ctx context.Context) error {
|
|||||||
// otherwise calls SessionManager.Login with user and password.
|
// otherwise calls SessionManager.Login with user and password.
|
||||||
func (connection *VSphereConnection) login(ctx context.Context, client *vim25.Client) error {
|
func (connection *VSphereConnection) login(ctx context.Context, client *vim25.Client) error {
|
||||||
m := session.NewManager(client)
|
m := session.NewManager(client)
|
||||||
|
connection.credentialsLock.Lock()
|
||||||
|
defer connection.credentialsLock.Unlock()
|
||||||
|
|
||||||
// TODO: Add separate fields for certificate and private-key.
|
// TODO: Add separate fields for certificate and private-key.
|
||||||
// For now we can leave the config structs and validation as-is and
|
// 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)))
|
client.RoundTripper = vim25.Retry(client.RoundTripper, vim25.TemporaryNetworkError(int(connection.RoundTripperCount)))
|
||||||
return client, nil
|
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