version: Fix parsing for gRPC version
Signed-off-by: Jacek J. Łakis <jacek.lakis@intel.com>
This commit is contained in:
parent
8d275cebb9
commit
85f7ebfb48
2 changed files with 1 additions and 28 deletions
|
@ -1,15 +1,10 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/kubernetes-incubator/cri-o/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -30,24 +25,6 @@ func sPtr(s string) *string {
|
||||||
return &s
|
return &s
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGPRCVersion() (string, error) {
|
|
||||||
_, file, _, ok := runtime.Caller(0)
|
|
||||||
if !ok {
|
|
||||||
return "", errors.New("failed to recover the caller information")
|
|
||||||
}
|
|
||||||
|
|
||||||
ocidRoot := filepath.Dir(filepath.Dir(file))
|
|
||||||
p := filepath.Join(ocidRoot, "Godeps/Godeps.json")
|
|
||||||
|
|
||||||
grepCmd := fmt.Sprintf(`grep -r "\"google.golang.org/grpc\"" %s -A 1 | grep "\"Rev\"" | cut -d: -f2 | tr -d ' "\n'`, p)
|
|
||||||
|
|
||||||
out, err := utils.ExecCmd("bash", "-c", grepCmd)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func copyFile(src, dest string) error {
|
func copyFile(src, dest string) error {
|
||||||
in, err := os.Open(src)
|
in, err := os.Open(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -7,10 +7,6 @@ import (
|
||||||
|
|
||||||
// Version returns the runtime name, runtime version and runtime API version
|
// Version returns the runtime name, runtime version and runtime API version
|
||||||
func (s *Server) Version(ctx context.Context, req *pb.VersionRequest) (*pb.VersionResponse, error) {
|
func (s *Server) Version(ctx context.Context, req *pb.VersionRequest) (*pb.VersionResponse, error) {
|
||||||
version, err := getGPRCVersion()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
runtimeVersion, err := s.runtime.Version()
|
runtimeVersion, err := s.runtime.Version()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -18,7 +14,7 @@ func (s *Server) Version(ctx context.Context, req *pb.VersionRequest) (*pb.Versi
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Track upstream code. For now it expects 0.1.0
|
// TODO: Track upstream code. For now it expects 0.1.0
|
||||||
version = "0.1.0"
|
version := "0.1.0"
|
||||||
|
|
||||||
// taking const address
|
// taking const address
|
||||||
rav := runtimeAPIVersion
|
rav := runtimeAPIVersion
|
||||||
|
|
Loading…
Reference in a new issue