Unverified Commit 5decaa24 authored by Matthew Fisher's avatar Matthew Fisher Committed by GitHub

Merge pull request #2754 from rbwsam/feat/get_kube_ver

feat(*): add k8s version to version debug cmd
parents 55ab4b86 558dcf3c
......@@ -25,6 +25,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
apiVersion "k8s.io/apimachinery/pkg/version"
"k8s.io/helm/pkg/helm"
pb "k8s.io/helm/pkg/proto/hapi/version"
"k8s.io/helm/pkg/version"
......@@ -89,7 +90,6 @@ func newVersionCmd(c helm.Interface, out io.Writer) *cobra.Command {
}
func (v *versionCmd) run() error {
if v.showClient {
cv := version.GetVersionProto()
fmt.Fprintf(v.out, "Client: %s\n", formatVersion(cv, v.short))
......@@ -99,6 +99,14 @@ func (v *versionCmd) run() error {
return nil
}
if settings.Debug {
k8sVersion, err := getK8sVersion()
if err != nil {
return err
}
fmt.Fprintf(v.out, "Kubernetes: %#v\n", k8sVersion)
}
resp, err := v.client.GetVersion()
if err != nil {
if grpc.Code(err) == codes.Unimplemented {
......@@ -111,6 +119,16 @@ func (v *versionCmd) run() error {
return nil
}
func getK8sVersion() (*apiVersion.Info, error) {
var v *apiVersion.Info
_, client, err := getKubeClient(settings.KubeContext)
if err != nil {
return v, err
}
v, err = client.Discovery().ServerVersion()
return v, err
}
func formatVersion(v *pb.Version, short bool) string {
if short {
return fmt.Sprintf("%s+g%s", v.SemVer, v.GitCommit[:7])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment