0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00
zot/pkg/test/mocks/secrets_manager_mock.go
Andreea Lupu 68a197d7cc
fix: add retry logic to recreate existing trustpolicy secret (#1776)
Signed-off-by: Andreea-Lupu <andreealupu1470@yahoo.com>
2023-09-11 10:13:22 +03:00

58 lines
2.1 KiB
Go

package mocks
import (
"context"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
)
type SecretsManagerMock struct {
CreateSecretFn func(ctx context.Context, params *secretsmanager.CreateSecretInput,
optFns ...func(*secretsmanager.Options)) (*secretsmanager.CreateSecretOutput, error)
DeleteSecretFn func(ctx context.Context, params *secretsmanager.DeleteSecretInput,
optFns ...func(*secretsmanager.Options)) (*secretsmanager.DeleteSecretOutput, error)
ListSecretsFn func(ctx context.Context, params *secretsmanager.ListSecretsInput,
optFns ...func(*secretsmanager.Options)) (*secretsmanager.ListSecretsOutput, error)
}
func (secretsManagerMock SecretsManagerMock) CreateSecret(ctx context.Context, params *secretsmanager.CreateSecretInput,
optFns ...func(*secretsmanager.Options),
) (*secretsmanager.CreateSecretOutput, error) {
if secretsManagerMock.CreateSecretFn != nil {
return secretsManagerMock.CreateSecretFn(ctx, params, optFns...)
}
return &secretsmanager.CreateSecretOutput{}, nil
}
func (secretsManagerMock SecretsManagerMock) DeleteSecret(ctx context.Context, params *secretsmanager.DeleteSecretInput,
optFns ...func(*secretsmanager.Options),
) (*secretsmanager.DeleteSecretOutput, error) {
if secretsManagerMock.DeleteSecretFn != nil {
return secretsManagerMock.DeleteSecretFn(ctx, params, optFns...)
}
return &secretsmanager.DeleteSecretOutput{}, nil
}
func (secretsManagerMock SecretsManagerMock) ListSecrets(ctx context.Context, params *secretsmanager.ListSecretsInput,
optFns ...func(*secretsmanager.Options),
) (*secretsmanager.ListSecretsOutput, error) {
if secretsManagerMock.ListSecretsFn != nil {
return secretsManagerMock.ListSecretsFn(ctx, params, optFns...)
}
return &secretsmanager.ListSecretsOutput{}, nil
}
type SecretsManagerCacheMock struct {
GetSecretStringFn func(string) (string, error)
}
func (secretsManagerCacheMock SecretsManagerCacheMock) GetSecretString(secretID string) (string, error) {
if secretsManagerCacheMock.GetSecretStringFn != nil {
return secretsManagerCacheMock.GetSecretStringFn(secretID)
}
return "", nil
}