storage

package
v0.0.0-...-880cb89 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Bucket         = "bucket"
	Endpoint       = "endpoint"
	Prefix         = "prefix"
	DoNotUseTLS    = "donotusetls"
	DoNotVerifyTLS = "donotverifytls"
)

config exported name consts

View Source
const (
	BucketNameKey             = "bucket"
	EndpointKey               = "endpoint"
	PrefixKey                 = "prefix"
	DisableTLSKey             = "disable_tls"
	DisableTLSVerificationKey = "disable_tls_verification"

	AccessKey       = "aws_access_key_id"
	SecretAccessKey = "aws_secret_access_key"
	SessionToken    = "aws_session_token"
)

config file keys

View Source
const (
	FilesystemPath = "path"
)
View Source
const (
	StorageProviderTypeKey = "provider"
)

Variables

View Source
var ErrVerifyingConfigStorage = clues.New("verifying configs in corso config file")
View Source
var StringToProviderType = map[string]ProviderType{
	ProviderUnknown.String():    ProviderUnknown,
	ProviderS3.String():         ProviderS3,
	ProviderFilesystem.String(): ProviderFilesystem,
}

Functions

This section is empty.

Types

type CommonConfig

type CommonConfig struct {
	credentials.Corso // requires: CorsoPassphrase

	KopiaCfgDir string
}

func (CommonConfig) StringConfig

func (c CommonConfig) StringConfig() (map[string]string, error)

StringConfig transforms a commonConfig struct into a plain map[string]string. All values in the original struct which serialize into the map are expected to be strings.

type Configurer

type Configurer interface {
	common.StringConfigurer

	// ApplyOverrides fetches config from file, processes overrides
	// from sources like environment variables and flags, and updates the
	// underlying configuration accordingly.
	ApplyConfigOverrides(
		g Getter,
		readConfigFromStore bool,
		matchFromConfig bool,
		overrides map[string]string,
	) error

	WriteConfigToStorer
	// contains filtered or unexported methods
}

func NewStorageConfig

func NewStorageConfig(provider ProviderType) (Configurer, error)

type FilesystemConfig

type FilesystemConfig struct {
	Path string
}

func (*FilesystemConfig) ApplyConfigOverrides

func (c *FilesystemConfig) ApplyConfigOverrides(
	g Getter,
	readConfigFromStore bool,
	matchFromConfig bool,
	overrides map[string]string,
) error

func (FilesystemConfig) StringConfig

func (c FilesystemConfig) StringConfig() (map[string]string, error)

TODO(pandeyabs): We need to sanitize paths e.g. handle relative paths, make paths cross platform compatible, etc.

func (FilesystemConfig) WriteConfigToStore

func (c FilesystemConfig) WriteConfigToStore(
	s Setter,
)

type Getter

type Getter interface {
	Get(key string) any
}

type ProviderType

type ProviderType int
const (
	ProviderUnknown    ProviderType = 0 // Unknown Provider
	ProviderS3         ProviderType = 1 // S3
	ProviderFilesystem ProviderType = 2 // Filesystem
)

func (ProviderType) String

func (i ProviderType) String() string

type S3Config

type S3Config struct {
	credentials.AWS
	Bucket         string // required
	Endpoint       string
	Prefix         string
	DoNotUseTLS    bool
	DoNotVerifyTLS bool
}

func (*S3Config) ApplyConfigOverrides

func (c *S3Config) ApplyConfigOverrides(
	kvg Getter,
	readConfigFromStore bool,
	matchFromConfig bool,
	overrides map[string]string,
) error

func (*S3Config) StringConfig

func (c *S3Config) StringConfig() (map[string]string, error)

StringConfig transforms a s3Config struct into a plain map[string]string. All values in the original struct which serialize into the map are expected to be strings.

func (*S3Config) WriteConfigToStore

func (c *S3Config) WriteConfigToStore(
	kvs Setter,
)

type Setter

type Setter interface {
	Set(key string, value any)
}

type Storage

type Storage struct {
	Provider ProviderType
	Config   map[string]string
	// TODO: These are AWS S3 specific -> move these out
	SessionTags     map[string]string
	Role            string
	SessionName     string
	SessionDuration string
	// QueryParams allows passing custom query parameters to S3 GET object
	// requests. Parameters prefixed by `x-` will be ignored by S3 (no functional
	// changes) but added to server access logs. These KV-pairs are session
	// specific and won't be persisted to or sourced from the corso config file.
	QueryParams map[string]string
}

Storage defines a storage provider, along with any configuration required to set up or communicate with that provider.

func NewStorage

func NewStorage(p ProviderType, cfgs ...common.StringConfigurer) (Storage, error)

NewStorage aggregates all the supplied configurations into a single configuration.

func NewStorageUsingRole

func NewStorageUsingRole(
	p ProviderType,
	roleARN string,
	sessionName string,
	sessionTags map[string]string,
	queryParams map[string]string,
	duration string,
	cfgs ...common.StringConfigurer,
) (Storage, error)

NewStorageUsingRole supports specifying an AWS IAM role the storage provider should assume.

func (Storage) CommonConfig

func (s Storage) CommonConfig() (CommonConfig, error)

CommonConfig retrieves the CommonConfig details from the Storage config.

func (Storage) GetStorageConfigHash

func (s Storage) GetStorageConfigHash() (string, error)

func (Storage) StorageConfig

func (s Storage) StorageConfig() (Configurer, error)

func (Storage) ToFilesystemConfig

func (s Storage) ToFilesystemConfig() (*FilesystemConfig, error)

func (Storage) ToS3Config

func (s Storage) ToS3Config() (*S3Config, error)

type WriteConfigToStorer

type WriteConfigToStorer interface {
	WriteConfigToStore(
		s Setter,
	)
}

WriteConfigToStorer writes config key value pairs to provided store.

Jump to

Keyboard shortcuts

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