Esempio n. 1
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()
}
Esempio n. 2
0
func init() {
	flag.IntVar(&last, "last-release-pr", 0, "The PR number of the last versioned release.")
	flag.IntVar(&current, "current-release-pr", 0, "The PR number of the current versioned release.")
	flag.StringVar(&token, "api-token", "", "Github api token for rate limiting. Background: https://developer.github.com/v3/#rate-limiting and create a token: https://github.com/settings/tokens")
	flag.StringVar(&base, "base", "master", "The base branch name for PRs to look for.")
	flag.BoolVar(&relnoteFilter, "relnote-filter", true, "Whether to filter PRs by the release-note label.")
}
Esempio n. 3
0
func initFlags(c *config) {
	pflag.StringSliceVar(&c.etcdServers, "etcd-servers", []string{}, "The comma-seprated list of etcd servers to use")
	pflag.StringVar(&c.key, "key", "", "The key to use for the lock")
	pflag.StringVar(&c.whoami, "whoami", "", "The name to use for the reservation.  If empty use os.Hostname")
	pflag.Uint64Var(&c.ttl, "ttl-secs", 30, "The time to live for the lock.")
	pflag.StringVar(&c.src, "source-file", "", "The source file to copy from.")
	pflag.StringVar(&c.dest, "dest-file", "", "The destination file to copy to.")
	pflag.DurationVar(&c.sleep, "sleep", 5*time.Second, "The length of time to sleep between checking the lock.")
}
Esempio n. 4
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()
}
Esempio n. 5
0
func init() {
	flag.VarP(&testList, "test", "t", "Test to execute (may be repeated or comma separated list of tests.) Defaults to running all tests.")

	flag.StringVar(&context.KubeConfig, clientcmd.RecommendedConfigPathFlag, "", "Path to kubeconfig containing embeded authinfo.")
	flag.StringVar(&context.KubeContext, clientcmd.FlagContext, "", "kubeconfig context to use/override. If unset, will use value from 'current-context'")
	flag.StringVar(&context.AuthConfig, "auth_config", "", "Path to the auth info file.")
	flag.StringVar(&context.CertDir, "cert_dir", "", "Path to the directory containing the certs. Default is empty, which doesn't use certs.")
	flag.StringVar(&context.Host, "host", "", "The host, or apiserver, to connect to")
	flag.StringVar(&context.RepoRoot, "repo_root", "./", "Root directory of kubernetes repository, for finding test files. Default assumes working directory is repository root")
	flag.StringVar(&context.Provider, "provider", "", "The name of the Kubernetes provider (gce, gke, local, vagrant, etc.)")

	// TODO: Flags per provider?  Rename gce_project/gce_zone?
	flag.StringVar(&cloudConfig.MasterName, "kube_master", "", "Name of the kubernetes master. Only required if provider is gce or gke")
	flag.StringVar(&cloudConfig.ProjectID, "gce_project", "", "The GCE project being used, if applicable")
	flag.StringVar(&cloudConfig.Zone, "gce_zone", "", "GCE zone being used, if applicable")
}
Esempio n. 6
0
// init initialize the extended testing suite.
// You can set these environment variables to configure extended tests:
// KUBECONFIG - Path to kubeconfig containing embedded authinfo
func InitTest() {
	// Turn on verbose by default to get spec names
	config.DefaultReporterConfig.Verbose = false

	// Turn on EmitSpecProgress to get spec progress (especially on interrupt)
	config.GinkgoConfig.EmitSpecProgress = false

	// Randomize specs as well as suites
	config.GinkgoConfig.RandomizeAllSpecs = false

	extendedOutputDir := filepath.Join(os.TempDir(), "openshift-extended-tests")
	os.MkdirAll(extendedOutputDir, 0777)

	TestContext.VerifyServiceAccount = true
	TestContext.RepoRoot = os.Getenv("KUBE_REPO_ROOT")
	TestContext.KubectlPath = "kubectl"
	TestContext.KubeConfig = KubeConfigPath()
	os.Setenv("KUBECONFIG", TestContext.KubeConfig)

	//flag.StringVar(&TestContext.KubeConfig, clientcmd.RecommendedConfigPathFlag, KubeConfigPath(), "Path to kubeconfig containing embedded authinfo.")
	flag.StringVar(&TestContext.OutputDir, "extended-tests-output-dir", extendedOutputDir, "Output directory for interesting/useful test data, like performance data, benchmarks, and other metrics.")

	// Ensure that Kube tests run privileged (like they do upstream)
	ginkgo.JustBeforeEach(ensureKubeE2EPrivilegedSA)

	// Override the default Kubernetes E2E configuration
	e2e.SetTestContext(TestContext)
}
Esempio n. 7
0
// init initialize the extended testing suite.
// You can set these environment variables to configure extended tests:
// KUBECONFIG - Path to kubeconfig containing embedded authinfo
// TEST_REPORT_DIR - If set, JUnit output will be written to this directory for each test
// TEST_REPORT_FILE_NAME - If set, will determine the name of the file that JUnit output is written to
func InitTest() {
	extendedOutputDir := filepath.Join(os.TempDir(), "openshift-extended-tests")
	os.MkdirAll(extendedOutputDir, 0777)

	TestContext.VerifyServiceAccount = true
	TestContext.RepoRoot = os.Getenv("KUBE_REPO_ROOT")
	TestContext.KubectlPath = "kubectl"
	TestContext.KubeConfig = KubeConfigPath()
	os.Setenv("KUBECONFIG", TestContext.KubeConfig)

	reportDir = os.Getenv("TEST_REPORT_DIR")

	reportFileName = os.Getenv("TEST_REPORT_FILE_NAME")
	if reportFileName == "" {
		reportFileName = "junit"
	}

	//flag.StringVar(&TestContext.KubeConfig, clientcmd.RecommendedConfigPathFlag, KubeConfigPath(), "Path to kubeconfig containing embedded authinfo.")
	flag.StringVar(&TestContext.OutputDir, "extended-tests-output-dir", extendedOutputDir, "Output directory for interesting/useful test data, like performance data, benchmarks, and other metrics.")
	rflag.StringVar(&config.GinkgoConfig.FocusString, "focus", "", "DEPRECATED: use --ginkgo.focus")

	// Ensure that Kube tests run privileged (like they do upstream)
	ginkgo.JustBeforeEach(ensureKubeE2EPrivilegedSA)

	// Override the default Kubernetes E2E configuration
	e2e.SetTestContext(TestContext)
}
Esempio n. 8
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
}
Esempio n. 9
0
func initFlags() {
	flag.IntVarP(&options.Port, "port", "p", 80, "The port to listen on")
	flag.StringVarP(&options.StaticDir, "www", "w", ".", "Directory to serve static files from")
	flag.StringVar(&options.StaticPrefix, "www-prefix", "/", "Prefix to serve static files on")
	flag.DurationVar(&options.StaticCacheMaxAge, "max-age", 0, "Set the Cache-Control header for static content with the max-age set to this value, e.g. 24h. Must confirm to http://golang.org/pkg/time/#ParseDuration")
	flag.StringVarP(&options.DefaultPage, "default-page", "d", "", "Default page to send if page not found")
	flag.VarP(&options.Services, "service", "s", "The Kubernetes services to proxy to in the form \"<prefix>=<serviceUrl>\"")
	flag.VarP(&options.Configs, "config-file", "c", "The configuration files to create in the form \"<template>=<output>\"")
	flag.Var(&options.CACerts, "ca-cert", "CA certs used to verify proxied server certificates")
	flag.StringVar(&options.TlsCertFile, "tls-cert", "", "Certificate file to use to serve using TLS")
	flag.StringVar(&options.TlsKeyFile, "tls-key", "", "Certificate file to use to serve using TLS")
	flag.BoolVar(&options.SkipCertValidation, "skip-cert-validation", false, "Skip remote certificate validation - dangerous!")
	flag.BoolVarP(&options.AccessLogging, "access-logging", "l", false, "Enable access logging")
	flag.BoolVar(&options.CompressHandler, "compress", false, "Enable gzip/deflate response compression")
	flag.BoolVar(&options.FailOnUnknownServices, "fail-on-unknown-services", false, "Fail on unknown services in DNS")
	flag.BoolVar(&options.ServeWww, "serve-www", true, "Whether to serve static content")
	flag.Parse()
}
Esempio n. 10
0
func init() {
	pflag.StringVar(&formula, "price-formula", "static", "What price formular to use? static, random, old, young")
	pflag.Float32Var(&formulaStaticPrice, "price-static", 1.0, "Price for static formular")
	pflag.Float32Var(&formulaDefaultPrice, "price-default", 1.0, "Default Price for old/young formular")
	pflag.Float32Var(&formulaOldPrice, "price-old", 1.0, "Age Price for old formular")
	pflag.Float32Var(&formulaYoungPrice, "price-young", 1.0, "Age Price for young formular")
	pflag.DurationVar(&formulaOldAge, "price-old-age", 6*30*24*time.Hour, "Minimum age before start bidding price-old")
	pflag.DurationVar(&formulaYoungAge, "price-young-age", 60*24*time.Hour, "Maximum age before stop bidding price-old")

	pflag.StringVar(&volumePath, "volume", "./lib", "What files to sync")

	pflag.StringVar(&fsConfig.Addr, "http-addr", "127.0.0.1", "IP to listen on. Must be resolvable by all peers")
	pflag.IntVar(&fsConfig.Port, "http-port", 8080, "Port for HTTP FileServer")

	pflag.IntVar(&p2pConfig.BindPort, "bind-port", 8000, "The port to bind to")
	pflag.StringVar(&p2pConfig.Name, "name", "mediasyncer", "The name of this process. Must be unique for the memberlist cluster")

	pflag.BoolVar(&printNetworkMessages, "debug", false, "Print network messages received/sent")
}
Esempio n. 11
0
// init initialize the extended testing suite.
// You can set these environment variables to configure extended tests:
// KUBECONFIG - Path to kubeconfig containing embeded authinfo
func init() {
	// Turn on verbose by default to get spec names
	config.DefaultReporterConfig.Verbose = true

	// Turn on EmitSpecProgress to get spec progress (especially on interrupt)
	config.GinkgoConfig.EmitSpecProgress = true

	// Randomize specs as well as suites
	config.GinkgoConfig.RandomizeAllSpecs = false

	extendedOutputDir := filepath.Join(os.TempDir(), "openshift-extended-tests")
	os.MkdirAll(extendedOutputDir, 0600)

	flag.StringVar(&testContext.KubeConfig, clientcmd.RecommendedConfigPathFlag, kubeConfigPath(), "Path to kubeconfig containing embeded authinfo.")
	flag.StringVar(&testContext.OutputDir, "extended-tests-output-dir", extendedOutputDir, "Output directory for interesting/useful test data, like performance data, benchmarks, and other metrics.")

	// Override the default Kubernetes E2E configuration
	SetTestContext(testContext)
}
Esempio n. 12
0
func initFlags(c *config) {
	pflag.StringSliceVar(&c.etcdServers, "etcd-servers", []string{}, "The comma-seprated list of etcd servers to use")
	pflag.BoolVar(&c.etcdSecure, "etcd-secure", false, "Set to true if etcd has https")
	pflag.StringVar(&c.etcdCertfile, "etcd-certfile", "", "Etcd TLS cert file, needed if etcd-secure")
	pflag.StringVar(&c.etcdKeyfile, "etcd-keyfile", "", "Etcd TLS key file, needed if etcd-secure")
	pflag.StringVar(&c.etcdCafile, "etcd-cafile", "", "Etcd CA file, needed if etcd-secure")
	pflag.StringVar(&c.key, "key", "", "The key to use for the lock")
	pflag.StringVar(&c.whoami, "whoami", "", "The name to use for the reservation.  If empty use os.Hostname")
	pflag.Uint64Var(&c.ttl, "ttl-secs", 30, "The time to live for the lock.")
	pflag.StringVar(&c.src, "source-file", "", "The source file to copy from.")
	pflag.StringVar(&c.dest, "dest-file", "", "The destination file to copy to.")
	pflag.DurationVar(&c.sleep, "sleep", 5*time.Second, "The length of time to sleep between checking the lock.")
}
Esempio n. 13
0
func initFlags(c *config) {
	pflag.StringVar(&c.etcdServers, "etcd-servers", "", "List of etcd servers to watch (http://ip:port), comma separated. Mutually exclusive with -etcd-config")
	pflag.StringVar(&c.etcdConfigFile, "etcd-config", "", "The config file for the etcd client. Mutually exclusive with -etcd-servers.")
	pflag.StringVar(&c.key, "key", "", "The key to use for the lock")
	pflag.StringVar(&c.whoami, "whoami", "", "The name to use for the reservation.  If empty use os.Hostname")
	pflag.Uint64Var(&c.ttl, "ttl-secs", 30, "The time to live for the lock.")
	pflag.StringVar(&c.src, "source-file", "", "The source file to copy from.")
	pflag.StringVar(&c.dest, "dest-file", "", "The destination file to copy to.")
	pflag.DurationVar(&c.sleep, "sleep", 5*time.Second, "The length of time to sleep between checking the lock.")
}
Esempio n. 14
0
// init initialize the extended testing suite.
// You can set these environment variables to configure extended tests:
// KUBECONFIG - Path to kubeconfig containing embedded authinfo
// TEST_REPORT_DIR - If set, JUnit output will be written to this directory for each test
// TEST_REPORT_FILE_NAME - If set, will determine the name of the file that JUnit output is written to
func InitTest() {
	// Add hooks to skip all kubernetes or origin tests
	ginkgo.BeforeEach(checkSuiteSkips)

	extendedOutputDir := filepath.Join(os.TempDir(), "openshift-extended-tests")
	os.MkdirAll(extendedOutputDir, 0777)

	TestContext.DeleteNamespace = os.Getenv("DELETE_NAMESPACE") != "false"
	TestContext.VerifyServiceAccount = true
	TestContext.RepoRoot = os.Getenv("KUBE_REPO_ROOT")
	TestContext.KubeVolumeDir = os.Getenv("VOLUME_DIR")
	if len(TestContext.KubeVolumeDir) == 0 {
		TestContext.KubeVolumeDir = "/var/lib/origin/volumes"
	}
	TestContext.KubectlPath = "kubectl"
	TestContext.KubeConfig = KubeConfigPath()
	os.Setenv("KUBECONFIG", TestContext.KubeConfig)

	// load and set the host variable for kubectl
	clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(&clientcmd.ClientConfigLoadingRules{ExplicitPath: TestContext.KubeConfig}, &clientcmd.ConfigOverrides{})
	cfg, err := clientConfig.ClientConfig()
	if err != nil {
		FatalErr(err)
	}
	TestContext.Host = cfg.Host

	reportDir = os.Getenv("TEST_REPORT_DIR")

	reportFileName = os.Getenv("TEST_REPORT_FILE_NAME")
	if reportFileName == "" {
		reportFileName = "junit"
	}

	quiet = os.Getenv("TEST_OUTPUT_QUIET") == "true"
	//flag.StringVar(&TestContext.KubeConfig, clientcmd.RecommendedConfigPathFlag, KubeConfigPath(), "Path to kubeconfig containing embedded authinfo.")
	flag.StringVar(&TestContext.OutputDir, "extended-tests-output-dir", extendedOutputDir, "Output directory for interesting/useful test data, like performance data, benchmarks, and other metrics.")
	rflag.StringVar(&config.GinkgoConfig.FocusString, "focus", "", "DEPRECATED: use --ginkgo.focus")

	// Ensure that Kube tests run privileged (like they do upstream)
	TestContext.CreateTestingNS = createTestingNS

	// Override the default Kubernetes E2E configuration
	e2e.SetTestContext(TestContext)
}
Esempio n. 15
0
func init() {
	flag.IntVar(&target, "last-release-pr", 0, "The PR number of the last versioned release.")
	flag.IntVar(&current, "current-release-pr", 0, "The PR number of the current versioned release.")
	flag.StringVar(&token, "api-token", "", "Github api token for rate limiting. See https://developer.github.com/v3/#rate-limiting.")
}
func main() {
	pflag.BoolVar(&sentinelMode, "sentinel-mode", false,
		"Whether using Sentinel")
	pflag.StringVar(&redisAddress, "redis-addr", ":6379",
		"Redis address, can be ignored while setting sentinel mode")
	pflag.StringVar(&conf.MasterName, "master-name", "mymaster",
		"Redis Sentinel master name")
	pflag.StringSliceVar(&conf.Addresses, "sentinel-ips",
		[]string{"172.31.33.2:26379", "172.31.33.3:26379", "172.31.75.4:26379"},
		"Sentinel failover addresses")
	pflag.Parse()

	if sentinelMode {
		fmt.Println("block to wait connection")
		var err error
		//go func() {store, err = connectSentinel()}()
		store, err = connectSentinel()
		if err != nil {
			fmt.Println("Failed to create connection! Please contact SysOps")
			return
		}
	} else {
		//store = sessions.NewCookieStore([]byte("something-very-secret"))
		//store = sessions.NewFilesystemStore("", []byte("something-very-secret"))
		//store, err := redistore.NewRediStore(10, "tcp", ".6379", "", []byte("secret-key"))
		redistore, err := redistore.NewRediStore(10, "tcp",
			redisAddress, "", []byte("authentication-secret-key"))
		if err != nil {
			fmt.Println("Failed to ping Redis! Please contact SysOps")
			return
		}
		store = redistore
	}

	gob.Register(&Person{})

	port := os.Getenv("PORT")
	if port == "" {
		port = "80"
	}

	router := mux.NewRouter()
	router.HandleFunc("/signup/{signup}", makeHandler(signupHandler)).Methods("GET", "POST")
	router.HandleFunc("/signin/{signin}", makeHandler(signinHandler)).Methods("GET", "POST")
	router.HandleFunc("/profile/{profile}", makeHandler(profileHandler)).Methods("GET", "POST")
	router.HandleFunc("/signout/{signout}", makeHandler(signoutHandler)).Methods("GET", "POST")
	//router.HandleFunc("/index.html", makeHandler(indexHandler)).Methods("GET") // substituted by following statement
	router.HandleFunc("/{others}", func(w http.ResponseWriter, r *http.Request) {
		vars := mux.Vars(r)
		others := vars["others"]
		if m := indexRegex.FindStringSubmatch(strings.ToLower(others)); m != nil {
			indexHandler(w, r, others[:len("index")])
			return
		}
		http.NotFound(w, r)
	}).Methods("GET")
	router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		if r.URL.Path == "/" {
			http.Redirect(w, r, "/index.html", http.StatusFound)
		}
	}).Methods("GET")

	http.Handle("/", router)
	loadTemplates()

	fmt.Printf("Listening on port %s\n", port)
	log.Fatal(http.ListenAndServe(":"+port, nil))
}
Esempio n. 17
0
func init() {
	pflag.IntVar(&l, "logLevel", 0, "log level in which gologger logs to")
	pflag.StringVar(&c, "logCatagory", "", "log catagory which used for logging")
	pflag.BoolVar(&forceToGlog, "forceToGlog", false, "use glog for all logging. cancel other logging.")
	pflag.BoolVar(&alsoLogToGlog, "alsoLogToGlog", false, "also use glog as side logging.")
}
Esempio n. 18
0
func init() {
	flag.IntVar(&last, "last-release-pr", 0, "The PR number of the last versioned release.")
	flag.IntVar(&current, "current-release-pr", 0, "The PR number of the current versioned release.")
	flag.StringVar(&token, "api-token", "", "Github api token for rate limiting. Background: https://developer.github.com/v3/#rate-limiting and create a token: https://github.com/settings/tokens")
}
Esempio n. 19
0
func init() {
	flag.StringVar(&inputFile, "input", defaultInputFile, "Go source code containing types to be documented")
	flag.StringVar(&outputFile, "output", defaultOutputFile, "file to which generated Go code should be written")
	flag.BoolVar(&verify, "verify", defaultVerify, "verify that types being documented are not missing any comments, write no output")
}
Esempio n. 20
0
File: le.go Progetto: jcftang/le_go
func init() {
	flag.StringVar(&endpoint, "endpoint", "data.logentries.com:80", "hostname:port - endpoint to send data")
}