envsecrets

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 6 Imported by: 0

README

envsecrets

"envsecrets" is a meta framework for environment variable loader. It is designed to load environment variables from various sources.

Installation

$ go get github.com/mackee/envsecrets

Usage

Environment variable format

If you want set from AWS Secrets Manager, you should set environment variable like below.

export <SECRET_ENVNAME>=secretfrom:aws_secretsmanager:<secret-name>

If set a json value to the secret, you can access the value by specifying the key.

export <SECRET_ENVNAME>=secretfrom:aws_secretsmanager:<secret-name>.<key>
Load environment variables
import (
    "github.com/mackee/envsecrets/dist/aws"
)

func main() {
    ctx := context.Background()
    if err := awsenvsecrets.Load(ctx); err != nil {
        log.Fatalf("failed to load environment variables: %v", err)
    }
}

Supported sources

✅: Implemented

🔍: Not implemented yet

Source Type Description Status
AWS Secrets Manager aws_secretsmanager Load secret from AWS Secrets Manager
AWS Systems Manager ParameterStore aws_ssm Load secret from AWS Systems Manager ParameterStore
Amazon S3 aws_s3 Load secret from Amazon S3 🔍
Google Cloud Secret Manager google_secretmanager Load secret from Google Cloud Secret Manager 🔍
1Password onepassword Load secret from 1Password 🔍

License

Copyright (c) 2024- mackee

Licensed under MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResolverNotInterested = errors.New("resolver not interested")

Functions

This section is empty.

Types

type Env

type Env struct {
	Key      string
	Type     string
	Args     string
	Value    string
	Resolved bool
}

func ParseEnvs

func ParseEnvs(src []string) ([]*Env, error)

type Loader

type Loader interface {
	Load(ctx context.Context) error
}

func NewLoader

func NewLoader(opts ...LoaderOption) Loader

type LoaderOption

type LoaderOption func(*loader)

func WithEnvLoader

func WithEnvLoader(_l func(ctx context.Context) ([]*Env, error)) LoaderOption

func WithResolver

func WithResolver(resolvers ...Resolver) LoaderOption

type Resolver

type Resolver interface {
	Push(env *Env) error
	Resolve(ctx context.Context) error
}

Directories

Path Synopsis
dist
aws

Jump to

Keyboard shortcuts

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