func main() {
	var token = flag.String("token", "nil", "log token")
	var logfile = flag.String("logfile", "/tmp/foo.txt", "log file to follow")
	var seekInfoOnStart = &tail.SeekInfo{Offset: 0, Whence: os.SEEK_END}

	flag.Parse()

	fmt.Println("using token: ", *token)

	if _, err := os.Stat(*logfile); os.IsNotExist(err) {
		fmt.Printf("no such file or directory: %s\n", *logfile)
		return
	}

	le, err := le_go.Connect(*token) // replace with token
	if err != nil {
		panic(err)
	}

	defer le.Close()
	t, err := tail.TailFile(*logfile, tail.Config{Follow: true, ReOpen: true, Location: seekInfoOnStart, Logger: tail.DiscardingLogger})
	if err == nil {
		for line := range t.Lines {
			le.Println(line.Text)
		}
	}
}
Exemplo n.º 2
0
func processVars() {
	flag.String("targetDirs", "", "Local directories  to back up.")
	flag.String("s3Host", "", "S3 host.")
	flag.String("s3AccessKey", "", "S3 access key.")
	flag.String("s3SecretKey", "", "S3 secret key.")
	flag.String("s3BucketName", "", "S3 Bucket Name.")
	flag.Int("remoteWorkerCount", 5, "Number of workers performing actions against S3 host.")
	flag.Bool("dryRun", false, "Flag to indicate that this should be a dry run.")
	flag.Parse()

	viper.BindPFlag("targetDirs", flag.CommandLine.Lookup("targetDirs"))
	viper.BindPFlag("s3Host", flag.CommandLine.Lookup("s3Host"))
	viper.BindPFlag("s3AccessKey", flag.CommandLine.Lookup("s3AccessKey"))
	viper.BindPFlag("s3SecretKey", flag.CommandLine.Lookup("s3SecretKey"))
	viper.BindPFlag("s3BucketName", flag.CommandLine.Lookup("s3BucketName"))
	viper.BindPFlag("remoteWorkerCount", flag.CommandLine.Lookup("remoteWorkerCount"))
	viper.BindPFlag("dryRun", flag.CommandLine.Lookup("dryRun"))

	viper.AutomaticEnv()
	viper.SetEnvPrefix("PERSONAL_BACKUP")
	viper.BindEnv("targetDirs")
	viper.BindEnv("s3Host")
	viper.BindEnv("s3AccessKey")
	viper.BindEnv("s3SecretKey")
	viper.BindEnv("s3BucketName")
	viper.BindEnv("remoteWorkerCount")

	viper.SetDefault("remoteWorkerCount", 5)
}
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	flag.Parse()

	var out io.Writer
	if *outputDest == "-" {
		out = os.Stdout
	} else {
		file, err := os.Create(*outputDest)
		if err != nil {
			glog.Fatalf("Couldn't open %v: %v", *outputDest, err)
		}
		defer file.Close()
		out = file
	}

	versionsForConversion := strings.Split(*versions, ",")
	for _, version := range versionsForConversion {
		generator := conversion.NewGenerator(api.Scheme.Raw())
		// TODO(wojtek-t): Change the overwrites to a flag.
		generator.OverwritePackage(version, "")
		generator.OverwritePackage("api", "newer")
		for _, knownType := range api.Scheme.KnownTypes(version) {
			if err := generator.GenerateConversionsForType(version, knownType); err != nil {
				glog.Errorf("error while generating conversion functions for %v: %v", knownType, err)
			}
		}
		if err := generator.WriteConversionFunctions(out); err != nil {
			glog.Fatalf("Error while writing conversion functions: %v", err)
		}
	}
}
Exemplo n.º 4
0
func main() {
	log.SetLevel(log.FatalLevel)

	var coordinator, responseAddr, taskName string
	var taskArgs []string
	flags.StringVarP(&coordinator, "coordinator_url", "c", "", "url of the coordinator")
	flags.StringVarP(&taskName, "task", "t", "", "task to run")
	flags.StringSliceVarP(&taskArgs, "request_arg", "a", []string{}, fmt.Sprintf("task specific argument the form 'key%svalue'. can be set multiple times", argSep))
	flags.StringVarP(&responseAddr, "response_addr", "r", ":4080", "address for response http handler to listen on")
	flags.Parse()

	args, err := parseTaskArgs(taskArgs)
	dieOnError(err)

	result, stream, respErr, err := startResponseServer(responseAddr)
	dieOnError(err)

	dieOnError(makeRequest(coordinator, taskName, responseAddr, args))

	select {
	case err := <-respErr:
		dieOnError(err)
	case result := <-result:
		j, _ := json.Marshal(result)
		fmt.Println(string(j))
	case stream := <-stream:
		dieOnError(acomm.Stream(os.Stdout, stream))
	}
}
Exemplo n.º 5
0
Arquivo: main.go Projeto: richm/origin
func main() {
	arguments := args.Default()
	flag.Parse()
	dependencies := []string{
		"k8s.io/kubernetes/pkg/fields",
		"k8s.io/kubernetes/pkg/labels",
		"k8s.io/kubernetes/pkg/watch",
		"k8s.io/kubernetes/pkg/client/unversioned",
		"k8s.io/kubernetes/pkg/client/testing/fake",
		"k8s.io/kubernetes/pkg/apimachinery/registered",
	}

	if *test {
		arguments.InputDirs = append(dependencies, []string{
			"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testdata/apis/testgroup",
		}...)
		// We may change the output path later.
		arguments.OutputPackagePath = "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput"
		arguments.CustomArgs = generators.ClientGenArgs{
			[]unversioned.GroupVersion{{"testgroup", ""}},
			map[unversioned.GroupVersion]string{
				unversioned.GroupVersion{"testgroup", ""}: "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testdata/apis/testgroup",
			},
			"test_internalclientset",
			"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput/clientset_generated/",
			false,
			false,
		}
	} else {
		inputPath, groupVersions, gvToPath, err := parseInputVersions()
		if err != nil {
			glog.Fatalf("Error: %v", err)
		}
		glog.Infof("going to generate clientset from these input paths: %v", inputPath)
		arguments.InputDirs = append(inputPath, dependencies...)
		// TODO: we need to make OutPackagePath a map[string]string. For example,
		// we need clientset and the individual typed clients be output to different
		// output path.

		// We may change the output path later.
		arguments.OutputPackagePath = "k8s.io/kubernetes/pkg/client/typed/generated"

		arguments.CustomArgs = generators.ClientGenArgs{
			groupVersions,
			gvToPath,
			*clientsetName,
			*clientsetPath,
			*clientsetOnly,
			*fakeClient,
		}
	}

	if err := arguments.Execute(
		generators.NameSystems(),
		generators.DefaultNameSystem(),
		generators.Packages,
	); err != nil {
		glog.Fatalf("Error: %v", err)
	}
}
Exemplo n.º 6
0
func Setup() {
	flag.Parse()

	AppSettings.BindPFlag("port", flag.Lookup("port"))
	AppSettings.BindPFlag("address", flag.Lookup("bind"))
	AppSettings.BindPFlag("config", flag.Lookup("config"))
	AppSettings.BindPFlag("env", flag.Lookup("env"))
	S3Settings.BindPFlag("env", flag.Lookup("env"))

	AppSettings.SetDefault("address", "0.0.0.0")
	AppSettings.SetDefault("port", "5000")
	AppSettings.SetDefault("env", "development")
	AppSettings.SetDefault("config", "./config.yml")
	S3Settings.SetDefault("env", "development")

	configPath := filepath.Dir(AppSettings.GetString("config"))
	configName := strings.Replace(filepath.Base(AppSettings.GetString("config")), filepath.Ext(AppSettings.GetString("config")), "", -1)

	AppSettings.SetConfigName(configName)
	AppSettings.AddConfigPath(configPath)

	err := AppSettings.ReadInConfig()
	if err != nil {
		log.Fatal(fmt.Errorf("Fatal error config file: %s \n", err))
	}

	S3Settings.SetConfigName("s3")
	S3Settings.AddConfigPath("./")

	err = S3Settings.ReadInConfig()
	if err != nil {
		log.Fatal(fmt.Errorf("Fatal error config file: %s \n", err))
	}
}
Exemplo n.º 7
0
func main() {
	// Set logging output to standard console out
	log.SetOutput(os.Stdout)

	pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
	pflag.Parse()
	flag.CommandLine.Parse(make([]string, 0)) // Init for glog calls in kubernetes packages

	log.Printf("Starting HTTP server on port %d", *argPort)

	apiserverClient, config, err := CreateApiserverClient(*argApiserverHost)
	if err != nil {
		handleFatalInitError(err)
	}

	versionInfo, err := apiserverClient.ServerVersion()
	if err != nil {
		handleFatalInitError(err)
	}
	log.Printf("Successful initial request to the apiserver, version: %s", versionInfo.String())

	heapsterRESTClient, err := CreateHeapsterRESTClient(*argHeapsterHost, apiserverClient)
	if err != nil {
		log.Printf("Could not create heapster client: %s. Continuing.", err)
	}

	// Run a HTTP server that serves static public files from './public' and handles API calls.
	// TODO(bryk): Disable directory listing.
	http.Handle("/", MakeGzipHandler(CreateLocaleHandler()))
	http.Handle("/api/", CreateHttpApiHandler(apiserverClient, heapsterRESTClient, config))
	// TODO(maciaszczykm): Move to /appConfig.json as it was discussed in #640.
	http.Handle("/api/appConfig.json", AppHandler(ConfigHandler))
	log.Print(http.ListenAndServe(fmt.Sprintf(":%d", *argPort), nil))
}
Exemplo n.º 8
0
func main() {
	m := app.NewNetworkManager()
	flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
	m.AddFlags(flag.CommandLine)
	flag.Parse()
	m.Run(flag.CommandLine.Args())
}
Exemplo n.º 9
0
func init() {
	c := viper.New()

	c.SetEnvPrefix("Q")
	c.AutomaticEnv()

	flag.StringVar(&configFile, "config", "", "")
	flag.Parse()
	c.BindPFlag("config", flag.Lookup("config"))

	if c.GetString("config") == "" {
		// Read from "default" configuration path
		c.SetConfigName("config")
		c.AddConfigPath("/etc/qurid")
		c.AddConfigPath("$HOME/.quarid")
		c.AddConfigPath(".")
	} else {
		c.SetConfigFile(c.GetString("config"))
	}

	if err := c.ReadInConfig(); err != nil {
		panic(fmt.Errorf("Unable to read any configuration file: %s\n", err))
	}

	location, err := time.LoadLocation(c.GetString("timezone"))
	if err == nil {
		c.Set("timezone", location)
	} else {
		c.Set("timezone", time.UTC)
	}

	config = c
}
Exemplo n.º 10
0
func main() {
	pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
	pflag.Parse()

	log.Printf("Starting HTTP server on port %d", *argPort)

	apiserverClient, config, err := CreateApiserverClient(*argApiserverHost)
	if err != nil {
		handleFatalInitError(err)
	}

	versionInfo, err := apiserverClient.ServerVersion()
	if err != nil {
		handleFatalInitError(err)
	}
	log.Printf("Successful initial request to the apiserver, version: %s", versionInfo.String())

	heapsterRESTClient, err := CreateHeapsterRESTClient(*argHeapsterHost, apiserverClient)
	if err != nil {
		log.Print("Could not create heapster client: %s. Continuing.", err)
	}

	// Run a HTTP server that serves static public files from './public' and handles API calls.
	// TODO(bryk): Disable directory listing.
	http.Handle("/", http.FileServer(http.Dir("./public")))
	http.Handle("/api/", CreateHttpApiHandler(apiserverClient, heapsterRESTClient, config))
	// TODO(maciaszczykm): Move to /appConfig.json as it was discussed in #640.
	http.Handle("/api/appConfig.json", AppHandler(configHandler))
	log.Print(http.ListenAndServe(fmt.Sprintf(":%d", *argPort), nil))
}
Exemplo n.º 11
0
// AddFlags adds flags for a specific LocalkubeServer
func AddFlags(s *localkube.LocalkubeServer) {
	flag.BoolVar(&s.Containerized, "containerized", s.Containerized, "If kubelet should run in containerized mode")
	flag.BoolVar(&s.EnableDNS, "enable-dns", s.EnableDNS, "If dns should be enabled")
	flag.StringVar(&s.DNSDomain, "dns-domain", s.DNSDomain, "The cluster dns domain")
	flag.IPVar(&s.DNSIP, "dns-ip", s.DNSIP, "The cluster dns IP")
	flag.StringVar(&s.LocalkubeDirectory, "localkube-directory", s.LocalkubeDirectory, "The directory localkube will store files in")
	flag.IPNetVar(&s.ServiceClusterIPRange, "service-cluster-ip-range", s.ServiceClusterIPRange, "The service-cluster-ip-range for the apiserver")
	flag.IPVar(&s.APIServerAddress, "apiserver-address", s.APIServerAddress, "The address the apiserver will listen securely on")
	flag.IntVar(&s.APIServerPort, "apiserver-port", s.APIServerPort, "The port the apiserver will listen securely on")
	flag.IPVar(&s.APIServerInsecureAddress, "apiserver-insecure-address", s.APIServerInsecureAddress, "The address the apiserver will listen insecurely on")
	flag.IntVar(&s.APIServerInsecurePort, "apiserver-insecure-port", s.APIServerInsecurePort, "The port the apiserver will listen insecurely on")
	flag.BoolVar(&s.ShouldGenerateCerts, "generate-certs", s.ShouldGenerateCerts, "If localkube should generate it's own certificates")
	flag.BoolVar(&s.ShowVersion, "version", s.ShowVersion, "If localkube should just print the version and exit.")
	flag.Var(&s.RuntimeConfig, "runtime-config", "A set of key=value pairs that describe runtime configuration that may be passed to apiserver. apis/<groupVersion> key can be used to turn on/off specific api versions. apis/<groupVersion>/<resource> can be used to turn on/off specific resources. api/all and api/legacy are special keys to control all and legacy api versions respectively.")
	flag.IPVar(&s.NodeIP, "node-ip", s.NodeIP, "IP address of the node. If set, kubelet will use this IP address for the node.")
	flag.StringVar(&s.ContainerRuntime, "container-runtime", "", "The container runtime to be used")
	flag.StringVar(&s.NetworkPlugin, "network-plugin", "", "The name of the network plugin")

	// These two come from vendor/ packages that use flags. We should hide them
	flag.CommandLine.MarkHidden("google-json-key")
	flag.CommandLine.MarkHidden("log-flush-frequency")

	// Parse them
	flag.Parse()
}
Exemplo n.º 12
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	flag.Parse()

	var funcOut io.Writer
	if *functionDest == "-" {
		funcOut = os.Stdout
	} else {
		file, err := os.Create(*functionDest)
		if err != nil {
			glog.Fatalf("Couldn't open %v: %v", *functionDest, err)
		}
		defer file.Close()
		funcOut = file
	}

	generator := pkg_runtime.NewConversionGenerator(api.Scheme.Raw())
	// TODO(wojtek-t): Change the overwrites to a flag.
	generator.OverwritePackage(*version, "")
	for _, knownType := range api.Scheme.KnownTypes(*version) {
		if err := generator.GenerateConversionsForType(*version, knownType); err != nil {
			glog.Errorf("error while generating conversion functions for %v: %v", knownType, err)
		}
	}
	if err := generator.WriteConversionFunctions(funcOut); err != nil {
		glog.Fatalf("Error while writing conversion functions: %v", err)
	}
	if err := generator.RegisterConversionFunctions(funcOut); err != nil {
		glog.Fatalf("Error while writing conversion functions: %v", err)
	}
}
Exemplo n.º 13
0
func TestE2eNode(t *testing.T) {
	pflag.Parse()
	if *runServicesMode {
		// If run-services-mode is specified, only run services in current process.
		services.RunE2EServices()
		return
	}
	// If run-services-mode is not specified, run test.
	rand.Seed(time.Now().UTC().UnixNano())
	RegisterFailHandler(Fail)
	reporters := []Reporter{}
	reportDir := framework.TestContext.ReportDir
	if reportDir != "" {
		// Create the directory if it doesn't already exists
		if err := os.MkdirAll(reportDir, 0755); err != nil {
			glog.Errorf("Failed creating report directory: %v", err)
		} else {
			// Configure a junit reporter to write to the directory
			junitFile := fmt.Sprintf("junit_%s%02d.xml", framework.TestContext.ReportPrefix, config.GinkgoConfig.ParallelNode)
			junitPath := path.Join(reportDir, junitFile)
			reporters = append(reporters, more_reporters.NewJUnitReporter(junitPath))
		}
	}
	RunSpecsWithDefaultAndCustomReporters(t, "E2eNode Suite", reporters)
}
Exemplo n.º 14
0
func main() {
	flag.Parse()
	if *version {
		fmt.Printf("rabbit-herder %s\n", Version)
		os.Exit(0)
	}

	apiHosts := herd.GetApiHosts(*apiPtr, *userPtr, *passwordPtr)
	if len(apiHosts) > 1 {
		fmt.Printf(
			"API responded len(%d) with hosts: %s\n",
			len(apiHosts),
			strings.Trim(fmt.Sprint(apiHosts), "[]"),
		)
		fmt.Println("Already in a cluster!")
		os.Exit(0)
	}

	ec2Hosts := herd.GetOtherHosts()
	if len(ec2Hosts) == 0 {
		fmt.Println("No hosts to join!")
	} else {
		fmt.Printf("Joining hosts: %s\n", ec2Hosts)
		herd.JoinCluster(ec2Hosts, *dryRunP)
	}
}
Exemplo n.º 15
0
func main() {
	flag.CommandLine.SetNormalizeFunc(util.WarnWordSepNormalizeFunc)
	flag.Parse()
	var err error
	// TODO: Validate input flags.
	domain := *argDomain
	if !strings.HasSuffix(domain, ".") {
		domain = fmt.Sprintf("%s.", domain)
	}
	ks := kube2sky{
		domain:              domain,
		etcdMutationTimeout: *argEtcdMutationTimeout,
	}
	if ks.etcdClient, err = newEtcdClient(*argEtcdServer); err != nil {
		glog.Fatalf("Failed to create etcd client - %v", err)
	}

	kubeClient, err := newKubeClient()
	if err != nil {
		glog.Fatalf("Failed to create a kubernetes client: %v", err)
	}

	ks.endpointsStore = watchEndpoints(kubeClient, &ks)
	ks.servicesStore = watchForServices(kubeClient, &ks)
	ks.podsStore = watchPods(kubeClient, &ks)

	select {}
}
Exemplo n.º 16
0
func main() {
	pflag.Parse()

	p2p.PrintMessages(printNetworkMessages)

	log.SetPrefix(p2pConfig.Name + " ")

	network := p2p.New(p2pConfig)
	network.Join(pflag.Args())

	cfg := libsyncer.Config{
		FileServerConfig: fsConfig,
		PriceFormula:     pricer(),
		Transport:        network,
		Volume:           volume(),
	}
	syncer := libsyncer.New(cfg)
	go syncer.Serve()

	ch := make(chan os.Signal)
	signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
	<-ch

	log.Println("Received shutdown signal. Stopping ...")
	syncer.Stop()

	if err := network.Leave(10 * time.Second); err != nil {
		log.Printf("ERROR: %v", err)
	}
}
Exemplo n.º 17
0
func main() {
	flag.Parse()

	if *fSymbol == "" {
		fmt.Println("Symbol is required: GOOG, AAPL")
		return
	}

	params := network.Params{
		Symbol:    strings.ToUpper(*fSymbol),
		StartDate: network.DateComponentsFromString(*fStartDate),
		EndDate:   network.DateComponentsFromString(*fEndDate),
	}

	fmt.Printf("Fetching: %s %s-%s\n", params.Symbol, params.StartDate, params.EndDate)

	stock, err := network.FetchStockData(params)
	if err != nil {
		fmt.Println("Unable to fetch stock:", err)
		fmt.Println("args:", fSymbol, fStartDate, *fEndDate)
		return
	}

	fmt.Println(stock)
}
Exemplo n.º 18
0
func main() {
	pflag.Parse()

	viper.SetConfigName("config")
	viper.AddConfigPath(".")

	if debug {
		logrus.SetLevel(logrus.DebugLevel)
	}

	if err := viper.ReadInConfig(); err != nil {
		logrus.Fatal(err)
	}

	nick := viper.GetString("twitch.nick")
	pass := viper.GetString("twitch.pass")
	channels := viper.GetStringSlice("twitch.join")
	dbFilename := viper.GetString("database.filename")
	superusers := viper.GetStringSlice("permissions.superusers")

	bot := bot.NewBot(nick, pass, channels, dbFilename, superusers)
	if err := bot.Start(); err != nil {
		logrus.Fatal(err)
	}

	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt)
	<-c
	fmt.Print("\r\r\b")

	if err := bot.Stop(); err != nil {
		logrus.Fatal(err)
	}
}
Exemplo n.º 19
0
func realMain() error {

	flag.StringSliceVarP(&configFiles, "file", "f", nil, "file")
	flag.BoolVar(&jsonOut, "json", false, "")
	flag.BoolVarP(&versionFlag, "version", "v", false, "")

	flag.Parse()

	if jsonOut {
		logrus.SetFormatter(&logrus.JSONFormatter{})
	}

	if versionFlag {
		fmt.Printf("gcron version %s\n", VERSION)
		os.Exit(0)
	}

	c := internal.NewCron()

	if len(configFiles) == 0 {
		return errors.New("No cronfiles")
	}

	if err := loadFiles(c); err != nil {
		return err
	}

	c.Start()

	return listen(c)
}
Exemplo n.º 20
0
func main() {
	pflag.CommandLine.AddGoFlagSet(flag.CommandLine)

	pflag.Parse()
	glog.Info("Starting HTTP server on port ", *argPort)
	defer glog.Flush()

	apiserverClient, err := CreateApiserverClient(*argApiserverHost, new(ClientFactoryImpl))
	if err != nil {
		glog.Fatal(err)
	}

	serverAPIVersion, err := apiserverClient.ServerAPIVersions()
	if err != nil {
		glog.Fatal(err)
	}

	// Display Apiserver version. This is just for tests.
	println("Server API version: " + serverAPIVersion.GoString())

	// Run a HTTP server that serves static public files from './public' and handles API calls.
	// TODO(bryk): Disable directory listing.
	http.Handle("/", http.FileServer(http.Dir("./public")))
	http.Handle("/api/", CreateHttpApiHandler(apiserverClient))
	glog.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *argPort), nil))
}
Exemplo n.º 21
0
func main() {
	flag.Parse()

	if *flLdapHost == "" {
		flag.Usage()
		glog.Fatal("kubernetes-ldap: --ldap-host arg is required")
	}

	if *flBaseDN == "" {
		flag.Usage()
		glog.Fatal("kubernetes-ldap: --ldap-base-dn arg is required")
	}

	if *flSearchUserDN == "" {
		flag.Usage()
		glog.Fatal("kubernetes-ldap: --ldap-search-user-dn arg is required")
	}

	if *flSearchUserPassword == "" {
		flag.Usage()
		glog.Fatal("kubernetes-ldap: --ldap-search-user-password arg is required")
	}

	if *flApiserver == "" {
		flag.Usage()
		glog.Fatal("kubernetes-ldap: --apiserver arg is required")
	}

	// glog.CopyStandardLogTo("INFO")

	l := auth.NewLdapAuth(*flLdapHost, *flLdapPort, *flInsecure, *flBaseDN, *flUserLoginAttribute, *flSearchUserDN, *flSearchUserPassword)

	target, err := url.Parse(*flApiserver)
	if err != nil {
		glog.Fatal(err)
	}
	proxy := NewSingleHostReverseProxy(target)

	server := &http.Server{Addr: fmt.Sprintf(":%d", *flPort)}

	http.Handle("/", l.Authenticate(proxy))

	glog.Infof("Serving on %s", fmt.Sprintf(":%d", *flPort))

	// TODO(bc): enable cert-dir flag

	if *flTLSCertFile != "" && *flTLSPrivateKeyFile != "" {

		server.TLSConfig = &tls.Config{
			// Change default from SSLv3 to TLSv1.0 (because of POODLE vulnerability)
			MinVersion: tls.VersionTLS10,
		}
		glog.Fatal(server.ListenAndServeTLS(*flTLSCertFile, *flTLSPrivateKeyFile))

	} else {
		glog.Fatal(server.ListenAndServe())
	}

}
Exemplo n.º 22
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	flag.Parse()

	var funcOut io.Writer
	if *functionDest == "-" {
		funcOut = os.Stdout
	} else {
		file, err := os.Create(*functionDest)
		if err != nil {
			glog.Fatalf("Couldn't open %v: %v", *functionDest, err)
		}
		defer file.Close()
		funcOut = file
	}

	data := new(bytes.Buffer)

	group, version := path.Split(*groupVersion)
	group = strings.TrimRight(group, "/")

	_, err := data.WriteString(fmt.Sprintf("package %v\n", version))
	if err != nil {
		glog.Fatalf("error writing package line: %v", err)
	}

	versionPath := path.Join(pkgBase, group, version)
	generator := pkg_runtime.NewConversionGenerator(api.Scheme.Raw(), versionPath)
	apiShort := generator.AddImport(path.Join(pkgBase, "api"))
	generator.AddImport(path.Join(pkgBase, "api/resource"))
	// TODO(wojtek-t): Change the overwrites to a flag.
	generator.OverwritePackage(version, "")
	for _, knownType := range api.Scheme.KnownTypes(version) {
		if !strings.HasPrefix(knownType.PkgPath(), versionPath) {
			continue
		}
		if err := generator.GenerateConversionsForType(version, knownType); err != nil {
			glog.Errorf("error while generating conversion functions for %v: %v", knownType, err)
		}
	}
	generator.RepackImports(util.NewStringSet())
	if err := generator.WriteImports(data); err != nil {
		glog.Fatalf("error while writing imports: %v", err)
	}
	if err := generator.WriteConversionFunctions(data); err != nil {
		glog.Fatalf("Error while writing conversion functions: %v", err)
	}
	if err := generator.RegisterConversionFunctions(data, fmt.Sprintf("%s.Scheme", apiShort)); err != nil {
		glog.Fatalf("Error while writing conversion functions: %v", err)
	}

	b, err := imports.Process("", data.Bytes(), nil)
	if err != nil {
		glog.Fatalf("error while update imports: %v", err)
	}
	if _, err := funcOut.Write(b); err != nil {
		glog.Fatalf("error while writing out the resulting file: %v", err)
	}
}
Exemplo n.º 23
0
Arquivo: main.go Projeto: uluyol/tools
func parseArgs() {
	pflag.Usage = usage
	pflag.Parse()
	if pflag.NArg() < 1 {
		log.Fatal("must specify a command")
	}
	command = pflag.Args()
	timeoutMS = uint64(timeoutDur / time.Millisecond)
}
Exemplo n.º 24
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	flag.Parse()
	log.SetOutput(os.Stderr)

	var funcOut io.Writer
	if *functionDest == "-" {
		funcOut = os.Stdout
	} else {
		file, err := os.Create(*functionDest)
		if err != nil {
			glog.Fatalf("Couldn't open %v: %v", *functionDest, err)
		}
		defer file.Close()
		funcOut = file
	}

	generator := pkg_runtime.NewConversionGenerator(api.Scheme, "github.com/openshift/origin/pkg/api")
	apiShort := generator.AddImport("k8s.io/kubernetes/pkg/api")
	generator.AddImport("k8s.io/kubernetes/pkg/api/resource")
	generator.AssumePrivateConversions()
	// TODO(wojtek-t): Change the overwrites to a flag.
	generator.OverwritePackage(*version, "")
	gv := unversioned.GroupVersion{Group: *group, Version: *version}

	knownTypes := api.Scheme.KnownTypes(gv)
	knownTypeKeys := []string{}
	for key := range knownTypes {
		knownTypeKeys = append(knownTypeKeys, key)
	}
	sort.Strings(knownTypeKeys)

	for _, knownTypeKey := range knownTypeKeys {
		knownType := knownTypes[knownTypeKey]
		if !strings.Contains(knownType.PkgPath(), "openshift/origin") {
			continue
		}
		if err := generator.GenerateConversionsForType(gv, knownType); err != nil {
			glog.Errorf("error while generating conversion functions for %v: %v", knownType, err)
		}
	}

	// generator.RepackImports(sets.NewString("k8s.io/kubernetes/pkg/runtime"))
	// the repack changes the name of the import
	apiShort = generator.AddImport("k8s.io/kubernetes/pkg/api")

	if err := generator.WriteImports(funcOut); err != nil {
		glog.Fatalf("error while writing imports: %v", err)
	}
	if err := generator.WriteConversionFunctions(funcOut); err != nil {
		glog.Fatalf("Error while writing conversion functions: %v", err)
	}
	if err := generator.RegisterConversionFunctions(funcOut, fmt.Sprintf("%s.Scheme", apiShort)); err != nil {
		glog.Fatalf("Error while writing conversion functions: %v", err)
	}
}
Exemplo n.º 25
0
func main() {
	c := Config{}
	initFlags(&c)
	pflag.Parse()
	validateFlags(&c)

	machines := strings.Split(c.etcdServers, ",")
	etcdClient := etcd.NewClient(machines)

	c.leaseAndUpdateLoop(etcdClient)
}
Exemplo n.º 26
0
func main() {
	pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
	pflag.Parse()
	glog.Info("Starting HTTP server on port ", *argPort)
	defer glog.Flush()

	// Run a HTTP server that serves static files from current directory.
	// TODO(bryk): Disable directory listing.
	http.Handle("/", http.FileServer(http.Dir("./")))
	glog.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *argPort), nil))
}
Exemplo n.º 27
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	flag.Parse()

	var funcOut io.Writer
	if *functionDest == "-" {
		funcOut = os.Stdout
	} else {
		file, err := os.Create(*functionDest)
		if err != nil {
			glog.Fatalf("Couldn't open %v: %v", *functionDest, err)
		}
		defer file.Close()
		funcOut = file
	}

	group, version := path.Split(*groupVersion)
	group = strings.TrimRight(group, "/")
	registerTo := "api.Scheme"
	if *groupVersion == "api/" {
		registerTo = "Scheme"
	}
	versionPath := path.Join(pkgBase, group, version)
	generator := pkg_runtime.NewDeepCopyGenerator(api.Scheme.Raw(), versionPath, util.NewStringSet("k8s.io/kubernetes"))
	generator.AddImport(path.Join(pkgBase, "api"))

	if len(*overwrites) > 0 {
		for _, overwrite := range strings.Split(*overwrites, ",") {
			if !strings.Contains(overwrite, "=") {
				glog.Fatalf("Invalid overwrite syntax: %s", overwrite)
			}
			vals := strings.Split(overwrite, "=")
			generator.OverwritePackage(vals[0], vals[1])
		}
	}
	for _, knownType := range api.Scheme.KnownTypes(version) {
		if !strings.HasPrefix(knownType.PkgPath(), versionPath) {
			continue
		}
		if err := generator.AddType(knownType); err != nil {
			glog.Errorf("error while generating deep copy functions for %v: %v", knownType, err)
		}
	}
	generator.RepackImports()
	if err := generator.WriteImports(funcOut); err != nil {
		glog.Fatalf("error while writing imports: %v", err)
	}
	if err := generator.WriteDeepCopyFunctions(funcOut); err != nil {
		glog.Fatalf("error while writing deep copy functions: %v", err)
	}
	if err := generator.RegisterDeepCopyFunctions(funcOut, registerTo); err != nil {
		glog.Fatalf("error while registering deep copy functions: %v", err)
	}
}
Exemplo n.º 28
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	app := &App{}
	app.addFlags(pflag.CommandLine)
	pflag.Parse()

	if app.Verbose {
		log.SetLevel(log.DebugLevel)
	}

	app.NewServer()
}
Exemplo n.º 29
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()
}
Exemplo n.º 30
0
func main() {
	c := config{}
	initFlags(&c)
	pflag.Parse()
	validateFlags(&c)

	etcdClient, err := newEtcdClient(c.etcdConfigFile, strings.Split(c.etcdServers, ","))
	if err != nil {
		glog.Fatalf("Failed to create etcd client: %v", err)
	}

	c.leaseAndUpdateLoop(etcdClient)
}