Categorygithub.com/oxplot/starenv
modulepackage
0.14.0
Repository: https://github.com/oxplot/starenv.git
Documentation: pkg.go.dev

# README

Starenv

Go
Reference

starenv (*env) allows populating environmental variables from variety of sources, such as AWS Parameter Store, GPG encrypted files and more, with extreme ease.

For the impatient, import the autoload package and you're set:

package main

import (
  "fmt"
  "os"

  _ "github.com/oxplot/starenv/autoload"
)

func main() {
  fmt.Printf("GITHUB_TOKEN=%s\n", os.Getenv("GITHUB_TOKEN"))
}

and set the value of the environmental variable to load from Parameter Store:

$ export GITHUB_TOKEN=*ssm:/github_token
$ go run main.go
GITHUB_TOKEN=abcdef-1235143-abcdef-123-abcdef-12314

or from a GPG encrypted file:

$ export GITHUB_TOKEN=*gpg*file:github_token.gpg
$ go run main.go
GITHUB_TOKEN=abcdef-1235143-abcdef-123-abcdef-12314

why not ditch the file and embed its content:

$ export GITHUB_TOKEN=*gpg*b64:eNeO7D2rBrBOOcW6TuETyHdyPEOaAfdgaTzgOTSvROI=
$ go run main.go
GITHUB_TOKEN=abcdef-1235143-abcdef-123-abcdef-12314

and thanks to the amazing godotenv which is run as part of starenv's autoload package, you can even do:

$ echo 'GITHUB_TOKEN=*keyring:awesome_app/github_token' > .env
$ go run main.go
GITHUB_TOKEN=abcdef-1235143-abcdef-123-abcdef-12314

For a full list, see the docs.

# Packages

No description provided by the author

# Functions

Base64 decodes base64 encoded ref and returns it.
Bzip2 decompresses bzipped2 compressed ref and returns it.
Env returns value of environmental variable with given name or empty string if not set.
Flate decompresses flate compressed ref and returns it.
GPG takes encrypted content ref, decrypts it and returns it.
Gzip decompresses gzipped compressed ref and returns it.
Hex decodes hex encoded ref and returns it.
Keyring uses system provided secret storage to retrive the secret stored for ref and returns it.
NewAWSParameterStore creates a new AWSParameterStore derefer with default configuration.
NewAWSParameterStoreWithConfig creates a new AWSParameterStore derefer with the given configuration.
NewLoader returns a new loader with empty "" tag mapped to to a passthrough derefer.
NewS3 creates a new S3 derefer with default configuration.
NewS3WithConfig creates a new S3 derefer with the given configuration.
TempFile creates a temporary file and stores the content of ref in it and returns its path.

# Variables

DefaultDerefers is a mapping of default tags to derefer creator functions that use sensible default config.
DefaultLoader is the default loader which has all the DefaultDerefers registered with it.

# Structs

AWSParameterStore derefs a Parameter Store ARN to its value.
File derefs a file path to the content of the file.
HTTP derefs a URL to its content.
LazyDerefer is a derefer that encapsulates a derefer creator function and delays its call until the first deref call.
Loader holds a registry of derefers which are looked up and applied to values of all environmental variables when Load() is called.
S3 derefs an S3 bucket and object path to its content.

# Interfaces

Derefer is an interface that wraps Deref method.

# Type aliases

DereferFunc type is an adapter to allow use of ordinary functions as derefers.