config

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConfigNotFound is returned on load if the config was not found
	ErrConfigNotFound = errors.Errorf("config not found")
	// ErrConfigNotParsed is returned on load if the config could not be decoded
	ErrConfigNotParsed = errors.Errorf("config not parseable")
)

Functions

func Directory

func Directory() string

Directory returns the configuration directory for the gopass config file

func Homedir

func Homedir() string

Homedir returns the users home dir or an empty string if the lookup fails

func PwStoreDir

func PwStoreDir(mount string) string

PwStoreDir reads the password store dir from the environment or returns the default location ~/.password-store if the env is not set

func UserCache added in v1.9.2

func UserCache() string

UserCache returns the users cache dir

func UserConfig added in v1.9.2

func UserConfig() string

UserConfig returns the users config dir

func UserData added in v1.9.2

func UserData() string

UserData returns the users data dir

Types

type Config

type Config struct {
	Path   string                  `yaml:"-"`
	Root   *StoreConfig            `yaml:"root"`
	Mounts map[string]*StoreConfig `yaml:"mounts"`

	// Catches all undefined files and must be empty after parsing
	XXX map[string]interface{} `yaml:",inline"`
}

Config is the current config struct

func Load

func Load() *Config

Load will try to load the config from one of the default locations

func New

func New() *Config

New creates a new config with sane default values

func (*Config) CheckOverflow

func (c *Config) CheckOverflow() error

CheckOverflow implements configer. It will check for any extra config values not handled by the current struct

func (*Config) CheckRecipientHash added in v1.8.0

func (c *Config) CheckRecipientHash(alias string) bool

CheckRecipientHash returns true if we should report/fail on any recipient hash errors for this store

func (*Config) Config

func (c *Config) Config() *Config

Config will return a current config

func (*Config) Directory

func (c *Config) Directory() string

Directory returns the directory this config is using

func (*Config) GetRecipientHash added in v1.8.0

func (c *Config) GetRecipientHash(alias, name string) string

GetRecipientHash returns the recipients hash for the given store and file

func (*Config) Save

func (c *Config) Save() error

Save saves the config

func (*Config) SetConfigValue

func (c *Config) SetConfigValue(mount, key, value string) error

SetConfigValue will try to set the given key to the value in the config struct

func (*Config) SetRecipientHash added in v1.8.0

func (c *Config) SetRecipientHash(alias, name, value string) error

SetRecipientHash will set and save the recipient hash for the given store and file

func (*Config) String

func (c *Config) String() string

type Pre130

type Pre130 struct {
	AlwaysTrust bool              `yaml:"alwaystrust"` // always trust public keys when encrypting
	AskForMore  bool              `yaml:"askformore"`  // ask for more data on generate
	AutoImport  bool              `yaml:"autoimport"`  // import missing public keys w/o asking
	AutoPull    bool              `yaml:"autopull"`    // pull from git before push
	AutoPush    bool              `yaml:"autopush"`    // push to git remote after commit
	ClipTimeout int               `yaml:"cliptimeout"` // clear clipboard after seconds
	Debug       bool              `yaml:"debug"`       // enable debug output
	LoadKeys    bool              `yaml:"loadkeys"`    // load missing keys from store
	Mounts      map[string]string `yaml:"mounts,omitempty"`
	NoColor     bool              `yaml:"nocolor"`     // disable colors in output
	NoConfirm   bool              `yaml:"noconfirm"`   // do not confirm recipients when encrypting
	Path        string            `yaml:"path"`        // path to the root store
	PersistKeys bool              `yaml:"persistkeys"` // store recipient keys in store
	SafeContent bool              `yaml:"safecontent"` // avoid showing passwords in terminal
	Version     string            `yaml:"version"`

	// Catches all undefined files and must be empty after parsing
	XXX map[string]interface{} `yaml:",inline"`
}

Pre130 is the gopass config structure before version 1.3.0. Not all fields were available between 1.0.0 and 1.3.0, but this struct should cover all of them.

func (*Pre130) CheckOverflow

func (c *Pre130) CheckOverflow() error

CheckOverflow implements configer

func (*Pre130) Config

func (c *Pre130) Config() *Config

Config converts the Pre130 config to the current config struct

type Pre140

type Pre140 struct {
	AskForMore  bool              `yaml:"askformore"`  // ask for more data on generate
	AutoImport  bool              `yaml:"autoimport"`  // import missing public keys w/o asking
	AutoSync    bool              `yaml:"autosync"`    // push to git remote after commit, pull before push if necessary
	ClipTimeout int               `yaml:"cliptimeout"` // clear clipboard after seconds
	Mounts      map[string]string `yaml:"mounts,omitempty"`
	NoConfirm   bool              `yaml:"noconfirm"`   // do not confirm recipients when encrypting
	Path        string            `yaml:"path"`        // path to the root store
	SafeContent bool              `yaml:"safecontent"` // avoid showing passwords in terminal
	Version     string            `yaml:"version"`

	// Catches all undefined files and must be empty after parsing
	XXX map[string]interface{} `yaml:",inline"`
}

