github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/cmd/juju/storage/storage.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package storage 5 6 import ( 7 "github.com/juju/cmd" 8 "github.com/juju/loggo" 9 10 "github.com/juju/juju/api/storage" 11 "github.com/juju/juju/cmd/envcmd" 12 ) 13 14 var logger = loggo.GetLogger("juju.cmd.juju.storage") 15 16 const storageCmdDoc = ` 17 "juju storage" is used to manage storage instances in 18 the Juju environment. 19 ` 20 21 const storageCmdPurpose = "manage storage instances" 22 23 // Command is the top-level command wrapping all storage functionality. 24 type Command struct { 25 cmd.SuperCommand 26 } 27 28 // NewSuperCommand creates the storage supercommand and 29 // registers the subcommands that it supports. 30 func NewSuperCommand() cmd.Command { 31 storagecmd := Command{ 32 SuperCommand: *cmd.NewSuperCommand( 33 cmd.SuperCommandParams{ 34 Name: "storage", 35 Doc: storageCmdDoc, 36 UsagePrefix: "juju", 37 Purpose: storageCmdPurpose, 38 })} 39 storagecmd.Register(envcmd.Wrap(&ShowCommand{})) 40 return &storagecmd 41 } 42 43 // StorageCommandBase is a helper base structure that has a method to get the 44 // storage managing client. 45 type StorageCommandBase struct { 46 envcmd.EnvCommandBase 47 } 48 49 // NewStorageAPI returns a storage api for the root api endpoint 50 // that the environment command returns. 51 func (c *StorageCommandBase) NewStorageAPI() (*storage.Client, error) { 52 root, err := c.NewAPIRoot() 53 if err != nil { 54 return nil, err 55 } 56 return storage.NewClient(root), nil 57 }