mirror of https://github.com/k3s-io/k3s
Handle -version flag on all commands
Tested: Passed -version argument to kubelet (and all other binaries): $ output/go/bin/kubecfg -version Kubernetes version 0.1, build 6454a541fd56 Signed-off-by: Filipe Brandenburger <filbranden@google.com>pull/6/head
parent
76e2cd70f7
commit
7e56609139
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/master"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
|
@ -54,6 +55,8 @@ func main() {
|
|||
util.InitLogs()
|
||||
defer util.FlushLogs()
|
||||
|
||||
version.PrintAndExitIfRequested()
|
||||
|
||||
if len(machineList) == 0 {
|
||||
glog.Fatal("No machines specified!")
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/controller"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||
"github.com/coreos/go-etcd/etcd"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
@ -46,6 +47,8 @@ func main() {
|
|||
util.InitLogs()
|
||||
defer util.FlushLogs()
|
||||
|
||||
version.PrintAndExitIfRequested()
|
||||
|
||||
if len(etcdServerList) == 0 || len(*master) == 0 {
|
||||
glog.Fatal("usage: controller-manager -etcd_servers <servers> -master <master>")
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
versionFlag = flag.Bool("V", false, "Print the version number.")
|
||||
serverVersion = flag.Bool("server_version", false, "Print the server's version number.")
|
||||
preventSkew = flag.Bool("expect_version_match", false, "Fail if server's version doesn't match own version.")
|
||||
httpServer = flag.String("h", "", "The host to connect to.")
|
||||
|
@ -107,10 +106,7 @@ func main() {
|
|||
util.InitLogs()
|
||||
defer util.FlushLogs()
|
||||
|
||||
if *versionFlag {
|
||||
fmt.Printf("Version: %#v\n", version.Get())
|
||||
os.Exit(0)
|
||||
}
|
||||
version.PrintAndExitIfRequested()
|
||||
|
||||
secure := true
|
||||
var masterServer string
|
||||
|
|
|
@ -35,6 +35,7 @@ import (
|
|||
kconfig "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/config"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||
"github.com/coreos/go-etcd/etcd"
|
||||
"github.com/fsouza/go-dockerclient"
|
||||
"github.com/golang/glog"
|
||||
|
@ -95,6 +96,8 @@ func main() {
|
|||
defer util.FlushLogs()
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
|
||||
version.PrintAndExitIfRequested()
|
||||
|
||||
etcd.SetLogger(util.NewLogger("etcd "))
|
||||
|
||||
dockerClient, err := docker.NewClient(getDockerEndpoint())
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/GoogleCloudPlatform/kubernetes/pkg/proxy"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/proxy/config"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||
"github.com/coreos/go-etcd/etcd"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
@ -40,6 +41,8 @@ func main() {
|
|||
util.InitLogs()
|
||||
defer util.FlushLogs()
|
||||
|
||||
version.PrintAndExitIfRequested()
|
||||
|
||||
// Set up logger for etcd client
|
||||
etcd.SetLogger(util.NewLogger("etcd "))
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ wait_for_url "http://localhost:4001/version" "etcd: "
|
|||
|
||||
|
||||
# Check kubecfg
|
||||
out=$(${GO_OUT}/kubecfg -V)
|
||||
out=$(${GO_OUT}/kubecfg -version)
|
||||
echo kubecfg: $out
|
||||
|
||||
# Start kubelet
|
||||
|
|
|
@ -16,6 +16,16 @@ limitations under the License.
|
|||
|
||||
package version
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
var (
|
||||
versionFlag = flag.Bool("version", false, "Print version information and quit")
|
||||
)
|
||||
|
||||
// Info contains versioning information.
|
||||
// TODO: Add []string of api versions supported? It's still unclear
|
||||
// how we'll want to distribute that information.
|
||||
|
@ -34,3 +44,17 @@ func Get() Info {
|
|||
GitCommit: commitFromGit,
|
||||
}
|
||||
}
|
||||
|
||||
// String returns info as a human-friendly version string.
|
||||
func (info Info) String() string {
|
||||
return fmt.Sprintf("version %s.%s, build %s", info.Major, info.Minor, info.GitCommit)
|
||||
}
|
||||
|
||||
// PrintAndExitIfRequested will check if the -version flag was passed
|
||||
// and, if so, print the version and exit.
|
||||
func PrintAndExitIfRequested() {
|
||||
if *versionFlag {
|
||||
fmt.Printf("Kubernetes %s\n", Get())
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue