cmd/client: add listimages command
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
e39cf0dd21
commit
b22c85068c
1 changed files with 32 additions and 0 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
pb "github.com/kubernetes/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||
"github.com/urfave/cli"
|
||||
"golang.org/x/net/context"
|
||||
|
@ -234,6 +235,7 @@ func main() {
|
|||
containerCommand,
|
||||
runtimeVersionCommand,
|
||||
pullImageCommand,
|
||||
listImagesCommand,
|
||||
}
|
||||
|
||||
app.Flags = []cli.Flag{
|
||||
|
@ -250,6 +252,36 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
var listImagesCommand = cli.Command{
|
||||
Name: "listimages",
|
||||
Usage: "list images",
|
||||
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.NewImageServiceClient(conn)
|
||||
if err := ListImages(client); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func ListImages(client pb.ImageServiceClient) error {
|
||||
resp, err := client.ListImages(context.Background(), &pb.ListImagesRequest{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("listing images failed: %v", err)
|
||||
}
|
||||
for _, i := range resp.Images {
|
||||
logrus.Println(i.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func PullImage(client pb.ImageServiceClient, image string) error {
|
||||
_, err := client.PullImage(context.Background(), &pb.PullImageRequest{Image: &pb.ImageSpec{Image: &image}})
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue