storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 {
	// AccessKey and SecretKey, embedded here from credentials.AWS, are
	// both required, with no opt-out anywhere in this fork - see
	// validate().
	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
}

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 (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) GoString

func (s Storage) GoString() string

GoString implements fmt.GoStringer, covering %#v specifically: fmt checks GoStringer separately from Stringer for that verb.

func (Storage) MarshalJSON

func (s Storage) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. encoding/json does not consult Stringer (or any other fmt interface) at all, so without this, json.Marshal(s) - or marshalling any struct that embeds or contains a Storage field, directly or several layers down - emits Config, and so the repository's encryption key and any S3 credentials, in plain text. This matters beyond logging: a payload persisted to a job queue or any other store that round-trips through JSON carries this struct's fields as-is, with no special handling for this one.

func (Storage) StorageConfig

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

func (Storage) String

func (s Storage) String() string

String implements fmt.Stringer, covering the %v, %+v, %s and %q verbs. Storage.Config is a plain map[string]string that, depending on Provider, holds the repository's own encryption key (CommonConfig.CorsoPassphrase) and, for S3-compatible storage, an access key and secret key. Without this, every one of those verbs printed Config in full. Callers needing the real values should use ToS3Config/ToFilesystemConfig/CommonConfig directly - this type's own default formatting never includes them.

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