Documentation ¶
Index ¶
- Constants
- func Abs(path string) string
- func BasePath() string
- func CaConfigFile() string
- func ConfigPath() string
- func ContextsFile() string
- func CurrentContextFile() string
- func DefaultsFile() string
- func Home() string
- func IdentityFile() string
- func IdentityPath() string
- func Init() error
- func Path() string
- func ProfileConfigPath() string
- func ProfileDefaultsFile() string
- func ProfilePath() string
- func ReleaseDate() string
- func Set(n, v, t string)
- func SetEnvVar(c *cli.Command)
- func Version() string
- type Context
- type ContextMap
- type CtxState
- func (cs *CtxState) Add(ctx *Context) error
- func (cs *CtxState) Apply(ctx *cli.Context) error
- func (cs *CtxState) Enabled() bool
- func (cs *CtxState) Get(name string) (ctx *Context, ok bool)
- func (cs *CtxState) GetConfig() (map[string]interface{}, error)
- func (cs *CtxState) GetCurrent() *Context
- func (cs *CtxState) Init() error
- func (cs *CtxState) List() []*Context
- func (cs *CtxState) ListAlphabetical() []*Context
- func (cs *CtxState) LoadVintage(f string) error
- func (cs *CtxState) PromptContext() error
- func (cs *CtxState) Remove(name string) error
- func (cs *CtxState) SaveCurrent(name string) error
- func (cs *CtxState) SetCurrent(name string) error
Constants ¶
const HomeEnv = "HOME"
HomeEnv defines the name of the environment variable that can overwrite the default home directory.
const IgnoreEnvVar = "STEP_IGNORE_ENV_VAR"
IgnoreEnvVar is a value added to a flag EnvVar to avoid the use of environment variables or configuration files.
const PathEnv = "STEPPATH"
PathEnv defines the name of the environment variable that can overwrite the default configuration path.
Variables ¶
This section is empty.
Functions ¶
func Abs ¶
Abs returns the given path relative to the STEPPATH if it's not an absolute path, relative to the home directory using the special string "~/", or relative to the working directory using "./"
Relative paths like 'certs/root_ca.crt' will be converted to '$STEPPATH/certs/root_ca.crt', but paths like './certs/root_ca.crt' will be relative to the current directory. Home relative paths like ~/certs/root_ca.crt will be converted to '$HOME/certs/root_ca.crt'. And absolute paths like '/certs/root_ca.crt' will remain the same.
func BasePath ¶
func BasePath() string
BasePath returns the base path for the step configuration directory.
func CaConfigFile ¶
func CaConfigFile() string
CaConfigFile returns the location of the ca.json file -- configuration for connecting to the CA.
func ConfigPath ¶
func ConfigPath() string
ConfigPath returns the location of the $(step path)/config directory.
func ContextsFile ¶
func ContextsFile() string
ContextsFile returns the location of the config file.
func CurrentContextFile ¶
func CurrentContextFile() string
CurrentContextFile returns the path to the file containing the current context.
func DefaultsFile ¶
func DefaultsFile() string
DefaultsFile returns the location of the defaults file at the base of the authority path.
func Home ¶
func Home() string
Home returns the user home directory using the environment variable HOME or the os/user package.
func IdentityFile ¶
func IdentityFile() string
IdentityFile returns the location of the identity file.
func IdentityPath ¶
func IdentityPath() string
IdentityPath returns the location of the identity directory.
func Init ¶ added in v0.8.0
func Init() error
Init initializes the step environment.
A program calling this function should fail because the step variables would be undefined.
func Path ¶
func Path() string
Path returns the path for the step configuration directory.
- If the base step path has a current context configured, then this method returns the path to the authority configured in the context.
- If the base step path does not have a current context configured this method returns the value defined by the environment variable STEPPATH, OR
- If no environment variable is set, this method returns `$HOME/.step`.
func ProfileConfigPath ¶
func ProfileConfigPath() string
ProfileConfigPath returns the location of the $(step path --profile)/config directory.
func ProfileDefaultsFile ¶
func ProfileDefaultsFile() string
ProfileDefaultsFile returns the location of the defaults file at the base of the profile path.
func ProfilePath ¶
func ProfilePath() string
ProfilePath returns the path for the currently selected profile path.
- If the base step path has a current context configured, then this method returns the path to the profile configured in the context.
- If the base step path does not have a current context configured this method returns the value defined by the environment variable STEPPATH, OR
- If no environment variable is set, this method returns `$HOME/.step`.
func ReleaseDate ¶
func ReleaseDate() string
ReleaseDate returns the time of when the binary was built
Types ¶
type Context ¶
type Context struct { Name string `json:"-"` Profile string `json:"profile"` Authority string `json:"authority"` // contains filtered or unexported fields }
Context represents a Step Path configuration context. A context is the combination of a profile and an authority.
func (*Context) DefaultsFile ¶
DefaultsFile returns the location of the defaults file for the context.
func (*Context) ProfileDefaultsFile ¶
ProfileDefaultsFile returns the location of the defaults file at the base of the profile path.
func (*Context) ProfilePath ¶
ProfilePath return the profile base path relative to the context.
type ContextMap ¶
ContextMap represents the map of available Contexts that is stored at the base of the Step Path.
type CtxState ¶
type CtxState struct {
// contains filtered or unexported fields
}
CtxState is the type that manages context state for the cli.
func Contexts ¶
func Contexts() *CtxState
Contexts returns an object that enables context management.
func (*CtxState) Add ¶
Add adds a new context to the context map. If current context is not set then store the new context as the current context for future commands.
func (*CtxState) Enabled ¶
Enabled returns true if one of the following is true:
- there is a current context configured
- the context map is (list of available contexts) is not empty.
func (*CtxState) GetCurrent ¶
GetCurrent returns the current context.
func (*CtxState) ListAlphabetical ¶ added in v0.7.3
ListAlphabetical returns a case-insensitive, alphabetically sorted list of all contexts.
func (*CtxState) LoadVintage ¶
LoadVintage loads context configuration from the vintage (non-context) path.
func (*CtxState) PromptContext ¶
PromptContext gets user input to select a context.
func (*CtxState) SaveCurrent ¶
SaveCurrent stores the given context name as the selected default context for future commands.
func (*CtxState) SetCurrent ¶
SetCurrent sets the current context or returns an error if a context with the given name does not exist.