Merge lp:~dave-cheney/juju-core/108-set-addresses-take-varargs into lp:~go-bot/juju-core/trunk
- 108-set-addresses-take-varargs
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Dave Cheney | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 2522 | ||||
Proposed branch: | lp:~dave-cheney/juju-core/108-set-addresses-take-varargs | ||||
Merge into: | lp:~go-bot/juju-core/trunk | ||||
Diff against target: |
461 lines (+43/-65) 23 files modified
cmd/juju/scp_test.go (+1/-1) cmd/juju/ssh_test.go (+1/-1) cmd/juju/status_test.go (+1/-1) cmd/jujud/machine_test.go (+1/-1) juju/testing/utils.go (+1/-3) state/api/deployer/deployer_test.go (+2/-5) state/api/machiner/machiner_test.go (+1/-1) state/api/provisioner/provisioner_test.go (+2/-4) state/apiserver/client/client_test.go (+6/-6) state/apiserver/client/run_test.go (+2/-2) state/apiserver/deployer/deployer_test.go (+2/-6) state/apiserver/uniter/uniter_test.go (+1/-3) state/machine.go (+1/-1) state/machine_test.go (+1/-1) state/megawatcher_internal_test.go (+1/-2) state/state_test.go (+5/-5) state/unit_test.go (+5/-7) worker/instancepoller/machine_test.go (+1/-1) worker/instancepoller/updater.go (+2/-2) worker/provisioner/kvm-broker_test.go (+1/-3) worker/provisioner/lxc-broker_test.go (+1/-3) worker/provisioner/provisioner_test.go (+1/-3) worker/uniter/uniter_test.go (+3/-3) |
||||
To merge this branch: | bzr merge lp:~dave-cheney/juju-core/108-set-addresses-take-varargs | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+213393@code.launchpad.net |
Commit message
unit.SetAddress now takes a vararg
Update LP#1298770
The previous branch updated instance.NewAddress to be varargs and demonstated that most callers of NewAddresses were used to get a slice of addresses so they could pass them to unit.SetAddresses. By making SetAddresses vararg NewAddresses is unneeded. This will be the next change.
Description of the change
unit.SetAddress now takes a vararg
Update LP#1298770
The previous branch updated instance.NewAddress to be varargs and demonstated that most callers of NewAddresses were used to get a slice of addresses so they could pass them to unit.SetAddresses. By making SetAddresses vararg NewAddresses is unneeded. This will be next change.
Dave Cheney (dave-cheney) wrote : | # |
Roger Peppe (rogpeppe) wrote : | # |
On 2014/03/31 01:25:18, dfc wrote:
> Please take a look.
LGTM, a definite win.
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~dave-cheney/juju-core/108-set-addresses-take-varargs into lp:juju-core failed. Below is the output from the failed tests.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
Dave Cheney (dave-cheney) wrote : | # |
Please take a look.
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~dave-cheney/juju-core/108-set-addresses-take-varargs into lp:juju-core failed. Below is the output from the failed tests.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
Dave Cheney (dave-cheney) wrote : | # |
Please take a look.
Preview Diff
1 | === modified file 'cmd/juju/scp_test.go' |
2 | --- cmd/juju/scp_test.go 2014-03-20 02:30:15 +0000 |
3 | +++ cmd/juju/scp_test.go 2014-03-31 23:06:49 +0000 |
4 | @@ -113,7 +113,7 @@ |
5 | Type: instance.Ipv4Address, // ..because SelectPublicAddress ignores IPv6 addresses |
6 | NetworkScope: instance.NetworkPublic, |
7 | } |
8 | - err = m[3].SetAddresses([]instance.Address{ipv6Addr}) |
9 | + err = m[3].SetAddresses(ipv6Addr) |
10 | c.Assert(err, gc.IsNil) |
11 | srv = s.AddTestingService(c, "ipv6-svc", dummyCharm) |
12 | s.addUnit(srv, m[3], c) |
13 | |
14 | === modified file 'cmd/juju/ssh_test.go' |
15 | --- cmd/juju/ssh_test.go 2014-03-20 02:30:15 +0000 |
16 | +++ cmd/juju/ssh_test.go 2014-03-31 23:06:49 +0000 |
17 | @@ -163,7 +163,7 @@ |
18 | func (s *SSHCommonSuite) setAddress(m *state.Machine, c *gc.C) { |
19 | addr := instance.NewAddress(fmt.Sprintf("dummyenv-%s.dns", m.Id())) |
20 | addr.NetworkScope = instance.NetworkPublic |
21 | - err := m.SetAddresses([]instance.Address{addr}) |
22 | + err := m.SetAddresses(addr) |
23 | c.Assert(err, gc.IsNil) |
24 | } |
25 | |
26 | |
27 | === modified file 'cmd/juju/status_test.go' |
28 | --- cmd/juju/status_test.go 2014-03-31 09:32:10 +0000 |
29 | +++ cmd/juju/status_test.go 2014-03-31 23:06:49 +0000 |
30 | @@ -1626,7 +1626,7 @@ |
31 | func (sa setAddresses) step(c *gc.C, ctx *context) { |
32 | m, err := ctx.st.Machine(sa.machineId) |
33 | c.Assert(err, gc.IsNil) |
34 | - err = m.SetAddresses(sa.addresses) |
35 | + err = m.SetAddresses(sa.addresses...) |
36 | c.Assert(err, gc.IsNil) |
37 | } |
38 | |
39 | |
40 | === modified file 'cmd/jujud/machine_test.go' |
41 | --- cmd/jujud/machine_test.go 2014-03-27 18:25:41 +0000 |
42 | +++ cmd/jujud/machine_test.go 2014-03-31 23:06:49 +0000 |
43 | @@ -298,7 +298,7 @@ |
44 | addrs := []instance.Address{ |
45 | instance.NewAddress("0.1.2.3"), |
46 | } |
47 | - err := machine.SetAddresses(addrs) |
48 | + err := machine.SetAddresses(addrs...) |
49 | c.Assert(err, gc.IsNil) |
50 | // Set the addresses in the environ instance as well so that if the instance poller |
51 | // runs it won't overwrite them. |
52 | |
53 | === modified file 'juju/testing/utils.go' |
54 | --- juju/testing/utils.go 2014-03-07 22:45:37 +0000 |
55 | +++ juju/testing/utils.go 2014-03-31 23:06:49 +0000 |
56 | @@ -20,9 +20,7 @@ |
57 | func AddStateServerMachine(c *gc.C, st *state.State) *state.Machine { |
58 | machine, err := st.AddMachine("quantal", state.JobManageEnviron) |
59 | c.Assert(err, gc.IsNil) |
60 | - err = machine.SetAddresses([]instance.Address{ |
61 | - instance.NewAddress("0.1.2.3"), |
62 | - }) |
63 | + err = machine.SetAddresses(instance.NewAddress("0.1.2.3")) |
64 | c.Assert(err, gc.IsNil) |
65 | return machine |
66 | } |
67 | |
68 | === modified file 'state/api/deployer/deployer_test.go' |
69 | --- state/api/deployer/deployer_test.go 2014-03-28 07:27:26 +0000 |
70 | +++ state/api/deployer/deployer_test.go 2014-03-31 23:06:49 +0000 |
71 | @@ -46,7 +46,7 @@ |
72 | func (s *deployerSuite) SetUpTest(c *gc.C) { |
73 | s.JujuConnSuite.SetUpTest(c) |
74 | s.stateAPI, s.machine = s.OpenAPIAsNewMachine(c, state.JobManageEnviron, state.JobHostUnits) |
75 | - err := s.machine.SetAddresses(instance.NewAddresses("0.1.2.3")) |
76 | + err := s.machine.SetAddresses(instance.NewAddress("0.1.2.3")) |
77 | c.Assert(err, gc.IsNil) |
78 | |
79 | // Create the needed services and relate them. |
80 | @@ -237,10 +237,7 @@ |
81 | } |
82 | |
83 | func (s *deployerSuite) TestStateAddresses(c *gc.C) { |
84 | - addrs := []instance.Address{ |
85 | - instance.NewAddress("0.1.2.3"), |
86 | - } |
87 | - err := s.machine.SetAddresses(addrs) |
88 | + err := s.machine.SetAddresses(instance.NewAddress("0.1.2.3")) |
89 | c.Assert(err, gc.IsNil) |
90 | |
91 | stateAddresses, err := s.State.Addresses() |
92 | |
93 | === modified file 'state/api/machiner/machiner_test.go' |
94 | --- state/api/machiner/machiner_test.go 2014-03-28 07:27:26 +0000 |
95 | +++ state/api/machiner/machiner_test.go 2014-03-31 23:06:49 +0000 |
96 | @@ -41,7 +41,7 @@ |
97 | s.JujuConnSuite.SetUpTest(c) |
98 | m, err := s.State.AddMachine("quantal", state.JobManageEnviron) |
99 | c.Assert(err, gc.IsNil) |
100 | - err = m.SetAddresses(instance.NewAddresses("127.0.0.1")) |
101 | + err = m.SetAddresses(instance.NewAddress("127.0.0.1")) |
102 | c.Assert(err, gc.IsNil) |
103 | |
104 | s.st, s.machine = s.OpenAPIAsNewMachine(c) |
105 | |
106 | === modified file 'state/api/provisioner/provisioner_test.go' |
107 | --- state/api/provisioner/provisioner_test.go 2014-03-28 07:27:26 +0000 |
108 | +++ state/api/provisioner/provisioner_test.go 2014-03-31 23:06:49 +0000 |
109 | @@ -56,7 +56,7 @@ |
110 | c.Assert(err, gc.IsNil) |
111 | s.st = s.OpenAPIAsMachine(c, s.machine.Tag(), password, "fake_nonce") |
112 | c.Assert(s.st, gc.NotNil) |
113 | - err = s.machine.SetAddresses(instance.NewAddresses("0.1.2.3")) |
114 | + err = s.machine.SetAddresses(instance.NewAddress("0.1.2.3")) |
115 | c.Assert(err, gc.IsNil) |
116 | |
117 | // Create the provisioner API facade. |
118 | @@ -367,9 +367,7 @@ |
119 | } |
120 | |
121 | func (s *provisionerSuite) TestStateAddresses(c *gc.C) { |
122 | - err := s.machine.SetAddresses([]instance.Address{ |
123 | - instance.NewAddress("0.1.2.3"), |
124 | - }) |
125 | + err := s.machine.SetAddresses(instance.NewAddress("0.1.2.3")) |
126 | c.Assert(err, gc.IsNil) |
127 | |
128 | stateAddresses, err := s.State.Addresses() |
129 | |
130 | === modified file 'state/apiserver/client/client_test.go' |
131 | --- state/apiserver/client/client_test.go 2014-03-28 13:31:26 +0000 |
132 | +++ state/apiserver/client/client_test.go 2014-03-31 23:06:49 +0000 |
133 | @@ -1404,12 +1404,12 @@ |
134 | cloudLocalAddress.NetworkScope = instance.NetworkCloudLocal |
135 | publicAddress := instance.NewAddress("public") |
136 | publicAddress.NetworkScope = instance.NetworkPublic |
137 | - err = m1.SetAddresses([]instance.Address{cloudLocalAddress}) |
138 | + err = m1.SetAddresses(cloudLocalAddress) |
139 | c.Assert(err, gc.IsNil) |
140 | addr, err := s.APIState.Client().PublicAddress("1") |
141 | c.Assert(err, gc.IsNil) |
142 | c.Assert(addr, gc.Equals, "cloudlocal") |
143 | - err = m1.SetAddresses([]instance.Address{cloudLocalAddress, publicAddress}) |
144 | + err = m1.SetAddresses(cloudLocalAddress, publicAddress) |
145 | addr, err = s.APIState.Client().PublicAddress("1") |
146 | c.Assert(err, gc.IsNil) |
147 | c.Assert(addr, gc.Equals, "public") |
148 | @@ -1423,7 +1423,7 @@ |
149 | m1, err := s.State.Machine("1") |
150 | publicAddress := instance.NewAddress("public") |
151 | publicAddress.NetworkScope = instance.NetworkPublic |
152 | - err = m1.SetAddresses([]instance.Address{publicAddress}) |
153 | + err = m1.SetAddresses(publicAddress) |
154 | c.Assert(err, gc.IsNil) |
155 | addr, err := s.APIState.Client().PublicAddress("wordpress/0") |
156 | c.Assert(err, gc.IsNil) |
157 | @@ -1464,12 +1464,12 @@ |
158 | cloudLocalAddress.NetworkScope = instance.NetworkCloudLocal |
159 | publicAddress := instance.NewAddress("public") |
160 | publicAddress.NetworkScope = instance.NetworkPublic |
161 | - err = m1.SetAddresses([]instance.Address{publicAddress}) |
162 | + err = m1.SetAddresses(publicAddress) |
163 | c.Assert(err, gc.IsNil) |
164 | addr, err := s.APIState.Client().PrivateAddress("1") |
165 | c.Assert(err, gc.IsNil) |
166 | c.Assert(addr, gc.Equals, "public") |
167 | - err = m1.SetAddresses([]instance.Address{cloudLocalAddress, publicAddress}) |
168 | + err = m1.SetAddresses(cloudLocalAddress, publicAddress) |
169 | addr, err = s.APIState.Client().PrivateAddress("1") |
170 | c.Assert(err, gc.IsNil) |
171 | c.Assert(addr, gc.Equals, "cloudlocal") |
172 | @@ -1483,7 +1483,7 @@ |
173 | m1, err := s.State.Machine("1") |
174 | publicAddress := instance.NewAddress("public") |
175 | publicAddress.NetworkScope = instance.NetworkCloudLocal |
176 | - err = m1.SetAddresses([]instance.Address{publicAddress}) |
177 | + err = m1.SetAddresses(publicAddress) |
178 | c.Assert(err, gc.IsNil) |
179 | addr, err := s.APIState.Client().PrivateAddress("wordpress/0") |
180 | c.Assert(err, gc.IsNil) |
181 | |
182 | === modified file 'state/apiserver/client/run_test.go' |
183 | --- state/apiserver/client/run_test.go 2014-03-25 15:06:31 +0000 |
184 | +++ state/apiserver/client/run_test.go 2014-03-31 23:06:49 +0000 |
185 | @@ -35,7 +35,7 @@ |
186 | |
187 | func (s *runSuite) addMachineWithAddress(c *gc.C, address string) *state.Machine { |
188 | machine := s.addMachine(c) |
189 | - machine.SetAddresses([]instance.Address{instance.NewAddress(address)}) |
190 | + machine.SetAddresses(instance.NewAddress(address)) |
191 | return machine |
192 | } |
193 | |
194 | @@ -70,7 +70,7 @@ |
195 | c.Assert(err, gc.IsNil) |
196 | machine, err := s.State.Machine(mId) |
197 | c.Assert(err, gc.IsNil) |
198 | - machine.SetAddresses([]instance.Address{instance.NewAddress("10.3.2.1")}) |
199 | + machine.SetAddresses(instance.NewAddress("10.3.2.1")) |
200 | return unit |
201 | } |
202 | |
203 | |
204 | === modified file 'state/apiserver/deployer/deployer_test.go' |
205 | --- state/apiserver/deployer/deployer_test.go 2014-03-17 13:22:55 +0000 |
206 | +++ state/apiserver/deployer/deployer_test.go 2014-03-31 23:06:49 +0000 |
207 | @@ -300,9 +300,7 @@ |
208 | } |
209 | |
210 | func (s *deployerSuite) TestStateAddresses(c *gc.C) { |
211 | - err := s.machine0.SetAddresses([]instance.Address{ |
212 | - instance.NewAddress("0.1.2.3"), |
213 | - }) |
214 | + err := s.machine0.SetAddresses(instance.NewAddress("0.1.2.3")) |
215 | c.Assert(err, gc.IsNil) |
216 | |
217 | addresses, err := s.State.Addresses() |
218 | @@ -316,9 +314,7 @@ |
219 | } |
220 | |
221 | func (s *deployerSuite) TestAPIAddresses(c *gc.C) { |
222 | - err := s.machine0.SetAddresses([]instance.Address{ |
223 | - instance.NewAddress("0.1.2.3"), |
224 | - }) |
225 | + err := s.machine0.SetAddresses(instance.NewAddress("0.1.2.3")) |
226 | c.Assert(err, gc.IsNil) |
227 | |
228 | apiAddresses, err := s.State.APIAddressesFromMachines() |
229 | |
230 | === modified file 'state/apiserver/uniter/uniter_test.go' |
231 | --- state/apiserver/uniter/uniter_test.go 2014-03-26 00:24:30 +0000 |
232 | +++ state/apiserver/uniter/uniter_test.go 2014-03-31 23:06:49 +0000 |
233 | @@ -1424,9 +1424,7 @@ |
234 | } |
235 | |
236 | func (s *uniterSuite) TestAPIAddresses(c *gc.C) { |
237 | - err := s.machine0.SetAddresses([]instance.Address{ |
238 | - instance.NewAddress("0.1.2.3"), |
239 | - }) |
240 | + err := s.machine0.SetAddresses(instance.NewAddress("0.1.2.3")) |
241 | c.Assert(err, gc.IsNil) |
242 | apiAddresses, err := s.State.APIAddressesFromMachines() |
243 | c.Assert(err, gc.IsNil) |
244 | |
245 | === modified file 'state/machine.go' |
246 | --- state/machine.go 2014-03-26 11:34:48 +0000 |
247 | +++ state/machine.go 2014-03-31 23:06:49 +0000 |
248 | @@ -834,7 +834,7 @@ |
249 | |
250 | // SetAddresses records any addresses related to the machine, sourced |
251 | // by asking the provider. |
252 | -func (m *Machine) SetAddresses(addresses []instance.Address) (err error) { |
253 | +func (m *Machine) SetAddresses(addresses ...instance.Address) (err error) { |
254 | stateAddresses := instanceAddressesToAddresses(addresses) |
255 | ops := []txn.Op{ |
256 | { |
257 | |
258 | === modified file 'state/machine_test.go' |
259 | --- state/machine_test.go 2014-03-28 04:37:31 +0000 |
260 | +++ state/machine_test.go 2014-03-31 23:06:49 +0000 |
261 | @@ -1221,7 +1221,7 @@ |
262 | instance.NewAddress("127.0.0.1"), |
263 | instance.NewAddress("8.8.8.8"), |
264 | } |
265 | - err = machine.SetAddresses(addresses) |
266 | + err = machine.SetAddresses(addresses...) |
267 | c.Assert(err, gc.IsNil) |
268 | err = machine.Refresh() |
269 | c.Assert(err, gc.IsNil) |
270 | |
271 | === modified file 'state/megawatcher_internal_test.go' |
272 | --- state/megawatcher_internal_test.go 2014-03-28 07:27:26 +0000 |
273 | +++ state/megawatcher_internal_test.go 2014-03-31 23:06:49 +0000 |
274 | @@ -78,8 +78,7 @@ |
275 | c.Assert(err, gc.IsNil) |
276 | hc, err := m.HardwareCharacteristics() |
277 | c.Assert(err, gc.IsNil) |
278 | - addresses := instance.NewAddresses("example.com") |
279 | - err = m.SetAddresses(addresses) |
280 | + err = m.SetAddresses(instance.NewAddress("example.com")) |
281 | c.Assert(err, gc.IsNil) |
282 | add(¶ms.MachineInfo{ |
283 | Id: "0", |
284 | |
285 | === modified file 'state/state_test.go' |
286 | --- state/state_test.go 2014-03-27 12:53:54 +0000 |
287 | +++ state/state_test.go 2014-03-31 23:06:49 +0000 |
288 | @@ -78,23 +78,23 @@ |
289 | c.Assert(err, gc.IsNil) |
290 | |
291 | for i, m := range machines { |
292 | - err := m.SetAddresses([]instance.Address{{ |
293 | + err := m.SetAddresses(instance.Address{ |
294 | Type: instance.Ipv4Address, |
295 | NetworkScope: instance.NetworkCloudLocal, |
296 | Value: fmt.Sprintf("10.0.0.%d", i), |
297 | - }, { |
298 | + }, instance.Address{ |
299 | Type: instance.Ipv6Address, |
300 | NetworkScope: instance.NetworkCloudLocal, |
301 | Value: "::1", |
302 | - }, { |
303 | + }, instance.Address{ |
304 | Type: instance.Ipv4Address, |
305 | NetworkScope: instance.NetworkMachineLocal, |
306 | Value: "127.0.0.1", |
307 | - }, { |
308 | + }, instance.Address{ |
309 | Type: instance.Ipv4Address, |
310 | NetworkScope: instance.NetworkPublic, |
311 | Value: "5.4.3.2", |
312 | - }}) |
313 | + }) |
314 | c.Assert(err, gc.IsNil) |
315 | } |
316 | envConfig, err := s.State.EnvironConfig() |
317 | |
318 | === modified file 'state/unit_test.go' |
319 | --- state/unit_test.go 2014-03-31 03:15:04 +0000 |
320 | +++ state/unit_test.go 2014-03-31 23:06:49 +0000 |
321 | @@ -194,15 +194,15 @@ |
322 | c.Assert(err, gc.IsNil) |
323 | err = machine.SetProvisioned("i-exist", "fake_nonce", nil) |
324 | c.Assert(err, gc.IsNil) |
325 | - err = machine.SetAddresses([]instance.Address{{ |
326 | + err = machine.SetAddresses(instance.Address{ |
327 | Type: instance.Ipv4Address, |
328 | NetworkScope: instance.NetworkCloudLocal, |
329 | Value: "private.address.example.com", |
330 | - }, { |
331 | + }, instance.Address{ |
332 | Type: instance.Ipv4Address, |
333 | NetworkScope: instance.NetworkPublic, |
334 | Value: "public.address.example.com", |
335 | - }}) |
336 | + }) |
337 | c.Assert(err, gc.IsNil) |
338 | } |
339 | |
340 | @@ -233,8 +233,7 @@ |
341 | private := instance.NewAddress("127.0.0.1") |
342 | private.NetworkScope = instance.NetworkCloudLocal |
343 | |
344 | - addresses := []instance.Address{public, private} |
345 | - err = machine.SetAddresses(addresses) |
346 | + err = machine.SetAddresses(public, private) |
347 | c.Assert(err, gc.IsNil) |
348 | |
349 | address, ok = s.unit.PublicAddress() |
350 | @@ -286,8 +285,7 @@ |
351 | private := instance.NewAddress("127.0.0.1") |
352 | private.NetworkScope = instance.NetworkCloudLocal |
353 | |
354 | - addresses := []instance.Address{public, private} |
355 | - err = machine.SetAddresses(addresses) |
356 | + err = machine.SetAddresses(public, private) |
357 | c.Assert(err, gc.IsNil) |
358 | |
359 | address, ok = s.unit.PrivateAddress() |
360 | |
361 | === modified file 'worker/instancepoller/machine_test.go' |
362 | --- worker/instancepoller/machine_test.go 2014-03-19 03:48:12 +0000 |
363 | +++ worker/instancepoller/machine_test.go 2014-03-31 23:06:49 +0000 |
364 | @@ -362,7 +362,7 @@ |
365 | return nil |
366 | } |
367 | |
368 | -func (m *testMachine) SetAddresses(addrs []instance.Address) error { |
369 | +func (m *testMachine) SetAddresses(addrs ...instance.Address) error { |
370 | if m.setAddressesErr != nil { |
371 | return m.setAddressesErr |
372 | } |
373 | |
374 | === modified file 'worker/instancepoller/updater.go' |
375 | --- worker/instancepoller/updater.go 2014-03-05 19:41:34 +0000 |
376 | +++ worker/instancepoller/updater.go 2014-03-31 23:06:49 +0000 |
377 | @@ -35,7 +35,7 @@ |
378 | Id() string |
379 | InstanceId() (instance.Id, error) |
380 | Addresses() []instance.Address |
381 | - SetAddresses([]instance.Address) error |
382 | + SetAddresses(...instance.Address) error |
383 | InstanceStatus() (string, error) |
384 | SetInstanceStatus(status string) error |
385 | String() string |
386 | @@ -247,7 +247,7 @@ |
387 | } |
388 | if !addressesEqual(m.Addresses(), instInfo.addresses) { |
389 | logger.Infof("machine %q has new addresses: %v", m.Id(), instInfo.addresses) |
390 | - if err = m.SetAddresses(instInfo.addresses); err != nil { |
391 | + if err = m.SetAddresses(instInfo.addresses...); err != nil { |
392 | logger.Errorf("cannot set addresses on %q: %v", m, err) |
393 | } |
394 | } |
395 | |
396 | === modified file 'worker/provisioner/kvm-broker_test.go' |
397 | --- worker/provisioner/kvm-broker_test.go 2014-03-14 02:19:35 +0000 |
398 | +++ worker/provisioner/kvm-broker_test.go 2014-03-31 23:06:49 +0000 |
399 | @@ -163,9 +163,7 @@ |
400 | // to be in state, in order to get the watcher. |
401 | m, err := s.State.AddMachine(config.DefaultSeries, state.JobHostUnits, state.JobManageEnviron) |
402 | c.Assert(err, gc.IsNil) |
403 | - err = m.SetAddresses([]instance.Address{ |
404 | - instance.NewAddress("0.1.2.3"), |
405 | - }) |
406 | + err = m.SetAddresses(instance.NewAddress("0.1.2.3")) |
407 | c.Assert(err, gc.IsNil) |
408 | s.machineId = m.Id() |
409 | s.APILogin(c, m) |
410 | |
411 | === modified file 'worker/provisioner/lxc-broker_test.go' |
412 | --- worker/provisioner/lxc-broker_test.go 2014-03-27 19:30:54 +0000 |
413 | +++ worker/provisioner/lxc-broker_test.go 2014-03-31 23:06:49 +0000 |
414 | @@ -192,9 +192,7 @@ |
415 | // to be in state, in order to get the watcher. |
416 | m, err := s.State.AddMachine(config.DefaultSeries, state.JobHostUnits, state.JobManageEnviron) |
417 | c.Assert(err, gc.IsNil) |
418 | - err = m.SetAddresses([]instance.Address{ |
419 | - instance.NewAddress("0.1.2.3"), |
420 | - }) |
421 | + err = m.SetAddresses(instance.NewAddress("0.1.2.3")) |
422 | c.Assert(err, gc.IsNil) |
423 | s.parentMachineId = m.Id() |
424 | s.APILogin(c, m) |
425 | |
426 | === modified file 'worker/provisioner/provisioner_test.go' |
427 | --- worker/provisioner/provisioner_test.go 2014-03-26 07:43:22 +0000 |
428 | +++ worker/provisioner/provisioner_test.go 2014-03-31 23:06:49 +0000 |
429 | @@ -110,9 +110,7 @@ |
430 | machine, err := s.State.AddMachine("quantal", state.JobManageEnviron) |
431 | c.Assert(err, gc.IsNil) |
432 | c.Assert(machine.Id(), gc.Equals, "0") |
433 | - err = machine.SetAddresses([]instance.Address{ |
434 | - instance.NewAddress("0.1.2.3"), |
435 | - }) |
436 | + err = machine.SetAddresses(instance.NewAddress("0.1.2.3")) |
437 | c.Assert(err, gc.IsNil) |
438 | s.APILogin(c, machine) |
439 | } |
440 | |
441 | === modified file 'worker/uniter/uniter_test.go' |
442 | --- worker/uniter/uniter_test.go 2014-03-31 03:15:04 +0000 |
443 | +++ worker/uniter/uniter_test.go 2014-03-31 23:06:49 +0000 |
444 | @@ -1098,15 +1098,15 @@ |
445 | c.Assert(err, gc.IsNil) |
446 | err = machine.SetProvisioned("i-exist", "fake_nonce", nil) |
447 | c.Assert(err, gc.IsNil) |
448 | - err = machine.SetAddresses([]instance.Address{{ |
449 | + err = machine.SetAddresses(instance.Address{ |
450 | Type: instance.Ipv4Address, |
451 | NetworkScope: instance.NetworkCloudLocal, |
452 | Value: "private.address.example.com", |
453 | - }, { |
454 | + }, instance.Address{ |
455 | Type: instance.Ipv4Address, |
456 | NetworkScope: instance.NetworkPublic, |
457 | Value: "public.address.example.com", |
458 | - }}) |
459 | + }) |
460 | c.Assert(err, gc.IsNil) |
461 | } |
462 |
Reviewers: mp+213393_ code.launchpad. net,
Message:
Please take a look.
Description:
unit.SetAddress now takes a vararg
Update LP#1298770
The previous branch updated instance.NewAddress to be varargs and
demonstated that most callers of NewAddresses were used to get a slice
of addresses so they could pass them to unit.SetAddresses. By making
SetAddresses vararg NewAddresses is unneeded. This will be next change.
https:/ /code.launchpad .net/~dave- cheney/ juju-core/ 108-set- addresses- take-varargs/ +merge/ 213393
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/82390045/
Affected files (+40, -60 lines): scp_test. go ssh_test. go status_ test.go machine_ test.go utils.go deployer/ deployer_ test.go machiner/ machiner_ test.go provisioner/ provisioner_ test.go /client/ client_ test.go /client/ run_test. go /deployer/ deployer_ test.go /uniter/ uniter_ test.go test.go er_internal_ test.go instancepoller/ machine_ test.go instancepoller/ updater. go provisioner/ kvm-broker_ test.go provisioner/ lxc-broker_ test.go provisioner/ provisioner_ test.go
A [revision details]
M cmd/juju/
M cmd/juju/
M cmd/juju/
M cmd/jujud/
M juju/testing/
M state/api/
M state/api/
M state/api/
M state/apiserver
M state/apiserver
M state/apiserver
M state/apiserver
M state/machine.go
M state/machine_
M state/megawatch
M state/state_test.go
M state/unit_test.go
M worker/
M worker/
M worker/
M worker/
M worker/