713bbabc61
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
pb "github.com/kubernetes/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
|
"github.com/urfave/cli"
|
|
"golang.org/x/net/context"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
const (
|
|
address = "localhost:49999"
|
|
)
|
|
|
|
// Version sends a VersionRequest to the server, and parses the returned VersionResponse.
|
|
func Version(client pb.RuntimeServiceClient, version string) error {
|
|
r, err := client.Version(context.Background(), &pb.VersionRequest{Version: &version})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log.Printf("VersionResponse: Version: %s, RuntimeName: %s, RuntimeVersion: %s, RuntimeApiVersion: %s\n", *r.Version, *r.RuntimeName, *r.RuntimeVersion, *r.RuntimeApiVersion)
|
|
return nil
|
|
}
|
|
|
|
func main() {
|
|
app := cli.NewApp()
|
|
app.Name = "ocic"
|
|
app.Usage = "client for ocid"
|
|
|
|
app.Commands = []cli.Command{
|
|
runtimeVersionCommand,
|
|
}
|
|
|
|
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 {
|
|
return fmt.Errorf("Failed to connect: %v", err)
|
|
}
|
|
defer conn.Close()
|
|
client := pb.NewRuntimeServiceClient(conn)
|
|
|
|
// Test RuntimeServiceClient.Version
|
|
version := "v1alpha1"
|
|
err = Version(client, version)
|
|
if err != nil {
|
|
return fmt.Errorf("Getting the runtime version failed: %v", err)
|
|
}
|
|
return nil
|
|
},
|
|
}
|