func fetchRemoteListFromOrchestrator()

in config/config.go [426:465]


func fetchRemoteListFromOrchestrator(
	client *http.Client,
	url string,
	logger *log.Logger,
) (int, []byte, error) {

	var bResp []byte

	// Build the request
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		logger.Warn("NewRequest", zap.Error(err))
		return 0, nil, err
	}
	resp, err := client.Do(req)
	if err != nil {
		logger.Warn("HTTP fetch failure", zap.Error(err))
		return 0, nil, err
	}
	defer resp.Body.Close()

	logger.Logger = logger.With(zap.String("status_text", http.StatusText(resp.StatusCode)),
		zap.Int("status_code", resp.StatusCode))

	switch resp.StatusCode {
	case http.StatusOK:
		logger.Debug("HTTP response status code from Orchestrator")
		bResp, err = ioutil.ReadAll(resp.Body)
	case http.StatusNotFound:
		err = errors.New("HTTP response from Orchestrator: 'Idle mode'")
	case http.StatusBadRequest:
		err = errors.New("HTTP response from Orchestrator: 'Please specify hostname or DC!'")
	case http.StatusInternalServerError:
		logger.Warn("HTTP response from Orchestrator: Error opening requested configuration file")
	default:
		err = errors.New("unhandled HTTP response from Orchestrator")
	}

	return resp.StatusCode, bResp, err
}