Make a default config variable (#1848)

* Make a default config variable

* decoder.Decode needs pointer to config
This commit is contained in:
Raja Subramanian
2023-07-03 23:49:03 +05:30
committed by GitHub
parent ab7cad4aab
commit 6198aac7a8
+6 -5
View File
@@ -264,9 +264,7 @@ func DefaultAPIConfig() APIConfig {
} }
} }
func NewConfig(confString string, strictMode bool, c *cli.Context, baseFlags []cli.Flag) (*Config, error) { var DefaultConfig = Config{
// start with defaults
conf := &Config{
Port: 7880, Port: 7880,
RTC: RTCConfig{ RTC: RTCConfig{
RTCConfig: rtcconfig.RTCConfig{ RTCConfig: rtcconfig.RTCConfig{
@@ -425,10 +423,13 @@ func NewConfig(confString string, strictMode bool, c *cli.Context, baseFlags []c
Keys: map[string]string{}, Keys: map[string]string{},
} }
func NewConfig(confString string, strictMode bool, c *cli.Context, baseFlags []cli.Flag) (*Config, error) {
// start with defaults
conf := DefaultConfig
if confString != "" { if confString != "" {
decoder := yaml.NewDecoder(strings.NewReader(confString)) decoder := yaml.NewDecoder(strings.NewReader(confString))
decoder.KnownFields(strictMode) decoder.KnownFields(strictMode)
if err := decoder.Decode(conf); err != nil { if err := decoder.Decode(&conf); err != nil {
return nil, fmt.Errorf("could not parse config: %v", err) return nil, fmt.Errorf("could not parse config: %v", err)
} }
} }
@@ -473,7 +474,7 @@ func NewConfig(confString string, strictMode bool, c *cli.Context, baseFlags []c
conf.Environment = "dev" conf.Environment = "dev"
} }
return conf, nil return &conf, nil
} }
func (conf *Config) IsTURNSEnabled() bool { func (conf *Config) IsTURNSEnabled() bool {