step

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 15 Imported by: 26

Documentation

Index

Constants

View Source
const HomeEnv = "HOME"

HomeEnv defines the name of the environment variable that can overwrite the default home directory.

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

View Source
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

func Abs(path string) string

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.

  1. If the base step path has a current context configured, then this method returns the path to the authority configured in the context.
  2. If the base step path does not have a current context configured this method returns the value defined by the environment variable STEPPATH, OR
  3. 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.

  1. If the base step path has a current context configured, then this method returns the path to the profile configured in the context.
  2. If the base step path does not have a current context configured this method returns the value defined by the environment variable STEPPATH, OR
  3. 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

func Set

func Set(n, v, t string)

Set updates the name, version, and build time

func SetEnvVar

func SetEnvVar(c *cli.Command)

SetEnvVar sets the the EnvVar element to each flag recursively.

func Version

func Version() string

Version returns the current version of the binary

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

func (c *Context) DefaultsFile() string

DefaultsFile returns the location of the defaults file for the context.

func (*Context) Load

func (c *Context) Load() error

Load loads the configuration for the given context.

func (*Context) Path

func (c *Context) Path() string

Path return the base path relative to the context.

func (*Context) ProfileDefaultsFile

func (c *Context) ProfileDefaultsFile() string

ProfileDefaultsFile returns the location of the defaults file at the base of the profile path.

func (*Context) ProfilePath

func (c *Context) ProfilePath() string

ProfilePath return the profile base path relative to the context.

func (*Context) Validate

func (c *Context) Validate() error

Validate validates a context and returns an error if invalid.

type ContextMap

type ContextMap map[string]*Context

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

func (cs *CtxState) Add(ctx *Context) error

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) Apply

func (cs *CtxState) Apply(ctx *cli.Context) error

Apply the current context configuration to the command line environment.

func (*CtxState) Enabled

func (cs *CtxState) Enabled() bool

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) Get

func (cs *CtxState) Get(name string) (ctx *Context, ok bool)

Get returns the context with the given name.

func (*CtxState) GetConfig

func (cs *CtxState) GetConfig() (map[string]interface{}, error)

GetConfig returns the current context configuration.

func (*CtxState) GetCurrent

func (cs *CtxState) GetCurrent() *Context

GetCurrent returns the current context.

func (*CtxState) Init

func (cs *CtxState) Init() error

Init initializes the context map and current context state.

func (*CtxState) List

func (cs *CtxState) List() []*Context

List returns a list of all contexts.

func (*CtxState) ListAlphabetical added in v0.7.3

func (cs *CtxState) ListAlphabetical() []*Context

ListAlphabetical returns a case-insensitive, alphabetically sorted list of all contexts.

func (*CtxState) LoadVintage

func (cs *CtxState) LoadVintage(f string) error

LoadVintage loads context configuration from the vintage (non-context) path.

func (*CtxState) PromptContext

func (cs *CtxState) PromptContext() error

PromptContext gets user input to select a context.

func (*CtxState) Remove

func (cs *CtxState) Remove(name string) error

Remove removes a context from the context state.

func (*CtxState) SaveCurrent

func (cs *CtxState) SaveCurrent(name string) error

SaveCurrent stores the given context name as the selected default context for future commands.

func (*CtxState) SetCurrent

func (cs *CtxState) SetCurrent(name string) error

SetCurrent sets the current context or returns an error if a context with the given name does not exist.

Jump to

Keyboard shortcuts

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