Refactor runtimeversion to be a command instead of option
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
588103f670
commit
32876892fc
2 changed files with 17 additions and 22 deletions
|
@ -28,14 +28,20 @@ func main() {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "ocic"
|
app.Name = "ocic"
|
||||||
app.Usage = "client for ocid"
|
app.Usage = "client for ocid"
|
||||||
app.Flags = []cli.Flag{
|
|
||||||
cli.StringFlag{
|
app.Commands = []cli.Command{
|
||||||
Name: "runtimeversion",
|
runtimeVersionCommand,
|
||||||
Value: "715fec664d75c6b5cb5b12718458621d4b75df37",
|
|
||||||
Usage: "the version of the gPRC client API",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
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.
|
// Set up a connection to the server.
|
||||||
conn, err := grpc.Dial(address, grpc.WithInsecure())
|
conn, err := grpc.Dial(address, grpc.WithInsecure())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -45,13 +51,12 @@ func main() {
|
||||||
client := pb.NewRuntimeServiceClient(conn)
|
client := pb.NewRuntimeServiceClient(conn)
|
||||||
|
|
||||||
// Test RuntimeServiceClient.Version
|
// Test RuntimeServiceClient.Version
|
||||||
err = Version(client, cxt.String("runtimeversion"))
|
version := "v1alpha1"
|
||||||
|
err = Version(client, version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("%s.Version failed: %v", app.Name, err)
|
log.Fatalf("Getting the runtime version failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
},
|
||||||
|
|
||||||
app.Run(os.Args)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
pb "github.com/kubernetes/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "github.com/kubernetes/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
@ -20,13 +17,6 @@ func (s *Server) Version(ctx context.Context, req *pb.VersionRequest) (*pb.Versi
|
||||||
return nil, nil
|
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"
|
runtimeName := "runc"
|
||||||
|
|
||||||
runtimeVersion, err := execRuncVersion("runc", "-v")
|
runtimeVersion, err := execRuncVersion("runc", "-v")
|
||||||
|
|
Loading…
Reference in a new issue