config

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: GPL-3.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

This section is empty.

Variables

This section is empty.

Functions

func ShowStruct added in v0.8.1

func ShowStruct(w io.Writer, orig interface{}) error

ShowStruct write out to w a human readable text representation of the orig parameter

Types

type BackupSection

type BackupSection struct {
	CheckBefore        bool                   `mapstructure:"check-before"`
	CheckAfter         bool                   `mapstructure:"check-after"`
	RunBefore          []string               `mapstructure:"run-before"`
	RunAfter           []string               `mapstructure:"run-after"`
	UseStdin           bool                   `mapstructure:"stdin" argument:"stdin"`
	Source             []string               `mapstructure:"source"`
	ExcludeFile        []string               `mapstructure:"exclude-file" argument:"exclude-file"`
	FilesFrom          []string               `mapstructure:"files-from" argument:"files-from"`
	Schedule           []string               `mapstructure:"schedule"`
	SchedulePermission string                 `mapstructure:"schedule-permission"`
	ScheduleLog        string                 `mapstructure:"schedule-log"`
	OtherFlags         map[string]interface{} `mapstructure:",remain"`
}

BackupSection contains the specific configuration to the 'backup' command

type Config added in v0.8.0

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

Config wraps up a viper configuration object

func Load added in v0.8.0

func Load(input io.Reader, format string) (*Config, error)

Load configuration from reader

func LoadFile added in v0.8.0

func LoadFile(configFile, format string) (*Config, error)

LoadFile loads configuration from file Leave format blank for auto-detection from the file extension

func (*Config) AllSettings added in v0.8.0

func (c *Config) AllSettings() map[string]interface{}

AllSettings merges all settings and returns them as a map[string]interface{}.

func (*Config) Get added in v0.8.0

func (c *Config) Get(key string) interface{}

Get the value from the key

func (*Config) GetConfigFile added in v0.8.0

func (c *Config) GetConfigFile() string

GetConfigFile returns the config file used

func (*Config) GetGlobalSection added in v0.8.0

func (c *Config) GetGlobalSection() (*Global, error)

GetGlobalSection returns the global configuration

func (*Config) GetProfile added in v0.8.0

func (c *Config) GetProfile(profileKey string) (*Profile, error)

GetProfile from configuration

func (*Config) GetProfileGroup added in v0.8.0

func (c *Config) GetProfileGroup(groupKey string) ([]string, error)

GetProfileGroup returns the list of profiles in a group

func (*Config) GetProfileGroups added in v0.8.0

func (c *Config) GetProfileGroups() map[string][]string

GetProfileGroups returns all groups from the configuration

If the groups section does not exist, it returns an empty map

func (*Config) GetProfileSections added in v0.8.0

func (c *Config) GetProfileSections() map[string][]string

GetProfileSections returns a list of profiles with all the sections defined inside each

func (*Config) HasProfile added in v0.8.0

func (c *Config) HasProfile(profileKey string) bool

HasProfile returns true if the profile exists in the configuration

func (*Config) HasProfileGroup added in v0.8.0

func (c *Config) HasProfileGroup(groupKey string) bool

HasProfileGroup returns true if the group of profiles exists in the configuration

func (*Config) IsSet added in v0.8.0

func (c *Config) IsSet(key string) bool

IsSet checks if the key contains a value

type Global

type Global struct {
	IONice         bool   `mapstructure:"ionice"`
	IONiceClass    int    `mapstructure:"ionice-class"`
	IONiceLevel    int    `mapstructure:"ionice-level"`
	Nice           int    `mapstructure:"nice"`
	Priority       string `mapstructure:"priority"`
	DefaultCommand string `mapstructure:"default-command"`
	Initialize     bool   `mapstructure:"initialize"`
	ResticBinary   string `mapstructure:"restic-binary"`
	MinMemory      uint64 `mapstructure:"min-memory"`
}

Global holds the configuration from the global section

type OtherSectionWithSchedule added in v0.9.0

type OtherSectionWithSchedule struct {
	Schedule           []string               `mapstructure:"schedule"`
	SchedulePermission string                 `mapstructure:"schedule-permission"`
	ScheduleLog        string                 `mapstructure:"schedule-log"`
	OtherFlags         map[string]interface{} `mapstructure:",remain"`
}

OtherSectionWithSchedule is a section containing schedule only specific parameters (the other parameters being for restic)

type Profile

type Profile struct {
	Name          string
	Quiet         bool                      `mapstructure:"quiet" argument:"quiet"`
	Verbose       bool                      `mapstructure:"verbose" argument:"verbose"`
	Repository    string                    `mapstructure:"repository" argument:"repo"`
	PasswordFile  string                    `mapstructure:"password-file" argument:"password-file"`
	CacheDir      string                    `mapstructure:"cache-dir" argument:"cache-dir"`
	CACert        string                    `mapstructure:"cacert" argument:"cacert"`
	TLSClientCert string                    `mapstructure:"tls-client-cert" argument:"tls-client-cert"`
	Initialize    bool                      `mapstructure:"initialize"`
	Inherit       string                    `mapstructure:"inherit"`
	Lock          string                    `mapstructure:"lock"`
	RunBefore     []string                  `mapstructure:"run-before"`
	RunAfter      []string                  `mapstructure:"run-after"`
	RunAfterFail  []string                  `mapstructure:"run-after-fail"`
	Environment   map[string]string         `mapstructure:"env"`
	Backup        *BackupSection            `mapstructure:"backup"`
	Retention     *RetentionSection         `mapstructure:"retention"`
	Check         *OtherSectionWithSchedule `mapstructure:"check"`
	Snapshots     map[string]interface{}    `mapstructure:"snapshots"`
	Forget        map[string]interface{}    `mapstructure:"forget"`
	Mount         map[string]interface{}    `mapstructure:"mount"`
	OtherFlags    map[string]interface{}    `mapstructure:",remain"`
	// contains filtered or unexported fields
}

Profile contains the whole profile configuration

func NewProfile

func NewProfile(c *Config, name string) *Profile

NewProfile instantiates a new blank profile

func (*Profile) GetBackupSource

func (p *Profile) GetBackupSource() []string

GetBackupSource returns the directories to backup

func (*Profile) GetCommandFlags

func (p *Profile) GetCommandFlags(command string) map[string][]string

GetCommandFlags returns the flags specific to the command (backup, snapshots, forget, etc.)

func (*Profile) GetCommonFlags

func (p *Profile) GetCommonFlags() map[string][]string

GetCommonFlags returns the flags common to all commands

func (*Profile) GetRetentionFlags

func (p *Profile) GetRetentionFlags() map[string][]string

GetRetentionFlags returns the flags specific to the "forget" command being run as part of a backup

func (*Profile) Schedules added in v0.9.0

func (p *Profile) Schedules() []*ScheduleConfig

Schedules returns a slice of ScheduleConfig that satisfy the schedule.Config interface

func (*Profile) SetHost

func (p *Profile) SetHost(hostname string)

SetHost will replace any host value from a boolean to the hostname

func (*Profile) SetRootPath

func (p *Profile) SetRootPath(rootPath string)

SetRootPath changes the path of all the relative paths and files in the configuration

type RetentionSection

type RetentionSection struct {
	BeforeBackup       bool                   `mapstructure:"before-backup"`
	AfterBackup        bool                   `mapstructure:"after-backup"`
	Schedule           []string               `mapstructure:"schedule"`
	SchedulePermission string                 `mapstructure:"schedule-permission"`
	ScheduleLog        string                 `mapstructure:"schedule-log"`
	OtherFlags         map[string]interface{} `mapstructure:",remain"`
}

RetentionSection contains the specific configuration to the 'forget' command when running as part of a backup

type ScheduleConfig added in v0.9.0

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

func (*ScheduleConfig) Arguments added in v0.9.0

func (s *ScheduleConfig) Arguments() []string

func (*ScheduleConfig) Command added in v0.9.0

func (s *ScheduleConfig) Command() string

func (*ScheduleConfig) Environment added in v0.9.0

func (s *ScheduleConfig) Environment() map[string]string

func (*ScheduleConfig) JobDescription added in v0.9.0

func (s *ScheduleConfig) JobDescription() string

func (*ScheduleConfig) Logfile added in v0.9.0

func (s *ScheduleConfig) Logfile() string

func (*ScheduleConfig) Nice added in v0.9.0

func (s *ScheduleConfig) Nice() int

func (*ScheduleConfig) Permission added in v0.9.0

func (s *ScheduleConfig) Permission() string

func (*ScheduleConfig) Schedules added in v0.9.0

func (s *ScheduleConfig) Schedules() []string

func (*ScheduleConfig) SetCommand added in v0.9.0

func (s *ScheduleConfig) SetCommand(wd, command string, args []string)

func (*ScheduleConfig) SetJobDescription added in v0.9.0

func (s *ScheduleConfig) SetJobDescription(description string)

func (*ScheduleConfig) SetTimerDescription added in v0.9.0

func (s *ScheduleConfig) SetTimerDescription(description string)

func (*ScheduleConfig) SubTitle added in v0.9.0

func (s *ScheduleConfig) SubTitle() string

func (*ScheduleConfig) TimerDescription added in v0.9.0

func (s *ScheduleConfig) TimerDescription() string

func (*ScheduleConfig) Title added in v0.9.0

func (s *ScheduleConfig) Title() string

func (*ScheduleConfig) WorkingDirectory added in v0.9.0

func (s *ScheduleConfig) WorkingDirectory() string

Jump to

Keyboard shortcuts

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