implement raw pullimage functionality

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2016-07-20 10:42:55 +02:00 committed by Mrunal Patel
parent cd6e223962
commit 05f679f643
2 changed files with 103 additions and 1 deletions

View file

@ -32,6 +32,7 @@ func main() {
app.Commands = []cli.Command{
runtimeVersionCommand,
pullImageCommand,
}
if err := app.Run(os.Args); err != nil {
@ -39,6 +40,35 @@ func main() {
}
}
func PullImage(client pb.ImageServiceClient, image string) error {
_, err := client.PullImage(context.Background(), &pb.PullImageRequest{Image: &pb.ImageSpec{Image: &image}})
if err != nil {
return err
}
return nil
}
// try this with ./ocic pullimage docker://busybox
var pullImageCommand = cli.Command{
Name: "pullimage",
Usage: "pull an image",
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.NewImageServiceClient(conn)
err = PullImage(client, context.Args().Get(0))
if err != nil {
return fmt.Errorf("pulling image failed: %v", err)
}
return nil
},
}
var runtimeVersionCommand = cli.Command{
Name: "runtimeversion",
Usage: "get runtime version information",