Documentation ¶
Index ¶
- Constants
- func Bool(ctx context.Context, key string) bool
- func DefaultPasswordLengthFromEnv(ctx context.Context) (int, bool)
- func Directory() string
- func HasGlobalConfig() bool
- func Int(ctx context.Context, key string) int
- func NewContextInMemory() context.Context
- func PwStoreDir(mount string) string
- func String(ctx context.Context, key string) string
- func WithMount(ctx context.Context, mp string) context.Context
- type Config
- func (c *Config) Get(key string) string
- func (c *Config) GetAll(key string) []string
- func (c *Config) GetBool(key string) bool
- func (c *Config) GetBoolM(mount, key string) bool
- func (c *Config) GetGlobal(key string) string
- func (c *Config) GetInt(key string) int
- func (c *Config) GetIntM(mount, key string) int
- func (c *Config) GetM(mount, key string) string
- func (c *Config) IsSet(key string) bool
- func (c *Config) Keys(mount string) []string
- func (c *Config) MountPath(mountPoint string) string
- func (c *Config) Mounts() []string
- func (c *Config) Path() string
- func (c *Config) Set(mount, key, value string) error
- func (c *Config) SetEnv(key, value string) error
- func (c *Config) SetMountPath(mount, path string) error
- func (c *Config) SetPath(path string) error
- func (c *Config) SetWithLevel(mount, key, value string) (Level, error)
- func (c *Config) Unset(mount, key string) error
- func (c *Config) WithConfig(ctx context.Context) context.Context
- type Level
Constants ¶
const ( DefaultPasswordLength = 24 DefaultXKCDLength = 4 )
Variables ¶
This section is empty.
Functions ¶
func DefaultPasswordLengthFromEnv ¶ added in v1.15.8
DefaultPasswordLengthFromEnv will determine the password length from the env variable GOPASS_PW_DEFAULT_LENGTH or fallback to the hard-coded default length. If the env variable is set by the user and is valid, the boolean return value will be true, otherwise it will be false.
func Directory ¶
func Directory() string
Directory returns the configuration directory for the gopass config file.
func HasGlobalConfig ¶ added in v1.15.1
func HasGlobalConfig() bool
HasGlobalConfig returns true if there is an existing global config.
func NewContextInMemory ¶ added in v1.15.11
NewContextReadOnly returns a context with a read-only config.
func PwStoreDir ¶
PwStoreDir reads the password store dir from the environment or returns the default location if the env is not set.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a gopass config handler.
func FromContext ¶ added in v1.15.0
FromContext returns a config from a context, as well as the current mount point (store name) if found.
func New ¶
func New() *Config
New initializes a new gopass config. It will handle legacy configs as well and legacy option names, migrating them to their new location and names on a best effort basis. Any system level config or env variables options are not migrated.
func NewInMemory ¶ added in v1.15.11
func NewInMemory() *Config
NewInMemory initializes a new config that does not allow writes. For use in tests. This does not migrate legacy option names to their correct config section.
func (*Config) GetBool ¶ added in v1.15.0
GetBool returns true if the value of the key evaluates to "true". Otherwise, it returns false.
func (*Config) GetBoolM ¶ added in v1.15.10
GetBoolM returns true if the value of the key evaluates to "true" for the provided mount, or the root config if mount is empty. Otherwise, it returns false.
func (*Config) GetGlobal ¶ added in v1.15.10
GetGlobal returns the given key from the root global config. This is typically used to prevent a local config override of sensitive config items, e.g. used for integrity checks.
func (*Config) GetInt ¶ added in v1.15.0
GetInt returns the integer value of the key if it can be parsed. Otherwise, it returns 0.
func (*Config) GetIntM ¶ added in v1.15.10
GetIntM returns the integer value of the key if it can be parsed for the provided mount, or the root config if mount is empty Otherwise, it returns 0.
func (*Config) GetM ¶ added in v1.15.0
GetM returns the given key from the mount or the root config if mount is empty.
func (*Config) Mounts ¶
Mounts returns all mount points from the root config. Note: Any mounts in local configs are ignored.
func (*Config) Set ¶ added in v1.15.0
Set tries to set the key to the given value. The mount option is necessary to discern between the per-user (global) and possible per-directory (local) config files.
- If mount is empty the setting will be written to the per-user config (global)
- If mount has the special value "<root>" the setting will be written to the per-directory config of the root store (local)
- If mount has any other value we will attempt to write the setting to the per-directory config of this mount.
- If the mount point does not exist we will return nil.
func (*Config) SetMountPath ¶ added in v1.15.0
SetMountPath is a shortcut to set a mount to a path.
func (*Config) SetWithLevel ¶ added in v1.15.10
SetWithLevel is the same as Set, but it also returns the level at which the config was set. It currently only supports global and local configs.