Documentation
¶
Index ¶
- func EncodeOSEnv(key, val string) string
- func EncodeOSEnvFunc(key, val string, fn callback) string
- func FlagOrEnv(cmd *cobra.Command, flagName string, envName string, defaultValue string) string
- func LogLevel(cmd *cobra.Command) logger.LogLevel
- func NewLogger(cmd *cobra.Command) logger.Logger
- func NewTelemetry(ctx context.Context, cmd *cobra.Command, serviceName string) (context.Context, logger.Logger, func(), error)
- func WriteEnvFile(fn string, envs []EnvLine) error
- type EnvLine
- type EnvLineComment
- type WithParseEnvOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeOSEnv ¶ added in v1.0.2
EncodeOSEnv encodes an environment variable for use in an OS environment.
func EncodeOSEnvFunc ¶ added in v1.0.2
EncodeOSEnvFunc encodes an environment variable for use in an OS environment using a custom sprintf function.
func FlagOrEnv ¶
FlagOrEnv will try and get a flag from the cobra.Command and if not found, look it up in the environment and fallback to defaultValue if non found
func NewLogger ¶
NewLogger returns a console logger by first checking the cobra.Command log-level flag, then use the AGENTUITY_LOG_LEVEL environment value and falling back to the info logger level
func NewTelemetry ¶ added in v1.0.8
func NewTelemetry(ctx context.Context, cmd *cobra.Command, serviceName string) (context.Context, logger.Logger, func(), error)
NewTelemetry returns a telemetry context, logger, shutdown function. The cobra flags it expects are:
--no-telemetry (boolean): if set, telemetry will be disabled
--otlp-url (string): the url of the otlp server
--otlp-shared-secret (string): the shared secret for the otlp server
func WriteEnvFile ¶ added in v1.0.2
WriteEnvFile writes an environment file to a file.
Types ¶
type EnvLine ¶ added in v1.0.2
type EnvLine struct {
Key string `json:"key"`
Val string `json:"val"`
Raw string `json:"-"` // the raw line from the file
}
func InterpolateEnvLines ¶ added in v1.0.61
InterpolateEnvLines interpolates the values of a list of EnvLine structs using the current environment.
func ParseEnvBuffer ¶ added in v1.0.2
func ParseEnvBuffer(buf []byte, opts ...WithParseEnvOptions) ([]EnvLine, error)
ParseEnvBuffer parses an environment buffer and returns a list of EnvLine structs.
func ParseEnvFile ¶ added in v1.0.2
func ParseEnvFile(filename string, opts ...WithParseEnvOptions) ([]EnvLine, error)
ParseEnvFile parses an environment file and returns a list of EnvLine structs.
func ParseEnvValue ¶ added in v1.0.2
func ProcessEnvLine ¶ added in v1.0.2
ProcessEnvLine processes an environment variable line and returns an EnvLine struct with the key, value, and secret flag set.
type EnvLineComment ¶ added in v1.0.34
EnvLineComment extends EnvLine to include an optional comment
func ParseEnvFileWithComments ¶ added in v1.0.60
func ParseEnvFileWithComments(filename string) ([]EnvLineComment, error)
ParseEnvFileWithComments parses an environment file and returns a list of EnvLineComment structs.
func ParseEnvLinesWithComments ¶ added in v1.0.34
func ParseEnvLinesWithComments(buf []byte) ([]EnvLineComment, error)
ParseEnvLinesWithComments parses an environment buffer and returns a list of EnvLineComment structs. Comments preceding environment variables (starting with #) are associated with the following variable.
type WithParseEnvOptions ¶ added in v1.0.34
type WithParseEnvOptions func(opts *parseEnvOptions)
func WithInterpolate ¶ added in v1.0.34
func WithInterpolate(interpolate bool) WithParseEnvOptions
WithInterpolate sets the Interpolate flag to true or false