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

Delta Between Two Patch Sets: cmd/juju/destroymachine.go

Issue 7370043: Change the way aliases to subcommands are handled.
Left Patch Set: Created 12 years, 2 months ago
Right Patch Set: Change the way aliases to subcommands are handled. Created 12 years, 1 month 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « cmd/juju/destroyenvironment.go ('k') | cmd/juju/destroyrelation.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package main 1 package main
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "launchpad.net/gnuflag" 5 "launchpad.net/gnuflag"
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 ) 9 )
10 10
11 // DestroyMachineCommand causes an existing machine to be destroyed. 11 // DestroyMachineCommand causes an existing machine to be destroyed.
12 type DestroyMachineCommand struct { 12 type DestroyMachineCommand struct {
13 EnvName string 13 EnvName string
14 MachineIds []string 14 MachineIds []string
15 } 15 }
16 16
17 func (c *DestroyMachineCommand) Info() *cmd.Info { 17 func (c *DestroyMachineCommand) Info() *cmd.Info {
18 » return cmd.NewInfo( 18 » return &cmd.Info{
19 » » "destroy-machine", "<machine> [, ...]", "destroy machines", 19 » » Name: "destroy-machine",
20 » » "Machines that have assigned units, or are responsible for the e nvironment, cannot be destroyed.", 20 » » Args: "<machine> ...",
21 » » "terminate-machine") 21 » » Purpose: "destroy machines",
22 » » Doc: "Machines that have assigned units, or are responsible for the environment, cannot be destroyed.",
23 » » Aliases: []string{"terminate-machine"},
24 » }
22 } 25 }
23 26
24 func (c *DestroyMachineCommand) SetFlags(f *gnuflag.FlagSet) { 27 func (c *DestroyMachineCommand) SetFlags(f *gnuflag.FlagSet) {
25 addEnvironFlags(&c.EnvName, f) 28 addEnvironFlags(&c.EnvName, f)
26 } 29 }
27 30
28 func (c *DestroyMachineCommand) Init(args []string) error { 31 func (c *DestroyMachineCommand) Init(args []string) error {
29 if len(args) == 0 { 32 if len(args) == 0 {
30 return fmt.Errorf("no machines specified") 33 return fmt.Errorf("no machines specified")
31 } 34 }
32 for _, id := range args { 35 for _, id := range args {
33 if !state.IsMachineId(id) { 36 if !state.IsMachineId(id) {
34 return fmt.Errorf("invalid machine id %q", id) 37 return fmt.Errorf("invalid machine id %q", id)
35 } 38 }
36 } 39 }
37 c.MachineIds = args 40 c.MachineIds = args
38 return nil 41 return nil
39 } 42 }
40 43
41 func (c *DestroyMachineCommand) Run(_ *cmd.Context) error { 44 func (c *DestroyMachineCommand) Run(_ *cmd.Context) error {
42 conn, err := juju.NewConnFromName(c.EnvName) 45 conn, err := juju.NewConnFromName(c.EnvName)
43 if err != nil { 46 if err != nil {
44 return err 47 return err
45 } 48 }
46 defer conn.Close() 49 defer conn.Close()
47 return conn.DestroyMachines(c.MachineIds...) 50 return conn.DestroyMachines(c.MachineIds...)
48 } 51 }
LEFTRIGHT

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