Use CLI tool xps
to generate encrypted tarball, then load it using only one line code.
- get xps
go get -u github.com/empirefox/confy
- generate xps tarball from
xps-config.json
xps -k yourpassword
- generate from
xps-config-dev.json
xps -x xps-config-dev.json
- test
go test
- Extract tarball to prod
xps -d ./prod [-x xps-config.json] [-k password]
- api to load app config file from xps tarball, equip with env, and validate
package xps
type EnvLoadable interface {
// load env to these ptrs
GetEnvPtrs() []interface{}
}
type Validable interface {
// overwrite default Validate func
Validate(v interface{}) error
}
func LoadConfig(config interface{}, opts *ConfigOptions) (err error)
- Parse ConfigOptions from env:
import "github.com/empirefox/confy/xps"
config := new(Config)
err := xps.LoadConfig(config, nil)