@@ -32,7 +32,7 @@ type Config struct {
3232 // Defaults to runtime.NumCPU() if zero.
3333 PoolSize int `json:"pool_size" mapstructure:"pool_size"`
3434 // Log configuration, uses eru core's ServerLogConfig.
35- Log coretypes.ServerLogConfig `json:"log" mapstructure:"log"`
35+ Log * coretypes.ServerLogConfig `json:"log" mapstructure:"log"`
3636}
3737
3838// DefaultConfig returns a Config with sensible defaults.
@@ -44,7 +44,7 @@ func DefaultConfig() *Config {
4444 CHBinary : "cloud-hypervisor" ,
4545 StopTimeoutSeconds : 30 ,
4646 PoolSize : runtime .NumCPU (),
47- Log : coretypes.ServerLogConfig {
47+ Log : & coretypes.ServerLogConfig {
4848 Level : "info" ,
4949 MaxSize : 500 ,
5050 MaxAge : 28 ,
@@ -78,5 +78,22 @@ func LoadConfig(path string) (*Config, error) {
7878 if conf .StopTimeoutSeconds <= 0 {
7979 conf .StopTimeoutSeconds = 30 //nolint:mnd
8080 }
81+ return EnsureDirs (conf )
82+ }
83+
84+ func EnsureDirs (conf * Config ) (* Config , error ) {
85+ defaults := DefaultConfig ()
86+ if conf .RootDir == "" {
87+ conf .RootDir = defaults .RootDir
88+ }
89+ if conf .RunDir == "" {
90+ conf .RunDir = defaults .RunDir
91+ }
92+ if conf .LogDir == "" {
93+ conf .LogDir = defaults .LogDir
94+ }
95+ if conf .CHBinary == "" {
96+ conf .CHBinary = defaults .CHBinary
97+ }
8198 return conf , nil
8299}
0 commit comments