Add 'dis' component

This commit adds a new 'dis' component to the distillery that serves a
list of all known instances for the moment.
This commit is contained in:
Tom Wiesing 2022-09-09 17:10:24 +02:00
parent 35bb95c5ca
commit 4b357476a3
No known key found for this signature in database
43 changed files with 434 additions and 167 deletions

View file

@ -73,6 +73,9 @@ type Config struct {
// admin credentials for the Mysql database
MysqlAdminUser string `env:"MYSQL_ADMIN_USER" default:"admin" validator:"is_nonempty"`
MysqlAdminPassword string `env:"MYSQL_ADMIN_PASSWORD" default:"admin" validator:"is_nonempty"`
// ConfigPath is the path this configuration was loaded from (if any)
ConfigPath string
}
func (config Config) String() string {
@ -87,7 +90,12 @@ func (config Config) String() string {
tField := tConfig.Field(i)
vField := vConfig.FieldByName(tField.Name)
fmt.Fprintf(values, "%s=%v\n", tField.Tag.Get("env"), vField.Interface())
env := tField.Tag.Get("env")
if env == "" {
continue
}
fmt.Fprintf(values, "%s=%v\n", env, vField.Interface())
}
return values.String()
@ -113,6 +121,11 @@ func (config *Config) Unmarshal(src io.Reader) error {
dflt := tField.Tag.Get("default")
validator := tField.Tag.Get("validator")
// skip it if it isn't loaded!
if env == "" {
continue
}
// read the value with a default
value, ok := values[env]
if !ok || value == "" {