本文整理汇总了Golang中github.com/spf13/pflag.StringVar函数的典型用法代码示例。如果您正苦于以下问题:Golang StringVar函数的具体用法?Golang StringVar怎么用?Golang StringVar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StringVar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AddFlags
// 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()
}
示例2: init
func init() {
flag.IntVar(&last, "last-release-pr", 0, "The PR number of the last versioned release.")
flag.IntVar(¤t, "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.")
}
示例3: initFlags
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.")
}
示例4: initializeFlags
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()
}
示例5: init
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")
}
示例6: InitTest
// 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)
}
示例7: InitTest
// 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)
}
示例8: init
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
}
示例9: initFlags
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()
}
示例10: init
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")
}
示例11: init
// 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)
}
示例12: initFlags
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.")
}
示例13: initFlags
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.")
}
示例14: InitTest
// 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)
}
示例15: init
func init() {
flag.IntVar(&target, "last-release-pr", 0, "The PR number of the last versioned release.")
flag.IntVar(¤t, "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.")
}