envdiff

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

This section is empty.

Variables

View Source
var IgnoredKeys = map[string]bool{
	"COMP_WORDBREAKS": true,
	"PS1":             true,

	"OLDPWD":    true,
	"PWD":       true,
	"SHELL":     true,
	"SHELLOPTS": true,
	"SHLVL":     true,
	"_":         true,
}

IgnoredKeys is list of keys we don't want to deal with

Functions

func FetchEncryptedEnv

func FetchEncryptedEnv(envKey string, keeper *crypt.Keeper, obj any) error

func FetchEnv

func FetchEnv(envKey string, obj any) error

func FetchLastEnv

func FetchLastEnv(diffKey string, keeper *crypt.Keeper) (config.Env, error)

func FetchRevert

func FetchRevert(envKey string) (map[string]*string, error)

FetchRevert undoes the recorded changes (if any) to the supplied environment, returning a new environment

func IgnoredEnv

func IgnoredEnv(key string) bool

IgnoredEnv returns true if the key should be ignored in environment diffs.

func LoadEnv

func LoadEnv(gzenvStr string, data any) (err error)

LoadEnv unmarshalls a gzenv string back into an EnvDiff.

Types

type EnvDiff

type EnvDiff struct {
	Revert map[string]string
	Last   map[string]string
}

EnvDiff represents the diff between two environments

func BuildEnvDiff

func BuildEnvDiff(e1, e2 config.Env) *EnvDiff

BuildEnvDiff analyses the changes between 'e1' and 'e2' and builds an EnvDiff out of it.

func LoadEnvDiff

func LoadEnvDiff(gzenvStr string) (diff *EnvDiff, err error)

LoadEnvDiff unmarshalls a gzenv string back into an EnvDiff.

func NewEnvDiff

func NewEnvDiff() *EnvDiff

NewEnvDiff is an empty constructor for EnvDiff

func (*EnvDiff) Any

func (d *EnvDiff) Any() bool

Any returns if the diff contains any changes.

func (*EnvDiff) Decrypt

func (d *EnvDiff) Decrypt(decrypter *crypt.Keeper) error

func (*EnvDiff) Patch

func (d *EnvDiff) Patch(env config.Env) (newEnv config.Env)

Patch applies the diff to the given env and returns a new env with the changes applied.

func (*EnvDiff) Reverse

func (d *EnvDiff) Reverse() *EnvDiff

Reverse flips the diff so that it applies the other way around.

func (*EnvDiff) Serialize

func (d *EnvDiff) Serialize() string

Serialize marshalls the environment diff to the gzenv format.

func (*EnvDiff) ToShell

func (d *EnvDiff) ToShell(sh shell.Shell) string

ToShell applies the env diff as a set of commands that are understood by the target `shell`. The outputted string is then meant to be evaluated in the target shell.

Jump to

Keyboard shortcuts

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