Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1508)

Side by Side Diff: cmd/juju/destroyunit.go

Issue 7554046: Add ServiceDestroyUnits to the API
Patch Set: Created 12 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 package main 1 package main
2 2
3 import ( 3 import (
4 "errors" 4 "errors"
5 "fmt" 5 "fmt"
6 "launchpad.net/juju-core/cmd" 6 "launchpad.net/juju-core/cmd"
7 "launchpad.net/juju-core/juju" 7 "launchpad.net/juju-core/juju"
8 "launchpad.net/juju-core/state" 8 "launchpad.net/juju-core/state"
9 "launchpad.net/juju-core/state/api/params"
10 "launchpad.net/juju-core/state/statecmd"
9 ) 11 )
10 12
11 // DestroyUnitCommand is responsible for destroying service units. 13 // DestroyUnitCommand is responsible for destroying service units.
12 type DestroyUnitCommand struct { 14 type DestroyUnitCommand struct {
13 EnvCommandBase 15 EnvCommandBase
14 UnitNames []string 16 UnitNames []string
15 } 17 }
16 18
17 func (c *DestroyUnitCommand) Info() *cmd.Info { 19 func (c *DestroyUnitCommand) Info() *cmd.Info {
18 return &cmd.Info{ 20 return &cmd.Info{
(...skipping 10 matching lines...) Expand all
29 return errors.New("no units specified") 31 return errors.New("no units specified")
30 } 32 }
31 for _, name := range c.UnitNames { 33 for _, name := range c.UnitNames {
32 if !state.IsUnitName(name) { 34 if !state.IsUnitName(name) {
33 return fmt.Errorf("invalid unit name %q", name) 35 return fmt.Errorf("invalid unit name %q", name)
34 } 36 }
35 } 37 }
36 return nil 38 return nil
37 } 39 }
38 40
39 // Run connects to the environment specified on the command line 41 // DestroyUnitCommand connects to the environment specified on the command line
dimitern 2013/03/14 14:18:49 It's still Run(), so it starts with // Run ... . P
benji 2013/03/15 13:39:12 Good catch, I'm still not used to reading Go's fun
dimitern 2013/03/15 13:52:36 Not that I know of, probably some quick research i
benji 2013/03/15 14:16:32 My search has found only an incomplete and abandon
40 // and calls conn.DestroyUnits. 42 // and calls destroys units therein.
41 func (c *DestroyUnitCommand) Run(_ *cmd.Context) (err error) { 43 func (c *DestroyUnitCommand) Run(_ *cmd.Context) (err error) {
42 conn, err := juju.NewConnFromName(c.EnvName) 44 conn, err := juju.NewConnFromName(c.EnvName)
43 if err != nil { 45 if err != nil {
44 return err 46 return err
45 } 47 }
46 defer conn.Close() 48 defer conn.Close()
47 » return conn.DestroyUnits(c.UnitNames...) 49 » params := params.ServiceDestroyUnits{
50 » » UnitNames: c.UnitNames,
51 » }
52 » return statecmd.ServiceDestroyUnits(conn.State, params)
48 } 53 }
OLDNEW
« no previous file with comments | « [revision details] ('k') | state/api/apiclient.go » ('j') | state/api/apiclient.go » ('J')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b