Switch to github.com/golang/dep for vendoring
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
d6ab91be27
commit
8e5b17cf13
15431 changed files with 3971413 additions and 8881 deletions
84
vendor/k8s.io/kubernetes/cmd/hyperkube/BUILD
generated
vendored
Normal file
84
vendor/k8s.io/kubernetes/cmd/hyperkube/BUILD
generated
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "hyperkube",
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["hyperkube_test.go"],
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor:github.com/spf13/cobra",
|
||||
"//vendor:github.com/stretchr/testify/assert",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"federation-apiserver.go",
|
||||
"federation-controller-manager.go",
|
||||
"hyperkube.go",
|
||||
"kube-apiserver.go",
|
||||
"kube-controller-manager.go",
|
||||
"kube-proxy.go",
|
||||
"kube-scheduler.go",
|
||||
"kubectl.go",
|
||||
"kubelet.go",
|
||||
"main.go",
|
||||
"server.go",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//cmd/kube-apiserver/app:go_default_library",
|
||||
"//cmd/kube-apiserver/app/options:go_default_library",
|
||||
"//cmd/kube-controller-manager/app:go_default_library",
|
||||
"//cmd/kube-controller-manager/app/options:go_default_library",
|
||||
"//cmd/kube-proxy/app:go_default_library",
|
||||
"//cmd/kube-proxy/app/options:go_default_library",
|
||||
"//cmd/kubelet/app:go_default_library",
|
||||
"//cmd/kubelet/app/options:go_default_library",
|
||||
"//federation/cmd/federation-apiserver/app:go_default_library",
|
||||
"//federation/cmd/federation-apiserver/app/options:go_default_library",
|
||||
"//federation/cmd/federation-controller-manager/app:go_default_library",
|
||||
"//federation/cmd/federation-controller-manager/app/options:go_default_library",
|
||||
"//pkg/client/metrics/prometheus:go_default_library",
|
||||
"//pkg/kubectl/cmd:go_default_library",
|
||||
"//pkg/kubectl/cmd/util:go_default_library",
|
||||
"//pkg/util:go_default_library",
|
||||
"//pkg/util/flag:go_default_library",
|
||||
"//pkg/util/logs:go_default_library",
|
||||
"//pkg/version/prometheus:go_default_library",
|
||||
"//pkg/version/verflag:go_default_library",
|
||||
"//plugin/cmd/kube-scheduler/app:go_default_library",
|
||||
"//plugin/cmd/kube-scheduler/app/options:go_default_library",
|
||||
"//vendor:github.com/spf13/pflag",
|
||||
"//vendor:k8s.io/apiserver/pkg/healthz",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
38
vendor/k8s.io/kubernetes/cmd/hyperkube/federation-apiserver.go
generated
vendored
Normal file
38
vendor/k8s.io/kubernetes/cmd/hyperkube/federation-apiserver.go
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
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 main
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/federation/cmd/federation-apiserver/app"
|
||||
"k8s.io/kubernetes/federation/cmd/federation-apiserver/app/options"
|
||||
)
|
||||
|
||||
// NewFederationAPIServer creates a new hyperkube Server object that includes the
|
||||
// description and flags.
|
||||
func NewFederationAPIServer() *Server {
|
||||
s := options.NewServerRunOptions()
|
||||
|
||||
hks := Server{
|
||||
SimpleUsage: "federation-apiserver",
|
||||
Long: "The API entrypoint for the federation control plane",
|
||||
Run: func(_ *Server, args []string) error {
|
||||
return app.Run(s)
|
||||
},
|
||||
}
|
||||
s.AddFlags(hks.Flags())
|
||||
return &hks
|
||||
}
|
38
vendor/k8s.io/kubernetes/cmd/hyperkube/federation-controller-manager.go
generated
vendored
Normal file
38
vendor/k8s.io/kubernetes/cmd/hyperkube/federation-controller-manager.go
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
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 main
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/federation/cmd/federation-controller-manager/app"
|
||||
"k8s.io/kubernetes/federation/cmd/federation-controller-manager/app/options"
|
||||
)
|
||||
|
||||
// NewFederationCMServer creates a new hyperkube Server object that includes the
|
||||
// description and flags.
|
||||
func NewFederationCMServer() *Server {
|
||||
s := options.NewCMServer()
|
||||
|
||||
hks := Server{
|
||||
SimpleUsage: "federation-controller-manager",
|
||||
Long: "Controller manager for federation control plane. Manages federation service endpoints and controllers",
|
||||
Run: func(_ *Server, args []string) error {
|
||||
return app.Run(s)
|
||||
},
|
||||
}
|
||||
s.AddFlags(hks.Flags())
|
||||
return &hks
|
||||
}
|
236
vendor/k8s.io/kubernetes/cmd/hyperkube/hyperkube.go
generated
vendored
Normal file
236
vendor/k8s.io/kubernetes/cmd/hyperkube/hyperkube.go
generated
vendored
Normal file
|
@ -0,0 +1,236 @@
|
|||
/*
|
||||
Copyright 2014 The Kubernetes Authors.
|
||||
|
||||
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 main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
utilflag "k8s.io/kubernetes/pkg/util/flag"
|
||||
"k8s.io/kubernetes/pkg/util/logs"
|
||||
"k8s.io/kubernetes/pkg/version/verflag"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
// HyperKube represents a single binary that can morph/manage into multiple
|
||||
// servers.
|
||||
type HyperKube struct {
|
||||
Name string // The executable name, used for help and soft-link invocation
|
||||
Long string // A long description of the binary. It will be world wrapped before output.
|
||||
|
||||
servers []Server
|
||||
baseFlags *pflag.FlagSet
|
||||
out io.Writer
|
||||
helpFlagVal bool
|
||||
makeSymlinksFlagVal bool
|
||||
}
|
||||
|
||||
// AddServer adds a server to the HyperKube object.
|
||||
func (hk *HyperKube) AddServer(s *Server) {
|
||||
hk.servers = append(hk.servers, *s)
|
||||
hk.servers[len(hk.servers)-1].hk = hk
|
||||
}
|
||||
|
||||
// FindServer will find a specific server named name.
|
||||
func (hk *HyperKube) FindServer(name string) (*Server, error) {
|
||||
for _, s := range hk.servers {
|
||||
if s.Name() == name {
|
||||
return &s, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("Server not found: %s", name)
|
||||
}
|
||||
|
||||
// Servers returns a list of all of the registered servers
|
||||
func (hk *HyperKube) Servers() []Server {
|
||||
return hk.servers
|
||||
}
|
||||
|
||||
// Flags returns a flagset for "global" flags.
|
||||
func (hk *HyperKube) Flags() *pflag.FlagSet {
|
||||
if hk.baseFlags == nil {
|
||||
hk.baseFlags = pflag.NewFlagSet(hk.Name, pflag.ContinueOnError)
|
||||
hk.baseFlags.SetOutput(ioutil.Discard)
|
||||
hk.baseFlags.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
|
||||
hk.baseFlags.BoolVarP(&hk.helpFlagVal, "help", "h", false, "help for "+hk.Name)
|
||||
hk.baseFlags.BoolVar(&hk.makeSymlinksFlagVal, "make-symlinks", false, "create a symlink for each server in current directory")
|
||||
hk.baseFlags.MarkHidden("make-symlinks") // hide this flag from appearing in servers' usage output
|
||||
|
||||
// These will add all of the "global" flags (defined with both the
|
||||
// flag and pflag packages) to the new flag set we have.
|
||||
hk.baseFlags.AddGoFlagSet(flag.CommandLine)
|
||||
hk.baseFlags.AddFlagSet(pflag.CommandLine)
|
||||
|
||||
}
|
||||
return hk.baseFlags
|
||||
}
|
||||
|
||||
// Out returns the io.Writer that is used for all usage/error information
|
||||
func (hk *HyperKube) Out() io.Writer {
|
||||
if hk.out == nil {
|
||||
hk.out = os.Stderr
|
||||
}
|
||||
return hk.out
|
||||
}
|
||||
|
||||
// SetOut sets the output writer for all usage/error information
|
||||
func (hk *HyperKube) SetOut(w io.Writer) {
|
||||
hk.out = w
|
||||
}
|
||||
|
||||
// Print is a convenience method to Print to the defined output
|
||||
func (hk *HyperKube) Print(i ...interface{}) {
|
||||
fmt.Fprint(hk.Out(), i...)
|
||||
}
|
||||
|
||||
// Println is a convenience method to Println to the defined output
|
||||
func (hk *HyperKube) Println(i ...interface{}) {
|
||||
fmt.Fprintln(hk.Out(), i...)
|
||||
}
|
||||
|
||||
// Printf is a convenience method to Printf to the defined output
|
||||
func (hk *HyperKube) Printf(format string, i ...interface{}) {
|
||||
fmt.Fprintf(hk.Out(), format, i...)
|
||||
}
|
||||
|
||||
// Run the server. This will pick the appropriate server and run it.
|
||||
func (hk *HyperKube) Run(args []string) error {
|
||||
// If we are called directly, parse all flags up to the first real
|
||||
// argument. That should be the server to run.
|
||||
command := args[0]
|
||||
baseCommand := path.Base(command)
|
||||
serverName := baseCommand
|
||||
args = args[1:]
|
||||
if serverName == hk.Name {
|
||||
|
||||
baseFlags := hk.Flags()
|
||||
baseFlags.SetInterspersed(false) // Only parse flags up to the next real command
|
||||
err := baseFlags.Parse(args)
|
||||
if err != nil || hk.helpFlagVal {
|
||||
if err != nil {
|
||||
hk.Println("Error:", err)
|
||||
}
|
||||
hk.Usage()
|
||||
return err
|
||||
}
|
||||
|
||||
if hk.makeSymlinksFlagVal {
|
||||
return hk.MakeSymlinks(command)
|
||||
}
|
||||
|
||||
verflag.PrintAndExitIfRequested()
|
||||
|
||||
args = baseFlags.Args()
|
||||
if len(args) > 0 && len(args[0]) > 0 {
|
||||
serverName = args[0]
|
||||
baseCommand = baseCommand + " " + serverName
|
||||
args = args[1:]
|
||||
} else {
|
||||
err = errors.New("no server specified")
|
||||
hk.Printf("Error: %v\n\n", err)
|
||||
hk.Usage()
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
s, err := hk.FindServer(serverName)
|
||||
if err != nil {
|
||||
hk.Printf("Error: %v\n\n", err)
|
||||
hk.Usage()
|
||||
return err
|
||||
}
|
||||
|
||||
s.Flags().AddFlagSet(hk.Flags())
|
||||
err = s.Flags().Parse(args)
|
||||
if err != nil || hk.helpFlagVal {
|
||||
if err != nil {
|
||||
hk.Printf("Error: %v\n\n", err)
|
||||
}
|
||||
s.Usage()
|
||||
return err
|
||||
}
|
||||
|
||||
verflag.PrintAndExitIfRequested()
|
||||
|
||||
logs.InitLogs()
|
||||
defer logs.FlushLogs()
|
||||
|
||||
err = s.Run(s, s.Flags().Args())
|
||||
if err != nil {
|
||||
hk.Println("Error:", err)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// RunToExit will run the hyperkube and then call os.Exit with an appropriate exit code.
|
||||
func (hk *HyperKube) RunToExit(args []string) {
|
||||
err := hk.Run(args)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Usage will write out a summary for all servers that this binary supports.
|
||||
func (hk *HyperKube) Usage() {
|
||||
tt := `{{if .Long}}{{.Long | trim | wrap ""}}
|
||||
{{end}}Usage
|
||||
|
||||
{{.Name}} <server> [flags]
|
||||
|
||||
Servers
|
||||
{{range .Servers}}
|
||||
{{.Name}}
|
||||
{{.Long | trim | wrap " "}}{{end}}
|
||||
Call '{{.Name}} --make-symlinks' to create symlinks for each server in the local directory.
|
||||
Call '{{.Name}} <server> --help' for help on a specific server.
|
||||
`
|
||||
util.ExecuteTemplate(hk.Out(), tt, hk)
|
||||
}
|
||||
|
||||
// MakeSymlinks will create a symlink for each registered hyperkube server in the local directory.
|
||||
func (hk *HyperKube) MakeSymlinks(command string) error {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var errs bool
|
||||
for _, s := range hk.servers {
|
||||
link := path.Join(wd, s.Name())
|
||||
|
||||
err := os.Symlink(command, link)
|
||||
if err != nil {
|
||||
errs = true
|
||||
hk.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
if errs {
|
||||
return errors.New("Error creating one or more symlinks.")
|
||||
}
|
||||
return nil
|
||||
}
|
223
vendor/k8s.io/kubernetes/cmd/hyperkube/hyperkube_test.go
generated
vendored
Normal file
223
vendor/k8s.io/kubernetes/cmd/hyperkube/hyperkube_test.go
generated
vendored
Normal file
|
@ -0,0 +1,223 @@
|
|||
/*
|
||||
Copyright 2014 The Kubernetes Authors.
|
||||
|
||||
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 main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
type result struct {
|
||||
err error
|
||||
output string
|
||||
}
|
||||
|
||||
func testServer(n string) *Server {
|
||||
return &Server{
|
||||
SimpleUsage: n,
|
||||
Long: fmt.Sprintf("A simple server named %s", n),
|
||||
Run: func(s *Server, args []string) error {
|
||||
s.hk.Printf("%s Run\n", s.Name())
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
func testServerError(n string) *Server {
|
||||
return &Server{
|
||||
SimpleUsage: n,
|
||||
Long: fmt.Sprintf("A simple server named %s that returns an error", n),
|
||||
Run: func(s *Server, args []string) error {
|
||||
s.hk.Printf("%s Run\n", s.Name())
|
||||
return errors.New("server returning error")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const defaultCobraMessage = "default message from cobra command"
|
||||
const defaultCobraSubMessage = "default sub-message from cobra command"
|
||||
const cobraMessageDesc = "message to print"
|
||||
const cobraSubMessageDesc = "sub-message to print"
|
||||
|
||||
func testCobraCommand(n string) *Server {
|
||||
|
||||
var cobraServer *Server
|
||||
var msg string
|
||||
cmd := &cobra.Command{
|
||||
Use: n,
|
||||
Long: n,
|
||||
Short: n,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cobraServer.hk.Printf("msg: %s\n", msg)
|
||||
},
|
||||
}
|
||||
cmd.PersistentFlags().StringVar(&msg, "msg", defaultCobraMessage, cobraMessageDesc)
|
||||
|
||||
var subMsg string
|
||||
subCmdName := "subcommand"
|
||||
subCmd := &cobra.Command{
|
||||
Use: subCmdName,
|
||||
Long: subCmdName,
|
||||
Short: subCmdName,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cobraServer.hk.Printf("submsg: %s", subMsg)
|
||||
},
|
||||
}
|
||||
subCmd.PersistentFlags().StringVar(&subMsg, "submsg", defaultCobraSubMessage, cobraSubMessageDesc)
|
||||
|
||||
cmd.AddCommand(subCmd)
|
||||
|
||||
localFlags := cmd.LocalFlags()
|
||||
localFlags.SetInterspersed(false)
|
||||
s := &Server{
|
||||
SimpleUsage: n,
|
||||
Long: fmt.Sprintf("A server named %s which uses a cobra command", n),
|
||||
Run: func(s *Server, args []string) error {
|
||||
cobraServer = s
|
||||
cmd.SetOutput(s.hk.Out())
|
||||
cmd.SetArgs(args)
|
||||
return cmd.Execute()
|
||||
},
|
||||
flags: localFlags,
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
func runFull(t *testing.T, args string) *result {
|
||||
buf := new(bytes.Buffer)
|
||||
hk := HyperKube{
|
||||
Name: "hyperkube",
|
||||
Long: "hyperkube is an all-in-one server binary.",
|
||||
}
|
||||
hk.SetOut(buf)
|
||||
|
||||
hk.AddServer(testServer("test1"))
|
||||
hk.AddServer(testServer("test2"))
|
||||
hk.AddServer(testServer("test3"))
|
||||
hk.AddServer(testServerError("test-error"))
|
||||
hk.AddServer(testCobraCommand("test-cobra-command"))
|
||||
|
||||
a := strings.Split(args, " ")
|
||||
t.Logf("Running full with args: %q", a)
|
||||
err := hk.Run(a)
|
||||
|
||||
r := &result{err, buf.String()}
|
||||
t.Logf("Result err: %v, output: %q", r.err, r.output)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func TestRun(t *testing.T) {
|
||||
x := runFull(t, "hyperkube test1")
|
||||
assert.Contains(t, x.output, "test1 Run")
|
||||
assert.NoError(t, x.err)
|
||||
}
|
||||
|
||||
func TestLinkRun(t *testing.T) {
|
||||
x := runFull(t, "test1")
|
||||
assert.Contains(t, x.output, "test1 Run")
|
||||
assert.NoError(t, x.err)
|
||||
}
|
||||
|
||||
func TestTopNoArgs(t *testing.T) {
|
||||
x := runFull(t, "hyperkube")
|
||||
assert.EqualError(t, x.err, "no server specified")
|
||||
}
|
||||
|
||||
func TestBadServer(t *testing.T) {
|
||||
x := runFull(t, "hyperkube bad-server")
|
||||
assert.EqualError(t, x.err, "Server not found: bad-server")
|
||||
assert.Contains(t, x.output, "Usage")
|
||||
}
|
||||
|
||||
func TestTopHelp(t *testing.T) {
|
||||
x := runFull(t, "hyperkube --help")
|
||||
assert.NoError(t, x.err)
|
||||
assert.Contains(t, x.output, "all-in-one")
|
||||
assert.Contains(t, x.output, "A simple server named test1")
|
||||
}
|
||||
|
||||
func TestTopFlags(t *testing.T) {
|
||||
x := runFull(t, "hyperkube --help test1")
|
||||
assert.NoError(t, x.err)
|
||||
assert.Contains(t, x.output, "all-in-one")
|
||||
assert.Contains(t, x.output, "A simple server named test1")
|
||||
assert.NotContains(t, x.output, "test1 Run")
|
||||
}
|
||||
|
||||
func TestTopFlagsBad(t *testing.T) {
|
||||
x := runFull(t, "hyperkube --bad-flag")
|
||||
assert.EqualError(t, x.err, "unknown flag: --bad-flag")
|
||||
assert.Contains(t, x.output, "all-in-one")
|
||||
assert.Contains(t, x.output, "A simple server named test1")
|
||||
}
|
||||
|
||||
func TestServerHelp(t *testing.T) {
|
||||
x := runFull(t, "hyperkube test1 --help")
|
||||
assert.NoError(t, x.err)
|
||||
assert.Contains(t, x.output, "A simple server named test1")
|
||||
assert.Contains(t, x.output, "-h, --help help for hyperkube")
|
||||
assert.NotContains(t, x.output, "test1 Run")
|
||||
}
|
||||
|
||||
func TestServerFlagsBad(t *testing.T) {
|
||||
x := runFull(t, "hyperkube test1 --bad-flag")
|
||||
assert.EqualError(t, x.err, "unknown flag: --bad-flag")
|
||||
assert.Contains(t, x.output, "A simple server named test1")
|
||||
assert.Contains(t, x.output, "-h, --help help for hyperkube")
|
||||
assert.NotContains(t, x.output, "test1 Run")
|
||||
}
|
||||
|
||||
func TestServerError(t *testing.T) {
|
||||
x := runFull(t, "hyperkube test-error")
|
||||
assert.Contains(t, x.output, "test-error Run")
|
||||
assert.EqualError(t, x.err, "server returning error")
|
||||
}
|
||||
|
||||
func TestCobraCommandHelp(t *testing.T) {
|
||||
x := runFull(t, "hyperkube test-cobra-command --help")
|
||||
assert.NoError(t, x.err)
|
||||
assert.Contains(t, x.output, "A server named test-cobra-command which uses a cobra command")
|
||||
assert.Contains(t, x.output, cobraMessageDesc)
|
||||
}
|
||||
func TestCobraCommandDefaultMessage(t *testing.T) {
|
||||
x := runFull(t, "hyperkube test-cobra-command")
|
||||
assert.Contains(t, x.output, fmt.Sprintf("msg: %s", defaultCobraMessage))
|
||||
}
|
||||
func TestCobraCommandMessage(t *testing.T) {
|
||||
x := runFull(t, "hyperkube test-cobra-command --msg foobar")
|
||||
assert.Contains(t, x.output, "msg: foobar")
|
||||
}
|
||||
|
||||
func TestCobraSubCommandHelp(t *testing.T) {
|
||||
x := runFull(t, "hyperkube test-cobra-command subcommand --help")
|
||||
assert.NoError(t, x.err)
|
||||
assert.Contains(t, x.output, cobraSubMessageDesc)
|
||||
}
|
||||
func TestCobraSubCommandDefaultMessage(t *testing.T) {
|
||||
x := runFull(t, "hyperkube test-cobra-command subcommand")
|
||||
assert.Contains(t, x.output, fmt.Sprintf("submsg: %s", defaultCobraSubMessage))
|
||||
}
|
||||
func TestCobraSubCommandMessage(t *testing.T) {
|
||||
x := runFull(t, "hyperkube test-cobra-command subcommand --submsg foobar")
|
||||
assert.Contains(t, x.output, "submsg: foobar")
|
||||
}
|
38
vendor/k8s.io/kubernetes/cmd/hyperkube/kube-apiserver.go
generated
vendored
Normal file
38
vendor/k8s.io/kubernetes/cmd/hyperkube/kube-apiserver.go
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 main
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/cmd/kube-apiserver/app"
|
||||
"k8s.io/kubernetes/cmd/kube-apiserver/app/options"
|
||||
)
|
||||
|
||||
// NewKubeAPIServer creates a new hyperkube Server object that includes the
|
||||
// description and flags.
|
||||
func NewKubeAPIServer() *Server {
|
||||
s := options.NewServerRunOptions()
|
||||
|
||||
hks := Server{
|
||||
SimpleUsage: "apiserver",
|
||||
Long: "The main API entrypoint and interface to the storage system. The API server is also the focal point for all authorization decisions.",
|
||||
Run: func(_ *Server, args []string) error {
|
||||
return app.Run(s)
|
||||
},
|
||||
}
|
||||
s.AddFlags(hks.Flags())
|
||||
return &hks
|
||||
}
|
38
vendor/k8s.io/kubernetes/cmd/hyperkube/kube-controller-manager.go
generated
vendored
Normal file
38
vendor/k8s.io/kubernetes/cmd/hyperkube/kube-controller-manager.go
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 main
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/cmd/kube-controller-manager/app"
|
||||
"k8s.io/kubernetes/cmd/kube-controller-manager/app/options"
|
||||
)
|
||||
|
||||
// NewKubeControllerManager creates a new hyperkube Server object that includes the
|
||||
// description and flags.
|
||||
func NewKubeControllerManager() *Server {
|
||||
s := options.NewCMServer()
|
||||
|
||||
hks := Server{
|
||||
SimpleUsage: "controller-manager",
|
||||
Long: "A server that runs a set of active components. This includes replication controllers, service endpoints and nodes.",
|
||||
Run: func(_ *Server, args []string) error {
|
||||
return app.Run(s)
|
||||
},
|
||||
}
|
||||
s.AddFlags(hks.Flags(), app.KnownControllers(), app.ControllersDisabledByDefault.List())
|
||||
return &hks
|
||||
}
|
54
vendor/k8s.io/kubernetes/cmd/hyperkube/kube-proxy.go
generated
vendored
Normal file
54
vendor/k8s.io/kubernetes/cmd/hyperkube/kube-proxy.go
generated
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 main
|
||||
|
||||
import (
|
||||
"k8s.io/apiserver/pkg/healthz"
|
||||
"k8s.io/kubernetes/cmd/kube-proxy/app"
|
||||
"k8s.io/kubernetes/cmd/kube-proxy/app/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
healthz.DefaultHealthz()
|
||||
}
|
||||
|
||||
// NewKubeProxy creates a new hyperkube Server object that includes the
|
||||
// description and flags.
|
||||
func NewKubeProxy() *Server {
|
||||
config := options.NewProxyConfig()
|
||||
|
||||
hks := Server{
|
||||
SimpleUsage: "proxy",
|
||||
Long: `The Kubernetes proxy server is responsible for taking traffic directed at
|
||||
services and forwarding it to the appropriate pods. It generally runs on
|
||||
nodes next to the Kubelet and proxies traffic from local pods to remote pods.
|
||||
It is also used when handling incoming external traffic.`,
|
||||
}
|
||||
|
||||
config.AddFlags(hks.Flags())
|
||||
|
||||
hks.Run = func(_ *Server, _ []string) error {
|
||||
s, err := app.NewProxyServerDefault(config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.Run()
|
||||
}
|
||||
|
||||
return &hks
|
||||
}
|
38
vendor/k8s.io/kubernetes/cmd/hyperkube/kube-scheduler.go
generated
vendored
Normal file
38
vendor/k8s.io/kubernetes/cmd/hyperkube/kube-scheduler.go
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 main
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/plugin/cmd/kube-scheduler/app"
|
||||
"k8s.io/kubernetes/plugin/cmd/kube-scheduler/app/options"
|
||||
)
|
||||
|
||||
// NewScheduler creates a new hyperkube Server object that includes the
|
||||
// description and flags.
|
||||
func NewScheduler() *Server {
|
||||
s := options.NewSchedulerServer()
|
||||
|
||||
hks := Server{
|
||||
SimpleUsage: "scheduler",
|
||||
Long: "Implements a Kubernetes scheduler. This will assign pods to kubelets based on capacity and constraints.",
|
||||
Run: func(_ *Server, _ []string) error {
|
||||
return app.Run(s)
|
||||
},
|
||||
}
|
||||
s.AddFlags(hks.Flags())
|
||||
return &hks
|
||||
}
|
42
vendor/k8s.io/kubernetes/cmd/hyperkube/kubectl.go
generated
vendored
Normal file
42
vendor/k8s.io/kubernetes/cmd/hyperkube/kubectl.go
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
)
|
||||
|
||||
// Create a Server that implements the kubectl command
|
||||
func NewKubectlServer() *Server {
|
||||
cmd := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, os.Stdout, os.Stderr)
|
||||
localFlags := cmd.LocalFlags()
|
||||
localFlags.SetInterspersed(false)
|
||||
|
||||
return &Server{
|
||||
name: "kubectl",
|
||||
SimpleUsage: "Kubernetes command line client",
|
||||
Long: "Kubernetes command line client",
|
||||
Run: func(s *Server, args []string) error {
|
||||
cmd.SetArgs(args)
|
||||
return cmd.Execute()
|
||||
},
|
||||
flags: localFlags,
|
||||
}
|
||||
}
|
42
vendor/k8s.io/kubernetes/cmd/hyperkube/kubelet.go
generated
vendored
Normal file
42
vendor/k8s.io/kubernetes/cmd/hyperkube/kubelet.go
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 main
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/cmd/kubelet/app"
|
||||
"k8s.io/kubernetes/cmd/kubelet/app/options"
|
||||
)
|
||||
|
||||
// NewKubelet creates a new hyperkube Server object that includes the
|
||||
// description and flags.
|
||||
func NewKubelet() *Server {
|
||||
s := options.NewKubeletServer()
|
||||
hks := Server{
|
||||
SimpleUsage: "kubelet",
|
||||
Long: `The kubelet binary is responsible for maintaining a set of containers on a
|
||||
particular node. It syncs data from a variety of sources including a
|
||||
Kubernetes API server, an etcd cluster, HTTP endpoint or local file. It then
|
||||
queries Docker to see what is currently running. It synchronizes the
|
||||
configuration data, with the running set of containers by starting or stopping
|
||||
Docker containers.`,
|
||||
Run: func(_ *Server, _ []string) error {
|
||||
return app.Run(s, nil)
|
||||
},
|
||||
}
|
||||
s.AddFlags(hks.Flags())
|
||||
return &hks
|
||||
}
|
47
vendor/k8s.io/kubernetes/cmd/hyperkube/main.go
generated
vendored
Normal file
47
vendor/k8s.io/kubernetes/cmd/hyperkube/main.go
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
Copyright 2014 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// A binary that can morph into all of the other kubernetes binaries. You can
|
||||
// also soft-link to it busybox style.
|
||||
//
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
_ "k8s.io/kubernetes/pkg/client/metrics/prometheus" // for client metric registration
|
||||
_ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration
|
||||
)
|
||||
|
||||
func main() {
|
||||
hk := HyperKube{
|
||||
Name: "hyperkube",
|
||||
Long: "This is an all-in-one binary that can run any of the various Kubernetes servers.",
|
||||
}
|
||||
|
||||
hk.AddServer(NewKubectlServer())
|
||||
hk.AddServer(NewKubeAPIServer())
|
||||
hk.AddServer(NewKubeControllerManager())
|
||||
hk.AddServer(NewScheduler())
|
||||
hk.AddServer(NewKubelet())
|
||||
hk.AddServer(NewKubeProxy())
|
||||
|
||||
//Federation servers
|
||||
hk.AddServer(NewFederationAPIServer())
|
||||
hk.AddServer(NewFederationCMServer())
|
||||
|
||||
hk.RunToExit(os.Args)
|
||||
}
|
75
vendor/k8s.io/kubernetes/cmd/hyperkube/server.go
generated
vendored
Normal file
75
vendor/k8s.io/kubernetes/cmd/hyperkube/server.go
generated
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
Copyright 2014 The Kubernetes Authors.
|
||||
|
||||
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 main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/flag"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
type serverRunFunc func(s *Server, args []string) error
|
||||
|
||||
// Server describes a server that this binary can morph into.
|
||||
type Server struct {
|
||||
SimpleUsage string // One line description of the server.
|
||||
Long string // Longer free form description of the server
|
||||
Run serverRunFunc // Run the server. This is not expected to return.
|
||||
|
||||
flags *pflag.FlagSet // Flags for the command (and all dependents)
|
||||
name string
|
||||
hk *HyperKube
|
||||
}
|
||||
|
||||
// Usage returns the full usage string including all of the flags.
|
||||
func (s *Server) Usage() error {
|
||||
tt := `{{if .Long}}{{.Long | trim | wrap ""}}
|
||||
{{end}}Usage:
|
||||
{{.SimpleUsage}} [flags]
|
||||
|
||||
Available Flags:
|
||||
{{.Flags.FlagUsages}}`
|
||||
|
||||
return util.ExecuteTemplate(s.hk.Out(), tt, s)
|
||||
}
|
||||
|
||||
// Name returns the name of the command as derived from the usage line.
|
||||
func (s *Server) Name() string {
|
||||
if s.name != "" {
|
||||
return s.name
|
||||
}
|
||||
name := s.SimpleUsage
|
||||
i := strings.Index(name, " ")
|
||||
if i >= 0 {
|
||||
name = name[:i]
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
// Flags returns a flagset for this server
|
||||
func (s *Server) Flags() *pflag.FlagSet {
|
||||
if s.flags == nil {
|
||||
s.flags = pflag.NewFlagSet(s.Name(), pflag.ContinueOnError)
|
||||
s.flags.SetOutput(ioutil.Discard)
|
||||
s.flags.SetNormalizeFunc(flag.WordSepNormalizeFunc)
|
||||
}
|
||||
return s.flags
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue