format Unix
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
package kubectl
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type toolClientVersion struct {
|
||||
GitVersion string `json:"gitVersion"`
|
||||
}
|
||||
|
||||
type toolVersion struct {
|
||||
ClientVersion toolClientVersion `json:"clientVersion"`
|
||||
}
|
||||
|
||||
func Version(path string) (string, error) {
|
||||
|
||||
cmd := exec.Command(path, "version", "-o", "json", "--client=true")
|
||||
stdout, err := cmd.CombinedOutput()
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var objmap toolVersion
|
||||
|
||||
json.Unmarshal(stdout, &objmap)
|
||||
res := objmap.ClientVersion.GitVersion
|
||||
|
||||
return res, nil
|
||||
}
|
||||
package kubectl
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type toolClientVersion struct {
|
||||
GitVersion string `json:"gitVersion"`
|
||||
}
|
||||
|
||||
type toolVersion struct {
|
||||
ClientVersion toolClientVersion `json:"clientVersion"`
|
||||
}
|
||||
|
||||
func Version(path string) (string, error) {
|
||||
|
||||
cmd := exec.Command(path, "version", "-o", "json", "--client=true")
|
||||
stdout, err := cmd.CombinedOutput()
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var objmap toolVersion
|
||||
|
||||
json.Unmarshal(stdout, &objmap)
|
||||
res := objmap.ClientVersion.GitVersion
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user