 fa9e9bdf46
			
		
	
	fa9e9bdf46
	
	
	
		
			
			This makes sure the client is always in sync with the server before performing any type of operations on the container metadata. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
		
			
				
	
	
		
			40 lines
		
	
	
		
			698 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			698 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package main
 | |
| 
 | |
| import (
 | |
| 	"github.com/pkg/errors"
 | |
| 	"github.com/urfave/cli"
 | |
| )
 | |
| 
 | |
| var containerInfoCommand = cli.Command{
 | |
| 	Name:      "info",
 | |
| 	Usage:     "get info about a container",
 | |
| 	ArgsUsage: "CONTAINER",
 | |
| 	Action: func(context *cli.Context) error {
 | |
| 		var (
 | |
| 			ctx, cancel = appContext(context)
 | |
| 			id          = context.Args().First()
 | |
| 		)
 | |
| 		defer cancel()
 | |
| 		if id == "" {
 | |
| 			return errors.New("container id must be provided")
 | |
| 		}
 | |
| 		client, err := newClient(context)
 | |
| 		if err != nil {
 | |
| 			return err
 | |
| 		}
 | |
| 
 | |
| 		container, err := client.LoadContainer(ctx, id)
 | |
| 		if err != nil {
 | |
| 			return err
 | |
| 		}
 | |
| 
 | |
| 		info, err := container.Info(ctx)
 | |
| 		if err != nil {
 | |
| 			return err
 | |
| 		}
 | |
| 		printAsJSON(info)
 | |
| 
 | |
| 		return nil
 | |
| 	},
 | |
| }
 |