Documentation ¶
Index ¶
- Constants
- func AsBool(s string) bool
- func AsBoolWithDefault(s string, def bool) bool
- func AsInt(s string) int
- func AsIntWithDefault(s string, def int) int
- 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) GetGlobal(key string) string
- func (c *Config) GetM(mount, key string) string
- func (c *Config) IsSet(key string) bool
- func (c *Config) IsSetM(mount, 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 AsBoolWithDefault ¶ added in v1.15.13
AsBoolWithDefault converts a string to a bool value with a default value.
func AsIntWithDefault ¶ added in v1.15.13
AsIntWithDefault converts a string to an integer value with a default value.
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
NewContextInMemory 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) 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) GetM ¶ added in v1.15.0
GetM returns the given key from the mount or the root config if mount is empty.
func (*Config) IsSetM ¶ added in v1.15.13
IsSetM returns true if the key is set in 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.