Exemple #1
0
func setValues(tt configTest) {
	if tt.FlagValue != "" {
		pflag.Set(tt.Name, tt.FlagValue)
	}
	if tt.EnvValue != "" {
		os.Setenv(getEnvVarName(tt.Name), tt.EnvValue)
	}
	if tt.ConfigValue != "" {
		initTestConfig(tt.Name + ": " + tt.ConfigValue)
	}
}
Exemple #2
0
func initializeFlags() {
	flag.Set("logtostderr", "true")
	flag.BoolVar(&options.CleanKeystore, "clean", false, "Clean-up keystore and start over?")
	flag.StringVar(&options.EtcdHost, "etcd_host", "127.0.0.1", "Hostname or IP address where Etcd is listening on")
	flag.Uint64Var(&options.LeaderTTL, "ttl", 10, "Leader health-check interval in seconds")
	flag.BoolVar(&options.MemberElectable, "electable", true, "Is member elegible for leader?")
	flag.Uint64Var(&options.MemberTTL, "member_ttl", 30, "Member health-check interval in seconds")
	flag.StringVar(&options.PgHost, "pg_host", "127.0.0.1", "Hostname or IP address where PostgreSQL server is listening on")
	flag.IntVar(&options.PgPort, "pg_port", 5432, "TCP port where PostgreSQL server is listening on")

	flag.Parse()
}
Exemple #3
0
func main() {
	client.BindClientConfigFlags(flag.CommandLine, clientConfig)
	flag.Set("logtostderr", "true")
	flag.Parse()

	cmd := exec.Command("haproxy", "-f", configPath, "-p", "/var/run/haproxy.pid")
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	err := cmd.Run()
	if err != nil {
		if o, err := cmd.CombinedOutput(); err != nil {
			glog.Error(string(o))
		}
		glog.Fatalf("haproxy process died, : %v", err)
	}
	glog.Info("started haproxy")

	clientConfig.TLSClientConfig = loadTLSConfigOrDie()
	//clientConfig.Version = "v1beta3"
	clientConfig.Version = "v1"
	kubeClient, err := client.New(clientConfig)
	if err != nil {
		glog.Fatalf("Invalid API configuration: %v", err)
	}

	cu := configUpdater{
		make([]api.Endpoints, 0),
		make([]api.Service, 0),
		make(chan []api.Endpoints),
		make(chan []api.Service),
		template.Must(template.ParseFiles(templatePath)),
		make(chan struct{}, 1),
	}

	endpointsConfig := config.NewEndpointsConfig()
	serviceConfig := config.NewServiceConfig()
	endpointsConfig.RegisterHandler(cu.eu)
	serviceConfig.RegisterHandler(cu.su)

	config.NewSourceAPI(
		kubeClient.Services(api.NamespaceAll),
		kubeClient.Endpoints(api.NamespaceAll),
		30*time.Second,
		serviceConfig.Channel("api"),
		endpointsConfig.Channel("api"),
	)
	glog.Info("started watch")

	go util.Forever(cu.reloadLoop, 1*time.Second)
	util.Forever(cu.syncLoop, 1*time.Second)
}
Exemple #4
0
func setValues(t *testing.T, tt configTest) {
	if tt.FlagValue != "" {
		pflag.Set(tt.Name, tt.FlagValue)
	}
	if tt.EnvValue != "" {
		s := strings.Replace(getEnvVarName(tt.Name), "-", "_", -1)
		os.Setenv(s, tt.EnvValue)
	}
	if tt.ConfigValue != "" {
		err := initTestConfig(tt.ConfigValue)
		if err != nil {
			t.Fatalf("Config %s not read correctly: %v", tt.ConfigValue, err)
		}
	}
}
Exemple #5
0
// Set sets the name/value pair in the flag set
func Set(name, value string) error {
	pflag.Set(name, value)
	return nil
}