github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/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/juju/api/imagemanager" 8 "github.com/juju/juju/cmd/modelcmd" 9 ) 10 11 // CachedImagesCommandBase is a helper base structure that has a method to get the 12 // image manager client. 13 type CachedImagesCommandBase struct { 14 modelcmd.ModelCommandBase 15 modelcmd.IAASOnlyCommand 16 } 17 18 // NewImagesManagerClient returns a imagemanager client for the root api endpoint 19 // that the environment command returns. 20 func (c *CachedImagesCommandBase) NewImagesManagerClient() (*imagemanager.Client, error) { 21 root, err := c.NewAPIRoot() 22 if err != nil { 23 return nil, err 24 } 25 return imagemanager.NewClient(root), nil 26 }