Merge lp:~waigani/juju-core/cmd_help_aliases_1299120 into lp:~go-bot/juju-core/trunk
- cmd_help_aliases_1299120
- Merge into trunk
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 |
Related bugs: |
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:/
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.
Jesse Meek (waigani) wrote : | # |
Jesse Meek (waigani) wrote : | # |
Please take a look.
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:/
File cmd/juju/
https:/
cmd/juju/
apiclient.
Replace?
https:/
File state/api/client.go (left):
https:/
state/api/
What about service? Did we keep "destroy" for service but "remove"
everything else? that seems somewhat incoherent to me.
https:/
File state/api/client.go (right):
https:/
state/api/
...string) error {
This Replace is surprising to me. Just a typo, or something deeper I
haven't figured out?
https:/
state/api/
nil)
We definitely can't change the stuff we call() -- we need to keep
working with old servers.
https:/
File state/api/
https:/
state/api/
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:/
File state/apiserver
https:/
state/apiserver
RemoveServiceUn
...but *this* is a break.
Jesse Meek (waigani) wrote : | # |
Please take a look.
William Reade (fwereade) wrote : | # |
LGTM, but please do the type/var renames for RemoveMachine as well
https:/
File cmd/juju/main.go (left):
https:/
cmd/juju/
Shouldn't we RemoveMachine as well? if not, why not? :)
https:/
File cmd/juju/
https:/
cmd/juju/
removeMachineDoc
https:/
cmd/juju/
*cmd.Info {
RemoveMachineCo
https:/
File cmd/juju/
https:/
cmd/juju/
containers
Remove machine 6, and all its units and containers?
John A Meinel (jameinel) wrote : | # |
https:/
File cmd/juju/main.go (left):
https:/
cmd/juju/
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:/
File cmd/juju/
https:/
cmd/juju/
It seems you can't comment on a rename-only change. I wanted to note
that removemachine_
for the changes of DestroyMachine to RemoveMachine.
John A Meinel (jameinel) wrote : | # |
Jesse Meek (waigani) wrote : | # |
On 2014/05/09 09:24:49, jameinel wrote:
> https:/
> File cmd/juju/main.go (left):
https:/
> cmd/juju/
> 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:/
> File cmd/juju/
https:/
> cmd/juju/
> It seems you can't comment on a rename-only change. I wanted to note
that
> removemachine_
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.
Jesse Meek (waigani) wrote : | # |
Please take a look.
Go Bot (go-bot) wrote : | # |
Attempt to merge into lp:juju-core failed due to conflicts:
text conflict in cmd/juju/
text conflict in cmd/juju/
text conflict in cmd/juju/
text conflict in cmd/juju/
Preview Diff
1 | === modified file 'cmd/juju/cmd_test.go' | |||
2 | --- cmd/juju/cmd_test.go 2014-05-09 13:24:50 +0000 | |||
3 | +++ cmd/juju/cmd_test.go 2014-05-11 22:53:23 +0000 | |||
4 | @@ -360,16 +360,16 @@ | |||
5 | 360 | c.Assert(err, gc.ErrorMatches, "no service name specified") | 360 | c.Assert(err, gc.ErrorMatches, "no service name specified") |
6 | 361 | } | 361 | } |
7 | 362 | 362 | ||
10 | 363 | func initDestroyUnitCommand(args ...string) (*DestroyUnitCommand, error) { | 363 | func initRemoveUnitCommand(args ...string) (*RemoveUnitCommand, error) { |
11 | 364 | com := &DestroyUnitCommand{} | 364 | com := &RemoveUnitCommand{} |
12 | 365 | return com, coretesting.InitCommand(com, args) | 365 | return com, coretesting.InitCommand(com, args) |
13 | 366 | } | 366 | } |
14 | 367 | 367 | ||
16 | 368 | func (*CmdSuite) TestDestroyUnitCommandInit(c *gc.C) { | 368 | func (*CmdSuite) TestRemoveUnitCommandInit(c *gc.C) { |
17 | 369 | // missing args | 369 | // missing args |
19 | 370 | _, err := initDestroyUnitCommand() | 370 | _, err := initRemoveUnitCommand() |
20 | 371 | c.Assert(err, gc.ErrorMatches, "no units specified") | 371 | c.Assert(err, gc.ErrorMatches, "no units specified") |
21 | 372 | // not a unit | 372 | // not a unit |
23 | 373 | _, err = initDestroyUnitCommand("seven/nine") | 373 | _, err = initRemoveUnitCommand("seven/nine") |
24 | 374 | c.Assert(err, gc.ErrorMatches, `invalid unit name "seven/nine"`) | 374 | c.Assert(err, gc.ErrorMatches, `invalid unit name "seven/nine"`) |
25 | 375 | } | 375 | } |
26 | 376 | 376 | ||
27 | === modified file 'cmd/juju/main.go' | |||
28 | --- cmd/juju/main.go 2014-04-25 13:57:06 +0000 | |||
29 | +++ cmd/juju/main.go 2014-05-11 22:53:23 +0000 | |||
30 | @@ -80,10 +80,10 @@ | |||
31 | 80 | jujucmd.Register(wrap(&AddUnitCommand{})) | 80 | jujucmd.Register(wrap(&AddUnitCommand{})) |
32 | 81 | 81 | ||
33 | 82 | // Destruction commands. | 82 | // Destruction commands. |
38 | 83 | jujucmd.Register(wrap(&DestroyMachineCommand{})) | 83 | jujucmd.Register(wrap(&RemoveMachineCommand{})) |
39 | 84 | jujucmd.Register(wrap(&DestroyRelationCommand{})) | 84 | jujucmd.Register(wrap(&RemoveRelationCommand{})) |
40 | 85 | jujucmd.Register(wrap(&DestroyServiceCommand{})) | 85 | jujucmd.Register(wrap(&RemoveServiceCommand{})) |
41 | 86 | jujucmd.Register(wrap(&DestroyUnitCommand{})) | 86 | jujucmd.Register(wrap(&RemoveUnitCommand{})) |
42 | 87 | jujucmd.Register(wrap(&DestroyEnvironmentCommand{})) | 87 | jujucmd.Register(wrap(&DestroyEnvironmentCommand{})) |
43 | 88 | 88 | ||
44 | 89 | // Reporting commands. | 89 | // Reporting commands. |
45 | 90 | 90 | ||
46 | === renamed file 'cmd/juju/destroymachine.go' => 'cmd/juju/removemachine.go' | |||
47 | --- cmd/juju/destroymachine.go 2014-05-09 13:24:50 +0000 | |||
48 | +++ cmd/juju/removemachine.go 2014-05-11 22:53:23 +0000 | |||
49 | @@ -14,36 +14,43 @@ | |||
50 | 14 | "launchpad.net/juju-core/names" | 14 | "launchpad.net/juju-core/names" |
51 | 15 | ) | 15 | ) |
52 | 16 | 16 | ||
55 | 17 | // DestroyMachineCommand causes an existing machine to be destroyed. | 17 | // RemoveMachineCommand causes an existing machine to be destroyed. |
56 | 18 | type DestroyMachineCommand struct { | 18 | type RemoveMachineCommand struct { |
57 | 19 | envcmd.EnvCommandBase | 19 | envcmd.EnvCommandBase |
58 | 20 | MachineIds []string | 20 | MachineIds []string |
59 | 21 | Force bool | 21 | Force bool |
60 | 22 | } | 22 | } |
61 | 23 | 23 | ||
62 | 24 | const destroyMachineDoc = ` | 24 | const destroyMachineDoc = ` |
66 | 25 | Machines that are responsible for the environment cannot be destroyed. Machines | 25 | Machines that are responsible for the environment cannot be removed. Machines |
67 | 26 | running units or containers can only be destroyed with the --force flag; doing | 26 | running units or containers can only be removed with the --force flag; doing |
68 | 27 | so will also destroy all those units and containers without giving them any | 27 | so will also remove all those units and containers without giving them any |
69 | 28 | opportunity to shut down cleanly. | 28 | opportunity to shut down cleanly. |
70 | 29 | |||
71 | 30 | Examples: | ||
72 | 31 | # Remove machine number 5 which has no running units or containers | ||
73 | 32 | $ juju remove-machine 5 | ||
74 | 33 | |||
75 | 34 | # Remove machine 6 and any running units or containers | ||
76 | 35 | $ juju remove-machine 6 --force | ||
77 | 29 | ` | 36 | ` |
78 | 30 | 37 | ||
80 | 31 | func (c *DestroyMachineCommand) Info() *cmd.Info { | 38 | func (c *RemoveMachineCommand) Info() *cmd.Info { |
81 | 32 | return &cmd.Info{ | 39 | return &cmd.Info{ |
83 | 33 | Name: "destroy-machine", | 40 | Name: "remove-machine", |
84 | 34 | Args: "<machine> ...", | 41 | Args: "<machine> ...", |
86 | 35 | Purpose: "destroy machines", | 42 | Purpose: "remove machines from the environment", |
87 | 36 | Doc: destroyMachineDoc, | 43 | Doc: destroyMachineDoc, |
89 | 37 | Aliases: []string{"remove-machine", "terminate-machine"}, | 44 | Aliases: []string{"destroy-machine", "terminate-machine"}, |
90 | 38 | } | 45 | } |
91 | 39 | } | 46 | } |
92 | 40 | 47 | ||
94 | 41 | func (c *DestroyMachineCommand) SetFlags(f *gnuflag.FlagSet) { | 48 | func (c *RemoveMachineCommand) SetFlags(f *gnuflag.FlagSet) { |
95 | 42 | c.EnvCommandBase.SetFlags(f) | 49 | c.EnvCommandBase.SetFlags(f) |
96 | 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") |
97 | 44 | } | 51 | } |
98 | 45 | 52 | ||
100 | 46 | func (c *DestroyMachineCommand) Init(args []string) error { | 53 | func (c *RemoveMachineCommand) Init(args []string) error { |
101 | 47 | if err := c.EnvCommandBase.EnsureEnvName(); err != nil { | 54 | if err := c.EnvCommandBase.EnsureEnvName(); err != nil { |
102 | 48 | return err | 55 | return err |
103 | 49 | } | 56 | } |
104 | @@ -59,7 +66,7 @@ | |||
105 | 59 | return nil | 66 | return nil |
106 | 60 | } | 67 | } |
107 | 61 | 68 | ||
109 | 62 | func (c *DestroyMachineCommand) Run(_ *cmd.Context) error { | 69 | func (c *RemoveMachineCommand) Run(_ *cmd.Context) error { |
110 | 63 | apiclient, err := juju.NewAPIClientFromName(c.EnvName) | 70 | apiclient, err := juju.NewAPIClientFromName(c.EnvName) |
111 | 64 | if err != nil { | 71 | if err != nil { |
112 | 65 | return err | 72 | return err |
113 | 66 | 73 | ||
114 | === renamed file 'cmd/juju/destroymachine_test.go' => 'cmd/juju/removemachine_test.go' | |||
115 | --- cmd/juju/destroymachine_test.go 2014-04-14 12:36:13 +0000 | |||
116 | +++ cmd/juju/removemachine_test.go 2014-05-11 22:53:23 +0000 | |||
117 | @@ -13,18 +13,18 @@ | |||
118 | 13 | "launchpad.net/juju-core/testing" | 13 | "launchpad.net/juju-core/testing" |
119 | 14 | ) | 14 | ) |
120 | 15 | 15 | ||
122 | 16 | type DestroyMachineSuite struct { | 16 | type RemoveMachineSuite struct { |
123 | 17 | jujutesting.RepoSuite | 17 | jujutesting.RepoSuite |
124 | 18 | } | 18 | } |
125 | 19 | 19 | ||
127 | 20 | var _ = gc.Suite(&DestroyMachineSuite{}) | 20 | var _ = gc.Suite(&RemoveMachineSuite{}) |
128 | 21 | 21 | ||
131 | 22 | func runDestroyMachine(c *gc.C, args ...string) error { | 22 | func runRemoveMachine(c *gc.C, args ...string) error { |
132 | 23 | _, err := testing.RunCommand(c, &DestroyMachineCommand{}, args) | 23 | _, err := testing.RunCommand(c, &RemoveMachineCommand{}, args) |
133 | 24 | return err | 24 | return err |
134 | 25 | } | 25 | } |
135 | 26 | 26 | ||
137 | 27 | func (s *DestroyMachineSuite) TestDestroyMachineWithUnit(c *gc.C) { | 27 | func (s *RemoveMachineSuite) TestRemoveMachineWithUnit(c *gc.C) { |
138 | 28 | // Create a machine running a unit. | 28 | // Create a machine running a unit. |
139 | 29 | testing.Charms.BundlePath(s.SeriesPath, "riak") | 29 | testing.Charms.BundlePath(s.SeriesPath, "riak") |
140 | 30 | err := runDeploy(c, "local:riak", "riak") | 30 | err := runDeploy(c, "local:riak", "riak") |
141 | @@ -38,30 +38,30 @@ | |||
142 | 38 | c.Assert(mid, gc.Equals, "0") | 38 | c.Assert(mid, gc.Equals, "0") |
143 | 39 | 39 | ||
144 | 40 | // Try to destroy the machine and fail. | 40 | // Try to destroy the machine and fail. |
146 | 41 | err = runDestroyMachine(c, "0") | 41 | err = runRemoveMachine(c, "0") |
147 | 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`) |
148 | 43 | } | 43 | } |
149 | 44 | 44 | ||
151 | 45 | func (s *DestroyMachineSuite) TestDestroyEmptyMachine(c *gc.C) { | 45 | func (s *RemoveMachineSuite) TestDestroyEmptyMachine(c *gc.C) { |
152 | 46 | // Destroy an empty machine alongside a state server; only the empty machine | 46 | // Destroy an empty machine alongside a state server; only the empty machine |
153 | 47 | // gets destroyed. | 47 | // gets destroyed. |
154 | 48 | m0, err := s.State.AddMachine("quantal", state.JobHostUnits) | 48 | m0, err := s.State.AddMachine("quantal", state.JobHostUnits) |
155 | 49 | c.Assert(err, gc.IsNil) | 49 | c.Assert(err, gc.IsNil) |
157 | 50 | err = runDestroyMachine(c, "0", "1") | 50 | err = runRemoveMachine(c, "0", "1") |
158 | 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`) |
159 | 52 | err = m0.Refresh() | 52 | err = m0.Refresh() |
160 | 53 | c.Assert(err, gc.IsNil) | 53 | c.Assert(err, gc.IsNil) |
161 | 54 | c.Assert(m0.Life(), gc.Equals, state.Dying) | 54 | c.Assert(m0.Life(), gc.Equals, state.Dying) |
162 | 55 | 55 | ||
163 | 56 | // Destroying a destroyed machine is a no-op. | 56 | // Destroying a destroyed machine is a no-op. |
165 | 57 | err = runDestroyMachine(c, "0") | 57 | err = runRemoveMachine(c, "0") |
166 | 58 | c.Assert(err, gc.IsNil) | 58 | c.Assert(err, gc.IsNil) |
167 | 59 | err = m0.Refresh() | 59 | err = m0.Refresh() |
168 | 60 | c.Assert(err, gc.IsNil) | 60 | c.Assert(err, gc.IsNil) |
169 | 61 | c.Assert(m0.Life(), gc.Equals, state.Dying) | 61 | c.Assert(m0.Life(), gc.Equals, state.Dying) |
170 | 62 | } | 62 | } |
171 | 63 | 63 | ||
173 | 64 | func (s *DestroyMachineSuite) TestDestroyDeadMachine(c *gc.C) { | 64 | func (s *RemoveMachineSuite) TestDestroyDeadMachine(c *gc.C) { |
174 | 65 | // Destroying a Dead machine is a no-op; destroying it alongside a JobManageEnviron | 65 | // Destroying a Dead machine is a no-op; destroying it alongside a JobManageEnviron |
175 | 66 | m0, err := s.State.AddMachine("quantal", state.JobManageEnviron) | 66 | m0, err := s.State.AddMachine("quantal", state.JobManageEnviron) |
176 | 67 | c.Assert(err, gc.IsNil) | 67 | c.Assert(err, gc.IsNil) |
177 | @@ -70,7 +70,7 @@ | |||
178 | 70 | c.Assert(err, gc.IsNil) | 70 | c.Assert(err, gc.IsNil) |
179 | 71 | err = m1.EnsureDead() | 71 | err = m1.EnsureDead() |
180 | 72 | c.Assert(err, gc.IsNil) | 72 | c.Assert(err, gc.IsNil) |
182 | 73 | err = runDestroyMachine(c, "0", "1") | 73 | err = runRemoveMachine(c, "0", "1") |
183 | 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`) |
184 | 75 | err = m1.Refresh() | 75 | err = m1.Refresh() |
185 | 76 | c.Assert(err, gc.IsNil) | 76 | c.Assert(err, gc.IsNil) |
186 | @@ -80,7 +80,7 @@ | |||
187 | 80 | c.Assert(m0.Life(), gc.Equals, state.Alive) | 80 | c.Assert(m0.Life(), gc.Equals, state.Alive) |
188 | 81 | } | 81 | } |
189 | 82 | 82 | ||
191 | 83 | func (s *DestroyMachineSuite) TestForce(c *gc.C) { | 83 | func (s *RemoveMachineSuite) TestForce(c *gc.C) { |
192 | 84 | // Create a manager machine. | 84 | // Create a manager machine. |
193 | 85 | m0, err := s.State.AddMachine("quantal", state.JobManageEnviron) | 85 | m0, err := s.State.AddMachine("quantal", state.JobManageEnviron) |
194 | 86 | c.Assert(err, gc.IsNil) | 86 | c.Assert(err, gc.IsNil) |
195 | @@ -97,7 +97,7 @@ | |||
196 | 97 | c.Assert(err, gc.IsNil) | 97 | c.Assert(err, gc.IsNil) |
197 | 98 | 98 | ||
198 | 99 | // Try to force-destroy the machines. | 99 | // Try to force-destroy the machines. |
200 | 100 | err = runDestroyMachine(c, "0", "1", "--force") | 100 | err = runRemoveMachine(c, "0", "1", "--force") |
201 | 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`) |
202 | 102 | 102 | ||
203 | 103 | // Clean up, check state. | 103 | // Clean up, check state. |
204 | @@ -115,17 +115,17 @@ | |||
205 | 115 | c.Assert(m0.Life(), gc.Equals, state.Alive) | 115 | c.Assert(m0.Life(), gc.Equals, state.Alive) |
206 | 116 | } | 116 | } |
207 | 117 | 117 | ||
209 | 118 | func (s *DestroyMachineSuite) TestBadArgs(c *gc.C) { | 118 | func (s *RemoveMachineSuite) TestBadArgs(c *gc.C) { |
210 | 119 | // Check invalid args. | 119 | // Check invalid args. |
212 | 120 | err := runDestroyMachine(c) | 120 | err := runRemoveMachine(c) |
213 | 121 | c.Assert(err, gc.ErrorMatches, `no machines specified`) | 121 | c.Assert(err, gc.ErrorMatches, `no machines specified`) |
215 | 122 | err = runDestroyMachine(c, "1", "2", "nonsense", "rubbish") | 122 | err = runRemoveMachine(c, "1", "2", "nonsense", "rubbish") |
216 | 123 | c.Assert(err, gc.ErrorMatches, `invalid machine id "nonsense"`) | 123 | c.Assert(err, gc.ErrorMatches, `invalid machine id "nonsense"`) |
217 | 124 | } | 124 | } |
218 | 125 | 125 | ||
220 | 126 | func (s *DestroyMachineSuite) TestEnvironmentArg(c *gc.C) { | 126 | func (s *RemoveMachineSuite) TestEnvironmentArg(c *gc.C) { |
221 | 127 | _, err := s.State.AddMachine("quantal", state.JobHostUnits) | 127 | _, err := s.State.AddMachine("quantal", state.JobHostUnits) |
222 | 128 | c.Assert(err, gc.IsNil) | 128 | c.Assert(err, gc.IsNil) |
224 | 129 | err = runDestroyMachine(c, "0", "-e", "dummyenv") | 129 | err = runRemoveMachine(c, "0", "-e", "dummyenv") |
225 | 130 | c.Assert(err, gc.IsNil) | 130 | c.Assert(err, gc.IsNil) |
226 | 131 | } | 131 | } |
227 | 132 | 132 | ||
228 | === renamed file 'cmd/juju/destroyrelation.go' => 'cmd/juju/removerelation.go' | |||
229 | --- cmd/juju/destroyrelation.go 2014-05-09 13:24:50 +0000 | |||
230 | +++ cmd/juju/removerelation.go 2014-05-11 22:53:23 +0000 | |||
231 | @@ -11,22 +11,22 @@ | |||
232 | 11 | "launchpad.net/juju-core/juju" | 11 | "launchpad.net/juju-core/juju" |
233 | 12 | ) | 12 | ) |
234 | 13 | 13 | ||
237 | 14 | // DestroyRelationCommand causes an existing service relation to be shut down. | 14 | // RemoveRelationCommand causes an existing service relation to be shut down. |
238 | 15 | type DestroyRelationCommand struct { | 15 | type RemoveRelationCommand struct { |
239 | 16 | envcmd.EnvCommandBase | 16 | envcmd.EnvCommandBase |
240 | 17 | Endpoints []string | 17 | Endpoints []string |
241 | 18 | } | 18 | } |
242 | 19 | 19 | ||
244 | 20 | func (c *DestroyRelationCommand) Info() *cmd.Info { | 20 | func (c *RemoveRelationCommand) Info() *cmd.Info { |
245 | 21 | return &cmd.Info{ | 21 | return &cmd.Info{ |
247 | 22 | Name: "destroy-relation", | 22 | Name: "remove-relation", |
248 | 23 | Args: "<service1>[:<relation name1>] <service2>[:<relation name2>]", | 23 | Args: "<service1>[:<relation name1>] <service2>[:<relation name2>]", |
251 | 24 | Purpose: "destroy a relation between two services", | 24 | Purpose: "remove a relation between two services", |
252 | 25 | Aliases: []string{"remove-relation"}, | 25 | Aliases: []string{"destroy-relation"}, |
253 | 26 | } | 26 | } |
254 | 27 | } | 27 | } |
255 | 28 | 28 | ||
257 | 29 | func (c *DestroyRelationCommand) Init(args []string) error { | 29 | func (c *RemoveRelationCommand) Init(args []string) error { |
258 | 30 | if err := c.EnsureEnvName(); err != nil { | 30 | if err := c.EnsureEnvName(); err != nil { |
259 | 31 | return err | 31 | return err |
260 | 32 | } | 32 | } |
261 | @@ -37,7 +37,7 @@ | |||
262 | 37 | return nil | 37 | return nil |
263 | 38 | } | 38 | } |
264 | 39 | 39 | ||
266 | 40 | func (c *DestroyRelationCommand) Run(_ *cmd.Context) error { | 40 | func (c *RemoveRelationCommand) Run(_ *cmd.Context) error { |
267 | 41 | client, err := juju.NewAPIClientFromName(c.EnvName) | 41 | client, err := juju.NewAPIClientFromName(c.EnvName) |
268 | 42 | if err != nil { | 42 | if err != nil { |
269 | 43 | return err | 43 | return err |
270 | 44 | 44 | ||
271 | === renamed file 'cmd/juju/destroyrelation_test.go' => 'cmd/juju/removerelation_test.go' | |||
272 | --- cmd/juju/destroyrelation_test.go 2013-09-13 14:48:13 +0000 | |||
273 | +++ cmd/juju/removerelation_test.go 2014-05-11 22:53:23 +0000 | |||
274 | @@ -10,18 +10,18 @@ | |||
275 | 10 | "launchpad.net/juju-core/testing" | 10 | "launchpad.net/juju-core/testing" |
276 | 11 | ) | 11 | ) |
277 | 12 | 12 | ||
279 | 13 | type DestroyRelationSuite struct { | 13 | type RemoveRelationSuite struct { |
280 | 14 | jujutesting.RepoSuite | 14 | jujutesting.RepoSuite |
281 | 15 | } | 15 | } |
282 | 16 | 16 | ||
284 | 17 | var _ = gc.Suite(&DestroyRelationSuite{}) | 17 | var _ = gc.Suite(&RemoveRelationSuite{}) |
285 | 18 | 18 | ||
288 | 19 | func runDestroyRelation(c *gc.C, args ...string) error { | 19 | func runRemoveRelation(c *gc.C, args ...string) error { |
289 | 20 | _, err := testing.RunCommand(c, &DestroyRelationCommand{}, args) | 20 | _, err := testing.RunCommand(c, &RemoveRelationCommand{}, args) |
290 | 21 | return err | 21 | return err |
291 | 22 | } | 22 | } |
292 | 23 | 23 | ||
294 | 24 | func (s *DestroyRelationSuite) TestDestroyRelation(c *gc.C) { | 24 | func (s *RemoveRelationSuite) TestRemoveRelation(c *gc.C) { |
295 | 25 | testing.Charms.BundlePath(s.SeriesPath, "riak") | 25 | testing.Charms.BundlePath(s.SeriesPath, "riak") |
296 | 26 | err := runDeploy(c, "local:riak", "riak") | 26 | err := runDeploy(c, "local:riak", "riak") |
297 | 27 | c.Assert(err, gc.IsNil) | 27 | c.Assert(err, gc.IsNil) |
298 | @@ -31,16 +31,16 @@ | |||
299 | 31 | runAddRelation(c, "riak", "logging") | 31 | runAddRelation(c, "riak", "logging") |
300 | 32 | 32 | ||
301 | 33 | // Destroy a relation that exists. | 33 | // Destroy a relation that exists. |
303 | 34 | err = runDestroyRelation(c, "logging", "riak") | 34 | err = runRemoveRelation(c, "logging", "riak") |
304 | 35 | c.Assert(err, gc.IsNil) | 35 | c.Assert(err, gc.IsNil) |
305 | 36 | 36 | ||
306 | 37 | // Destroy a relation that used to exist. | 37 | // Destroy a relation that used to exist. |
308 | 38 | err = runDestroyRelation(c, "riak", "logging") | 38 | err = runRemoveRelation(c, "riak", "logging") |
309 | 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`) |
310 | 40 | 40 | ||
311 | 41 | // Invalid removes. | 41 | // Invalid removes. |
313 | 42 | err = runDestroyRelation(c, "ping", "pong") | 42 | err = runRemoveRelation(c, "ping", "pong") |
314 | 43 | c.Assert(err, gc.ErrorMatches, `service "ping" not found`) | 43 | c.Assert(err, gc.ErrorMatches, `service "ping" not found`) |
316 | 44 | err = runDestroyRelation(c, "riak") | 44 | err = runRemoveRelation(c, "riak") |
317 | 45 | c.Assert(err, gc.ErrorMatches, `a relation must involve two services`) | 45 | c.Assert(err, gc.ErrorMatches, `a relation must involve two services`) |
318 | 46 | } | 46 | } |
319 | 47 | 47 | ||
320 | === renamed file 'cmd/juju/destroyservice.go' => 'cmd/juju/removeservice.go' | |||
321 | --- cmd/juju/destroyservice.go 2014-05-09 13:24:50 +0000 | |||
322 | +++ cmd/juju/removeservice.go 2014-05-11 22:53:23 +0000 | |||
323 | @@ -12,23 +12,23 @@ | |||
324 | 12 | "launchpad.net/juju-core/names" | 12 | "launchpad.net/juju-core/names" |
325 | 13 | ) | 13 | ) |
326 | 14 | 14 | ||
329 | 15 | // DestroyServiceCommand causes an existing service to be destroyed. | 15 | // RemoveServiceCommand causes an existing service to be destroyed. |
330 | 16 | type DestroyServiceCommand struct { | 16 | type RemoveServiceCommand struct { |
331 | 17 | envcmd.EnvCommandBase | 17 | envcmd.EnvCommandBase |
332 | 18 | ServiceName string | 18 | ServiceName string |
333 | 19 | } | 19 | } |
334 | 20 | 20 | ||
336 | 21 | func (c *DestroyServiceCommand) Info() *cmd.Info { | 21 | func (c *RemoveServiceCommand) Info() *cmd.Info { |
337 | 22 | return &cmd.Info{ | 22 | return &cmd.Info{ |
339 | 23 | Name: "destroy-service", | 23 | Name: "remove-service", |
340 | 24 | Args: "<service>", | 24 | Args: "<service>", |
344 | 25 | Purpose: "destroy a service", | 25 | Purpose: "remove a service from the environment", |
345 | 26 | Doc: "Destroying a service will destroy all its units and relations.", | 26 | Doc: "Removing a service will remove all its units and relations.", |
346 | 27 | Aliases: []string{"remove-service"}, | 27 | Aliases: []string{"destroy-service"}, |
347 | 28 | } | 28 | } |
348 | 29 | } | 29 | } |
349 | 30 | 30 | ||
351 | 31 | func (c *DestroyServiceCommand) Init(args []string) error { | 31 | func (c *RemoveServiceCommand) Init(args []string) error { |
352 | 32 | if err := c.EnsureEnvName(); err != nil { | 32 | if err := c.EnsureEnvName(); err != nil { |
353 | 33 | return err | 33 | return err |
354 | 34 | } | 34 | } |
355 | @@ -42,7 +42,7 @@ | |||
356 | 42 | return cmd.CheckEmpty(args) | 42 | return cmd.CheckEmpty(args) |
357 | 43 | } | 43 | } |
358 | 44 | 44 | ||
360 | 45 | func (c *DestroyServiceCommand) Run(_ *cmd.Context) error { | 45 | func (c *RemoveServiceCommand) Run(_ *cmd.Context) error { |
361 | 46 | client, err := juju.NewAPIClientFromName(c.EnvName) | 46 | client, err := juju.NewAPIClientFromName(c.EnvName) |
362 | 47 | if err != nil { | 47 | if err != nil { |
363 | 48 | return err | 48 | return err |
364 | 49 | 49 | ||
365 | === renamed file 'cmd/juju/destroyservice_test.go' => 'cmd/juju/removeservice_test.go' | |||
366 | --- cmd/juju/destroyservice_test.go 2013-09-13 14:48:13 +0000 | |||
367 | +++ cmd/juju/removeservice_test.go 2014-05-11 22:53:23 +0000 | |||
368 | @@ -11,40 +11,40 @@ | |||
369 | 11 | "launchpad.net/juju-core/testing" | 11 | "launchpad.net/juju-core/testing" |
370 | 12 | ) | 12 | ) |
371 | 13 | 13 | ||
373 | 14 | type DestroyServiceSuite struct { | 14 | type RemoveServiceSuite struct { |
374 | 15 | jujutesting.RepoSuite | 15 | jujutesting.RepoSuite |
375 | 16 | } | 16 | } |
376 | 17 | 17 | ||
378 | 18 | var _ = gc.Suite(&DestroyServiceSuite{}) | 18 | var _ = gc.Suite(&RemoveServiceSuite{}) |
379 | 19 | 19 | ||
382 | 20 | func runDestroyService(c *gc.C, args ...string) error { | 20 | func runRemoveService(c *gc.C, args ...string) error { |
383 | 21 | _, err := testing.RunCommand(c, &DestroyServiceCommand{}, args) | 21 | _, err := testing.RunCommand(c, &RemoveServiceCommand{}, args) |
384 | 22 | return err | 22 | return err |
385 | 23 | } | 23 | } |
386 | 24 | 24 | ||
388 | 25 | func (s *DestroyServiceSuite) TestSuccess(c *gc.C) { | 25 | func (s *RemoveServiceSuite) TestSuccess(c *gc.C) { |
389 | 26 | // Destroy a service that exists. | 26 | // Destroy a service that exists. |
390 | 27 | testing.Charms.BundlePath(s.SeriesPath, "riak") | 27 | testing.Charms.BundlePath(s.SeriesPath, "riak") |
391 | 28 | err := runDeploy(c, "local:riak", "riak") | 28 | err := runDeploy(c, "local:riak", "riak") |
392 | 29 | c.Assert(err, gc.IsNil) | 29 | c.Assert(err, gc.IsNil) |
394 | 30 | err = runDestroyService(c, "riak") | 30 | err = runRemoveService(c, "riak") |
395 | 31 | c.Assert(err, gc.IsNil) | 31 | c.Assert(err, gc.IsNil) |
396 | 32 | riak, err := s.State.Service("riak") | 32 | riak, err := s.State.Service("riak") |
397 | 33 | c.Assert(err, gc.IsNil) | 33 | c.Assert(err, gc.IsNil) |
398 | 34 | c.Assert(riak.Life(), gc.Equals, state.Dying) | 34 | c.Assert(riak.Life(), gc.Equals, state.Dying) |
399 | 35 | } | 35 | } |
400 | 36 | 36 | ||
402 | 37 | func (s *DestroyServiceSuite) TestFailure(c *gc.C) { | 37 | func (s *RemoveServiceSuite) TestFailure(c *gc.C) { |
403 | 38 | // Destroy a service that does not exist. | 38 | // Destroy a service that does not exist. |
405 | 39 | err := runDestroyService(c, "gargleblaster") | 39 | err := runRemoveService(c, "gargleblaster") |
406 | 40 | c.Assert(err, gc.ErrorMatches, `service "gargleblaster" not found`) | 40 | c.Assert(err, gc.ErrorMatches, `service "gargleblaster" not found`) |
407 | 41 | } | 41 | } |
408 | 42 | 42 | ||
411 | 43 | func (s *DestroyServiceSuite) TestInvalidArgs(c *gc.C) { | 43 | func (s *RemoveServiceSuite) TestInvalidArgs(c *gc.C) { |
412 | 44 | err := runDestroyService(c) | 44 | err := runRemoveService(c) |
413 | 45 | c.Assert(err, gc.ErrorMatches, `no service specified`) | 45 | c.Assert(err, gc.ErrorMatches, `no service specified`) |
415 | 46 | err = runDestroyService(c, "ping", "pong") | 46 | err = runRemoveService(c, "ping", "pong") |
416 | 47 | c.Assert(err, gc.ErrorMatches, `unrecognized args: \["pong"\]`) | 47 | c.Assert(err, gc.ErrorMatches, `unrecognized args: \["pong"\]`) |
418 | 48 | err = runDestroyService(c, "invalid:name") | 48 | err = runRemoveService(c, "invalid:name") |
419 | 49 | c.Assert(err, gc.ErrorMatches, `invalid service name "invalid:name"`) | 49 | c.Assert(err, gc.ErrorMatches, `invalid service name "invalid:name"`) |
420 | 50 | } | 50 | } |
421 | 51 | 51 | ||
422 | === renamed file 'cmd/juju/destroyunit.go' => 'cmd/juju/removeunit.go' | |||
423 | --- cmd/juju/destroyunit.go 2014-05-09 13:24:50 +0000 | |||
424 | +++ cmd/juju/removeunit.go 2014-05-11 22:53:23 +0000 | |||
425 | @@ -13,22 +13,22 @@ | |||
426 | 13 | "launchpad.net/juju-core/names" | 13 | "launchpad.net/juju-core/names" |
427 | 14 | ) | 14 | ) |
428 | 15 | 15 | ||
431 | 16 | // DestroyUnitCommand is responsible for destroying service units. | 16 | // RemoveUnitCommand is responsible for destroying service units. |
432 | 17 | type DestroyUnitCommand struct { | 17 | type RemoveUnitCommand struct { |
433 | 18 | envcmd.EnvCommandBase | 18 | envcmd.EnvCommandBase |
434 | 19 | UnitNames []string | 19 | UnitNames []string |
435 | 20 | } | 20 | } |
436 | 21 | 21 | ||
438 | 22 | func (c *DestroyUnitCommand) Info() *cmd.Info { | 22 | func (c *RemoveUnitCommand) Info() *cmd.Info { |
439 | 23 | return &cmd.Info{ | 23 | return &cmd.Info{ |
441 | 24 | Name: "destroy-unit", | 24 | Name: "remove-unit", |
442 | 25 | Args: "<unit> [...]", | 25 | Args: "<unit> [...]", |
445 | 26 | Purpose: "destroy service units", | 26 | Purpose: "remove service units from the environment", |
446 | 27 | Aliases: []string{"remove-unit"}, | 27 | Aliases: []string{"destroy-unit"}, |
447 | 28 | } | 28 | } |
448 | 29 | } | 29 | } |
449 | 30 | 30 | ||
451 | 31 | func (c *DestroyUnitCommand) Init(args []string) error { | 31 | func (c *RemoveUnitCommand) Init(args []string) error { |
452 | 32 | if err := c.EnsureEnvName(); err != nil { | 32 | if err := c.EnsureEnvName(); err != nil { |
453 | 33 | return err | 33 | return err |
454 | 34 | } | 34 | } |
455 | @@ -46,7 +46,7 @@ | |||
456 | 46 | 46 | ||
457 | 47 | // Run connects to the environment specified on the command line and destroys | 47 | // Run connects to the environment specified on the command line and destroys |
458 | 48 | // units therein. | 48 | // units therein. |
460 | 49 | func (c *DestroyUnitCommand) Run(_ *cmd.Context) error { | 49 | func (c *RemoveUnitCommand) Run(_ *cmd.Context) error { |
461 | 50 | client, err := juju.NewAPIClientFromName(c.EnvName) | 50 | client, err := juju.NewAPIClientFromName(c.EnvName) |
462 | 51 | if err != nil { | 51 | if err != nil { |
463 | 52 | return err | 52 | return err |
464 | 53 | 53 | ||
465 | === renamed file 'cmd/juju/destroyunit_test.go' => 'cmd/juju/removeunit_test.go' | |||
466 | --- cmd/juju/destroyunit_test.go 2013-09-13 14:48:13 +0000 | |||
467 | +++ cmd/juju/removeunit_test.go 2014-05-11 22:53:23 +0000 | |||
468 | @@ -12,25 +12,25 @@ | |||
469 | 12 | "launchpad.net/juju-core/testing" | 12 | "launchpad.net/juju-core/testing" |
470 | 13 | ) | 13 | ) |
471 | 14 | 14 | ||
473 | 15 | type DestroyUnitSuite struct { | 15 | type RemoveUnitSuite struct { |
474 | 16 | jujutesting.RepoSuite | 16 | jujutesting.RepoSuite |
475 | 17 | } | 17 | } |
476 | 18 | 18 | ||
478 | 19 | var _ = gc.Suite(&DestroyUnitSuite{}) | 19 | var _ = gc.Suite(&RemoveUnitSuite{}) |
479 | 20 | 20 | ||
482 | 21 | func runDestroyUnit(c *gc.C, args ...string) error { | 21 | func runRemoveUnit(c *gc.C, args ...string) error { |
483 | 22 | _, err := testing.RunCommand(c, &DestroyUnitCommand{}, args) | 22 | _, err := testing.RunCommand(c, &RemoveUnitCommand{}, args) |
484 | 23 | return err | 23 | return err |
485 | 24 | } | 24 | } |
486 | 25 | 25 | ||
488 | 26 | func (s *DestroyUnitSuite) TestDestroyUnit(c *gc.C) { | 26 | func (s *RemoveUnitSuite) TestRemoveUnit(c *gc.C) { |
489 | 27 | testing.Charms.BundlePath(s.SeriesPath, "dummy") | 27 | testing.Charms.BundlePath(s.SeriesPath, "dummy") |
490 | 28 | err := runDeploy(c, "-n", "2", "local:dummy", "dummy") | 28 | err := runDeploy(c, "-n", "2", "local:dummy", "dummy") |
491 | 29 | c.Assert(err, gc.IsNil) | 29 | c.Assert(err, gc.IsNil) |
492 | 30 | curl := charm.MustParseURL("local:precise/dummy-1") | 30 | curl := charm.MustParseURL("local:precise/dummy-1") |
493 | 31 | svc, _ := s.AssertService(c, "dummy", curl, 2, 0) | 31 | svc, _ := s.AssertService(c, "dummy", curl, 2, 0) |
494 | 32 | 32 | ||
496 | 33 | err = runDestroyUnit(c, "dummy/0", "dummy/1", "dummy/2", "sillybilly/17") | 33 | err = runRemoveUnit(c, "dummy/0", "dummy/1", "dummy/2", "sillybilly/17") |
497 | 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`) |
498 | 35 | units, err := svc.AllUnits() | 35 | units, err := svc.AllUnits() |
499 | 36 | c.Assert(err, gc.IsNil) | 36 | c.Assert(err, gc.IsNil) |
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): cmd_test. go removemachine. go removemachine_ test.go removerelation. go removerelation_ test.go removeservice. go removeservice_ test.go removeunit. go removeunit_ test.go manual/ provisioner. go params/ params. go /client/ client. go /client/ client_ test.go /client/ perm_test. go its_test. go test.go nit_test. go
A [revision details]
M cmd/juju/
M cmd/juju/main.go
M cmd/juju/
M cmd/juju/
M cmd/juju/
M cmd/juju/
M cmd/juju/
M cmd/juju/
M cmd/juju/
M cmd/juju/
M environs/
M state/api/client.go
M state/api/
M state/apiserver
M state/apiserver
M state/apiserver
M state/minimumun
M state/relation_
M state/relationu
M state/unit_test.go