Merge pull request #3480 from jbeda/all_pflag

Convert all main binaries to pflag library
This commit is contained in:
Joe Beda
2015-01-15 11:26:41 -08:00
46 changed files with 335 additions and 272 deletions

View File

@@ -1 +1 @@
log_level: "-v=2"
log_level: "--v=2"

View File

@@ -78,7 +78,7 @@ case "$1" in
do_start
case "$?" in
0|1) log_end_msg 0 || exit 0 ;;
2) verblog_end_msg 1 || exit 1 ;;
2) log_end_msg 1 || exit 1 ;;
esac
;;
stop)

View File

@@ -5,50 +5,50 @@
{% set cloud_provider = "" -%}
{% if grains.cloud_provider is defined -%}
{% set cloud_provider = "-cloud_provider=" + grains.cloud_provider -%}
{% set cloud_provider = "--cloud_provider=" + grains.cloud_provider -%}
{% endif -%}
{% set address = "-address=127.0.0.1" -%}
{% set address = "--address=127.0.0.1" -%}
{% set publicAddressOverride = "" -%}
{% if grains.publicAddressOverride is defined -%}
{% set publicAddressOverride = "-public_address_override=" + grains.publicAddressOverride -%}
{% set publicAddressOverride = "--public_address_override=" + grains.publicAddressOverride -%}
{% endif -%}
{% if grains.etcd_servers is defined -%}
{% set etcd_servers = "-etcd_servers=http://" + grains.etcd_servers + ":4001" -%}
{% set etcd_servers = "--etcd_servers=http://" + grains.etcd_servers + ":4001" -%}
{% else -%}
{% set ips = salt['mine.get']('roles:kubernetes-master', 'network.ip_addrs', 'grain').values() -%}
{% set etcd_servers = "-etcd_servers=http://" + ips[0][0] + ":4001" -%}
{% set etcd_servers = "--etcd_servers=http://" + ips[0][0] + ":4001" -%}
{% endif -%}
{% if grains.cloud is defined -%}
{% if grains.cloud == 'gce' -%}
{% set cloud_provider = "-cloud_provider=gce" -%}
{% set cloud_provider = "--cloud_provider=gce" -%}
{% endif -%}
{% endif -%}
{% if pillar['portal_net'] is defined -%}
{% set portal_net = "-portal_net=" + pillar['portal_net'] -%}
{% set portal_net = "--portal_net=" + pillar['portal_net'] -%}
{% endif -%}
{% set cert_file = "-tls_cert_file=/srv/kubernetes/server.cert" -%}
{% set key_file = "-tls_private_key_file=/srv/kubernetes/server.key" -%}
{% set cert_file = "--tls_cert_file=/srv/kubernetes/server.cert" -%}
{% set key_file = "--tls_private_key_file=/srv/kubernetes/server.key" -%}
{% set secure_port = "-secure_port=6443" -%}
{% set token_auth_file = "-token_auth_file=/dev/null" -%}
{% set secure_port = "--secure_port=6443" -%}
{% set token_auth_file = "--token_auth_file=/dev/null" -%}
{% if grains.cloud is defined -%}
{% if grains.cloud == 'gce' or grains.cloud == 'vagrant' -%}
# TODO: generate and distribute tokens for other cloud providers.
{% set token_auth_file = "-token_auth_file=/srv/kubernetes/known_tokens.csv" -%}
{% set token_auth_file = "--token_auth_file=/srv/kubernetes/known_tokens.csv" -%}
{% endif -%}
{% endif -%}
{% set admission_control = "" -%}
{% if grains.admission_control is defined -%}
{% set admission_control = "-admission_control=" + grains.admission_control -%}
{% set admission_control = "--admission_control=" + grains.admission_control -%}
{% endif -%}
DAEMON_ARGS="{{daemon_args}} {{address}} {{etcd_servers}} {{ cloud_provider }} {{admission_control}} --allow_privileged={{pillar['allow_privileged']}} {{portal_net}} {{cert_file}} {{key_file}} {{secure_port}} {{token_auth_file}} {{publicAddressOverride}} {{pillar['log_level']}}"

View File

@@ -78,7 +78,7 @@ case "$1" in
do_start
case "$?" in
0|1) log_end_msg 0 || exit 0 ;;
2) verblog_end_msg 1 || exit 1 ;;
2) log_end_msg 1 || exit 1 ;;
esac
;;
stop)

View File

@@ -4,33 +4,33 @@
{% set daemon_args = "" -%}
{% endif -%}
{% set master="-master=127.0.0.1:8080" -%}
{% set master="--master=127.0.0.1:8080" -%}
{% set machines = ""-%}
{% set cloud_provider = "" -%}
{% set minion_regexp = "-minion_regexp=.*" -%}
{% set minion_regexp = "--minion_regexp=.*" -%}
{% if grains.cloud_provider is defined -%}
{% set cloud_provider = "-cloud_provider=" + grains.cloud_provider -%}
{% set cloud_provider = "--cloud_provider=" + grains.cloud_provider -%}
{% endif -%}
{% if pillar['node_instance_prefix'] is defined -%}
{% set minion_regexp = "-minion_regexp='" + pillar['node_instance_prefix'] + ".*'" -%}
{% set minion_regexp = "--minion_regexp='" + pillar['node_instance_prefix'] + ".*'" -%}
{% endif -%}
{% if grains.cloud is defined -%}
{% if grains.cloud == 'gce' -%}
{% set cloud_provider = "-cloud_provider=gce" -%}
{% set machines = "-machines=" + ','.join(salt['mine.get']('roles:kubernetes-pool', 'network.ip_addrs', expr_form='grain').keys()) -%}
{% set cloud_provider = "--cloud_provider=gce" -%}
{% set machines = "--machines=" + ','.join(salt['mine.get']('roles:kubernetes-pool', 'network.ip_addrs', expr_form='grain').keys()) -%}
{% endif -%}
{% if grains.cloud == 'aws' -%}
{% set cloud_provider = "-cloud_provider=aws" -%}
{% set cloud_config = "-cloud_config=/etc/aws.conf" -%}
{% set cloud_provider = "--cloud_provider=aws" -%}
{% set cloud_config = "--cloud_config=/etc/aws.conf" -%}
{% set minion_regexp = "" -%}
{% set machines = "-machines " + ','.join(salt['mine.get']('roles:kubernetes-pool', 'network.ip_addrs', expr_form='grain').keys()) -%}
{% set machines = "--machines " + ','.join(salt['mine.get']('roles:kubernetes-pool', 'network.ip_addrs', expr_form='grain').keys()) -%}
{% endif -%}
{% if grains.cloud == 'azure' -%}
MACHINES="{{ salt['mine.get']('roles:kubernetes-pool', 'grains.items', expr_form='grain').values()|join(',', attribute='hostnamef') }}"
{% set machines = "-machines=$MACHINES" -%}
{% set machines = "--machines=$MACHINES" -%}
{% endif -%}
{% if grains.cloud == 'vsphere' -%}
# Collect IPs of minions as machines list.
@@ -42,7 +42,7 @@
{% for addrs in salt['mine.get']('roles:kubernetes-pool', 'network.ip_addrs', expr_form='grain').values() -%}
MACHINE_IPS+=( {{ addrs[0] }} )
{% endfor -%}
{% set machines = "-machines=$(echo ${MACHINE_IPS[@]} | xargs -n1 echo | paste -sd,)" -%}
{% set machines = "--machines=$(echo ${MACHINE_IPS[@]} | xargs -n1 echo | paste -sd,)" -%}
{% set minion_regexp = "" -%}
{% endif -%}
{% endif -%}

View File

@@ -80,7 +80,7 @@ case "$1" in
do_start
case "$?" in
0|1) log_end_msg 0 || exit 0 ;;
2) verblog_end_msg 1 || exit 1 ;;
2) log_end_msg 1 || exit 1 ;;
esac
;;
stop)

View File

@@ -3,10 +3,10 @@
{% set daemon_args = "" -%}
{% endif -%}
{% if grains.api_servers is defined -%}
{% set api_servers = "-master=http://" + grains.api_servers + ":7080" -%}
{% set api_servers = "--master=http://" + grains.api_servers + ":7080" -%}
{% else -%}
{% set ips = salt['mine.get']('roles:kubernetes-master', 'network.ip_addrs', 'grain').values() -%}
{% set api_servers = "-master=http://" + ips[0][0] + ":7080" -%}
{% set api_servers = "--master=http://" + ips[0][0] + ":7080" -%}
{% endif -%}
DAEMON_ARGS="{{daemon_args}} {{api_servers}} {{pillar['log_level']}}"

View File

@@ -80,7 +80,7 @@ case "$1" in
do_start
case "$?" in
0|1) log_end_msg 0 || exit 0 ;;
2) verblog_end_msg 1 || exit 1 ;;
2) log_end_msg 1 || exit 1 ;;
esac
;;
stop)

View File

@@ -2,6 +2,6 @@
{% if grains['os_family'] == 'RedHat' -%}
{% set daemon_args = "" -%}
{% endif -%}
{% set master="-master=127.0.0.1:8080" -%}
{% set master="--master=127.0.0.1:8080" -%}
DAEMON_ARGS="{{daemon_args}} {{master}} {{pillar['log_level']}}"

View File

@@ -80,7 +80,7 @@ case "$1" in
do_start
case "$?" in
0|1) log_end_msg 0 || exit 0 ;;
2) verblog_end_msg 1 || exit 1 ;;
2) log_end_msg 1 || exit 1 ;;
esac
;;
stop)

View File

@@ -3,35 +3,35 @@
{% set daemon_args = "" -%}
{% endif -%}
{% if grains.etcd_servers is defined -%}
{% set etcd_servers = "-etcd_servers=http://" + grains.etcd_servers + ":4001" -%}
{% set etcd_servers = "--etcd_servers=http://" + grains.etcd_servers + ":4001" -%}
{% else -%}
{% set ips = salt['mine.get']('roles:kubernetes-master', 'network.ip_addrs', 'grain').values() -%}
{% set etcd_servers = "-etcd_servers=http://" + ips[0][0] + ":4001" -%}
{% set etcd_servers = "--etcd_servers=http://" + ips[0][0] + ":4001" -%}
{% endif -%}
{% if grains.apiservers is defined -%}
{% set apiservers = "-api_servers=https://" + grains.apiservers + ":6443" -%}
{% set apiservers = "--api_servers=https://" + grains.apiservers + ":6443" -%}
{% else -%}
{% set ips = salt['mine.get']('roles:kubernetes-master', 'network.ip_addrs', 'grain').values() -%}
{% set apiservers = "-api_servers=https://" + ips[0][0] + ":6443" -%}
{% set apiservers = "--api_servers=https://" + ips[0][0] + ":6443" -%}
{% endif -%}
{% set address = "-address=0.0.0.0" -%}
{% set config = "-config=/etc/kubernetes/manifests" -%}
{% set address = "--address=0.0.0.0" -%}
{% set config = "--config=/etc/kubernetes/manifests" -%}
{% set hostname_override = "" -%}
{% if grains.minion_ip is defined -%}
{% set hostname_override = " -hostname_override=" + grains.minion_ip -%}
{% set hostname_override = " --hostname_override=" + grains.minion_ip -%}
{% endif -%}
{% set auth_path = "-auth_path=/var/lib/kubelet/kubernetes_auth" -%}
{% set auth_path = "--auth_path=/var/lib/kubelet/kubernetes_auth" -%}
{% set registry_qps = "-registry_qps=0.1" %}
{% set registry_qps = "--registry_qps=0.1" %}
{% set cluster_dns = "" %}
{% set cluster_domain = "" %}
{% if pillar['enable_cluster_dns'] is defined and pillar['enable_cluster_dns'] %}
{% set cluster_dns = "-cluster_dns=" + pillar['dns_server'] %}
{% set cluster_domain = "-cluster_domain=" + pillar['dns_domain'] %}
{% set cluster_dns = "--cluster_dns=" + pillar['dns_server'] %}
{% set cluster_domain = "--cluster_domain=" + pillar['dns_domain'] %}
{% endif %}
DAEMON_ARGS="{{daemon_args}} {{etcd_servers}} {{apiservers}} {{auth_path}} {{hostname_override}} {{address}} {{config}} --allow_privileged={{pillar['allow_privileged']}} {{pillar['log_level']}} {{cluster_dns}} {{cluster_domain}}"

View File

@@ -79,7 +79,7 @@ case "$1" in
do_start
case "$?" in
0|1) log_end_msg 0 || exit 0 ;;
2) verblog_end_msg 1 || exit 1 ;;
2) log_end_msg 1 || exit 1 ;;
esac
;;
stop)

View File

@@ -17,7 +17,6 @@ limitations under the License.
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
@@ -35,6 +34,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/glog"
flag "github.com/spf13/pflag"
)
var (
@@ -699,7 +700,7 @@ func TestPodHasServiceEnvVars(c *client.Client) bool {
}
func main() {
flag.Parse()
util.InitFlags()
goruntime.GOMAXPROCS(goruntime.NumCPU())
util.ReallyCrash = true
util.InitLogs()

View File

@@ -19,7 +19,6 @@ limitations under the License.
package main
import (
"flag"
"io/ioutil"
"net"
"net/http"
@@ -563,7 +562,7 @@ func runServiceTest(client *client.Client) {
type testFunc func(*client.Client)
func main() {
flag.Parse()
util.InitFlags()
runtime.GOMAXPROCS(runtime.NumCPU())
util.ReallyCrash = true
util.InitLogs()

View File

@@ -20,7 +20,6 @@ package main
import (
"crypto/tls"
"flag"
"net"
"net/http"
"strconv"
@@ -40,6 +39,7 @@ import (
"github.com/coreos/go-etcd/etcd"
"github.com/golang/glog"
flag "github.com/spf13/pflag"
)
var (
@@ -124,7 +124,7 @@ func newEtcd(etcdConfigFile string, etcdServerList util.StringList) (helper tool
}
func main() {
flag.Parse()
util.InitFlags()
util.InitLogs()
defer util.FlushLogs()

View File

@@ -21,7 +21,6 @@ limitations under the License.
package main
import (
"flag"
"net"
"net/http"
"strconv"
@@ -38,7 +37,9 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/service"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version/verflag"
"github.com/golang/glog"
flag "github.com/spf13/pflag"
)
var (
@@ -74,7 +75,7 @@ func verifyMinionFlags() {
}
func main() {
flag.Parse()
util.InitFlags()
util.InitLogs()
defer util.FlushLogs()

View File

@@ -17,7 +17,6 @@ limitations under the License.
package main
import (
"flag"
"net"
"net/http"
"strconv"
@@ -32,8 +31,10 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/iptables"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version/verflag"
"github.com/coreos/go-etcd/etcd"
"github.com/golang/glog"
flag "github.com/spf13/pflag"
)
var (
@@ -52,7 +53,7 @@ func init() {
}
func main() {
flag.Parse()
util.InitFlags()
util.InitLogs()
defer util.FlushLogs()

View File

@@ -37,6 +37,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version/verflag"
"github.com/golang/glog"
"github.com/skratchdot/open-golang/open"
)

View File

@@ -21,7 +21,6 @@ limitations under the License.
package main
import (
"flag"
"math/rand"
"net"
"time"
@@ -33,7 +32,9 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/standalone"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version/verflag"
"github.com/golang/glog"
flag "github.com/spf13/pflag"
)
const defaultRootDir = "/var/lib/kubelet"
@@ -89,7 +90,7 @@ func setupRunOnce() {
}
func main() {
flag.Parse()
util.InitFlags()
util.InitLogs()
defer util.FlushLogs()
rand.Seed(time.Now().UTC().UnixNano())

View File

@@ -21,7 +21,6 @@ limitations under the License.
package main
import (
"flag"
"fmt"
"time"
@@ -33,6 +32,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/glog"
flag "github.com/spf13/pflag"
)
var (
@@ -66,7 +66,7 @@ func newApiClient(addr string, port int) *client.Client {
}
func main() {
flag.Parse()
util.InitFlags()
util.InitLogs()
defer util.FlushLogs()

View File

@@ -24,9 +24,9 @@ First, create your kube-apiserver.service file (change necessary variables)
ExecStartPre=/usr/bin/wget -P /opt/bin https://path/to/kube-apiserver/binary
ExecStartPre=/usr/bin/chmod +x /opt/bin/kube-apiserver
ExecStart=/opt/bin/kube-apiserver \
-address=0.0.0.0 \
-port=8080 \
-etcd_servers=http://10.1.10.10:4001
--address=0.0.0.0 \
--port=8080 \
--etcd_servers=http://10.1.10.10:4001
ExecStartPost=/usr/bin/etcdctl -C 10.1.10.10:4001 set /frontend:172.20.1.20 '[ "kubernetes", "http://${DEFAULT_IPV4}:8080" ]'
Restart=always
RestartSec=10

View File

@@ -253,7 +253,7 @@ Congratulations!
The following will run all of the end-to-end testing scenarios assuming you set your environment in cluster/kube-env.sh
```
hack/e2e-test.sh
NUM_MINIONS=3 hack/e2e-test.sh
```
### Troubleshooting

View File

@@ -14,64 +14,64 @@ The **kubernetes** API server validates and configures data for 3 types of objec
The the kube-apiserver several options.
# OPTIONS
**-address**=""
**--address**=""
The address on the local server to listen to. Default 127.0.0.1
**-allow_privileged**=""
**--allow_privileged**=""
If true, allow privileged containers.
**-alsologtostderr**=
**--alsologtostderr**=
log to standard error as well as files. Default is false.
**-api_prefix**="/api"
**--api_prefix**="/api"
The prefix for API requests on the server. Default '/api'
**-cloud_config**=""
**--cloud_config**=""
The path to the cloud provider configuration file. Empty string for no configuration file.
**-cloud_provider**=""
**--cloud_provider**=""
The provider for cloud services. Empty string for no provider.
**-cors_allowed_origins**=[]
**--cors_allowed_origins**=[]
List of allowed origins for CORS, comma separated. An allowed origin can be a regular expression to support subdomain matching. If this list is empty CORS will not be enabled.
**-etcd_servers**=[]
**--etcd_servers**=[]
List of etcd servers to watch (http://ip:port), comma separated
**-health_check_minions**=
**--health_check_minions**=
If true, health check minions and filter unhealthy ones. Default true.
**-log_backtrace_at=**:0
**--log_backtrace_at=**:0
when logging hits line file:N, emit a stack trace
**-log_dir**=""
**--log_dir**=""
If non-empty, write log files in this directory
**-log_flush_frequency**=5s
**--log_flush_frequency**=5s
Maximum number of seconds between log flushes. Default is 5 seconds.
**-logtostderr**=
**--logtostderr**=
log to standard error instead of files. Default is false.
**-kubelet_port**=10250
**--kubelet_port**=10250
The port at which kubelet will be listening on the minions. Default is 10250.
**-port**=8080
**--port**=8080
The port to listen on. Default is 8080.
**-stderrthreshold**=0
**--stderrthreshold**=0
logs at or above this threshold go to stderr. Default is 0.
**-storage_version**=""
**--storage_version**=""
The version to store resources with. Defaults to server preferred.
**-v**=0
**--v**=0
Log level for V logs.
**-version**=false
**--version**=false
Print version information and quit. Default is false.
**-vmodule**=
**--vmodule**=
comma-separated list of pattern=N settings for file-filtered logging
# EXAMPLES

View File

@@ -14,64 +14,64 @@ The **kubernetes** controller manager is really a service that is layered on top
The kube-controller-manager has several options.
# OPTIONS
**-address**=""
**--address**=""
The address on the local server to listen to. Default 127.0.0.1.
**-allow_privileged**="false"
**--allow_privileged**="false"
If true, allow privileged containers.
**-address=**"127.0.0.1"
**--address=**"127.0.0.1"
The address to serve from.
**-alsologtostderr**=false
**--alsologtostderr**=false
log to standard error as well as files.
**-api_version**=""
**--api_version**=""
The API version to use when talking to the server.
**-cloud_config**=""
**--cloud_config**=""
The path to the cloud provider configuration file. Empty string for no configuration file.
**-cloud_provider**=""
**--cloud_provider**=""
The provider for cloud services. Empty string for no provider.
**-minion_regexp**=""
**--minion_regexp**=""
If non empty, and -cloud_provider is specified, a regular expression for matching minion VMs.
**-insecure_skip_tls_verify**=false
**--insecure_skip_tls_verify**=false
If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
**-log_backtrace_at**=:0
**--log_backtrace_at**=:0
when logging hits line file:N, emit a stack trace.
**-log_dir**=""
**--log_dir**=""
If non-empty, write log files in this directory.
**-log_flush_frequency**=5s
**--log_flush_frequency**=5s
Maximum number of seconds between log flushes.
**-logtostderr**=false
**--logtostderr**=false
log to standard error instead of files.
**-machines**=[]
**--machines**=[]
List of machines to schedule onto, comma separated.
**-master**=""
**--master**=""
The address of the Kubernetes API server.
**-port**=10252
**--port**=10252
The port that the controller-manager's http service runs on.
**-stderrthreshold**=0
**--stderrthreshold**=0
logs at or above this threshold go to stderr.
**-v**=0
**--v**=0
log level for V logs.
**-version**=false
**--version**=false
Print version information and quit.
**-vmodule**=
**--vmodule**=
comma-separated list of pattern=N settings for file-filtered logging.
# EXAMPLES

View File

@@ -14,46 +14,46 @@ The **kubernetes** network proxy runs on each node. This reflects services as de
The kube-proxy takes several options.
# OPTIONS
**-alsologtostderr**=false
**--alsologtostderr**=false
log to standard error as well as files
**-api_version=**""
**--api_version=**""
The API version to use when talking to the server
**-bindaddress**="0.0.0.0"
**--bindaddress**="0.0.0.0"
The address for the proxy server to serve on (set to 0.0.0.0 or "" for all interfaces)
**-etcd_servers**=[]
**--etcd_servers**=[]
List of etcd servers to watch (http://ip:port), comma separated (optional)
**-insecure_skip_tls_verify**=false
**--insecure_skip_tls_verify**=false
If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
**-log_backtrace_at**=:0
**--log_backtrace_at**=:0
when logging hits line file:N, emit a stack trace
**-log_dir**=""
**--log_dir**=""
If non-empty, write log files in this directory
**-log_flush_frequency**=5s
**--log_flush_frequency**=5s
Maximum number of seconds between log flushes
**-logtostderr**=false
**--logtostderr**=false
log to standard error instead of files
**-master**=""
**--master**=""
The address of the Kubernetes API server
**-stderrthreshold**=0
**--stderrthreshold**=0
logs at or above this threshold go to stderr
**-v**=0
**--v**=0
log level for V logs
**-version**=false
**--version**=false
Print version information and quit
**-vmodule**=
**--vmodule**=
comma-separated list of pattern=N settings for file-filtered logging

View File

@@ -14,46 +14,46 @@ The **kubernetes** scheduler is a policy-rich, topology-aware, workload-specific
The kube-scheduler can take several options.
# OPTIONS
**-address=**"127.0.0.1"
**--address=**"127.0.0.1"
The address to serve from.
**-alsologtostderr=**false
**--alsologtostderr=**false
log to standard error as well as files.
**-api_version=**""
**--api_version=**""
The API version to use when talking to the server.
**-insecure_skip_tls_verify**=false
**--insecure_skip_tls_verify**=false
If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
**-log_backtrace_at=**:0
**--log_backtrace_at=**:0
when logging hits line file:N, emit a stack trace.
**-log_dir=**""
**--log_dir=**""
If non-empty, write log files in this directory.
**-log_flush_frequency**=5s
**--log_flush_frequency**=5s
Maximum number of seconds between log flushes.
**-logtostderr**=false
**--logtostderr**=false
log to standard error instead of files.
**-master=**""
**--master=**""
The address of the Kubernetes API server.
**-port=**10251
**--port=**10251
The port that the scheduler's http service runs on.
**-stderrthreshold**=0
**--stderrthreshold**=0
logs at or above this threshold go to stderr.
**-v**=0
**--v**=0
log level for V logs.
**-version**=false
**--version**=false
Print version information and quit.
**-vmodule**=
**--vmodule**=
comma-separated list of pattern=N settings for file-filtered logging.
# EXAMPLES

View File

@@ -20,79 +20,79 @@ There are 4 ways that a container manifest can be provided to the Kubelet:
# OPTIONS
**-address**="127.0.0.1"
**--address**="127.0.0.1"
The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces).
**-allow_privileged**=false
**--allow_privileged**=false
If true, allow containers to request privileged mode. [default=false].
**-alsologtostderr**=false
**--alsologtostderr**=false
log to standard error as well as files.
**-config**=""
**--config**=""
Path to the config file or directory of files.
**-docker_endpoint**=""
**--docker_endpoint**=""
If non-empty, use this for the docker endpoint to communicate with.
**-enable_server**=true
**--enable_server**=true
Enable the info server.
**-etcd_servers**=[]
**--etcd_servers**=[]
List of etcd servers to watch (http://ip:port), comma separated.
**-file_check_frequency**=20s
**--file_check_frequency**=20s
Duration between checking config files for new data.
**-hostname_override**=""
**--hostname_override**=""
If non-empty, will use this string as identification instead of the actual hostname.
**-http_check_frequency**=20s
**--http_check_frequency**=20s
Duration between checking http for new data.
**-log_backtrace_at**=:0
**--log_backtrace_at**=:0
when logging hits line file:N, emit a stack trace.
**-log_dir**=""
**--log_dir**=""
If non-empty, write log files in this directory.
**-log_flush_frequency**=5s
**--log_flush_frequency**=5s
Maximum number of seconds between log flushes.
**-logtostderr**=false
**--logtostderr**=false
log to standard error instead of files.
**-manifest_url**=""
**--manifest_url**=""
URL for accessing the container manifest.
**-network_container_image**="kubernetes/pause:latest"
**--network_container_image**="kubernetes/pause:latest"
The image that network containers in each pod will use.
**-port**=10250
**--port**=10250
The port for the info server to serve on.
**-registry_burst**=10
**--registry_burst**=10
Maximum size of a bursty pulls, temporarily allows pulls to burst to this number, while still not exceeding registry_qps. Only used if --registry_qps > 0.
**-registry_qps**=0
**--registry_qps**=0
If > 0, limit registry pull QPS to this value. If 0, unlimited. [default=0.0].
**-root_dir**="/var/lib/kubelet"
**--root_dir**="/var/lib/kubelet"
Directory path for managing kubelet files (volume mounts,etc).
**-stderrthreshold**=0
**--stderrthreshold**=0
logs at or above this threshold go to stderr.
**-sync_frequency**=10s
**--sync_frequency**=10s
Max period between synchronizing running containers and config.
**-v**=0
**--v**=0
log level for V logs.
**-version**=false
**--version**=false
Print version information and quit.
**-vmodule**=
**--vmodule**=
comma-separated list of pattern=N settings for file-filtered logging.

View File

@@ -17,84 +17,84 @@ The the kube\-apiserver several options.
.SH OPTIONS
.PP
\fB\-address\fP=""
\fB\-\-address\fP=""
The address on the local server to listen to. Default 127.0.0.1
.PP
\fB\-allow\_privileged\fP=""
\fB\-\-allow\_privileged\fP=""
If true, allow privileged containers.
.PP
\fB\-alsologtostderr\fP=
\fB\-\-alsologtostderr\fP=
log to standard error as well as files. Default is false.
.PP
\fB\-api\_prefix\fP="/api"
\fB\-\-api\_prefix\fP="/api"
The prefix for API requests on the server. Default '/api'
.PP
\fB\-cloud\_config\fP=""
\fB\-\-cloud\_config\fP=""
The path to the cloud provider configuration file. Empty string for no configuration file.
.PP
\fB\-cloud\_provider\fP=""
\fB\-\-cloud\_provider\fP=""
The provider for cloud services. Empty string for no provider.
.PP
\fB\-cors\_allowed\_origins\fP=[]
\fB\-\-cors\_allowed\_origins\fP=[]
List of allowed origins for CORS, comma separated. An allowed origin can be a regular expression to support subdomain matching. If this list is empty CORS will not be enabled.
.PP
\fB\-etcd\_servers\fP=[]
\fB\-\-etcd\_servers\fP=[]
List of etcd servers to watch (
\[la]http://ip:port\[ra]), comma separated
.PP
\fB\-health\_check\_minions\fP=
\fB\-\-health\_check\_minions\fP=
If true, health check minions and filter unhealthy ones. Default true.
.PP
\fB\-log\_backtrace\_at=\fP:0
\fB\-\-log\_backtrace\_at=\fP:0
when logging hits line file:N, emit a stack trace
.PP
\fB\-log\_dir\fP=""
\fB\-\-log\_dir\fP=""
If non\-empty, write log files in this directory
.PP
\fB\-log\_flush\_frequency\fP=5s
\fB\-\-log\_flush\_frequency\fP=5s
Maximum number of seconds between log flushes. Default is 5 seconds.
.PP
\fB\-logtostderr\fP=
\fB\-\-logtostderr\fP=
log to standard error instead of files. Default is false.
.PP
\fB\-kubelet\_port\fP=10250
\fB\-\-kubelet\_port\fP=10250
The port at which kubelet will be listening on the minions. Default is 10250.
.PP
\fB\-port\fP=8080
\fB\-\-port\fP=8080
The port to listen on. Default is 8080.
.PP
\fB\-stderrthreshold\fP=0
\fB\-\-stderrthreshold\fP=0
logs at or above this threshold go to stderr. Default is 0.
.PP
\fB\-storage\_version\fP=""
\fB\-\-storage\_version\fP=""
The version to store resources with. Defaults to server preferred.
.PP
\fB\-v\fP=0
\fB\-\-v\fP=0
Log level for V logs.
.PP
\fB\-version\fP=false
\fB\-\-version\fP=false
Print version information and quit. Default is false.
.PP
\fB\-vmodule\fP=
\fB\-\-vmodule\fP=
comma\-separated list of pattern=N settings for file\-filtered logging
.SH EXAMPLES
@@ -102,7 +102,7 @@ The the kube\-apiserver several options.
.RS
.nf
/usr/bin/kube\-apiserver \-\-logtostderr=true \-\-v=0 \-\-etcd\_servers=http://127.0.0.1:4001 \-\-address=0.0.0.0 \-\-port=8080 \-\-machines=127.0.0.1 \-\-kubelet\_port=10250 \-\-allow\_privileged=false
/usr/bin/kube\-apiserver \-\-logtostderr=true \-\-v=0 \-\-etcd\_servers=http://127.0.0.1:4001 \-\-address=0.0.0.0 \-\-port=8080 \-\-kubelet\_port=10250 \-\-allow\_privileged=false
.fi

View File

@@ -17,83 +17,83 @@ The kube\-controller\-manager has several options.
.SH OPTIONS
.PP
\fB\-address\fP=""
\fB\-\-address\fP=""
The address on the local server to listen to. Default 127.0.0.1.
.PP
\fB\-allow\_privileged\fP="false"
\fB\-\-allow\_privileged\fP="false"
If true, allow privileged containers.
.PP
\fB\-address=\fP"127.0.0.1"
\fB\-\-address=\fP"127.0.0.1"
The address to serve from.
.PP
\fB\-alsologtostderr\fP=false
\fB\-\-alsologtostderr\fP=false
log to standard error as well as files.
.PP
\fB\-api\_version\fP=""
\fB\-\-api\_version\fP=""
The API version to use when talking to the server.
.PP
\fB\-cloud\_config\fP=""
\fB\-\-cloud\_config\fP=""
The path to the cloud provider configuration file. Empty string for no configuration file.
.PP
\fB\-cloud\_provider\fP=""
\fB\-\-cloud\_provider\fP=""
The provider for cloud services. Empty string for no provider.
.PP
\fB\-minion\_regexp\fP=""
\fB\-\-minion\_regexp\fP=""
If non empty, and \-cloud\_provider is specified, a regular expression for matching minion VMs.
.PP
\fB\-insecure\_skip\_tls\_verify\fP=false
\fB\-\-insecure\_skip\_tls\_verify\fP=false
If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
.PP
\fB\-log\_backtrace\_at\fP=:0
\fB\-\-log\_backtrace\_at\fP=:0
when logging hits line file:N, emit a stack trace.
.PP
\fB\-log\_dir\fP=""
\fB\-\-log\_dir\fP=""
If non\-empty, write log files in this directory.
.PP
\fB\-log\_flush\_frequency\fP=5s
\fB\-\-log\_flush\_frequency\fP=5s
Maximum number of seconds between log flushes.
.PP
\fB\-logtostderr\fP=false
\fB\-\-logtostderr\fP=false
log to standard error instead of files.
.PP
\fB\-machines\fP=[]
\fB\-\-machines\fP=[]
List of machines to schedule onto, comma separated.
.PP
\fB\-master\fP=""
\fB\-\-master\fP=""
The address of the Kubernetes API server.
.PP
\fB\-port\fP=10252
\fB\-\-port\fP=10252
The port that the controller\-manager's http service runs on.
.PP
\fB\-stderrthreshold\fP=0
\fB\-\-stderrthreshold\fP=0
logs at or above this threshold go to stderr.
.PP
\fB\-v\fP=0
\fB\-\-v\fP=0
log level for V logs.
.PP
\fB\-version\fP=false
\fB\-\-version\fP=false
Print version information and quit.
.PP
\fB\-vmodule\fP=
\fB\-\-vmodule\fP=
comma\-separated list of pattern=N settings for file\-filtered logging.
.SH EXAMPLES

View File

@@ -17,60 +17,60 @@ The kube\-proxy takes several options.
.SH OPTIONS
.PP
\fB\-alsologtostderr\fP=false
\fB\-\-alsologtostderr\fP=false
log to standard error as well as files
.PP
\fB\-api\_version=\fP""
\fB\-\-api\_version=\fP""
The API version to use when talking to the server
.PP
\fB\-bindaddress\fP="0.0.0.0"
\fB\-\-bindaddress\fP="0.0.0.0"
The address for the proxy server to serve on (set to 0.0.0.0 or "" for all interfaces)
.PP
\fB\-etcd\_servers\fP=[]
\fB\-\-etcd\_servers\fP=[]
List of etcd servers to watch (
\[la]http://ip:port\[ra]), comma separated (optional)
.PP
\fB\-insecure\_skip\_tls\_verify\fP=false
\fB\-\-insecure\_skip\_tls\_verify\fP=false
If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
.PP
\fB\-log\_backtrace\_at\fP=:0
\fB\-\-log\_backtrace\_at\fP=:0
when logging hits line file:N, emit a stack trace
.PP
\fB\-log\_dir\fP=""
\fB\-\-log\_dir\fP=""
If non\-empty, write log files in this directory
.PP
\fB\-log\_flush\_frequency\fP=5s
\fB\-\-log\_flush\_frequency\fP=5s
Maximum number of seconds between log flushes
.PP
\fB\-logtostderr\fP=false
\fB\-\-logtostderr\fP=false
log to standard error instead of files
.PP
\fB\-master\fP=""
\fB\-\-master\fP=""
The address of the Kubernetes API server
.PP
\fB\-stderrthreshold\fP=0
\fB\-\-stderrthreshold\fP=0
logs at or above this threshold go to stderr
.PP
\fB\-v\fP=0
\fB\-\-v\fP=0
log level for V logs
.PP
\fB\-version\fP=false
\fB\-\-version\fP=false
Print version information and quit
.PP
\fB\-vmodule\fP=
\fB\-\-vmodule\fP=
comma\-separated list of pattern=N settings for file\-filtered logging
.SH EXAMPLES

View File

@@ -17,59 +17,59 @@ The kube\-scheduler can take several options.
.SH OPTIONS
.PP
\fB\-address=\fP"127.0.0.1"
\fB\-\-address=\fP"127.0.0.1"
The address to serve from.
.PP
\fB\-alsologtostderr=\fPfalse
\fB\-\-alsologtostderr=\fPfalse
log to standard error as well as files.
.PP
\fB\-api\_version=\fP""
\fB\-\-api\_version=\fP""
The API version to use when talking to the server.
.PP
\fB\-insecure\_skip\_tls\_verify\fP=false
\fB\-\-insecure\_skip\_tls\_verify\fP=false
If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
.PP
\fB\-log\_backtrace\_at=\fP:0
\fB\-\-log\_backtrace\_at=\fP:0
when logging hits line file:N, emit a stack trace.
.PP
\fB\-log\_dir=\fP""
\fB\-\-log\_dir=\fP""
If non\-empty, write log files in this directory.
.PP
\fB\-log\_flush\_frequency\fP=5s
\fB\-\-log\_flush\_frequency\fP=5s
Maximum number of seconds between log flushes.
.PP
\fB\-logtostderr\fP=false
\fB\-\-logtostderr\fP=false
log to standard error instead of files.
.PP
\fB\-master=\fP""
\fB\-\-master=\fP""
The address of the Kubernetes API server.
.PP
\fB\-port=\fP10251
\fB\-\-port=\fP10251
The port that the scheduler's http service runs on.
.PP
\fB\-stderrthreshold\fP=0
\fB\-\-stderrthreshold\fP=0
logs at or above this threshold go to stderr.
.PP
\fB\-v\fP=0
\fB\-\-v\fP=0
log level for V logs.
.PP
\fB\-version\fP=false
\fB\-\-version\fP=false
Print version information and quit.
.PP
\fB\-vmodule\fP=
\fB\-\-vmodule\fP=
comma\-separated list of pattern=N settings for file\-filtered logging.
.SH EXAMPLES

View File

@@ -28,104 +28,104 @@ HTTP server The kubelet can also listen for HTTP and respond to a simple API (un
.SH OPTIONS
.PP
\fB\-address\fP="127.0.0.1"
\fB\-\-address\fP="127.0.0.1"
The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces).
.PP
\fB\-allow\_privileged\fP=false
\fB\-\-allow\_privileged\fP=false
If true, allow containers to request privileged mode. [default=false].
.PP
\fB\-alsologtostderr\fP=false
\fB\-\-alsologtostderr\fP=false
log to standard error as well as files.
.PP
\fB\-config\fP=""
\fB\-\-config\fP=""
Path to the config file or directory of files.
.PP
\fB\-docker\_endpoint\fP=""
\fB\-\-docker\_endpoint\fP=""
If non\-empty, use this for the docker endpoint to communicate with.
.PP
\fB\-enable\_server\fP=true
\fB\-\-enable\_server\fP=true
Enable the info server.
.PP
\fB\-etcd\_servers\fP=[]
\fB\-\-etcd\_servers\fP=[]
List of etcd servers to watch (
\[la]http://ip:port\[ra]), comma separated.
.PP
\fB\-file\_check\_frequency\fP=20s
\fB\-\-file\_check\_frequency\fP=20s
Duration between checking config files for new data.
.PP
\fB\-hostname\_override\fP=""
\fB\-\-hostname\_override\fP=""
If non\-empty, will use this string as identification instead of the actual hostname.
.PP
\fB\-http\_check\_frequency\fP=20s
\fB\-\-http\_check\_frequency\fP=20s
Duration between checking http for new data.
.PP
\fB\-log\_backtrace\_at\fP=:0
\fB\-\-log\_backtrace\_at\fP=:0
when logging hits line file:N, emit a stack trace.
.PP
\fB\-log\_dir\fP=""
\fB\-\-log\_dir\fP=""
If non\-empty, write log files in this directory.
.PP
\fB\-log\_flush\_frequency\fP=5s
\fB\-\-log\_flush\_frequency\fP=5s
Maximum number of seconds between log flushes.
.PP
\fB\-logtostderr\fP=false
\fB\-\-logtostderr\fP=false
log to standard error instead of files.
.PP
\fB\-manifest\_url\fP=""
\fB\-\-manifest\_url\fP=""
URL for accessing the container manifest.
.PP
\fB\-network\_container\_image\fP="kubernetes/pause:latest"
\fB\-\-network\_container\_image\fP="kubernetes/pause:latest"
The image that network containers in each pod will use.
.PP
\fB\-port\fP=10250
\fB\-\-port\fP=10250
The port for the info server to serve on.
.PP
\fB\-registry\_burst\fP=10
\fB\-\-registry\_burst\fP=10
Maximum size of a bursty pulls, temporarily allows pulls to burst to this number, while still not exceeding registry\_qps. Only used if \-\-registry\_qps > 0.
.PP
\fB\-registry\_qps\fP=0
\fB\-\-registry\_qps\fP=0
If > 0, limit registry pull QPS to this value. If 0, unlimited. [default=0.0].
.PP
\fB\-root\_dir\fP="/var/lib/kubelet"
\fB\-\-root\_dir\fP="/var/lib/kubelet"
Directory path for managing kubelet files (volume mounts,etc).
.PP
\fB\-stderrthreshold\fP=0
\fB\-\-stderrthreshold\fP=0
logs at or above this threshold go to stderr.
.PP
\fB\-sync\_frequency\fP=10s
\fB\-\-sync\_frequency\fP=10s
Max period between synchronizing running containers and config.
.PP
\fB\-v\fP=0
\fB\-\-v\fP=0
log level for V logs.
.PP
\fB\-version\fP=false
\fB\-\-version\fP=false
Print version information and quit.
.PP
\fB\-vmodule\fP=
\fB\-\-vmodule\fP=
comma\-separated list of pattern=N settings for file\-filtered logging.
.SH EXAMPLES

View File

@@ -82,4 +82,4 @@ else
auth_config=()
fi
"${e2e}" "${auth_config[@]:+${auth_config[@]}}" -host="https://${KUBE_MASTER_IP-}"
"${e2e}" "${auth_config[@]:+${auth_config[@]}}" --host="https://${KUBE_MASTER_IP-}"

View File

@@ -46,7 +46,7 @@ rm -rf ~/.kube*
git clean -fdx
# Build
go run ./hack/e2e.go -v -build
go run ./hack/e2e.go -v --build
# Push to GCS
./build/push-ci-build.sh

View File

@@ -77,8 +77,8 @@ if [[ ! -z ${E2E_SET_CLUSTER_API_VERSION:-} ]]; then
export CLUSTER_API_VERSION=$(echo ${GITHASH} | cut -c 2-)
fi
go run ./hack/e2e.go ${E2E_OPT} -v -down
go run ./hack/e2e.go ${E2E_OPT} -v -up
go run ./hack/e2e.go -v -ctl="version --match-server-version=false"
go run ./hack/e2e.go ${E2E_OPT} --test -tap | tee ../e2e.${JOB_NAME}.${BUILD_NUMBER}.${GITHASH}.tap
go run ./hack/e2e.go ${E2E_OPT} -v -down
go run ./hack/e2e.go ${E2E_OPT} -v --down
go run ./hack/e2e.go ${E2E_OPT} -v --up
go run ./hack/e2e.go -v --ctl="version --match-server-version=false"
go run ./hack/e2e.go ${E2E_OPT} --test --tap | tee ../e2e.${JOB_NAME}.${BUILD_NUMBER}.${GITHASH}.tap
go run ./hack/e2e.go ${E2E_OPT} -v --down

View File

@@ -89,7 +89,7 @@ GO_OUT="${KUBE_ROOT}/_output/local/bin/${host_os}/${host_arch}"
APISERVER_LOG=/tmp/kube-apiserver.log
sudo "${GO_OUT}/kube-apiserver" \
-v=${LOG_LEVEL} \
--v=${LOG_LEVEL} \
--address="${API_HOST}" \
--port="${API_PORT}" \
--runtime_config=api/v1beta3 \
@@ -103,14 +103,14 @@ kube::util::wait_for_url "http://${API_HOST}:${API_PORT}/api/v1beta1/pods" "apis
CTLRMGR_LOG=/tmp/kube-controller-manager.log
sudo "${GO_OUT}/kube-controller-manager" \
-v=${LOG_LEVEL} \
--v=${LOG_LEVEL} \
--machines="127.0.0.1" \
--master="${API_HOST}:${API_PORT}" >"${CTLRMGR_LOG}" 2>&1 &
CTLRMGR_PID=$!
KUBELET_LOG=/tmp/kubelet.log
sudo "${GO_OUT}/kubelet" \
-v=${LOG_LEVEL} \
--v=${LOG_LEVEL} \
--etcd_servers="http://127.0.0.1:4001" \
--hostname_override="127.0.0.1" \
--address="127.0.0.1" \
@@ -121,13 +121,13 @@ KUBELET_PID=$!
PROXY_LOG=/tmp/kube-proxy.log
sudo "${GO_OUT}/kube-proxy" \
-v=${LOG_LEVEL} \
--v=${LOG_LEVEL} \
--master="http://${API_HOST}:${API_PORT}" >"${PROXY_LOG}" 2>&1 &
PROXY_PID=$!
SCHEDULER_LOG=/tmp/kube-scheduler.log
sudo "${GO_OUT}/kube-scheduler" \
-v=${LOG_LEVEL} \
--v=${LOG_LEVEL} \
--master="http://${API_HOST}:${API_PORT}" >"${SCHEDULER_LOG}" 2>&1 &
SCHEDULER_PID=$!

View File

@@ -18,12 +18,12 @@ package resource
import (
"errors"
"flag"
"fmt"
"math/big"
"regexp"
"strings"
flag "github.com/spf13/pflag"
"speter.net/go/exp/math/dec/inf"
)

View File

@@ -19,7 +19,6 @@ package api_test
import (
"encoding/json"
"flag"
"math/rand"
"reflect"
"strconv"
@@ -37,6 +36,7 @@ import (
docker "github.com/fsouza/go-dockerclient"
fuzz "github.com/google/gofuzz"
flag "github.com/spf13/pflag"
"speter.net/go/exp/math/dec/inf"
)

View File

@@ -18,7 +18,6 @@ package conversion
import (
"encoding/json"
"flag"
"fmt"
"reflect"
"strings"
@@ -28,6 +27,7 @@ import (
"github.com/ghodss/yaml"
"github.com/google/gofuzz"
flag "github.com/spf13/pflag"
)
var fuzzIters = flag.Int("fuzz_iters", 50, "How many fuzzing iterations to do.")

View File

@@ -143,6 +143,10 @@ func (f *Factory) BindFlags(flags *pflag.FlagSet) {
// any flags defined by external projects (not part of pflags)
util.AddAllFlagsToPFlagSet(flags)
// This is necessary as github.com/spf13/cobra doesn't support "global"
// pflags currently. See https://github.com/spf13/cobra/issues/44.
util.AddPFlagSetToPFlagSet(pflag.CommandLine, flags)
if f.flags != nil {
f.flags.VisitAll(func(flag *pflag.Flag) {
flags.AddFlag(flag)

27
pkg/util/flags.go Normal file
View File

@@ -0,0 +1,27 @@
/*
Copyright 2014 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package util
import (
flag "github.com/spf13/pflag"
)
// InitFlags normalizes and parses the command line flags
func InitFlags() {
AddAllFlagsToPFlags()
flag.Parse()
}

View File

@@ -22,9 +22,10 @@ import (
"time"
"github.com/golang/glog"
"github.com/spf13/pflag"
)
var logFlushFreq = flag.Duration("log_flush_frequency", 5*time.Second, "Maximum number of seconds between log flushes")
var logFlushFreq = pflag.Duration("log_flush_frequency", 5*time.Second, "Maximum number of seconds between log flushes")
// TODO(thockin): This is temporary until we agree on log dirs and put those into each cmd.
func init() {

View File

@@ -17,8 +17,9 @@ limitations under the License.
package util
import (
"flag"
"testing"
flag "github.com/spf13/pflag"
)
func TestIP(t *testing.T) {

View File

@@ -42,7 +42,13 @@ func wrapFlagValue(v flag.Value) pflag.Value {
pv := &flagValueWrapper{
inner: v,
}
pv.flagType = reflect.TypeOf(v).Elem().Name()
t := reflect.TypeOf(v)
if t.Kind() == reflect.Interface || t.Kind() == reflect.Ptr {
t = t.Elem()
}
pv.flagType = t.Name()
pv.flagType = strings.TrimSuffix(pv.flagType, "Value")
return pv
}
@@ -76,3 +82,17 @@ func AddFlagSetToPFlagSet(fsIn *flag.FlagSet, fsOut *pflag.FlagSet) {
func AddAllFlagsToPFlagSet(fs *pflag.FlagSet) {
AddFlagSetToPFlagSet(flag.CommandLine, fs)
}
// Add al of the top level 'flag' package flags to the top level 'pflag' flags.
func AddAllFlagsToPFlags() {
AddFlagSetToPFlagSet(flag.CommandLine, pflag.CommandLine)
}
// Merge all of the flags from fsFrom into fsTo.
func AddPFlagSetToPFlagSet(fsFrom *pflag.FlagSet, fsTo *pflag.FlagSet) {
fsFrom.VisitAll(func(f *pflag.Flag) {
if fsTo.Lookup(f.Name) == nil {
fsTo.AddFlag(f)
}
})
}

View File

@@ -19,12 +19,12 @@ limitations under the License.
package verflag
import (
"flag"
"fmt"
"os"
"strconv"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
flag "github.com/spf13/pflag"
)
type versionValue int
@@ -66,6 +66,11 @@ func (v *versionValue) String() string {
return fmt.Sprintf("%v", bool(*v == VersionTrue))
}
// The type of the flag as requred by the pflag.Value interface
func (v *versionValue) Type() string {
return "version"
}
func VersionVar(p *versionValue, name string, value versionValue, usage string) {
*p = value
flag.Var(p, name, usage)

View File

@@ -17,7 +17,6 @@ limitations under the License.
package main
import (
"flag"
"net"
"net/http"
"strconv"
@@ -33,6 +32,8 @@ import (
_ "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler/algorithmprovider"
"github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler/factory"
"github.com/golang/glog"
flag "github.com/spf13/pflag"
)
var (
@@ -47,7 +48,7 @@ func init() {
}
func main() {
flag.Parse()
util.InitFlags()
util.InitLogs()
defer util.FlushLogs()