Skip to content

v1.8.1

Compare
Choose a tag to compare
@yoyofx yoyofx released this 25 Apr 06:25
· 40 commits to master since this release
4485272

Features

  1. Get config value for DSL, that support key or ref object.

Such as YAML:

env: ${CUSTOM_ENV}
profile:
  dns: ${REMOTE_HOST}
  ip: ${REMOTE_IP:10.0.1.12}
  namespace: ${MYNAMESPACE:space.localhost}

Go Example

type Profile struct {
	DNS string `config:"dns"`
	IP  string `config:"ip"`
	NS  string `config:"namespace"`
}

config := abstractions.NewConfigurationBuilder().
       AddEnvironment().
       AddYamlFile("config").Build()

config.GetConfigObject("profile", &profile)
assert.Equal(t, profile.NS, "space.yoyogo.run")
assert.Equal(t, profile.DNS, "my host")
assert.Equal(t, profile.IP, "10.0.1.12")

or

env := config.Get("env")
dns := config.Get("profile.dns")
ip := config.Get("profile.ip")

assert.Equal(t, env, "my env variable")
assert.Equal(t, dns, "my host")
assert.Equal(t, ip, "10.0.1.12")