profile

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultFilename = "profiles.yaml"

DefaultFilename is the conventional name of the profiles file inside the config directory. See DefaultPath for the full location.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath(configDir string) (string, error)

DefaultPath returns where the profiles file lives when no path is given: profiles.yaml inside the config directory, which configDir may override (see paths.ConfigDir, whose meaning it carries — empty means CLOUDSTIC_CONFIG_DIR or the platform default).

It resolves a path without touching the filesystem, so asking where profiles would live does not create anything.

CLOUDSTIC_PROFILES_FILE is deliberately not consulted. The cloudstic CLI binds it to -profiles-file as an ordinary environment default, so by the time a caller needs this, that variable was either applied already or not set.

func EnsureMaps

func EnsureMaps(cfg *Config)

EnsureMaps guarantees cfg's map fields are non-nil, so callers can write into them unconditionally.

func Save

func Save(path string, cfg *Config) error

Save writes a profiles YAML file atomically.

Types

type Auth

type Auth struct {
	Provider          string `yaml:"provider"` // google | onedrive
	GoogleCreds       string `yaml:"google_credentials,omitempty"`
	GoogleCredsRef    string `yaml:"google_credentials_ref,omitempty"`
	GoogleCredsJSON   string `yaml:"google_credentials_json,omitempty"`
	GoogleTokenFile   string `yaml:"google_token_file,omitempty"`
	GoogleTokenRef    string `yaml:"google_token_ref,omitempty"`
	OneDriveClientID  string `yaml:"onedrive_client_id,omitempty"`
	OneDriveTokenFile string `yaml:"onedrive_token_file,omitempty"`
	OneDriveTokenRef  string `yaml:"onedrive_token_ref,omitempty"`
}

Auth defines reusable OAuth settings for cloud providers.

type Config

type Config struct {
	Version  int                `yaml:"version"`
	Stores   map[string]Store   `yaml:"stores"`
	Auth     map[string]Auth    `yaml:"auth"`
	Profiles map[string]Profile `yaml:"profiles"`
}

Config is the top-level YAML document for backup profiles.

func Load

func Load(path string) (*Config, error)

Load reads and parses a profiles YAML file.

func LoadOrEmpty

func LoadOrEmpty(path string) (*Config, error)

LoadOrEmpty loads profiles from path, treating a missing file as an empty, version-1 config rather than an error. Callers that only read or manage profiles (list, setup, the TUI) want this; callers running a command against a named profile want Load's hard error, since a silently-empty config there would misreport "unknown profile" instead of "no profiles file".

func Normalize

func Normalize(cfg *Config) *Config

Normalize returns a config that is safe to read and write into: a nil config becomes an empty one, the version defaults to 1, and every map field is non-nil.

It is the nil-tolerant form of EnsureMaps, which mutates an existing config in place and leaves the version alone. Prefer Normalize when the config may be nil or may have come from an empty file.

func (*Config) StoreFor

func (c *Config) StoreFor(name string) (*Store, error)

StoreFor returns the store definition that profile name selects, or nil when the profile names no store.

A nil store is not an error. A profile may leave the store to whoever runs it — the cloudstic CLI then takes it from -store or CLOUDSTIC_STORE — so "this profile says nothing about where the repository is" is a legitimate answer, distinct from the broken reference that produces an error.

Resolving the store: pass the result to config.FromProfileStore, which reads the secret references it names, or to config.MergeProfileStore to fold it under a configuration the caller has already partly decided.

type Profile

type Profile struct {
	Source            string   `yaml:"source"`
	Store             string   `yaml:"store,omitempty"`
	AuthRef           string   `yaml:"auth_ref,omitempty"`
	Tags              []string `yaml:"tags,omitempty"`
	Excludes          []string `yaml:"excludes,omitempty"`
	ExcludeFile       string   `yaml:"exclude_file,omitempty"`
	IgnoreEmpty       bool     `yaml:"ignore_empty,omitempty"`
	SkipNativeFiles   bool     `yaml:"skip_native_files,omitempty"`
	VolumeUUID        string   `yaml:"volume_uuid,omitempty"`
	GoogleCreds       string   `yaml:"google_credentials,omitempty"`
	GoogleCredsRef    string   `yaml:"google_credentials_ref,omitempty"`
	GoogleCredsJSON   string   `yaml:"google_credentials_json,omitempty"`
	GoogleTokenFile   string   `yaml:"google_token_file,omitempty"`
	GoogleTokenRef    string   `yaml:"google_token_ref,omitempty"`
	OneDriveClientID  string   `yaml:"onedrive_client_id,omitempty"`
	OneDriveTokenFile string   `yaml:"onedrive_token_file,omitempty"`
	OneDriveTokenRef  string   `yaml:"onedrive_token_ref,omitempty"`
	Enabled           *bool    `yaml:"enabled,omitempty"`
}

Profile defines one backup job preset.

func (Profile) IsEnabled

func (p Profile) IsEnabled() bool

IsEnabled reports whether the profile should be included in -all-profiles.

type Store

type Store struct {
	URI               string `yaml:"uri"`
	S3Endpoint        string `yaml:"s3_endpoint,omitempty"`
	S3Region          string `yaml:"s3_region,omitempty"`
	S3Profile         string `yaml:"s3_profile,omitempty"`
	S3AccessKey       string `yaml:"s3_access_key,omitempty"`
	S3SecretKey       string `yaml:"s3_secret_key,omitempty"`
	B2KeyID           string `yaml:"b2_key_id,omitempty"`
	B2AppKey          string `yaml:"b2_app_key,omitempty"`
	StoreSFTPPassword string `yaml:"store_sftp_password,omitempty"`
	StoreSFTPKey      string `yaml:"store_sftp_key,omitempty"`

	// Encryption: env var indirection for secrets, direct values for non-secrets.
	PasswordSecret          string `yaml:"password_secret,omitempty"`
	EncryptionKeySecret     string `yaml:"encryption_key_secret,omitempty"`
	RecoveryKeySecret       string `yaml:"recovery_key_secret,omitempty"`
	S3AccessKeySecret       string `yaml:"s3_access_key_secret,omitempty"`
	S3SecretKeySecret       string `yaml:"s3_secret_key_secret,omitempty"`
	B2KeyIDSecret           string `yaml:"b2_key_id_secret,omitempty"`
	B2AppKeySecret          string `yaml:"b2_app_key_secret,omitempty"`
	StoreSFTPPasswordSecret string `yaml:"store_sftp_password_secret,omitempty"`
	StoreSFTPKeySecret      string `yaml:"store_sftp_key_secret,omitempty"`
	KMSKeyARN               string `yaml:"kms_key_arn,omitempty"`
	KMSRegion               string `yaml:"kms_region,omitempty"`
	KMSEndpoint             string `yaml:"kms_endpoint,omitempty"`
}

Store defines reusable backend settings.

Jump to

Keyboard shortcuts

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