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) }
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 }