config

package module
v0.0.0-...-e2b82d5 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 15 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandBundle

func CommandBundle(appName string, global bool, merged bool) error

CommandBundle creates a tarball of a .env.d directory containing env vars for the app

func CommandClear

func CommandClear(appName string, global bool, noRestart bool) error

CommandClear unsets all environment variables in use

func CommandExport

func CommandExport(appName string, global bool, merged bool, format string) error

CommandExport outputs all env vars (merged or not, global or not) in the specified format for consumption by other tools

func CommandGet

func CommandGet(appName string, keys []string, global bool, quoted bool) error

CommandGet gets the value for the specified environment variable

func CommandKeys

func CommandKeys(appName string, global bool, merged bool) error

CommandKeys shows the keys set for the specified environment

func CommandSet

func CommandSet(appName string, pairs []string, global bool, noRestart bool, encoded bool) error

CommandSet sets one or more environment variable pairs

func CommandShow

func CommandShow(appName string, global bool, merged bool, shell bool, export bool) error

CommandShow pretty-prints the specified environment vaiables

func CommandUnset

func CommandUnset(appName string, keys []string, global bool, noRestart bool) error

CommandUnset unsets one or more keys in a specified environment

func Get

func Get(appName string, key string) (value string, ok bool)

Get retrieves a value from a config. If appName is empty the global config is used.

func GetWithDefault

func GetWithDefault(appName string, key string, defaultValue string) (value string)

GetWithDefault gets a value from a config. If appName is empty the global config is used. If the appName or key do not exist defaultValue is returned.

func SetMany

func SetMany(appName string, entries map[string]string, restart bool) (err error)

SetMany variables in the environment. If appName is empty the global config is used. If restart is true the app is restarted.

func SubBundle

func SubBundle(appName string, merged bool) error

SubBundle implements the logic for config:bundle without app name validation

func SubClear

func SubClear(appName string, noRestart bool) error

SubClear implements the logic for config:clear without app name validation

func SubExport

func SubExport(appName string, merged bool, format string) error

SubExport implements the logic for config:export without app name validation

func SubGet

func SubGet(appName string, keys []string, quoted bool) error

SubGet implements the logic for config:get without app name validation

func SubKeys

func SubKeys(appName string, merged bool) error

SubKeys implements the logic for config:keys without app name validation

func SubSet

func SubSet(appName string, pairs []string, noRestart bool, encoded bool) error

SubSet implements the logic for config:set without app name validation

func SubShow

func SubShow(appName string, merged bool, shell bool, export bool) error

SubShow implements the logic for config:show without app name validation

func SubUnset

func SubUnset(appName string, keys []string, noRestart bool) error

SubUnset implements the logic for config:unset without app name validation

func TriggerConfigExport

func TriggerConfigExport(appName string, global string, merged string, format string) error

TriggerConfigExport returns a global config value by key

func TriggerConfigGet

func TriggerConfigGet(appName string, key string) error

TriggerConfigGet returns an app config value by key

func TriggerConfigGetGlobal

func TriggerConfigGetGlobal(key string) error

TriggerConfigGetGlobal returns a global config value by key

func TriggerPostAppCloneSetup

func TriggerPostAppCloneSetup(oldAppName string, newAppName string) error

TriggerPostAppCloneSetup creates new buildpacks files

func TriggerPostAppRenameSetup

func TriggerPostAppRenameSetup(oldAppName string, newAppName string) error

TriggerPostAppRenameSetup renames buildpacks files

func UnsetAll

func UnsetAll(appName string, restart bool) (err error)

UnsetAll removes all config keys

func UnsetMany

func UnsetMany(appName string, keys []string, restart bool) (err error)

UnsetMany a value in a config. If appName is empty the global config is used. If restart is true the app is restarted.

Types

type Env

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

Env is a representation for global or app environment

func LoadAppEnv

func LoadAppEnv(appName string) (env *Env, err error)

LoadAppEnv loads an environment for the given app

func LoadGlobalEnv

func LoadGlobalEnv() (*Env, error)

