getenv

package
v0.0.0-...-3a9ac50 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 10 Imported by: 0

README

getenv

*getenv` provides utility to retrieve a text variable from one of these sources:

  1. Environment variable.
  2. AWS Parameter Store via AWS Parameter and Secrets Lambda extension. See documentation.
  3. AWS Secrets Manager also via the same AWS Parameter and Secrets Lambda extension. See documentation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Getter

type Getter func(ctx context.Context) (string, error)

Getter implements the Variable interface for a function.

func (Getter) Get

func (g Getter) Get() (string, error)

func (Getter) GetWithContext

func (g Getter) GetWithContext(ctx context.Context) (string, error)

func (Getter) MustGet

func (g Getter) MustGet() string

func (Getter) MustGetWithContext

func (g Getter) MustGetWithContext(ctx context.Context) string

type ParameterGetter

type ParameterGetter struct {
	// contains filtered or unexported fields
}

func NewParameterGetter

func NewParameterGetter(name string, opts ...func(*ParameterOpts)) (*ParameterGetter, error)

NewParameterGetter returns an instance of ParameterGetter that can be used to get the raw ssm.GetParameterOutput.

func (*ParameterGetter) Get

Get executes the GET request the AWS Parameter and Secrets Lambda extension.

type ParameterOpts

type ParameterOpts struct {
	Name           string
	Version        string
	Label          string
	WithDecryption bool
	Client         http.Client
}

ParameterOpts contains customisable settings when retrieving a variable from AWS Parameter Store.

type SecretsGetter

type SecretsGetter struct {
	// contains filtered or unexported fields
}

func NewSecretsGetter

func NewSecretsGetter(secretId string, opts ...func(secretsOpts *SecretsOpts)) (*SecretsGetter, error)

NewSecretsGetter returns an instance of SecretsGetter that can be used to get the raw secretsmanager.GetSecretValueOutput.

func (*SecretsGetter) Get

Get executes the GET request the AWS Parameter and Secrets Lambda extension.

type SecretsOpts

type SecretsOpts struct {
	SecretId     string
	VersionId    string
	VersionStage string
	Client       http.Client
}

SecretsOpts contains customisable settings when retrieving a variable from AWS Secrets Manager.

type Variable

type Variable interface {
	Get() (string, error)
	GetWithContext(ctx context.Context) (string, error)
	MustGet() string
	MustGetWithContext(ctx context.Context) string
}

Variable defines ways to retrieve a string variable.

func Env

func Env(key string) Variable

Env calls os.Getenv and returns that value in subsequent calls.

See Getenv if you need something that calls os.Getenv on every invocation.

func Getenv

func Getenv(key string) Variable

Getenv calls os.Getenv on every invocation and returns its value.

Most of the time, Env suffices because environment variables are not updated that often. Use Getenv if you have a use case where the environment variables might be updated by some other processes.

func Parameter

func Parameter(name string, opts ...func(*ParameterOpts)) Variable

Parameter creates Getter that reads parameters from the AWS Parameter and Secrets Lambda extension.

If you need to customize the request with version, label, and/or with decryption, pass in a function to modify those values.

See https://docs.aws.amazon.com/systems-manager/latest/userguide/ps-integration-lambda-extensions.html#ps-integration-lambda-extensions-sample-commands.

func Secrets

func Secrets(secretId string, opts ...func(*SecretsOpts)) Variable

Secrets creates Getter that reads secrets from the AWS Parameter and Secrets Lambda extension.

If you need to customize the request with version, label, and/or with decryption, pass in a function to modify those values.

See https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets_lambda.html.

Jump to

Keyboard shortcuts

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