func GetConfig()

in config.go [53:99]


func GetConfig(configSourceName string, earlyLogger Logger) (*Config, error) {
	EarlyLogger.Printf("loading config from source %s", configSourceName)

	// Get the chosen configuration source and read
	configSource := GetConfigSource(configSourceName)
	if configSource == nil {
		return nil, &ErrComponentDoesNotExist{Component: "ConfigSource::" + configSourceName}
	}
	config, err := configSource.ReadConfig()
	if err != nil {
		return nil, err
	}

	cfg := &Config{}

	if err := LoadGlobalConfiguration(config); err != nil {
		return nil, err
	}

	loggers, err := GetLoggers(config)
	if err != nil {
		return nil, err
	}

	// if we're provided a copy of the early logger used
	// before config load, then add it to the logger list
	if earlyLogger != nil {
		realLoggers := make([]Logger, len(loggers)+1)
		copy(realLoggers[1:], loggers)
		realLoggers[0] = earlyLogger
		loggers = realLoggers
	}

	cfg.Loggers = loggers

	// initialize the global logger!
	InitGlobalLogger(cfg.Loggers)

	// pull steps
	steps, err := GetSteps(config)
	if err != nil {
		return nil, err
	}
	cfg.Steps = steps

	return cfg, nil
}