LoadGlobalEnv loads the global environment

func LoadMergedAppEnv

func LoadMergedAppEnv(appName string) (env *Env, err error)

LoadMergedAppEnv loads an app environment merged with the global environment

func (*Env) DockerArgsKeysString

func (e *Env) DockerArgsKeysString() string

DockerArgsKeysString gets the contents of this Env in the form -env=KEY --env...

func (*Env) DockerArgsString

func (e *Env) DockerArgsString() string

DockerArgsString gets the contents of this Env in the form -env=KEY=VALUE --env...

func (*Env) EnvfileString

func (e *Env) EnvfileString() string

EnvfileString returns the contents of this Env in dotenv format

func (*Env) Export

func (e *Env) Export(format ExportFormat) string

Export the Env in the given format

func (*Env) ExportBundle

func (e *Env) ExportBundle(dest io.Writer) error

ExportBundle writes a tarfile of the environment to the given io.Writer. for every environment variable there is a file with the variable's key with its content set to the variable's value

func (*Env) ExportfileString

func (e *Env) ExportfileString() string

ExportfileString returns the contents of this Env as bash exports

func (*Env) Filename

func (e *Env) Filename() string

Filename returns the full path on disk to the file holding the env vars

func (*Env) Get

func (e *Env) Get(key string) (value string, ok bool)

Get an environment variable

func (*Env) GetBoolDefault

func (e *Env) GetBoolDefault(key string, defaultValue bool) bool

GetBoolDefault gets the bool value of the given key with the given default right now that is evaluated as `value != "0"`

func (*Env) GetDefault

func (e *Env) GetDefault(key string, defaultValue string) string

GetDefault an environment variable or a default if it doesn't exist

func (*Env) JSONListString

func (e *Env) JSONListString() string

JSONListString returns the contents of this Env as a json list of objects containing the name and the value of the env var

func (*Env) JSONString

func (e *Env) JSONString() string

JSONString returns the contents of this Env as a key/value json object

func (*Env) Keys

func (e *Env) Keys() (keys []string)

Keys gets the keys in this environment

func (*Env) Len

func (e *Env) Len() int

Len returns the number of items in this environment

func (*Env) Map

func (e *Env) Map() map[string]string

Map returns the Env as a map

func (*Env) Merge

func (e *Env) Merge(other *Env)

Merge merges the given environment on top of the receiver

func (*Env) PackArgKeysAsString

func (e *Env) PackArgKeysAsString() string

PackArgKeysAsString gets the contents of this Env in the form -env KEY --env...

func (*Env) Set

func (e *Env) Set(key string, value string)

Set an environment variable

func (*Env) ShellString

func (e *Env) ShellString() string

ShellString gets the contents of this Env in the form "KEY='value' KEY2='value'" for passing the environment in the shell

func (*Env) String

func (e *Env) String() string

func (*Env) Unset

func (e *Env) Unset(key string)

Unset an environment variable

func (*Env) Write

func (e *Env) Write() error

Write an Env back to the file it was read from as an exportfile

type ExportFormat

type ExportFormat int

ExportFormat types of possible exports

const (
	//ExportFormatExports format: Sourceable exports
	ExportFormatExports ExportFormat = iota
	//ExportFormatEnvfile format: dotenv file
	ExportFormatEnvfile
	//ExportFormatDockerArgs format: --env KEY=VALUE args for docker
	ExportFormatDockerArgs
	//ExportFormatDockerArgsKeys format: --env=KEY args for docker
	ExportFormatDockerArgsKeys
	//ExportFormatShell format: env arguments for shell
	ExportFormatShell
	//ExportFormatPretty format: pretty-printed in columns
	ExportFormatPretty
	//ExportFormatJSON format: json key/value output
	ExportFormatJSON
	//ExportFormatJSONList format: json output as a list of objects
	ExportFormatJSONList
	//ExportFormatPackArgKeys format: --env KEY args for pack
	ExportFormatPackArgKeys
)

Directories

Path Synopsis
src

Jump to

Keyboard shortcuts

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