项目作者: hookactions

项目描述 :
Configuration management in Go
高级语言: Go
项目地址: git://github.com/hookactions/fig.git
创建时间: 2019-05-25T16:38:31Z
项目社区:https://github.com/hookactions/fig

开源协议:MIT License

下载


No longer maintained, in favor of: https://github.com/hookactions/config

fig

header
CircleCI

Usage

AWS

Pre-process config values by reading secrets from AWS.

  1. // main.go
  2. package main
  3. import (
  4. "context"
  5. "fmt"
  6. figAws "github.com/hookactions/fig/aws"
  7. "github.com/spf13/viper"
  8. )
  9. func main() {
  10. viper.SetConfigName("config")
  11. viper.AddConfigPath(".")
  12. if err := viper.ReadInConfig(); err != nil {
  13. panic(err)
  14. }
  15. fig, err := figAws.New(nil)
  16. if err != nil {
  17. panic(err)
  18. }
  19. fig.PreProcessConfigItems(context.Background())
  20. value := viper.GetString("my_var")
  21. fmt.Println(value)
  22. }
  1. echo "my_var: sm://foo" >> config.yaml
  2. go run main.go

Supported prefixes

  • sm:// – Get string value from secrets manager
  • smb:// – Get binary value from secrets manager
  • ssm:// – Get string value from parameter store
    • Note: decryption of the value is automatically requested.
  • ssmb64:// – Get base64 encoded binary value from parameter store
    • Note: decryption of the value is automatically requested.

AWS via Env

Pre-process config values by reading secrets from AWS.

  1. // main.go
  2. package main
  3. import (
  4. "context"
  5. "fmt"
  6. "os"
  7. "github.com/hookactions/fig/awsEnv"
  8. )
  9. func main() {
  10. fig, err := awsEnv.New()
  11. if err != nil {
  12. panic(err)
  13. }
  14. fmt.Println(fig.GetEnv(context.Background(), "MY_VAR"))
  15. }
  1. MY_VAR=sm://foo go run main.go

Supported prefixes

  • sm:// – Get string value from secrets manager
  • ssm:// – Get string value from parameter store
    • Note: decryption of the value is automatically requested.