client: Add crio client package
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
4fadbea75d
commit
2e3d5240c2
6 changed files with 202 additions and 28 deletions
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
|
@ -8,6 +9,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/kubernetes-incubator/cri-o/client"
|
||||
"github.com/urfave/cli"
|
||||
"golang.org/x/net/context"
|
||||
remocommandconsts "k8s.io/apimachinery/pkg/util/remotecommand"
|
||||
|
@ -21,6 +23,7 @@ var containerCommand = cli.Command{
|
|||
Aliases: []string{"ctr"},
|
||||
Subcommands: []cli.Command{
|
||||
createContainerCommand,
|
||||
inspectContainerCommand,
|
||||
startContainerCommand,
|
||||
stopContainerCommand,
|
||||
removeContainerCommand,
|
||||
|
@ -617,3 +620,37 @@ func ListContainers(client pb.RuntimeServiceClient, opts listOptions) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var inspectContainerCommand = cli.Command{
|
||||
Name: "inspect",
|
||||
Usage: "get container info from crio daemon",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "id",
|
||||
Value: "",
|
||||
Usage: "id of the container",
|
||||
},
|
||||
},
|
||||
Action: func(context *cli.Context) error {
|
||||
ID := context.String("id")
|
||||
if ID == "" {
|
||||
return fmt.Errorf("ID cannot be empty")
|
||||
}
|
||||
c, err := client.New(context.GlobalString("connect"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cInfo, err := c.ContainerInfo(ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
jsonBytes, err := json.MarshalIndent(cInfo, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(string(jsonBytes))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
31
cmd/crioctl/info.go
Normal file
31
cmd/crioctl/info.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/kubernetes-incubator/cri-o/client"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var infoCommand = cli.Command{
|
||||
Name: "info",
|
||||
Usage: "get crio daemon info",
|
||||
Action: func(context *cli.Context) error {
|
||||
c, err := client.New(context.GlobalString("connect"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
di, err := c.DaemonInfo()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
jsonBytes, err := json.MarshalIndent(di, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(string(jsonBytes))
|
||||
return nil
|
||||
},
|
||||
}
|
|
@ -91,6 +91,7 @@ func main() {
|
|||
containerCommand,
|
||||
runtimeVersionCommand,
|
||||
imageCommand,
|
||||
infoCommand,
|
||||
}
|
||||
|
||||
app.Flags = []cli.Flag{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue