config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CKWatchEnvKey  = "CK_WATCH"
	CKRevertEnvKey = "CK_REVERT"
	CKLastEnvKey   = "CK_LAST"

	DirenvMode     Mode = "direnv"
	StandaloneMode Mode = "standalone"
)

Variables

Functions

func FileName

func FileName() string

func Init

func Init(config *Config) error

func KeyFileName

func KeyFileName() string

func Path

func Path() (string, error)

func ReadInConfig

func ReadInConfig() error

func Serialize

func Serialize[E AnyEnv](e E) string

Serialize marshalls the environment diff to the gzenv format.

func Write

func Write(config *Config) error

Types

type AnyEnv

type AnyEnv interface {
	map[string]string | map[string]*string | Env
}

type Config

type Config struct {
	Mode       Mode       `json:"mode"`
	Encryption Encryption `json:"encryption"`
	Env        Env        `json:"env"`

	Path string
}

func GetConfig

func GetConfig() (*Config, error)

func GetConfigFromPath

func GetConfigFromPath(path string) (*Config, error)

func (*Config) IsDirenvIntegrated

func (c *Config) IsDirenvIntegrated() bool

func (*Config) MarshalJSON

func (c *Config) MarshalJSON() ([]byte, error)

type Direnv

type Direnv struct {
	RCPath string `json:"rc_path"`
}

func (*Direnv) Enabled

func (d *Direnv) Enabled() bool

type Encryption

type Encryption struct {
	Type    crypt.EncryptionType `json:"type"`
	KeyPath string               `json:"key_path"`
}

type Env

type Env map[string]string

func (Env) CleanContext

func (e Env) CleanContext()

CleanContext removes all the direnv-related environment variables. Call this after reverting the environment, otherwise direnv will just be amnesic about the previously-loaded environment.

func (Env) Copy

func (e Env) Copy() Env

Copy returns a fresh copy of the env. Because the env is a map under the hood, we want to get a copy whenever we mutate it and want to keep the original around.

func (Env) Decrypt

func (e Env) Decrypt(decrypter *crypt.Keeper) error

func (Env) Keys

func (e Env) Keys() []string

type Mode added in v0.1.1

type Mode string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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