|
@@ -113,16 +113,16 @@ type includedMirrorConfig struct {
|
|
|
}
|
|
|
|
|
|
type mirrorConfig struct {
|
|
|
- Name string `toml:"name"`
|
|
|
- Provider providerEnum `toml:"provider"`
|
|
|
- Upstream string `toml:"upstream"`
|
|
|
- Interval int `toml:"interval"`
|
|
|
- Retry int `toml:"retry"`
|
|
|
- MirrorDir string `toml:"mirror_dir"`
|
|
|
- MirrorSubDir string `toml:"mirror_subdir"`
|
|
|
- LogDir string `toml:"log_dir"`
|
|
|
- Env map[string]string `toml:"env"`
|
|
|
- Role string `toml:"role"`
|
|
|
+ Name string `toml:"name"`
|
|
|
+ Provider providerEnum `toml:"provider"`
|
|
|
+ Upstream string `toml:"upstream"`
|
|
|
+ Interval int `toml:"interval"`
|
|
|
+ Retry int `toml:"retry"`
|
|
|
+ MirrorDir string `toml:"mirror_dir"`
|
|
|
+ MirrorSubDir string `toml:"mirror_subdir"`
|
|
|
+ LogDir string `toml:"log_dir"`
|
|
|
+ Env map[string]string `toml:"env"`
|
|
|
+ Role string `toml:"role"`
|
|
|
|
|
|
// These two options over-write the global options
|
|
|
ExecOnSuccess []string `toml:"exec_on_success"`
|
|
@@ -152,7 +152,7 @@ type mirrorConfig struct {
|
|
|
|
|
|
SnapshotPath string `toml:"snapshot_path"`
|
|
|
|
|
|
- ChildMirrors []mirrorConfig `toml:"mirrors"`
|
|
|
+ ChildMirrors []mirrorConfig `toml:"mirrors"`
|
|
|
}
|
|
|
|
|
|
// LoadConfig loads configuration
|
|
@@ -185,7 +185,7 @@ func LoadConfig(cfgFile string) (*Config, error) {
|
|
|
|
|
|
for _, m := range cfg.MirrorsConf {
|
|
|
if err := recursiveMirrors(cfg, nil, m); err != nil {
|
|
|
- return nil, err;
|
|
|
+ return nil, err
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -193,22 +193,22 @@ func LoadConfig(cfgFile string) (*Config, error) {
|
|
|
}
|
|
|
|
|
|
func recursiveMirrors(cfg *Config, parent *mirrorConfig, mirror mirrorConfig) error {
|
|
|
- var curMir mirrorConfig;
|
|
|
+ var curMir mirrorConfig
|
|
|
if parent != nil {
|
|
|
- curMir = *parent;
|
|
|
+ curMir = *parent
|
|
|
}
|
|
|
- curMir.ChildMirrors = nil;
|
|
|
+ curMir.ChildMirrors = nil
|
|
|
if err := mergo.Merge(&curMir, mirror, mergo.WithOverride); err != nil {
|
|
|
- return err;
|
|
|
+ return err
|
|
|
}
|
|
|
if mirror.ChildMirrors == nil {
|
|
|
- cfg.Mirrors = append(cfg.Mirrors, curMir);
|
|
|
+ cfg.Mirrors = append(cfg.Mirrors, curMir)
|
|
|
} else {
|
|
|
for _, m := range mirror.ChildMirrors {
|
|
|
if err := recursiveMirrors(cfg, &curMir, m); err != nil {
|
|
|
- return err;
|
|
|
+ return err
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return nil;
|
|
|
+ return nil
|
|
|
}
|