From aea93ac6abf1be843b1db223d3e2f236a7637ab7 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Tue, 16 Aug 2016 10:27:36 -0700 Subject: [PATCH] Add client code for remove pod sandbox Signed-off-by: Mrunal Patel --- cmd/client/main.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/cmd/client/main.go b/cmd/client/main.go index 3c952ae3..e27d0694 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -100,6 +100,20 @@ func StopPodSandbox(client pb.RuntimeServiceClient, ID string) error { return nil } +// RemovePodSandbox sends a RemovePodSandboxRequest to the server, and parses +// the returned RemovePodSandboxResponse. +func RemovePodSandbox(client pb.RuntimeServiceClient, ID string) error { + if ID == "" { + return fmt.Errorf("ID cannot be empty") + } + r, err := client.RemovePodSandbox(context.Background(), &pb.RemovePodSandboxRequest{PodSandboxId: &ID}) + if err != nil { + return err + } + fmt.Println(r) + return nil +} + // CreateContainer sends a CreateContainerRequest to the server, and parses // the returned CreateContainerResponse. func CreateContainer(client pb.RuntimeServiceClient, sandbox string, path string) error { @@ -138,6 +152,7 @@ func main() { runtimeVersionCommand, createPodSandboxCommand, stopPodSandboxCommand, + removePodSandboxCommand, createContainerCommand, pullImageCommand, } @@ -253,6 +268,33 @@ var stopPodSandboxCommand = cli.Command{ }, } +var removePodSandboxCommand = cli.Command{ + Name: "removepodsandbox", + Usage: "remove a pod sandbox", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "id", + Value: "", + Usage: "id of the pod sandbox", + }, + }, + Action: func(context *cli.Context) error { + // Set up a connection to the server. + conn, err := getClientConnection() + if err != nil { + return fmt.Errorf("failed to connect: %v", err) + } + defer conn.Close() + client := pb.NewRuntimeServiceClient(conn) + + err = RemovePodSandbox(client, context.String("id")) + if err != nil { + return fmt.Errorf("removing the pod sandbox failed: %v", err) + } + return nil + }, +} + var createContainerCommand = cli.Command{ Name: "createcontainer", Usage: "create a container",