diff --git a/go.mod b/go.mod index 8194275c..d7f07944 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible k8s.io/code-generator v0.18.8 k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29 - knative.dev/pkg v0.0.0-20201018212257-b39d5da935b0 + knative.dev/pkg v0.0.0-20201019233058-fc447086b7b0 knative.dev/test-infra v0.0.0-20201015231956-d236fb0ea9ff ) diff --git a/go.sum b/go.sum index 67af69b2..d5367dd1 100644 --- a/go.sum +++ b/go.sum @@ -1921,8 +1921,8 @@ knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2/go.mod h1:Q6sL35DdGs8hIQZKdaC knative.dev/pkg v0.0.0-20200515002500-16d7b963416f/go.mod h1:tMOHGbxtRz8zYFGEGpV/bpoTEM1o89MwYFC4YJXl3GY= knative.dev/pkg v0.0.0-20200528142800-1c6815d7e4c9/go.mod h1:QgNZTxnwpB/oSpNcfnLVlw+WpEwwyKAvJlvR3hgeltA= knative.dev/pkg v0.0.0-20200711004937-22502028e31a/go.mod h1:AqAJV6rYi8IGikDjJ/9ZQd9qKdkXVlesVnVjwx62YB8= -knative.dev/pkg v0.0.0-20201018212257-b39d5da935b0 h1:wJCy+yItW/7ml/i6voJdhuW/3r/4kyOhQAc1Kinlnpo= -knative.dev/pkg v0.0.0-20201018212257-b39d5da935b0/go.mod h1:wW3vq+5MMACzyzWpk8THk2Q8n2HSKGndsFp1FX8XiaU= +knative.dev/pkg v0.0.0-20201019233058-fc447086b7b0 h1:lgXE/cUCgdUm5G8/eX/Bt6wvm6/XIkmyIaZU+vp1Ofw= +knative.dev/pkg v0.0.0-20201019233058-fc447086b7b0/go.mod h1:Gd7eJYKYPveffVad0/wImHpQSYn+Pt9q09HGJyL/b54= knative.dev/test-infra v0.0.0-20200407185800-1b88cb3b45a5/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ= knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55/go.mod h1:WqF1Azka+FxPZ20keR2zCNtiQA1MP9ZB4BH4HuI+SIU= knative.dev/test-infra v0.0.0-20200513011557-d03429a76034/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE= diff --git a/vendor/knative.dev/pkg/injection/config.go b/vendor/knative.dev/pkg/injection/config.go index bae2b2e2..d8228fe5 100644 --- a/vendor/knative.dev/pkg/injection/config.go +++ b/vendor/knative.dev/pkg/injection/config.go @@ -24,41 +24,68 @@ import ( "os" "os/user" "path/filepath" + "sync" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" "k8s.io/klog" ) +// Environment holds the config for flag based config. +type Environment struct { + // ServerURL - The address of the Kubernetes API server. Overrides any value in kubeconfig. + ServerURL string + // Kubeconfig - Path to a kubeconfig. + Kubeconfig string // Note: named Kubeconfig because of legacy reasons vs KubeConfig. + // Burst - Maximum burst for throttle. + Burst int + // QPS - Maximum QPS to the server from the client. + QPS float64 +} + +var ( + env *Environment + once sync.Once +) + +func Flags() *Environment { + once.Do(func() { + env = new(Environment) + + flag.StringVar(&env.ServerURL, "server", "", + "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.") + + flag.StringVar(&env.Kubeconfig, "kubeconfig", "", + "Path to a kubeconfig. Only required if out-of-cluster.") + + flag.IntVar(&env.Burst, "kube-api-burst", 0, "Maximum burst for throttle.") + + flag.Float64Var(&env.QPS, "kube-api-qps", 0, "Maximum QPS to the server from the client.") + }) + return env +} + // ParseAndGetRESTConfigOrDie parses the rest config flags and creates a client or // dies by calling log.Fatalf. func ParseAndGetRESTConfigOrDie() *rest.Config { - var ( - serverURL = flag.String("server", "", - "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.") - kubeconfig = flag.String("kubeconfig", "", - "Path to a kubeconfig. Only required if out-of-cluster.") + env := Flags() - burst = flag.Int("kube-api-burst", 0, "Maximum burst for throttle.") - qps = flag.Float64("kube-api-qps", 0, "Maximum QPS to the server from the client.") - ) klog.InitFlags(flag.CommandLine) flag.Parse() + if env.Burst < 0 { + log.Fatal("Invalid burst value", env.Burst) + } + if env.QPS < 0 || env.QPS > math.MaxFloat32 { + log.Fatal("Invalid QPS value", env.QPS) + } - cfg, err := GetRESTConfig(*serverURL, *kubeconfig) + cfg, err := GetRESTConfig(env.ServerURL, env.Kubeconfig) if err != nil { log.Fatal("Error building kubeconfig: ", err) } - if *burst < 0 { - log.Fatal("Invalid burst value", *burst) - } - if *qps < 0 || *qps > math.MaxFloat32 { - log.Fatal("Invalid QPS value", *qps) - } - - cfg.Burst = *burst - cfg.QPS = float32(*qps) + cfg.Burst = env.Burst + cfg.QPS = float32(env.QPS) return cfg } diff --git a/vendor/modules.txt b/vendor/modules.txt index cbef9ebd..b1f30996 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -734,7 +734,7 @@ k8s.io/kube-openapi/pkg/util/sets k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/trace -# knative.dev/pkg v0.0.0-20201018212257-b39d5da935b0 +# knative.dev/pkg v0.0.0-20201019233058-fc447086b7b0 ## explicit knative.dev/pkg/apis knative.dev/pkg/apis/duck