Documentation ¶
Overview ¶
Package conman aims to make your config setup less verbose.
This package uses `reflect` so watch out
Example ¶
A normal use case. Will set myAppConfig.Port to:
- your PORT environment variable if it is set
- your AWS SSM Parameter value set in /Prod/app/port
- then default to 8080
package main import ( "github.com/JoelPagliuca/conman" ) func main() { var myAppConfig struct { Port string `cmssm:"/Prod/app/port" cmenv:"PORT" cmdefault:"8080"` } cm, _ := conman.New() cm.Hydrate(&myAppConfig) }
Output:
Example (Options) ¶
package main import ( "github.com/JoelPagliuca/conman" ) func main() { conman.New( // Use APP_ as a prefix for all env values conman.SetEnvPrefix("APP_"), // Use /app-name as a prefix for all ssm names conman.SetSSMPrefix("/app-name"), // Change the ordering conman tries to load config values conman.SetOrder(conman.TagSSM, conman.TagEnvironment), // Help find out why your config wasn't loaded Properly conman.EnableLogging(), // Add a strategy to be used by Hydrate conman.AddStrategy( "cmadd", conman.Strategy( func(_ *conman.Conman, _ string) (*string, error) { return nil, nil }, ), ), // Add your own `aws.Config` to be used by Hydrate conman.AddAWSConfig(nil), ) }
Output:
Index ¶
Examples ¶
Constants ¶
const ( TagEnvironment = "cmenv" TagSSM = "cmssm" TagDefault = "cmdefault" )
Tags for the Hydrater to look for
Variables ¶
This section is empty.
Functions ¶
func DefaultStrategy ¶
DefaultStrategy sets the default defined by "in"
func EnvironmentStrategy ¶
EnvironmentStrategy gets the value of the environment variable "in"
Types ¶
type Conman ¶
type Conman struct {
// contains filtered or unexported fields
}
Conman ...
type Option ¶ added in v0.2.0
Option applies some sort of option to a Conman
func AddAWSConfig ¶ added in v0.3.0
AddAWSConfig add your own AWS config to Conman if you don't want default
func AddStrategy ¶ added in v0.2.0
AddStrategy add a strategy to be used by the Hydrater will add it as first in the ordering
func EnableLogging ¶ added in v0.2.0
func EnableLogging() Option
EnableLogging - Log kinda interesting info
func SetEnvPrefix ¶ added in v0.3.0
SetEnvPrefix - Hydrate will use p as a prefix for all env values
func SetSSMPrefix ¶ added in v0.3.0
SetSSMPrefix - Hydrate will use p as a prefix for all ssm names