From 32876892fcb286a1a84e950bfa9c6ea11dc61c84 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Fri, 15 Jul 2016 14:28:52 -0700 Subject: [PATCH] Refactor runtimeversion to be a command instead of option Signed-off-by: Mrunal Patel --- cmd/client/main.go | 29 +++++++++++++++++------------ server/server.go | 10 ---------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/cmd/client/main.go b/cmd/client/main.go index 925bcff3..8e058885 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -28,14 +28,20 @@ func main() { app := cli.NewApp() app.Name = "ocic" app.Usage = "client for ocid" - app.Flags = []cli.Flag{ - cli.StringFlag{ - Name: "runtimeversion", - Value: "715fec664d75c6b5cb5b12718458621d4b75df37", - Usage: "the version of the gPRC client API", - }, + + app.Commands = []cli.Command{ + runtimeVersionCommand, } - app.Action = func(cxt *cli.Context) error { + + if err := app.Run(os.Args); err != nil { + log.Fatal(err) + } +} + +var runtimeVersionCommand = cli.Command{ + Name: "runtimeversion", + Usage: "get runtime version information", + Action: func(context *cli.Context) error { // Set up a connection to the server. conn, err := grpc.Dial(address, grpc.WithInsecure()) if err != nil { @@ -45,13 +51,12 @@ func main() { client := pb.NewRuntimeServiceClient(conn) // Test RuntimeServiceClient.Version - err = Version(client, cxt.String("runtimeversion")) + version := "v1alpha1" + err = Version(client, version) if err != nil { - log.Fatalf("%s.Version failed: %v", app.Name, err) + log.Fatalf("Getting the runtime version failed: %v", err) } return nil - } - - app.Run(os.Args) + }, } diff --git a/server/server.go b/server/server.go index 2645ccad..ac651b92 100644 --- a/server/server.go +++ b/server/server.go @@ -1,9 +1,6 @@ package server import ( - "errors" - "strings" - pb "github.com/kubernetes/kubernetes/pkg/kubelet/api/v1alpha1/runtime" "golang.org/x/net/context" ) @@ -20,13 +17,6 @@ func (s *Server) Version(ctx context.Context, req *pb.VersionRequest) (*pb.Versi return nil, nil } - // FIXME: the logic here may need to be changed. How to determine whether the client/server APIs are compatible? - if strings.Compare(version, *req.Version) != 0 { - return &pb.VersionResponse{ - Version: &version, - }, errors.New("The version of the gRPC server API is different from the version of the gRPC client API.") - } - runtimeName := "runc" runtimeVersion, err := execRuncVersion("runc", "-v")