in go/config/config.go [145:198]
func (c *CTConfig) Init() {
var confFile string
var flagBatchSize uint64
flag.StringVar(&confFile, "config", "", "configuration .ini file")
flag.Uint64Var(&flagBatchSize, "batchSize", 0, "limit on number of CT log entries to download per job")
flag.Parse()
if len(confFile) == 0 {
userObj, err := user.Current()
if err == nil {
defPath := fmt.Sprintf("%s/.ct-fetch.ini", userObj.HomeDir)
if _, err := os.Stat(defPath); err == nil {
confFile = defPath
}
}
}
// First, check the config file, which might have come from a CLI paramater
var section *ini.Section
if len(confFile) > 0 {
cfg, err := ini.Load(confFile)
if err == nil {
glog.Infof("Loaded config file from %s\n", confFile)
section = cfg.Section("")
} else {
glog.Errorf("Could not load config file: %s\n", err)
}
}
// Fill in values, where conf file < env vars
confUint64(c.BatchSize, section, "batchSize", 4096)
confString(c.RemoteSettingsURL, section, "remoteSettingsURL", "")
confString(c.CTLogMetadata, section, "ctLogMetadata", "")
confInt(c.NumThreads, section, "numThreads", 1)
confBool(c.LogExpiredEntries, section, "logExpiredEntries", false)
confBool(c.RunForever, section, "runForever", false)
confUint64(c.PollingDelay, section, "pollingDelay", 600)
confUint64(c.RemoteSettingsUpdateInterval, section, "remoteSettingsUpdateInterval", 3600)
confString(c.SavePeriod, section, "savePeriod", "15m")
confString(c.CertPath, section, "certPath", "")
confString(c.GoogleProjectId, section, "googleProjectId", "")
confString(c.RedisHost, section, "redisHost", "")
confString(c.RedisTimeout, section, "redisTimeout", "5s")
confString(c.StatsRefreshPeriod, section, "statsRefreshPeriod", "10m")
confString(c.StatsDHost, section, "statsdHost", "")
confInt(c.StatsDPort, section, "statsdPort", 8125)
confString(c.HealthAddr, section, "healthAddr", ":8080")
// Finally, CLI flags override
if flagBatchSize > 0 {
*c.BatchSize = flagBatchSize
}
}