add tags to structs

This commit is contained in:
A.Unger
2021-11-05 11:37:16 +01:00
parent 91c766210c
commit be9eff8ba8
2 changed files with 41 additions and 29 deletions
+29 -29
View File
@@ -10,59 +10,59 @@ import (
// Log defines the available logging configuration.
type Log struct {
Level string
Pretty bool
Color bool
File string
Level string `mapstructure:"level"`
Pretty bool `mapstructure:"pretty"`
Color bool `mapstructure:"color"`
File string `mapstructure:"file"`
}
// Debug defines the available debug configuration.
type Debug struct {
Addr string
Token string
Pprof bool
Zpages bool
Addr string `mapstructure:"addr"`
Token string `mapstructure:"token"`
Pprof bool `mapstructure:"pprof"`
Zpages bool `mapstructure:"zpages"`
}
// HTTP defines the available http configuration.
type HTTP struct {
Addr string
Root string
Namespace string
Addr string `mapstructure:"addr"`
Root string `mapstructure:"root"`
Namespace string `mapstructure:"namespace"`
}
// Server configures a server.
type Server struct {
Version string
Name string
Version string `mapstructure:"version"`
Name string `mapstructure:"name"`
}
// Tracing defines the available tracing configuration.
type Tracing struct {
Enabled bool
Type string
Endpoint string
Collector string
Service string
Enabled bool `mapstructure:"enabled"`
Type string `mapstructure:"type"`
Endpoint string `mapstructure:"endpoint"`
Collector string `mapstructure:"collector"`
Service string `mapstructure:"service"`
}
// GraphExplorer defines the available graph-explorer configuration.
type GraphExplorer struct {
ClientID string
Issuer string
GraphURLBase string
GraphURLPath string
ClientID string `mapstructure:"client_id"`
Issuer string `mapstructure:"issuer"`
GraphURLBase string `mapstructure:"graph_url_base"`
GraphURLPath string `mapstructure:"graph_url_path"`
}
// Config combines all available configuration parts.
type Config struct {
File string
Log Log
Debug Debug
HTTP HTTP
Server Server
Tracing Tracing
GraphExplorer GraphExplorer
File string `mapstructure:"file"`
Log Log `mapstructure:"log"`
Debug Debug `mapstructure:"debug"`
HTTP HTTP `mapstructure:"http"`
Server Server `mapstructure:"server"`
Tracing Tracing `mapstructure:"tracing"`
GraphExplorer GraphExplorer `mapstructure:"graph_explorer"`
Context context.Context
Supervised bool
+12
View File
@@ -8,6 +8,18 @@ type mapping struct {
// structMappings binds a set of environment variables to a destination on cfg.
func structMappings(cfg *Config) []mapping {
return []mapping{
{
EnvVars: []string{"GRAPH_EXPLORER_LOG_LEVEL", "OCIS_LOG_LEVEL"},
Destination: &cfg.Log.Level,
},
{
EnvVars: []string{"GRAPH_EXPLORER_LOG_PRETTY", "OCIS_LOG_PRETTY"},
Destination: &cfg.Log.Pretty,
},
{
EnvVars: []string{"GRAPH_EXPLORER_LOG_COLOR", "OCIS_LOG_COLOR"},
Destination: &cfg.Log.Color,
},
{
EnvVars: []string{"GRAPH_EXPLORER_LOG_FILE", "OCIS_LOG_FILE"},
Destination: &cfg.Log.File,