Documentation
¶
Index ¶
- Constants
- Variables
- type CommonConfig
- type Configurer
- type FilesystemConfig
- type Getter
- type ProviderType
- type S3Config
- type Setter
- type Storage
- func (s Storage) CommonConfig() (CommonConfig, error)
- func (s Storage) GetStorageConfigHash() (string, error)
- func (s Storage) GoString() string
- func (s Storage) MarshalJSON() ([]byte, error)
- func (s Storage) StorageConfig() (Configurer, error)
- func (s Storage) String() string
- func (s Storage) ToFilesystemConfig() (*FilesystemConfig, error)
- func (s Storage) ToS3Config() (*S3Config, error)
- type WriteConfigToStorer
Constants ¶
const ( Bucket = "bucket" Endpoint = "endpoint" Prefix = "prefix" DoNotUseTLS = "donotusetls" DoNotVerifyTLS = "donotverifytls" )
config exported name consts
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
const (
FilesystemPath = "path"
)
const (
StorageProviderTypeKey = "provider"
)
Variables ¶
var ErrVerifyingConfigStorage = clues.New("verifying configs in corso config file")
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 (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 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 (*S3Config) StringConfig ¶
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 ¶
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 (Storage) GoString ¶
GoString implements fmt.GoStringer, covering %#v specifically: fmt checks GoStringer separately from Stringer for that verb.
func (Storage) MarshalJSON ¶
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 ¶
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 ¶
type WriteConfigToStorer ¶
type WriteConfigToStorer interface {
WriteConfigToStore(
s Setter,
)
}
WriteConfigToStorer writes config key value pairs to provided store.