config

package
v1.15.13 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPasswordLength = 24
	DefaultXKCDLength     = 4
)

Variables

This section is empty.

Functions

func AsBool added in v1.15.13

func AsBool(s string) bool

AsBool converts a string to a bool value.

func AsBoolWithDefault added in v1.15.13

func AsBoolWithDefault(s string, def bool) bool

AsBoolWithDefault converts a string to a bool value with a default value.

func AsInt added in v1.15.13

func AsInt(s string) int

AsInt converts a string to an integer value.

func AsIntWithDefault added in v1.15.13

func AsIntWithDefault(s string, def int) int

AsIntWithDefault converts a string to an integer value with a default value.

func Bool added in v1.15.0

func Bool(ctx context.Context, key string) bool

Bool returns a bool value from the config in the context.

func DefaultPasswordLengthFromEnv added in v1.15.8

func DefaultPasswordLengthFromEnv(ctx context.Context) (int, bool)

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 Int added in v1.15.0

func Int(ctx context.Context, key string) int

Int returns an integer value from the config in the context.

func NewContextInMemory added in v1.15.11

func NewContextInMemory() context.Context

NewContextReadOnly returns a context with a read-only config.

func PwStoreDir

func PwStoreDir(mount string) string

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

func String added in v1.15.0

func String(ctx context.Context, key string) string

String returns a string value from the config in the context.

func WithMount added in v1.15.10

func WithMount(ctx context.Context, mp string) context.Context

Types

type Config

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

Config is a gopass config handler.

func FromContext added in v1.15.0

func FromContext(ctx context.Context) (*Config, string)

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) Get added in v1.15.0

func (c *Config) Get(key string) string

Get returns the given key from the root config.

func (*Config) GetAll added in v1.15.3

func (c *Config) GetAll(key string) []string

GetAll returns all values for the given key.

func (*Config) GetGlobal added in v1.15.10

func (c *Config) GetGlobal(key string) string

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

func (c *Config) GetM(mount, key string) string

GetM returns the given key from the mount or the root config if mount is empty.

func (*Config) IsSet added in v1.15.0

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

IsSet returns true if the key is set in the root config.

func (*Config) IsSetM added in v1.15.13

func (c *Config) IsSetM(mount, key string) bool

IsSetM returns true if the key is set in the mount or the root config if mount is empty.

func (*Config) Keys added in v1.15.0

func (c *Config) Keys(mount string) []string

Keys returns all keys in the given config.

func (*Config) MountPath added in v1.15.0

func (c *Config) MountPath(mountPoint string) string

MountPath returns the mount store path.

func (*Config) Mounts

func (c *Config) Mounts() []string

Mounts returns all mount points from the root config. Note: Any mounts in local configs are ignored.

func (*Config) Path

func (c *Config) Path() string

Path returns the root store path.

func (*Config) Set added in v1.15.0

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

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) SetEnv added in v1.15.0

func (c *Config) SetEnv(key, value string) error

SetEnv overrides a key in the non-persistent layer.

func (*Config) SetMountPath added in v1.15.0

func (c *Config) SetMountPath(mount, path string) error

SetMountPath is a shortcut to set a mount to a path.

func (*Config) SetPath added in v1.15.0

func (c *Config) SetPath(path string) error

SetPath is a shortcut to set the root store path.

func (*Config) SetWithLevel added in v1.15.10

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

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.

func (*Config) Unset added in v1.15.0

func (c *Config) Unset(mount, key string) error

Unset deletes the key from the given config.

func (*Config) WithConfig added in v1.15.0

func (c *Config) WithConfig(ctx context.Context) context.Context

type Level added in v1.15.10

type Level int
const (
	None Level = iota
	Env
	Worktree
	Local
	Global
	System
	Preset
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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