Ejemplo n.º 1
0
func (h *Helper) updateConfig(configDir, hostDir, serverIP, metricsHost string) error {
	masterConfig := filepath.Join(configDir, "master", "master-config.yaml")
	glog.V(1).Infof("Reading master config from %s", masterConfig)
	cfg, err := configapilatest.ReadMasterConfig(masterConfig)
	if err != nil {
		glog.V(1).Infof("Could not read master config: %v", err)
		return err
	}

	if len(h.routingSuffix) > 0 {
		cfg.RoutingConfig.Subdomain = h.routingSuffix
	} else {
		cfg.RoutingConfig.Subdomain = fmt.Sprintf("%s.xip.io", serverIP)
	}

	if len(metricsHost) > 0 && cfg.AssetConfig != nil {
		cfg.AssetConfig.MetricsPublicURL = fmt.Sprintf("https://%s/hawkular/metrics", metricsHost)
	}

	cfgBytes, err := configapilatest.WriteYAML(cfg)
	if err != nil {
		return err
	}
	err = ioutil.WriteFile(masterConfig, cfgBytes, 0644)
	if err != nil {
		return err
	}
	return h.hostHelper.CopyMasterConfigToHost(masterConfig, hostDir)
}
Ejemplo n.º 2
0
func (h *Helper) GetConfig(configDir string) (*configapi.MasterConfig, string, error) {
	configPath := filepath.Join(configDir, "master", "master-config.yaml")
	glog.V(1).Infof("Reading master config from %s", configPath)
	cfg, err := configapilatest.ReadMasterConfig(configPath)
	if err != nil {
		glog.V(1).Infof("Could not read master config: %v", err)
		return nil, "", err
	}
	return cfg, configPath, nil
}