env

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 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"`
}

func ParseEnvBuffer added in v1.0.2

func ParseEnvBuffer(buf []byte) ([]EnvLine, error)

ParseEnvBuffer parses an environment file from a buffer and returns a list of EnvLine structs.

func ParseEnvFile added in v1.0.2

func ParseEnvFile(filename string) ([]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.

Jump to

Keyboard shortcuts

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