github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/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  }
    16  
    17  // NewImagesManagerClient returns a imagemanager client for the root api endpoint
    18  // that the environment command returns.
    19  func (c *CachedImagesCommandBase) NewImagesManagerClient() (*imagemanager.Client, error) {
    20  	root, err := c.NewAPIRoot()
    21  	if err != nil {
    22  		return nil, err
    23  	}
    24  	return imagemanager.NewClient(root), nil
    25  }