github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/cmd/juju/cachedimages/cachedimages.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package cachedimages 5 6 import ( 7 "github.com/juju/cmd" 8 9 "github.com/juju/juju/api/imagemanager" 10 "github.com/juju/juju/cmd/envcmd" 11 ) 12 13 const cachedimagesCommandDoc = ` 14 "juju cached-images" is used to manage the cached os images in 15 the Juju environment. 16 ` 17 18 const cachedImagesCommandPurpose = "manage cached os images" 19 20 // NewSuperCommand creates the user supercommand and registers the subcommands 21 // that it supports. 22 func NewSuperCommand() cmd.Command { 23 usercmd := cmd.NewSuperCommand(cmd.SuperCommandParams{ 24 Name: "cached-images", 25 Doc: cachedimagesCommandDoc, 26 UsagePrefix: "juju", 27 Purpose: cachedImagesCommandPurpose, 28 }) 29 usercmd.Register(envcmd.Wrap(&DeleteCommand{})) 30 usercmd.Register(envcmd.Wrap(&ListCommand{})) 31 return usercmd 32 } 33 34 // CachedImagesCommandBase is a helper base structure that has a method to get the 35 // image manager client. 36 type CachedImagesCommandBase struct { 37 envcmd.EnvCommandBase 38 } 39 40 // NewImagesManagerClient returns a imagemanager client for the root api endpoint 41 // that the environment command returns. 42 func (c *CachedImagesCommandBase) NewImagesManagerClient() (*imagemanager.Client, error) { 43 root, err := c.NewAPIRoot() 44 if err != nil { 45 return nil, err 46 } 47 return imagemanager.NewClient(root), nil 48 }