store

package
v1.203.0-test.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package store is a generated GoMock package.

Index

Constants

View Source
const (

	// AzureKeyVaultHyphen is the hyphen character used for Azure Key Vault secret name normalization.
	AzureKeyVaultHyphen = "-"
)

Variables

View Source
var (
	// Common validation errors.
	ErrEmptyStack           = errors.New("stack cannot be empty")
	ErrEmptyComponent       = errors.New("component cannot be empty")
	ErrEmptyKey             = errors.New("key cannot be empty")
	ErrStackDelimiterNotSet = errors.New("stack delimiter is not set")
	ErrGetKey               = errors.New("failed to get key")

	// AWS SSM specific errors.
	ErrRegionRequired = errors.New("region is required in ssm store configuration")
	ErrLoadAWSConfig  = errors.New("failed to load AWS config")
	ErrSetParameter   = errors.New("failed to set parameter")
	ErrGetParameter   = errors.New("failed to get parameter")

	// Azure Key Vault specific errors.
	ErrVaultURLRequired = errors.New("vault_url is required in azure key vault store configuration")
	ErrCreateClient     = errors.New("failed to create client")
	ErrAccessSecret     = errors.New("failed to access secret")
	ErrResourceNotFound = errors.New("resource not found")
	ErrPermissionDenied = errors.New("permission denied")

	// Redis specific errors.
	ErrParseRedisURL   = errors.New("failed to parse redis url")
	ErrMissingRedisURL = errors.New("either url must be set in options or ATMOS_REDIS_URL environment variable must be set")
	ErrGetRedisKey     = errors.New("failed to get key from redis")

	// Artifactory specific errors.
	ErrMissingArtifactoryToken = errors.New("either access_token must be set in options or one of JFROG_ACCESS_TOKEN or ARTIFACTORY_ACCESS_TOKEN environment variables must be set")
	ErrCreateTempDir           = errors.New("failed to create temp dir")
	ErrCreateTempFile          = errors.New("failed to create temp file")
	ErrDownloadFile            = errors.New("failed to download file")
	ErrNoFilesDownloaded       = errors.New("no files downloaded")
	ErrReadFile                = errors.New("failed to read file")
	ErrUnmarshalFile           = errors.New("failed to unmarshal file")
	ErrWriteTempFile           = errors.New("failed to write to temp file")
	ErrUploadFile              = errors.New("failed to upload file")

	// Google Secret Manager specific errors.
	ErrProjectIDRequired = errors.New("project_id is required in Google Secret Manager store configuration")
	ErrValueMustBeString = errors.New("value must be a string")
	ErrCreateSecret      = errors.New("failed to create secret")
	ErrAddSecretVersion  = errors.New("failed to add secret version")

	// Registry specific errors.
	ErrParseArtifactoryOptions = errors.New("failed to parse Artifactory store options")
	ErrParseSSMOptions         = errors.New("failed to parse SSM store options")
	ErrParseRedisOptions       = errors.New("failed to parse Redis store options")
	ErrStoreTypeNotFound       = errors.New("store type not found")

	// Shared errors.
	ErrSerializeJSON = errors.New("failed to serialize value to JSON")
	ErrMarshalValue  = errors.New("failed to marshal value")
	ErrNilValue      = errors.New("cannot store nil value")
)

Common errors shared across store implementations.

Functions

This section is empty.

Types

type ArtifactoryClient added in v1.148.1

type ArtifactoryClient interface {
	DownloadFiles(...services.DownloadParams) (int, int, error)
	UploadFiles(artifactory.UploadServiceOptions, ...services.UploadParams) (int, int, error)
}

ArtifactoryClient interface allows us to mock the Artifactory Services Manager in test with only the methods we are using in the ArtifactoryStore.

type ArtifactoryStore added in v1.148.1

type ArtifactoryStore struct {
	// contains filtered or unexported fields
}

func (*ArtifactoryStore) Get added in v1.148.1

func (s *ArtifactoryStore) Get(stack string, component string, key string) (interface{}, error)

func (*ArtifactoryStore) GetKey added in v1.187.0

func (s *ArtifactoryStore) GetKey(key string) (interface{}, error)

func (*ArtifactoryStore) Set added in v1.148.1

func (s *ArtifactoryStore) Set(stack string, component string, key string, value interface{}) error

type ArtifactoryStoreOptions added in v1.148.1

type ArtifactoryStoreOptions struct {
	AccessToken    *string `mapstructure:"access_token"`
	Prefix         *string `mapstructure:"prefix"`
	RepoName       string  `mapstructure:"repo_name"`
	StackDelimiter *string `mapstructure:"stack_delimiter"`
	URL            string  `mapstructure:"url"`
}

