Merge lp:~waigani/juju-core/cmd_help_aliases_1299120 into lp:~go-bot/juju-core/trunk

Proposed by Jesse Meek
Status: Merged
Approved by: Jesse Meek
Approved revision: no longer in the source branch.
Merged at revision: 2717
Proposed branch: lp:~waigani/juju-core/cmd_help_aliases_1299120
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 499 lines (+98/-91)
10 files modified
cmd/juju/cmd_test.go (+5/-5)
cmd/juju/main.go (+4/-4)
cmd/juju/removemachine.go (+19/-12)
cmd/juju/removemachine_test.go (+18/-18)
cmd/juju/removerelation.go (+8/-8)
cmd/juju/removerelation_test.go (+9/-9)
cmd/juju/removeservice.go (+9/-9)
cmd/juju/removeservice_test.go (+12/-12)
cmd/juju/removeunit.go (+8/-8)
cmd/juju/removeunit_test.go (+6/-6)
To merge this branch: bzr merge lp:~waigani/juju-core/cmd_help_aliases_1299120
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+218728@code.launchpad.net

Commit message

Fix 1299120 command aliases

Fix bug 1299120 by ensuring that the
preferred command is not displayed as
an alias of another command in juju
help commands.

Change file and function names to
be consistant with the preferred
command.

https://codereview.appspot.com/92080046/

R=fwereade

Description of the change

Fix 1299120 command aliases

Fix bug 1299120 by ensuring that the
preferred command is not displayed as
an alias of another command in juju
help commands.

Change file and function names to
be consistant with the preferred
command.

https://codereview.appspot.com/92080046/

To post a comment you must log in.
Revision history for this message
Jesse Meek (waigani) wrote :

Reviewers: mp+218728_code.launchpad.net,

Message:
Please take a look.

Description:
Fix 1299120 command aliases

Fix bug 1299120 by ensuring that the
preferred command is not displayed as
an alias of another command in juju
help commands.

Change file and function names to
be consistant with the preferred
command.

https://code.launchpad.net/~waigani/juju-core/cmd_help_aliases_1299120/+merge/218728

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/92080046/

Affected files (+149, -140 lines):
   A [revision details]
   M cmd/juju/cmd_test.go
   M cmd/juju/main.go
   M cmd/juju/removemachine.go
   M cmd/juju/removemachine_test.go
   M cmd/juju/removerelation.go
   M cmd/juju/removerelation_test.go
   M cmd/juju/removeservice.go
   M cmd/juju/removeservice_test.go
   M cmd/juju/removeunit.go
   M cmd/juju/removeunit_test.go
   M environs/manual/provisioner.go
   M state/api/client.go
   M state/api/params/params.go
   M state/apiserver/client/client.go
   M state/apiserver/client/client_test.go
   M state/apiserver/client/perm_test.go
   M state/minimumunits_test.go
   M state/relation_test.go
   M state/relationunit_test.go
   M state/unit_test.go

Revision history for this message
Jesse Meek (waigani) wrote :
Revision history for this message
William Reade (fwereade) wrote :

This breaks compatibility in some places, and we can't do that. The
changes in cmd/juju are fine, but anything that changes what we send
over the wire for the API is not.

https://codereview.appspot.com/92080046/diff/20001/cmd/juju/removemachine.go
File cmd/juju/removemachine.go (right):

https://codereview.appspot.com/92080046/diff/20001/cmd/juju/removemachine.go#newcode77
cmd/juju/removemachine.go:77: return
apiclient.ForceReplaceMachines(c.MachineIds...)
Replace?

https://codereview.appspot.com/92080046/diff/20001/state/api/client.go
File state/api/client.go (left):

https://codereview.appspot.com/92080046/diff/20001/state/api/client.go#oldcode378
state/api/client.go:378: // ServiceDestroy destroys a given service.
What about service? Did we keep "destroy" for service but "remove"
everything else? that seems somewhat incoherent to me.

https://codereview.appspot.com/92080046/diff/20001/state/api/client.go
File state/api/client.go (right):

https://codereview.appspot.com/92080046/diff/20001/state/api/client.go#newcode274
state/api/client.go:274: func (c *Client) ReplaceMachines(machines
...string) error {
This Replace is surprising to me. Just a typo, or something deeper I
haven't figured out?

https://codereview.appspot.com/92080046/diff/20001/state/api/client.go#newcode375
state/api/client.go:375: return c.call("RemoveServiceUnits", params,
nil)
We definitely can't change the stuff we call() -- we need to keep
working with old servers.

https://codereview.appspot.com/92080046/diff/20001/state/api/params/params.go
File state/api/params/params.go (right):

https://codereview.appspot.com/92080046/diff/20001/state/api/params/params.go#newcode285
state/api/params/params.go:285: type RemoveServiceUnits struct {
Yeah, please just don't touch the API at all. We can use the better
names with new api versions -- when we get versioning -- but for now
this is just a break.

(ok, *this* is not -- the names of the types aren't reflected in what we
sent over the wire)

https://codereview.appspot.com/92080046/diff/20001/state/apiserver/client/client.go
File state/apiserver/client/client.go (right):

https://codereview.appspot.com/92080046/diff/20001/state/apiserver/client/client.go#newcode490
state/apiserver/client/client.go:490: func (c *Client)
RemoveServiceUnits(args params.RemoveServiceUnits) error {
...but *this* is a break.

https://codereview.appspot.com/92080046/

Revision history for this message
Jesse Meek (waigani) wrote :
Revision history for this message
William Reade (fwereade) wrote :

LGTM, but please do the type/var renames for RemoveMachine as well

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/main.go
File cmd/juju/main.go (left):

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/main.go#oldcode83
cmd/juju/main.go:83: jujucmd.Register(wrap(&DestroyMachineCommand{}))
Shouldn't we RemoveMachine as well? if not, why not? :)

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/removemachine.go
File cmd/juju/removemachine.go (left):

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/removemachine.go#oldcode24
cmd/juju/removemachine.go:24: const destroyMachineDoc = `
removeMachineDoc

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/removemachine.go#oldcode31
cmd/juju/removemachine.go:31: func (c *DestroyMachineCommand) Info()
*cmd.Info {
RemoveMachineCommand

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/removemachine.go
File cmd/juju/removemachine.go (right):

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/removemachine.go#newcode34
cmd/juju/removemachine.go:34: # Remove machine 6, running units or
containers
Remove machine 6, and all its units and containers?

https://codereview.appspot.com/92080046/

Revision history for this message
John A Meinel (jameinel) wrote :

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/main.go
File cmd/juju/main.go (left):

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/main.go#oldcode83
cmd/juju/main.go:83: jujucmd.Register(wrap(&DestroyMachineCommand{}))
On 2014/05/09 06:51:55, fwereade wrote:
> Shouldn't we RemoveMachine as well? if not, why not? :)

It was intended to switch to "juju remove-machine" at least in the bug.

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/removemachine.go
File cmd/juju/removemachine.go (left):

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/removemachine.go#oldcode39
cmd/juju/removemachine.go:39: }
It seems you can't comment on a rename-only change. I wanted to note
that removemachine_test.go certainly seems like it would need updating
for the changes of DestroyMachine to RemoveMachine.

https://codereview.appspot.com/92080046/

Revision history for this message
John A Meinel (jameinel) wrote :
Revision history for this message
Jesse Meek (waigani) wrote :

On 2014/05/09 09:24:49, jameinel wrote:
> https://codereview.appspot.com/92080046/diff/40001/cmd/juju/main.go
> File cmd/juju/main.go (left):

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/main.go#oldcode83
> cmd/juju/main.go:83: jujucmd.Register(wrap(&DestroyMachineCommand{}))
> On 2014/05/09 06:51:55, fwereade wrote:
> > Shouldn't we RemoveMachine as well? if not, why not? :)

> It was intended to switch to "juju remove-machine" at least in the
bug.

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/removemachine.go
> File cmd/juju/removemachine.go (left):

https://codereview.appspot.com/92080046/diff/40001/cmd/juju/removemachine.go#oldcode39
> cmd/juju/removemachine.go:39: }
> It seems you can't comment on a rename-only change. I wanted to note
that
> removemachine_test.go certainly seems like it would need updating for
the
> changes of DestroyMachine to RemoveMachine.

Yes, you're right. It seems I'm being sloppy with my commits. I'd made
the changes but managed not to commit them, sorry.

https://codereview.appspot.com/92080046/

Revision history for this message
Jesse Meek (waigani) wrote :
Revision history for this message
Go Bot (go-bot) wrote :

Attempt to merge into lp:juju-core failed due to conflicts:

text conflict in cmd/juju/removemachine.go
text conflict in cmd/juju/removerelation.go
text conflict in cmd/juju/removeservice.go
text conflict in cmd/juju/removeunit.go

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmd/juju/cmd_test.go'
--- cmd/juju/cmd_test.go 2014-05-09 13:24:50 +0000
+++ cmd/juju/cmd_test.go 2014-05-11 22:53:23 +0000
@@ -360,16 +360,16 @@
360 c.Assert(err, gc.ErrorMatches, "no service name specified")360 c.Assert(err, gc.ErrorMatches, "no service name specified")
361}361}
362362
363func initDestroyUnitCommand(args ...string) (*DestroyUnitCommand, error) {363func initRemoveUnitCommand(args ...string) (*RemoveUnitCommand, error) {
364 com := &DestroyUnitCommand{}364 com := &RemoveUnitCommand{}
365 return com, coretesting.InitCommand(com, args)365 return com, coretesting.InitCommand(com, args)
366}366}
367367
368func (*CmdSuite) TestDestroyUnitCommandInit(c *gc.C) {368func (*CmdSuite) TestRemoveUnitCommandInit(c *gc.C) {
369 // missing args369 // missing args
370 _, err := initDestroyUnitCommand()370 _, err := initRemoveUnitCommand()
371 c.Assert(err, gc.ErrorMatches, "no units specified")371 c.Assert(err, gc.ErrorMatches, "no units specified")
372 // not a unit372 // not a unit
373 _, err = initDestroyUnitCommand("seven/nine")373 _, err = initRemoveUnitCommand("seven/nine")
374 c.Assert(err, gc.ErrorMatches, `invalid unit name "seven/nine"`)374 c.Assert(err, gc.ErrorMatches, `invalid unit name "seven/nine"`)
375}375}
376376
=== modified file 'cmd/juju/main.go'
--- cmd/juju/main.go 2014-04-25 13:57:06 +0000
+++ cmd/juju/main.go 2014-05-11 22:53:23 +0000
@@ -80,10 +80,10 @@
80 jujucmd.Register(wrap(&AddUnitCommand{}))80 jujucmd.Register(wrap(&AddUnitCommand{}))
8181
82 // Destruction commands.82 // Destruction commands.
83 jujucmd.Register(wrap(&DestroyMachineCommand{}))83 jujucmd.Register(wrap(&RemoveMachineCommand{}))
84 jujucmd.Register(wrap(&DestroyRelationCommand{}))84 jujucmd.Register(wrap(&RemoveRelationCommand{}))
85 jujucmd.Register(wrap(&DestroyServiceCommand{}))85 jujucmd.Register(wrap(&RemoveServiceCommand{}))
86 jujucmd.Register(wrap(&DestroyUnitCommand{}))86 jujucmd.Register(wrap(&RemoveUnitCommand{}))
87 jujucmd.Register(wrap(&DestroyEnvironmentCommand{}))87 jujucmd.Register(wrap(&DestroyEnvironmentCommand{}))
8888
89 // Reporting commands.89 // Reporting commands.
9090
=== renamed file 'cmd/juju/destroymachine.go' => 'cmd/juju/removemachine.go'
--- cmd/juju/destroymachine.go 2014-05-09 13:24:50 +0000
+++ cmd/juju/removemachine.go 2014-05-11 22:53:23 +0000
@@ -14,36 +14,43 @@
14 "launchpad.net/juju-core/names"14 "launchpad.net/juju-core/names"
15)15)
1616
17// DestroyMachineCommand causes an existing machine to be destroyed.17// RemoveMachineCommand causes an existing machine to be destroyed.
18type DestroyMachineCommand struct {18type RemoveMachineCommand struct {
19 envcmd.EnvCommandBase19 envcmd.EnvCommandBase
20 MachineIds []string20 MachineIds []string
21 Force bool21 Force bool
22}22}
2323
24const destroyMachineDoc = `24const destroyMachineDoc = `
25Machines that are responsible for the environment cannot be destroyed. Machines25Machines that are responsible for the environment cannot be removed. Machines
26running units or containers can only be destroyed with the --force flag; doing26running units or containers can only be removed with the --force flag; doing
27so will also destroy all those units and containers without giving them any27so will also remove all those units and containers without giving them any
28opportunity to shut down cleanly.28opportunity to shut down cleanly.
29
30Examples:
31 # Remove machine number 5 which has no running units or containers
32 $ juju remove-machine 5
33
34 # Remove machine 6 and any running units or containers
35 $ juju remove-machine 6 --force
29`36`
3037
31func (c *DestroyMachineCommand) Info() *cmd.Info {38func (c *RemoveMachineCommand) Info() *cmd.Info {
32 return &cmd.Info{39 return &cmd.Info{
33 Name: "destroy-machine",40 Name: "remove-machine",
34 Args: "<machine> ...",41 Args: "<machine> ...",
35 Purpose: "destroy machines",42 Purpose: "remove machines from the environment",
36 Doc: destroyMachineDoc,43 Doc: destroyMachineDoc,
37 Aliases: []string{"remove-machine", "terminate-machine"},44 Aliases: []string{"destroy-machine", "terminate-machine"},
38 }45 }
39}46}
4047
41func (c *DestroyMachineCommand) SetFlags(f *gnuflag.FlagSet) {48func (c *RemoveMachineCommand) SetFlags(f *gnuflag.FlagSet) {
42 c.EnvCommandBase.SetFlags(f)49 c.EnvCommandBase.SetFlags(f)
43 f.BoolVar(&c.Force, "force", false, "completely remove machine and all dependencies")50 f.BoolVar(&c.Force, "force", false, "completely remove machine and all dependencies")
44}51}
4552
46func (c *DestroyMachineCommand) Init(args []string) error {53func (c *RemoveMachineCommand) Init(args []string) error {
47 if err := c.EnvCommandBase.EnsureEnvName(); err != nil {54 if err := c.EnvCommandBase.EnsureEnvName(); err != nil {
48 return err55 return err
49 }56 }
@@ -59,7 +66,7 @@
59 return nil66 return nil
60}67}
6168
62func (c *DestroyMachineCommand) Run(_ *cmd.Context) error {69func (c *RemoveMachineCommand) Run(_ *cmd.Context) error {
63 apiclient, err := juju.NewAPIClientFromName(c.EnvName)70 apiclient, err := juju.NewAPIClientFromName(c.EnvName)
64 if err != nil {71 if err != nil {
65 return err72 return err
6673
=== renamed file 'cmd/juju/destroymachine_test.go' => 'cmd/juju/removemachine_test.go'
--- cmd/juju/destroymachine_test.go 2014-04-14 12:36:13 +0000
+++ cmd/juju/removemachine_test.go 2014-05-11 22:53:23 +0000
@@ -13,18 +13,18 @@
13 "launchpad.net/juju-core/testing"13 "launchpad.net/juju-core/testing"
14)14)
1515
16type DestroyMachineSuite struct {16type RemoveMachineSuite struct {
17 jujutesting.RepoSuite17 jujutesting.RepoSuite
18}18}
1919
20var _ = gc.Suite(&DestroyMachineSuite{})20var _ = gc.Suite(&RemoveMachineSuite{})
2121
22func runDestroyMachine(c *gc.C, args ...string) error {22func runRemoveMachine(c *gc.C, args ...string) error {
23 _, err := testing.RunCommand(c, &DestroyMachineCommand{}, args)23 _, err := testing.RunCommand(c, &RemoveMachineCommand{}, args)
24 return err24 return err
25}25}
2626
27func (s *DestroyMachineSuite) TestDestroyMachineWithUnit(c *gc.C) {27func (s *RemoveMachineSuite) TestRemoveMachineWithUnit(c *gc.C) {
28 // Create a machine running a unit.28 // Create a machine running a unit.
29 testing.Charms.BundlePath(s.SeriesPath, "riak")29 testing.Charms.BundlePath(s.SeriesPath, "riak")
30 err := runDeploy(c, "local:riak", "riak")30 err := runDeploy(c, "local:riak", "riak")
@@ -38,30 +38,30 @@
38 c.Assert(mid, gc.Equals, "0")38 c.Assert(mid, gc.Equals, "0")
3939
40 // Try to destroy the machine and fail.40 // Try to destroy the machine and fail.
41 err = runDestroyMachine(c, "0")41 err = runRemoveMachine(c, "0")
42 c.Assert(err, gc.ErrorMatches, `no machines were destroyed: machine 0 has unit "riak/0" assigned`)42 c.Assert(err, gc.ErrorMatches, `no machines were destroyed: machine 0 has unit "riak/0" assigned`)
43}43}
4444
45func (s *DestroyMachineSuite) TestDestroyEmptyMachine(c *gc.C) {45func (s *RemoveMachineSuite) TestDestroyEmptyMachine(c *gc.C) {
46 // Destroy an empty machine alongside a state server; only the empty machine46 // Destroy an empty machine alongside a state server; only the empty machine
47 // gets destroyed.47 // gets destroyed.
48 m0, err := s.State.AddMachine("quantal", state.JobHostUnits)48 m0, err := s.State.AddMachine("quantal", state.JobHostUnits)
49 c.Assert(err, gc.IsNil)49 c.Assert(err, gc.IsNil)
50 err = runDestroyMachine(c, "0", "1")50 err = runRemoveMachine(c, "0", "1")
51 c.Assert(err, gc.ErrorMatches, `some machines were not destroyed: machine 1 does not exist`)51 c.Assert(err, gc.ErrorMatches, `some machines were not destroyed: machine 1 does not exist`)
52 err = m0.Refresh()52 err = m0.Refresh()
53 c.Assert(err, gc.IsNil)53 c.Assert(err, gc.IsNil)
54 c.Assert(m0.Life(), gc.Equals, state.Dying)54 c.Assert(m0.Life(), gc.Equals, state.Dying)
5555
56 // Destroying a destroyed machine is a no-op.56 // Destroying a destroyed machine is a no-op.
57 err = runDestroyMachine(c, "0")57 err = runRemoveMachine(c, "0")
58 c.Assert(err, gc.IsNil)58 c.Assert(err, gc.IsNil)
59 err = m0.Refresh()59 err = m0.Refresh()
60 c.Assert(err, gc.IsNil)60 c.Assert(err, gc.IsNil)
61 c.Assert(m0.Life(), gc.Equals, state.Dying)61 c.Assert(m0.Life(), gc.Equals, state.Dying)
62}62}
6363
64func (s *DestroyMachineSuite) TestDestroyDeadMachine(c *gc.C) {64func (s *RemoveMachineSuite) TestDestroyDeadMachine(c *gc.C) {
65 // Destroying a Dead machine is a no-op; destroying it alongside a JobManageEnviron65 // Destroying a Dead machine is a no-op; destroying it alongside a JobManageEnviron
66 m0, err := s.State.AddMachine("quantal", state.JobManageEnviron)66 m0, err := s.State.AddMachine("quantal", state.JobManageEnviron)
67 c.Assert(err, gc.IsNil)67 c.Assert(err, gc.IsNil)
@@ -70,7 +70,7 @@
70 c.Assert(err, gc.IsNil)70 c.Assert(err, gc.IsNil)
71 err = m1.EnsureDead()71 err = m1.EnsureDead()
72 c.Assert(err, gc.IsNil)72 c.Assert(err, gc.IsNil)
73 err = runDestroyMachine(c, "0", "1")73 err = runRemoveMachine(c, "0", "1")
74 c.Assert(err, gc.ErrorMatches, `some machines were not destroyed: machine 0 is required by the environment`)74 c.Assert(err, gc.ErrorMatches, `some machines were not destroyed: machine 0 is required by the environment`)
75 err = m1.Refresh()75 err = m1.Refresh()
76 c.Assert(err, gc.IsNil)76 c.Assert(err, gc.IsNil)
@@ -80,7 +80,7 @@
80 c.Assert(m0.Life(), gc.Equals, state.Alive)80 c.Assert(m0.Life(), gc.Equals, state.Alive)
81}81}
8282
83func (s *DestroyMachineSuite) TestForce(c *gc.C) {83func (s *RemoveMachineSuite) TestForce(c *gc.C) {
84 // Create a manager machine.84 // Create a manager machine.
85 m0, err := s.State.AddMachine("quantal", state.JobManageEnviron)85 m0, err := s.State.AddMachine("quantal", state.JobManageEnviron)
86 c.Assert(err, gc.IsNil)86 c.Assert(err, gc.IsNil)
@@ -97,7 +97,7 @@
97 c.Assert(err, gc.IsNil)97 c.Assert(err, gc.IsNil)
9898
99 // Try to force-destroy the machines.99 // Try to force-destroy the machines.
100 err = runDestroyMachine(c, "0", "1", "--force")100 err = runRemoveMachine(c, "0", "1", "--force")
101 c.Assert(err, gc.ErrorMatches, `some machines were not destroyed: machine 0 is required by the environment`)101 c.Assert(err, gc.ErrorMatches, `some machines were not destroyed: machine 0 is required by the environment`)
102102
103 // Clean up, check state.103 // Clean up, check state.
@@ -115,17 +115,17 @@
115 c.Assert(m0.Life(), gc.Equals, state.Alive)115 c.Assert(m0.Life(), gc.Equals, state.Alive)
116}116}
117117
118func (s *DestroyMachineSuite) TestBadArgs(c *gc.C) {118func (s *RemoveMachineSuite) TestBadArgs(c *gc.C) {
119 // Check invalid args.119 // Check invalid args.
120 err := runDestroyMachine(c)120 err := runRemoveMachine(c)
121 c.Assert(err, gc.ErrorMatches, `no machines specified`)121 c.Assert(err, gc.ErrorMatches, `no machines specified`)
122 err = runDestroyMachine(c, "1", "2", "nonsense", "rubbish")122 err = runRemoveMachine(c, "1", "2", "nonsense", "rubbish")
123 c.Assert(err, gc.ErrorMatches, `invalid machine id "nonsense"`)123 c.Assert(err, gc.ErrorMatches, `invalid machine id "nonsense"`)
124}124}
125125
126func (s *DestroyMachineSuite) TestEnvironmentArg(c *gc.C) {126func (s *RemoveMachineSuite) TestEnvironmentArg(c *gc.C) {
127 _, err := s.State.AddMachine("quantal", state.JobHostUnits)127 _, err := s.State.AddMachine("quantal", state.JobHostUnits)
128 c.Assert(err, gc.IsNil)128 c.Assert(err, gc.IsNil)
129 err = runDestroyMachine(c, "0", "-e", "dummyenv")129 err = runRemoveMachine(c, "0", "-e", "dummyenv")
130 c.Assert(err, gc.IsNil)130 c.Assert(err, gc.IsNil)
131}131}
132132
=== renamed file 'cmd/juju/destroyrelation.go' => 'cmd/juju/removerelation.go'
--- cmd/juju/destroyrelation.go 2014-05-09 13:24:50 +0000
+++ cmd/juju/removerelation.go 2014-05-11 22:53:23 +0000
@@ -11,22 +11,22 @@
11 "launchpad.net/juju-core/juju"11 "launchpad.net/juju-core/juju"
12)12)
1313
14// DestroyRelationCommand causes an existing service relation to be shut down.14// RemoveRelationCommand causes an existing service relation to be shut down.
15type DestroyRelationCommand struct {15type RemoveRelationCommand struct {
16 envcmd.EnvCommandBase16 envcmd.EnvCommandBase
17 Endpoints []string17 Endpoints []string
18}18}
1919
20func (c *DestroyRelationCommand) Info() *cmd.Info {20func (c *RemoveRelationCommand) Info() *cmd.Info {
21 return &cmd.Info{21 return &cmd.Info{
22 Name: "destroy-relation",22 Name: "remove-relation",
23 Args: "<service1>[:<relation name1>] <service2>[:<relation name2>]",23 Args: "<service1>[:<relation name1>] <service2>[:<relation name2>]",
24 Purpose: "destroy a relation between two services",24 Purpose: "remove a relation between two services",
25 Aliases: []string{"remove-relation"},25 Aliases: []string{"destroy-relation"},
26 }26 }
27}27}
2828
29func (c *DestroyRelationCommand) Init(args []string) error {29func (c *RemoveRelationCommand) Init(args []string) error {
30 if err := c.EnsureEnvName(); err != nil {30 if err := c.EnsureEnvName(); err != nil {
31 return err31 return err
32 }32 }
@@ -37,7 +37,7 @@
37 return nil37 return nil
38}38}
3939
40func (c *DestroyRelationCommand) Run(_ *cmd.Context) error {40func (c *RemoveRelationCommand) Run(_ *cmd.Context) error {
41 client, err := juju.NewAPIClientFromName(c.EnvName)41 client, err := juju.NewAPIClientFromName(c.EnvName)
42 if err != nil {42 if err != nil {
43 return err43 return err
4444
=== renamed file 'cmd/juju/destroyrelation_test.go' => 'cmd/juju/removerelation_test.go'
--- cmd/juju/destroyrelation_test.go 2013-09-13 14:48:13 +0000
+++ cmd/juju/removerelation_test.go 2014-05-11 22:53:23 +0000
@@ -10,18 +10,18 @@
10 "launchpad.net/juju-core/testing"10 "launchpad.net/juju-core/testing"
11)11)
1212
13type DestroyRelationSuite struct {13type RemoveRelationSuite struct {
14 jujutesting.RepoSuite14 jujutesting.RepoSuite
15}15}
1616
17var _ = gc.Suite(&DestroyRelationSuite{})17var _ = gc.Suite(&RemoveRelationSuite{})
1818
19func runDestroyRelation(c *gc.C, args ...string) error {19func runRemoveRelation(c *gc.C, args ...string) error {
20 _, err := testing.RunCommand(c, &DestroyRelationCommand{}, args)20 _, err := testing.RunCommand(c, &RemoveRelationCommand{}, args)
21 return err21 return err
22}22}
2323
24func (s *DestroyRelationSuite) TestDestroyRelation(c *gc.C) {24func (s *RemoveRelationSuite) TestRemoveRelation(c *gc.C) {
25 testing.Charms.BundlePath(s.SeriesPath, "riak")25 testing.Charms.BundlePath(s.SeriesPath, "riak")
26 err := runDeploy(c, "local:riak", "riak")26 err := runDeploy(c, "local:riak", "riak")
27 c.Assert(err, gc.IsNil)27 c.Assert(err, gc.IsNil)
@@ -31,16 +31,16 @@
31 runAddRelation(c, "riak", "logging")31 runAddRelation(c, "riak", "logging")
3232
33 // Destroy a relation that exists.33 // Destroy a relation that exists.
34 err = runDestroyRelation(c, "logging", "riak")34 err = runRemoveRelation(c, "logging", "riak")
35 c.Assert(err, gc.IsNil)35 c.Assert(err, gc.IsNil)
3636
37 // Destroy a relation that used to exist.37 // Destroy a relation that used to exist.
38 err = runDestroyRelation(c, "riak", "logging")38 err = runRemoveRelation(c, "riak", "logging")
39 c.Assert(err, gc.ErrorMatches, `relation "logging:info riak:juju-info" not found`)39 c.Assert(err, gc.ErrorMatches, `relation "logging:info riak:juju-info" not found`)
4040
41 // Invalid removes.41 // Invalid removes.
42 err = runDestroyRelation(c, "ping", "pong")42 err = runRemoveRelation(c, "ping", "pong")
43 c.Assert(err, gc.ErrorMatches, `service "ping" not found`)43 c.Assert(err, gc.ErrorMatches, `service "ping" not found`)
44 err = runDestroyRelation(c, "riak")44 err = runRemoveRelation(c, "riak")
45 c.Assert(err, gc.ErrorMatches, `a relation must involve two services`)45 c.Assert(err, gc.ErrorMatches, `a relation must involve two services`)
46}46}
4747
=== renamed file 'cmd/juju/destroyservice.go' => 'cmd/juju/removeservice.go'
--- cmd/juju/destroyservice.go 2014-05-09 13:24:50 +0000
+++ cmd/juju/removeservice.go 2014-05-11 22:53:23 +0000
@@ -12,23 +12,23 @@
12 "launchpad.net/juju-core/names"12 "launchpad.net/juju-core/names"
13)13)
1414
15// DestroyServiceCommand causes an existing service to be destroyed.15// RemoveServiceCommand causes an existing service to be destroyed.
16type DestroyServiceCommand struct {16type RemoveServiceCommand struct {
17 envcmd.EnvCommandBase17 envcmd.EnvCommandBase
18 ServiceName string18 ServiceName string
19}19}
2020
21func (c *DestroyServiceCommand) Info() *cmd.Info {21func (c *RemoveServiceCommand) Info() *cmd.Info {
22 return &cmd.Info{22 return &cmd.Info{
23 Name: "destroy-service",23 Name: "remove-service",
24 Args: "<service>",24 Args: "<service>",
25 Purpose: "destroy a service",25 Purpose: "remove a service from the environment",
26 Doc: "Destroying a service will destroy all its units and relations.",26 Doc: "Removing a service will remove all its units and relations.",
27 Aliases: []string{"remove-service"},27 Aliases: []string{"destroy-service"},
28 }28 }
29}29}
3030
31func (c *DestroyServiceCommand) Init(args []string) error {31func (c *RemoveServiceCommand) Init(args []string) error {
32 if err := c.EnsureEnvName(); err != nil {32 if err := c.EnsureEnvName(); err != nil {
33 return err33 return err
34 }34 }
@@ -42,7 +42,7 @@
42 return cmd.CheckEmpty(args)42 return cmd.CheckEmpty(args)
43}43}
4444
45func (c *DestroyServiceCommand) Run(_ *cmd.Context) error {45func (c *RemoveServiceCommand) Run(_ *cmd.Context) error {
46 client, err := juju.NewAPIClientFromName(c.EnvName)46 client, err := juju.NewAPIClientFromName(c.EnvName)
47 if err != nil {47 if err != nil {
48 return err48 return err
4949
=== renamed file 'cmd/juju/destroyservice_test.go' => 'cmd/juju/removeservice_test.go'
--- cmd/juju/destroyservice_test.go 2013-09-13 14:48:13 +0000
+++ cmd/juju/removeservice_test.go 2014-05-11 22:53:23 +0000
@@ -11,40 +11,40 @@
11 "launchpad.net/juju-core/testing"11 "launchpad.net/juju-core/testing"
12)12)
1313
14type DestroyServiceSuite struct {14type RemoveServiceSuite struct {
15 jujutesting.RepoSuite15 jujutesting.RepoSuite
16}16}
1717
18var _ = gc.Suite(&DestroyServiceSuite{})18var _ = gc.Suite(&RemoveServiceSuite{})
1919
20func runDestroyService(c *gc.C, args ...string) error {20func runRemoveService(c *gc.C, args ...string) error {
21 _, err := testing.RunCommand(c, &DestroyServiceCommand{}, args)21 _, err := testing.RunCommand(c, &RemoveServiceCommand{}, args)
22 return err22 return err
23}23}
2424
25func (s *DestroyServiceSuite) TestSuccess(c *gc.C) {25func (s *RemoveServiceSuite) TestSuccess(c *gc.C) {
26 // Destroy a service that exists.26 // Destroy a service that exists.
27 testing.Charms.BundlePath(s.SeriesPath, "riak")27 testing.Charms.BundlePath(s.SeriesPath, "riak")
28 err := runDeploy(c, "local:riak", "riak")28 err := runDeploy(c, "local:riak", "riak")
29 c.Assert(err, gc.IsNil)29 c.Assert(err, gc.IsNil)
30 err = runDestroyService(c, "riak")30 err = runRemoveService(c, "riak")
31 c.Assert(err, gc.IsNil)31 c.Assert(err, gc.IsNil)
32 riak, err := s.State.Service("riak")32 riak, err := s.State.Service("riak")
33 c.Assert(err, gc.IsNil)33 c.Assert(err, gc.IsNil)
34 c.Assert(riak.Life(), gc.Equals, state.Dying)34 c.Assert(riak.Life(), gc.Equals, state.Dying)
35}35}
3636
37func (s *DestroyServiceSuite) TestFailure(c *gc.C) {37func (s *RemoveServiceSuite) TestFailure(c *gc.C) {
38 // Destroy a service that does not exist.38 // Destroy a service that does not exist.
39 err := runDestroyService(c, "gargleblaster")39 err := runRemoveService(c, "gargleblaster")
40 c.Assert(err, gc.ErrorMatches, `service "gargleblaster" not found`)40 c.Assert(err, gc.ErrorMatches, `service "gargleblaster" not found`)
41}41}
4242
43func (s *DestroyServiceSuite) TestInvalidArgs(c *gc.C) {43func (s *RemoveServiceSuite) TestInvalidArgs(c *gc.C) {
44 err := runDestroyService(c)44 err := runRemoveService(c)
45 c.Assert(err, gc.ErrorMatches, `no service specified`)45 c.Assert(err, gc.ErrorMatches, `no service specified`)
46 err = runDestroyService(c, "ping", "pong")46 err = runRemoveService(c, "ping", "pong")
47 c.Assert(err, gc.ErrorMatches, `unrecognized args: \["pong"\]`)47 c.Assert(err, gc.ErrorMatches, `unrecognized args: \["pong"\]`)
48 err = runDestroyService(c, "invalid:name")48 err = runRemoveService(c, "invalid:name")
49 c.Assert(err, gc.ErrorMatches, `invalid service name "invalid:name"`)49 c.Assert(err, gc.ErrorMatches, `invalid service name "invalid:name"`)
50}50}
5151
=== renamed file 'cmd/juju/destroyunit.go' => 'cmd/juju/removeunit.go'
--- cmd/juju/destroyunit.go 2014-05-09 13:24:50 +0000
+++ cmd/juju/removeunit.go 2014-05-11 22:53:23 +0000
@@ -13,22 +13,22 @@
13 "launchpad.net/juju-core/names"13 "launchpad.net/juju-core/names"
14)14)
1515
16// DestroyUnitCommand is responsible for destroying service units.16// RemoveUnitCommand is responsible for destroying service units.
17type DestroyUnitCommand struct {17type RemoveUnitCommand struct {
18 envcmd.EnvCommandBase18 envcmd.EnvCommandBase
19 UnitNames []string19 UnitNames []string
20}20}
2121
22func (c *DestroyUnitCommand) Info() *cmd.Info {22func (c *RemoveUnitCommand) Info() *cmd.Info {
23 return &cmd.Info{23 return &cmd.Info{
24 Name: "destroy-unit",24 Name: "remove-unit",
25 Args: "<unit> [...]",25 Args: "<unit> [...]",
26 Purpose: "destroy service units",26 Purpose: "remove service units from the environment",
27 Aliases: []string{"remove-unit"},27 Aliases: []string{"destroy-unit"},
28 }28 }
29}29}
3030
31func (c *DestroyUnitCommand) Init(args []string) error {31func (c *RemoveUnitCommand) Init(args []string) error {
32 if err := c.EnsureEnvName(); err != nil {32 if err := c.EnsureEnvName(); err != nil {
33 return err33 return err
34 }34 }
@@ -46,7 +46,7 @@
4646
47// Run connects to the environment specified on the command line and destroys47// Run connects to the environment specified on the command line and destroys
48// units therein.48// units therein.
49func (c *DestroyUnitCommand) Run(_ *cmd.Context) error {49func (c *RemoveUnitCommand) Run(_ *cmd.Context) error {
50 client, err := juju.NewAPIClientFromName(c.EnvName)50 client, err := juju.NewAPIClientFromName(c.EnvName)
51 if err != nil {51 if err != nil {
52 return err52 return err
5353
=== renamed file 'cmd/juju/destroyunit_test.go' => 'cmd/juju/removeunit_test.go'
--- cmd/juju/destroyunit_test.go 2013-09-13 14:48:13 +0000
+++ cmd/juju/removeunit_test.go 2014-05-11 22:53:23 +0000
@@ -12,25 +12,25 @@
12 "launchpad.net/juju-core/testing"12 "launchpad.net/juju-core/testing"
13)13)
1414
15type DestroyUnitSuite struct {15type RemoveUnitSuite struct {
16 jujutesting.RepoSuite16 jujutesting.RepoSuite
17}17}
1818
19var _ = gc.Suite(&DestroyUnitSuite{})19var _ = gc.Suite(&RemoveUnitSuite{})
2020
21func runDestroyUnit(c *gc.C, args ...string) error {21func runRemoveUnit(c *gc.C, args ...string) error {
22 _, err := testing.RunCommand(c, &DestroyUnitCommand{}, args)22 _, err := testing.RunCommand(c, &RemoveUnitCommand{}, args)
23 return err23 return err
24}24}
2525
26func (s *DestroyUnitSuite) TestDestroyUnit(c *gc.C) {26func (s *RemoveUnitSuite) TestRemoveUnit(c *gc.C) {
27 testing.Charms.BundlePath(s.SeriesPath, "dummy")27 testing.Charms.BundlePath(s.SeriesPath, "dummy")
28 err := runDeploy(c, "-n", "2", "local:dummy", "dummy")28 err := runDeploy(c, "-n", "2", "local:dummy", "dummy")
29 c.Assert(err, gc.IsNil)29 c.Assert(err, gc.IsNil)
30 curl := charm.MustParseURL("local:precise/dummy-1")30 curl := charm.MustParseURL("local:precise/dummy-1")
31 svc, _ := s.AssertService(c, "dummy", curl, 2, 0)31 svc, _ := s.AssertService(c, "dummy", curl, 2, 0)
3232
33 err = runDestroyUnit(c, "dummy/0", "dummy/1", "dummy/2", "sillybilly/17")33 err = runRemoveUnit(c, "dummy/0", "dummy/1", "dummy/2", "sillybilly/17")
34 c.Assert(err, gc.ErrorMatches, `some units were not destroyed: unit "dummy/2" does not exist; unit "sillybilly/17" does not exist`)34 c.Assert(err, gc.ErrorMatches, `some units were not destroyed: unit "dummy/2" does not exist; unit "sillybilly/17" does not exist`)
35 units, err := svc.AllUnits()35 units, err := svc.AllUnits()
36 c.Assert(err, gc.IsNil)36 c.Assert(err, gc.IsNil)

Subscribers

People subscribed via source and target branches

to status/vote changes: