config

package
v1.15.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 Directory

func Directory() string

Directory returns the configuration directory for the gopass config file.

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 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.

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

func New

func New() *Config

New initializes a new gopass config. It will handle legacy configs as well.

func NewNoWrites added in v1.15.0

func NewNoWrites() *Config

NewNoWrites initializes a new config that does not allow writes. For use in tests.

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

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

GetBool returns true if the value of the key evaluates to "true". Otherwise it returns false.

func (*Config) GetInt added in v1.15.0

func (c *Config) GetInt(key string) int

GetInt returns the integer value of the key if it can be parsed. Otherwise it returns 0.

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) 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 short cut 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 short cut to set the root store path.

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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