type AzureKeyVaultClient added in v1.181.0

type AzureKeyVaultClient interface {
	SetSecret(ctx context.Context, name string, parameters azsecrets.SetSecretParameters, options *azsecrets.SetSecretOptions) (azsecrets.SetSecretResponse, error)
	GetSecret(ctx context.Context, name string, version string, options *azsecrets.GetSecretOptions) (azsecrets.GetSecretResponse, error)
}

AzureKeyVaultClient interface allows us to mock the Azure Key Vault client.

type AzureKeyVaultStore added in v1.181.0

type AzureKeyVaultStore struct {
	// contains filtered or unexported fields
}

AzureKeyVaultStore is an implementation of the Store interface for Azure Key Vault.

func (*AzureKeyVaultStore) Get added in v1.181.0

func (s *AzureKeyVaultStore) Get(stack string, component string, key string) (interface{}, error)

func (*AzureKeyVaultStore) GetKey added in v1.187.0

func (s *AzureKeyVaultStore) GetKey(key string) (interface{}, error)

func (*AzureKeyVaultStore) Set added in v1.181.0

func (s *AzureKeyVaultStore) Set(stack string, component string, key string, value interface{}) error

type AzureKeyVaultStoreOptions added in v1.181.0

type AzureKeyVaultStoreOptions struct {
	VaultURL       string  `mapstructure:"vault_url"`
	Prefix         *string `mapstructure:"prefix"`
	StackDelimiter *string `mapstructure:"stack_delimiter"`
}

type GSMClient added in v1.166.0

GSMClient is the interface that wraps the Google Secret Manager client methods we use.

type GSMStore added in v1.166.0

type GSMStore struct {
	// contains filtered or unexported fields
}

GSMStore is an implementation of the Store interface for Google Secret Manager.

func (*GSMStore) Get added in v1.166.0

func (s *GSMStore) Get(stack string, component string, key string) (any, error)

Get retrieves a value by key from Google Secret Manager.

func (*GSMStore) GetKey added in v1.187.0

func (s *GSMStore) GetKey(key string) (interface{}, error)

func (*GSMStore) Set added in v1.166.0

func (s *GSMStore) Set(stack string, component string, key string, value any) error

Set stores a key-value pair in Google Secret Manager.

type GSMStoreOptions added in v1.166.0

type GSMStoreOptions struct {
	Prefix         *string   `mapstructure:"prefix"`
	ProjectID      string    `mapstructure:"project_id"`
	StackDelimiter *string   `mapstructure:"stack_delimiter"`
	Credentials    *string   `mapstructure:"credentials"` // Optional JSON credentials
	Locations      *[]string `mapstructure:"locations"`   // Optional replication locations
}

GSMStoreOptions defines the configuration options for Google Secret Manager store.

type MockStore added in v1.203.0

type MockStore struct {
	// contains filtered or unexported fields
}

MockStore is a mock of Store interface.

func NewMockStore added in v1.203.0

func NewMockStore(ctrl *gomock.Controller) *MockStore

NewMockStore creates a new mock instance.

func (*MockStore) EXPECT added in v1.203.0

func (m *MockStore) EXPECT() *MockStoreMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockStore) Get added in v1.203.0

func (m *MockStore) Get(stack, component, key string) (any, error)

Get mocks base method.

func (*MockStore) GetKey added in v1.203.0

func (m *MockStore) GetKey(key string) (any, error)

GetKey mocks base method.

func (*MockStore) Set added in v1.203.0

func (m *MockStore) Set(stack, component, key string, value any) error

Set mocks base method.

type MockStoreMockRecorder added in v1.203.0

type MockStoreMockRecorder struct {
	// contains filtered or unexported fields
}

MockStoreMockRecorder is the mock recorder for MockStore.

func (*MockStoreMockRecorder) Get added in v1.203.0

func (mr *MockStoreMockRecorder) Get(stack, component, key any) *gomock.Call

Get indicates an expected call of Get.

func (*MockStoreMockRecorder) GetKey added in v1.203.0

func (mr *MockStoreMockRecorder) GetKey(key any) *gomock.Call

GetKey indicates an expected call of GetKey.

func (*MockStoreMockRecorder) Set added in v1.203.0

func (mr *MockStoreMockRecorder) Set(stack, component, key, value any) *gomock.Call

Set indicates an expected call of Set.

type RedisClient added in v1.159.0

