feat(*): add k8s version to version debug cmd

When 'helm version --debug' is run, this will print the kubernetes server
version as well as the helm client and server versions.

Closes #1398
pull/2754/head
Sam Leavens 7 years ago
parent 3eeab04e0b
commit fa40e60f7d

@ -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,6 +90,13 @@ func newVersionCmd(c helm.Interface, out io.Writer) *cobra.Command {
}
func (v *versionCmd) run() error {
if settings.Debug {
k8sVersion, err := getK8sVersion()
if err != nil {
return err
}
fmt.Fprintf(v.out, "Kubernetes: %#v\n", k8sVersion)
}
if v.showClient {
cv := version.GetVersionProto()
@ -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])

Loading…
Cancel
Save