env

package
v1.0.138 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeOSEnv added in v1.0.2

func EncodeOSEnv(key, val string) string

EncodeOSEnv encodes an environment variable for use in an OS environment.

func EncodeOSEnvFunc added in v1.0.2

func EncodeOSEnvFunc(key, val string, fn callback) string

EncodeOSEnvFunc encodes an environment variable for use in an OS environment using a custom sprintf function.

func FlagOrEnv

func FlagOrEnv(cmd *cobra.Command, flagName string, envName string, defaultValue string) string

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 LogLevel added in v1.0.8

func LogLevel(cmd *cobra.Command) logger.LogLevel

func NewLogger

func NewLogger(cmd *cobra.Command) logger.Logger

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

func WriteEnvFile(fn string, envs []EnvLine) error

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

func InterpolateEnvLines(envs []EnvLine) []EnvLine

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 ParseEnvValue(key, val string) EnvLine

func ProcessEnvLine added in v1.0.2

func ProcessEnvLine(env string) EnvLine

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

type EnvLineComment struct {
	EnvLine
	Comment string `json:"comment,omitempty"`
}

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

Jump to

Keyboard shortcuts

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