type RedisClient interface {
	Get(ctx context.Context, key string) *redis.StringCmd
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
}

RedisClient interface allows us to mock the Redis Client in test with only the methods we are using in the RedisStore.

type RedisStore added in v1.159.0

type RedisStore struct {
	// contains filtered or unexported fields
}

func (*RedisStore) Get added in v1.159.0

func (s *RedisStore) Get(stack string, component string, key string) (interface{}, error)

func (*RedisStore) GetKey added in v1.187.0

func (s *RedisStore) GetKey(key string) (interface{}, error)

func (*RedisStore) RedisClient added in v1.187.0

func (s *RedisStore) RedisClient() RedisClient

RedisClient returns the underlying Redis client for testing purposes.

func (*RedisStore) Set added in v1.159.0

func (s *RedisStore) Set(stack string, component string, key string, value interface{}) error

type RedisStoreOptions added in v1.159.0

type RedisStoreOptions struct {
	Prefix         *string `mapstructure:"prefix"`
	StackDelimiter *string `mapstructure:"stack_delimiter"`
	URL            *string `mapstructure:"url"`
}

type SSMClient

type SSMClient interface {
	PutParameter(ctx context.Context, params *ssm.PutParameterInput, optFns ...func(*ssm.Options)) (*ssm.PutParameterOutput, error)
	GetParameter(ctx context.Context, params *ssm.GetParameterInput, optFns ...func(*ssm.Options)) (*ssm.GetParameterOutput, error)
}

SSMClient interface allows us to mock the AWS SSM client.

type SSMStore

type SSMStore struct {
	// contains filtered or unexported fields
}

SSMStore is an implementation of the Store interface for AWS SSM Parameter Store.

func (*SSMStore) Get

func (s *SSMStore) Get(stack string, component string, key string) (any, error)

Get retrieves a value by key for an Atmos component in a stack from AWS SSM Parameter Store.

func (*SSMStore) GetKey added in v1.187.0

func (s *SSMStore) GetKey(key string) (any, error)

GetKey retrieves a value by key from AWS SSM Parameter Store.

func (*SSMStore) Set

func (s *SSMStore) Set(stack string, component string, key string, value any) error

Set stores a key-value pair in AWS SSM Parameter Store.

type SSMStoreOptions

type SSMStoreOptions struct {
	Prefix         *string `mapstructure:"prefix"`
	Region         string  `mapstructure:"region"`
	StackDelimiter *string `mapstructure:"stack_delimiter"`
	ReadRoleArn    *string `mapstructure:"read_role_arn"`
	WriteRoleArn   *string `mapstructure:"write_role_arn"`
}

type STSClient added in v1.168.0

type STSClient interface {
	AssumeRole(ctx context.Context, params *sts.AssumeRoleInput, optFns ...func(*sts.Options)) (*sts.AssumeRoleOutput, error)
}

STSClient interface allows us to mock the AWS STS client.

type Store

type Store interface {
	// Set stores a value for a specific stack, component, and key combination.
	Set(stack string, component string, key string, value any) error
	// Get retrieves a value for a specific stack, component, and key combination.
	Get(stack string, component string, key string) (any, error)
	// GetKey retrieves a value directly by key without stack or component context.
	GetKey(key string) (any, error)
}

Store defines the common interface for all store implementations.

func NewArtifactoryStore added in v1.148.1

func NewArtifactoryStore(options ArtifactoryStoreOptions) (Store, error)

func NewAzureKeyVaultStore added in v1.181.0

func NewAzureKeyVaultStore(options AzureKeyVaultStoreOptions) (Store, error)

func NewGSMStore added in v1.166.0

func NewGSMStore(options GSMStoreOptions) (Store, error)

NewGSMStore initializes a new Google Secret Manager Store.

func NewRedisStore added in v1.159.0

func NewRedisStore(options RedisStoreOptions) (Store, error)

func NewSSMStore

func NewSSMStore(options SSMStoreOptions) (Store, error)

NewSSMStore initializes a new SSMStore.

type StoreConfig

type StoreConfig struct {
	Type    string                 `yaml:"type"`
	Options map[string]interface{} `yaml:"options"`
}

type StoreFactory

type StoreFactory func(options map[string]any) (Store, error)

StoreFactory is a function type to initialize a new store.

type StoreRegistry

type StoreRegistry map[string]Store

func NewStoreRegistry

func NewStoreRegistry(config *StoresConfig) (StoreRegistry, error)

type StoresConfig

type StoresConfig = map[string]StoreConfig

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL