1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-15 17:51:01 +00:00

Yandex Lockbox Connection Leaks (#835)

* fix Yandex Lockbox provider connection leaks (https://github.com/external-secrets/external-secrets/issues/833)

* fix Yandex Lockbox provider connection leaks (https://github.com/external-secrets/external-secrets/issues/833)
This commit is contained in:
AndreyZamyslov 2022-03-16 19:58:01 +03:00 committed by GitHub
parent 29d2418d8e
commit 45449dccc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,6 +40,9 @@ func (lb *YandexCloudCreator) CreateLockboxClient(ctx context.Context, apiEndpoi
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer func() {
_ = closeSDK(ctx, sdk)
}()
payloadAPIEndpoint, err := sdk.ApiEndpoint().ApiEndpoint().Get(ctx, &endpoint.GetApiEndpointRequest{ payloadAPIEndpoint, err := sdk.ApiEndpoint().ApiEndpoint().Get(ctx, &endpoint.GetApiEndpointRequest{
ApiEndpointId: "lockbox-payload", // the ID from https://api.cloud.yandex.net/endpoints ApiEndpointId: "lockbox-payload", // the ID from https://api.cloud.yandex.net/endpoints
@ -48,11 +51,6 @@ func (lb *YandexCloudCreator) CreateLockboxClient(ctx context.Context, apiEndpoi
return nil, err return nil, err
} }
err = closeSDK(ctx, sdk)
if err != nil {
return nil, err
}
tlsConfig := tls.Config{MinVersion: tls.VersionTLS12} tlsConfig := tls.Config{MinVersion: tls.VersionTLS12}
if caCertificate != nil { if caCertificate != nil {
@ -85,17 +83,15 @@ func (lb *YandexCloudCreator) CreateIamToken(ctx context.Context, apiEndpoint st
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer func() {
_ = closeSDK(ctx, sdk)
}()
iamToken, err := sdk.CreateIAMToken(ctx) iamToken, err := sdk.CreateIAMToken(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = closeSDK(ctx, sdk)
if err != nil {
return nil, err
}
return &client.IamToken{Token: iamToken.IamToken, ExpiresAt: iamToken.ExpiresAt.AsTime()}, nil return &client.IamToken{Token: iamToken.IamToken, ExpiresAt: iamToken.ExpiresAt.AsTime()}, nil
} }