mirror of
https://github.com/helm/helm.git
synced 2026-03-29 05:43:57 -04:00
Merge pull request #2754 from rbwsam/feat/get_kube_ver
feat(*): add k8s version to version debug cmd
This commit is contained in:
commit
5decaa244e
1 changed files with 19 additions and 1 deletions
|
|
@ -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])
|
||||
|
|
|
|||
Loading…
Reference in a new issue