Pre140 is the gopass config structure before version 1.4.0

func (*Pre140) CheckOverflow

func (c *Pre140) CheckOverflow() error

CheckOverflow implements configer

func (*Pre140) Config

func (c *Pre140) Config() *Config

Config converts the Pre140 config to the current config struct

type Pre182 added in v1.8.2

type Pre182 struct {
	Path    string                        `yaml:"-"`
	Root    *Pre182StoreConfig            `yaml:"root"`
	Mounts  map[string]*Pre182StoreConfig `yaml:"mounts"`
	Version string                        `yaml:"version"`

	// Catches all undefined files and must be empty after parsing
	XXX map[string]interface{} `yaml:",inline"`
}

Pre182 is the current config struct

func (*Pre182) CheckOverflow added in v1.8.2

func (c *Pre182) CheckOverflow() error

CheckOverflow implements configer

func (*Pre182) Config added in v1.8.2

func (c *Pre182) Config() *Config

Config converts the Pre140 config to the current config struct

type Pre182StoreConfig added in v1.8.2

type Pre182StoreConfig struct {
	AskForMore     bool              `yaml:"askformore"` // ask for more data on generate
	AutoClip       bool              `yaml:"autoclip"`   // decide whether passwords are automatically copied or not
	AutoImport     bool              `yaml:"autoimport"` // import missing public keys w/o asking
	AutoSync       bool              `yaml:"autosync"`   // push to git remote after commit, pull before push if necessary
	CheckRecpHash  bool              `yaml:"check_recipient_hash"`
	ClipTimeout    int               `yaml:"cliptimeout"`    // clear clipboard after seconds
	Concurrency    int               `yaml:"concurrency"`    // allow to run multiple thread when batch processing
	EditRecipients bool              `yaml:"editrecipients"` // edit recipients when confirming
	NoColor        bool              `yaml:"nocolor"`        // do not use color when outputing text
	NoConfirm      bool              `yaml:"noconfirm"`      // do not confirm recipients when encrypting
	NoPager        bool              `yaml:"nopager"`        // do not invoke a pager to display long lists
	Notifications  bool              `yaml:"notifications"`  // enable desktop notifications
	Path           *backend.URL      `yaml:"path"`           // path to the root store
	RecipientHash  map[string]string `yaml:"recipient_hash"`
	SafeContent    bool              `yaml:"safecontent"` // avoid showing passwords in terminal
	UseSymbols     bool              `yaml:"usesymbols"`  // always use symbols when generating passwords
}

Pre182StoreConfig is a per-store (root or mount) config

func (*Pre182StoreConfig) StoreConfig added in v1.8.2

func (c *Pre182StoreConfig) StoreConfig() *StoreConfig

StoreConfig returns a current StoreConfig

type StoreConfig

type StoreConfig struct {
	AskForMore     bool              `yaml:"askformore"` // ask for more data on generate
	AutoClip       bool              `yaml:"autoclip"`   // decide whether passwords are automatically copied or not
	AutoPrint      bool              `yaml:"autoprint"`  // decide whether passwords are automatically printed or not
	AutoImport     bool              `yaml:"autoimport"` // import missing public keys w/o asking
	AutoSync       bool              `yaml:"autosync"`   // push to git remote after commit, pull before push if necessary
	CheckRecpHash  bool              `yaml:"check_recipient_hash"`
	ClipTimeout    int               `yaml:"cliptimeout"`    // clear clipboard after seconds
	Concurrency    int               `yaml:"concurrency"`    // allow to run multiple thread when batch processing
	EditRecipients bool              `yaml:"editrecipients"` // edit recipients when confirming
	ExportKeys     bool              `yaml:"exportkeys"`     // automatically export public keys of all recipients
	NoColor        bool              `yaml:"nocolor"`        // do not use color when outputing text
	NoConfirm      bool              `yaml:"noconfirm"`      // do not confirm recipients when encrypting
	NoPager        bool              `yaml:"nopager"`        // do not invoke a pager to display long lists
	Notifications  bool              `yaml:"notifications"`  // enable desktop notifications
	Path           *backend.URL      `yaml:"path"`           // path to the root store
	RecipientHash  map[string]string `yaml:"recipient_hash"`
	SafeContent    bool              `yaml:"safecontent"` // avoid showing passwords in terminal
	UseSymbols     bool              `yaml:"usesymbols"`  // always use symbols when generating passwords
}

StoreConfig is a per-store (root or mount) config

func (*StoreConfig) ConfigMap

func (c *StoreConfig) ConfigMap() map[string]string

ConfigMap returns a map of stringified config values for easy printing

func (*StoreConfig) SetConfigValue

func (c *StoreConfig) SetConfigValue(key, value string) error

SetConfigValue will try to set the given key to the value in the config struct

func (*StoreConfig) String

func (c *StoreConfig) String() string

func (StoreConfig) WithContext

func (c StoreConfig) WithContext(ctx context.Context) context.Context

WithContext returns a context with all config options set for this store config, iff they have not been already set in the context

Jump to

Keyboard shortcuts

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