forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_test.go
573 lines (520 loc) · 18.4 KB
/
api_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package juju_test
import (
"context"
"crypto/tls"
"fmt"
"net"
"time"
"github.com/juju/errors"
"github.com/juju/names/v4"
"github.com/juju/testing"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"gopkg.in/macaroon.v2"
"github.com/juju/juju/api"
apitesting "github.com/juju/juju/api/testing"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/model"
"github.com/juju/juju/core/network"
sstesting "github.com/juju/juju/environs/simplestreams/testing"
envtesting "github.com/juju/juju/environs/testing"
"github.com/juju/juju/juju"
"github.com/juju/juju/juju/keys"
"github.com/juju/juju/jujuclient"
"github.com/juju/juju/jujuclient/jujuclienttesting"
"github.com/juju/juju/provider/dummy"
"github.com/juju/juju/rpc/jsoncodec"
coretesting "github.com/juju/juju/testing"
"github.com/juju/juju/version"
)
type NewAPIClientSuite struct {
coretesting.FakeJujuXDGDataHomeSuite
testing.MgoSuite
envtesting.ToolsFixture
}
var fakeUUID = "df136476-12e9-11e4-8a70-b2227cce2b54"
var _ = gc.Suite(&NewAPIClientSuite{})
func (s *NewAPIClientSuite) SetUpSuite(c *gc.C) {
s.FakeJujuXDGDataHomeSuite.SetUpSuite(c)
s.MgoSuite.SetUpSuite(c)
s.PatchValue(&keys.JujuPublicKey, sstesting.SignedMetadataPublicKey)
}
func (s *NewAPIClientSuite) TearDownSuite(c *gc.C) {
s.MgoSuite.TearDownSuite(c)
s.FakeJujuXDGDataHomeSuite.TearDownSuite(c)
}
func (s *NewAPIClientSuite) SetUpTest(c *gc.C) {
s.ToolsFixture.SetUpTest(c)
s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
s.MgoSuite.SetUpTest(c)
s.PatchValue(&dummy.LogDir, c.MkDir())
}
func (s *NewAPIClientSuite) TearDownTest(c *gc.C) {
dummy.Reset(c)
s.ToolsFixture.TearDownTest(c)
s.MgoSuite.TearDownTest(c)
s.FakeJujuXDGDataHomeSuite.TearDownTest(c)
}
func (s *NewAPIClientSuite) TestWithBootstrapConfig(c *gc.C) {
store := newClientStore(c, "noconfig")
called := 0
expectState := mockedAPIState(mockedHostPort | mockedModelTag)
apiOpen := func(apiInfo *api.Info, opts api.DialOpts) (api.Connection, error) {
checkCommonAPIInfoAttrs(c, apiInfo, opts)
c.Check(apiInfo.ModelTag, gc.Equals, names.NewModelTag(fakeUUID))
called++
return expectState, nil
}
st, err := newAPIConnectionFromNames(c, "noconfig", "admin/admin", store, apiOpen)
c.Assert(err, jc.ErrorIsNil)
c.Assert(st, gc.Equals, expectState)
c.Assert(called, gc.Equals, 1)
// The addresses should have been updated.
c.Assert(
store.Controllers["noconfig"].APIEndpoints,
jc.DeepEquals,
[]string{"0.1.2.3:1234", "[2001:db8::1]:1234"},
)
c.Assert(
store.Controllers["noconfig"].AgentVersion,
gc.Equals,
"1.2.3",
)
controllerBefore, err := store.ControllerByName("noconfig")
c.Assert(err, jc.ErrorIsNil)
// If APIHostPorts or agent version haven't changed, then the store won't be updated.
stubStore := jujuclienttesting.WrapClientStore(store)
st, err = newAPIConnectionFromNames(c, "noconfig", "admin/admin", stubStore, apiOpen)
c.Assert(err, jc.ErrorIsNil)
c.Assert(st, gc.Equals, expectState)
c.Assert(called, gc.Equals, 2)
stubStore.CheckCallNames(c, "AccountDetails", "ModelByName", "ControllerByName", "AccountDetails", "UpdateAccount")
controllerAfter, err := store.ControllerByName("noconfig")
c.Assert(err, jc.ErrorIsNil)
c.Assert(controllerBefore, gc.DeepEquals, controllerAfter)
}
func (s *NewAPIClientSuite) TestUpdatesLastKnownAccess(c *gc.C) {
store := newClientStore(c, "noconfig")
called := 0
expectState := mockedAPIState(mockedHostPort | mockedModelTag)
apiOpen := func(apiInfo *api.Info, opts api.DialOpts) (api.Connection, error) {
checkCommonAPIInfoAttrs(c, apiInfo, opts)
c.Check(apiInfo.ModelTag, gc.Equals, names.NewModelTag(fakeUUID))
called++
return expectState, nil
}
stubStore := jujuclienttesting.WrapClientStore(store)
st, err := newAPIConnectionFromNames(c, "noconfig", "admin/admin", stubStore, apiOpen)
c.Assert(err, jc.ErrorIsNil)
c.Assert(st, gc.Equals, expectState)
c.Assert(called, gc.Equals, 1)
stubStore.CheckCallNames(c, "AccountDetails", "ModelByName", "ControllerByName", "UpdateController", "AccountDetails", "UpdateAccount")
c.Assert(
store.Accounts["noconfig"],
jc.DeepEquals,
jujuclient.AccountDetails{User: "admin", Password: "hunter2", LastKnownAccess: "superuser"},
)
}
func (s *NewAPIClientSuite) TestUpdatesPublicDNSName(c *gc.C) {
apiOpen := func(apiInfo *api.Info, opts api.DialOpts) (api.Connection, error) {
c.Assert(apiInfo.ControllerUUID, gc.Equals, fakeUUID)
conn := mockedAPIState(noFlags)
conn.publicDNSName = "somewhere.invalid"
conn.addr = "0.1.2.3:1234"
return conn, nil
}
store := newClientStore(c, "controllername")
_, err := newAPIConnectionFromNames(c, "controllername", "", store, apiOpen)
c.Assert(err, jc.ErrorIsNil)
c.Assert(store.Controllers["controllername"].PublicDNSName, gc.Equals, "somewhere.invalid")
}
func (s *NewAPIClientSuite) TestWithInfoNoAddresses(c *gc.C) {
store := newClientStore(c, "noconfig")
err := store.UpdateController("noconfig", jujuclient.ControllerDetails{
ControllerUUID: fakeUUID,
CACert: "certificate",
})
c.Assert(err, jc.ErrorIsNil)
st, err := newAPIConnectionFromNames(c, "noconfig", "", store, panicAPIOpen)
c.Assert(err, jc.Satisfies, juju.IsNoAddressesError)
c.Assert(st, gc.IsNil)
}
func (s *NewAPIClientSuite) TestWithMacaroons(c *gc.C) {
store := newClientStore(c, "withmac")
mac, err := apitesting.NewMacaroon("id")
c.Assert(err, jc.ErrorIsNil)
err = store.UpdateAccount("withmac", jujuclient.AccountDetails{
User: "admin",
Password: "",
Macaroons: []macaroon.Slice{{mac}},
})
c.Assert(err, jc.ErrorIsNil)
ad, err := store.AccountDetails("withmac")
c.Assert(err, jc.ErrorIsNil)
info, _, err := juju.ConnectionInfo(juju.NewAPIConnectionParams{
ControllerName: "withmac",
Store: store,
AccountDetails: ad,
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(info.Macaroons, gc.DeepEquals, []macaroon.Slice{{mac}})
}
func (s *NewAPIClientSuite) TestWithRedirect(c *gc.C) {
store := newClientStore(c, "ctl")
err := store.UpdateController("ctl", jujuclient.ControllerDetails{
ControllerUUID: fakeUUID,
CACert: "certificate",
APIEndpoints: []string{"0.1.2.3:5678"},
})
c.Assert(err, jc.ErrorIsNil)
controllerBefore, err := store.ControllerByName("ctl")
c.Assert(err, jc.ErrorIsNil)
redirHPs := []network.MachineHostPorts{{
network.MachineHostPort{MachineAddress: network.NewMachineAddress("0.0.9.9"), NetPort: network.NetPort(1234)},
network.MachineHostPort{MachineAddress: network.NewMachineAddress("0.0.9.10"), NetPort: network.NetPort(1235)},
}}
openCount := 0
redirOpen := func(apiInfo *api.Info, opts api.DialOpts) (api.Connection, error) {
c.Check(apiInfo.ControllerUUID, gc.Equals, fakeUUID)
c.Check(apiInfo.ModelTag.Id(), gc.Equals, fakeUUID)
openCount++
switch openCount {
case 1:
c.Check(apiInfo.Addrs, jc.DeepEquals, []string{"0.1.2.3:5678"})
c.Check(apiInfo.CACert, gc.Equals, "certificate")
return nil, errors.Trace(&api.RedirectError{
Servers: redirHPs,
CACert: "alternative CA cert",
FollowRedirect: true,
})
case 2:
c.Check(apiInfo.Addrs, jc.DeepEquals, network.CollapseToHostPorts(redirHPs).Strings())
c.Check(apiInfo.CACert, gc.Equals, "alternative CA cert")
st := mockedAPIState(noFlags)
st.apiHostPorts = redirHPs
st.modelTag = fakeUUID
return st, nil
}
c.Errorf("OpenAPI called too many times")
return nil, fmt.Errorf("OpenAPI called too many times")
}
st0, err := newAPIConnectionFromNames(c, "ctl", "admin/admin", store, redirOpen)
c.Assert(err, jc.ErrorIsNil)
c.Assert(openCount, gc.Equals, 2)
st := st0.(*mockAPIState)
c.Assert(st.modelTag, gc.Equals, fakeUUID)
// Check that the addresses of the original controller
// have not been changed.
controllerAfter, err := store.ControllerByName("ctl")
c.Assert(err, jc.ErrorIsNil)
c.Assert(controllerBefore, gc.DeepEquals, controllerAfter)
}
func (s *NewAPIClientSuite) TestWithInfoAPIOpenError(c *gc.C) {
jujuClient := newClientStore(c, "noconfig")
apiOpen := func(apiInfo *api.Info, opts api.DialOpts) (api.Connection, error) {
return nil, errors.Errorf("an error")
}
st, err := newAPIConnectionFromNames(c, "noconfig", "", jujuClient, apiOpen)
// We expect to get the error from apiOpen, because it is not
// fatal to have no bootstrap config.
c.Assert(err, gc.ErrorMatches, "an error")
c.Assert(st, gc.IsNil)
}
func (s *NewAPIClientSuite) TestDialedAddressIsCached(c *gc.C) {
store := jujuclient.NewMemStore()
err := store.AddController("foo", jujuclient.ControllerDetails{
ControllerUUID: fakeUUID,
APIEndpoints: []string{
"example1:1111",
"example2:2222",
},
})
c.Assert(err, jc.ErrorIsNil)
dialed := make(chan string, 10)
start := make(chan struct{})
// Wait for both dials to complete, so we
// know their addresses are cached.
go func() {
addrs := make(map[string]bool)
for len(addrs) < 2 {
addrs[<-dialed] = true
}
// Allow the dials to complete.
close(start)
}()
conn, err := juju.NewAPIConnection(juju.NewAPIConnectionParams{
Store: store,
ControllerName: "foo",
DialOpts: api.DialOpts{
DialWebsocket: func(ctx context.Context, urlStr string, tlsConfig *tls.Config, ipAddr string) (jsoncodec.JSONConn, error) {
apiConn := testRootAPI{
serverAddrs: params.FromProviderHostsPorts([]network.ProviderHostPorts{{
network.ProviderHostPort{ProviderAddress: network.NewProviderAddress("example3"), NetPort: 3333},
network.ProviderHostPort{ProviderAddress: network.NewProviderAddress("example4"), NetPort: 4444},
}}),
}
dialed <- ipAddr
<-start
if ipAddr != "0.1.1.2:1111" {
return nil, errors.New("fail")
}
return jsoncodec.NetJSONConn(apitesting.FakeAPIServer(apiConn)), nil
},
IPAddrResolver: apitesting.IPAddrResolverMap{
"example1": {"0.1.1.1", "0.1.1.2"},
"example2": {"0.2.2.2"},
},
},
AccountDetails: new(jujuclient.AccountDetails),
})
c.Assert(err, jc.ErrorIsNil)
defer conn.Close()
details, err := store.ControllerByName("foo")
c.Assert(err, jc.ErrorIsNil)
// The cache should contain both results. The IP address
// that was successfully dialed should be at the start of its
// slice.
c.Assert(details.DNSCache, jc.DeepEquals, map[string][]string{
"example1": {"0.1.1.2", "0.1.1.1"},
"example2": {"0.2.2.2"},
})
// The API addresses should have all the returned server addresses
// there as well as the one we actually succeeded in dialing.
// The successfully dialed address should be at the start.
c.Assert(details.APIEndpoints, jc.DeepEquals, []string{
"example1:1111",
"example3:3333",
"example4:4444",
})
}
func (s *NewAPIClientSuite) TestWithExistingDNSCache(c *gc.C) {
store := jujuclient.NewMemStore()
err := store.AddController("foo", jujuclient.ControllerDetails{
ControllerUUID: fakeUUID,
APIEndpoints: []string{
"example1:1111",
"example3:3333",
"example4:4444",
},
DNSCache: map[string][]string{
"example1": {"0.1.1.2", "0.1.1.1"},
"example2": {"0.2.2.2"},
},
})
c.Assert(err, jc.ErrorIsNil)
start := make(chan struct{})
conn, err := juju.NewAPIConnection(juju.NewAPIConnectionParams{
Store: store,
ControllerName: "foo",
DialOpts: api.DialOpts{
DialWebsocket: func(ctx context.Context, urlStr string, tlsConfig *tls.Config, ipAddr string) (jsoncodec.JSONConn, error) {
apiConn := testRootAPI{
serverAddrs: params.FromProviderHostsPorts([]network.ProviderHostPorts{{
network.ProviderHostPort{ProviderAddress: network.NewProviderAddress("example3"), NetPort: 3333},
network.ProviderHostPort{ProviderAddress: network.NewProviderAddress("example5"), NetPort: 5555},
}}),
}
c.Logf("Dial: %q requested", ipAddr)
if ipAddr != "0.1.1.2:1111" {
// It's not the blessed IP address - block indefinitely
// until we're called upon to start.
select {
case <-start:
case <-time.After(testing.LongWait):
c.Fatalf("timeout while waiting for start dialing %v", ipAddr)
}
return nil, errors.New("fail")
}
// We're trying to connect to the blessed IP address.
// Succeed immediately.
return jsoncodec.NetJSONConn(apitesting.FakeAPIServer(apiConn)), nil
},
IPAddrResolver: ipAddrResolverFunc(func(ctx context.Context, host string) ([]net.IPAddr, error) {
c.Logf("Resolve: %q requested", host)
// We shouldn't block here, because IP Address lookups are done blocking in the main loop.
return nil, errors.New("no DNS available")
}),
},
AccountDetails: new(jujuclient.AccountDetails),
})
c.Assert(err, jc.ErrorIsNil)
defer conn.Close()
close(start)
details, err := store.ControllerByName("foo")
c.Assert(err, jc.ErrorIsNil)
// The DNS cache should not have changed.
c.Assert(details.DNSCache, jc.DeepEquals, map[string][]string{
"example1": {"0.1.1.2", "0.1.1.1"},
"example2": {"0.2.2.2"},
})
// The API addresses should have all the returned server addresses
// there as well as the one we actually succeeded in dialing.
// The successfully dialed address should be still at the start.
c.Assert(details.APIEndpoints, jc.DeepEquals, []string{
"example1:1111",
"example3:3333",
"example5:5555",
})
}
func (s *NewAPIClientSuite) TestEndpointFiltering(c *gc.C) {
store := jujuclient.NewMemStore()
err := store.AddController("foo", jujuclient.ControllerDetails{
ControllerUUID: fakeUUID,
APIEndpoints: []string{
"example1:1111",
},
DNSCache: map[string][]string{
"example1": {"0.1.1.1"},
},
})
c.Assert(err, jc.ErrorIsNil)
serverAddrs := params.FromProviderHostsPorts([]network.ProviderHostPorts{{
network.ProviderHostPort{ProviderAddress: network.NewProviderAddress("0.1.2.3"), NetPort: 1234},
network.ProviderHostPort{ProviderAddress: network.NewProviderAddress("2001:db8::1"), NetPort: 1234},
network.ProviderHostPort{ProviderAddress: network.NewProviderAddress("10.0.0.1"), NetPort: 1234},
network.ProviderHostPort{ProviderAddress: network.NewProviderAddress("127.0.0.1"), NetPort: 1234},
network.ProviderHostPort{ProviderAddress: network.NewProviderAddress("169.254.1.1"), NetPort: 1234},
//Duplicate
network.ProviderHostPort{ProviderAddress: network.NewProviderAddress("0.1.2.3"), NetPort: 1234},
//Duplicate host, same IP.
network.ProviderHostPort{ProviderAddress: network.NewProviderAddress("0.1.2.3"), NetPort: 1235},
}})
conn, err := juju.NewAPIConnection(juju.NewAPIConnectionParams{
Store: store,
ControllerName: "foo",
DialOpts: api.DialOpts{
DialWebsocket: func(ctx context.Context, urlStr string, tlsConfig *tls.Config, ipAddr string) (jsoncodec.JSONConn, error) {
apiConn := testRootAPI{
serverAddrs: serverAddrs,
}
return jsoncodec.NetJSONConn(apitesting.FakeAPIServer(apiConn)), nil
},
IPAddrResolver: ipAddrResolverFunc(func(ctx context.Context, host string) ([]net.IPAddr, error) {
return nil, errors.New("no DNS available")
}),
},
AccountDetails: new(jujuclient.AccountDetails),
})
c.Assert(err, jc.ErrorIsNil)
defer conn.Close()
details, err := store.ControllerByName("foo")
c.Assert(err, jc.ErrorIsNil)
// The API addresses should have filtered out duplicates
// and unusable addresses.
c.Assert(details.APIEndpoints, jc.DeepEquals, []string{
"example1:1111",
"0.1.2.3:1234",
"[2001:db8::1]:1234",
"10.0.0.1:1234",
"0.1.2.3:1235",
})
}
var moveToFrontTests = []struct {
item string
items []string
expect []string
}{{
item: "x",
items: []string{"y", "x"},
expect: []string{"x", "y"},
}, {
item: "z",
items: []string{"y", "x"},
expect: []string{"y", "x"},
}, {
item: "y",
items: []string{"y", "x"},
expect: []string{"y", "x"},
}, {
item: "x",
items: []string{"y", "x", "z"},
expect: []string{"x", "y", "z"},
}, {
item: "d",
items: []string{"a", "b", "c", "d", "e", "f"},
expect: []string{"d", "a", "b", "c", "e", "f"},
}}
func (s *NewAPIClientSuite) TestMoveToFront(c *gc.C) {
for i, test := range moveToFrontTests {
c.Logf("test %d: moveToFront %q %v", i, test.item, test.items)
juju.MoveToFront(test.item, test.items)
c.Assert(test.items, jc.DeepEquals, test.expect)
}
}
type testRootAPI struct {
serverAddrs [][]params.HostPort
}
func (r testRootAPI) Admin(id string) (testAdminAPI, error) {
return testAdminAPI{r: r}, nil
}
type testAdminAPI struct {
r testRootAPI
}
func (a testAdminAPI) Login(req params.LoginRequest) params.LoginResult {
return params.LoginResult{
ControllerTag: names.NewControllerTag(fakeUUID).String(),
Servers: a.r.serverAddrs,
ServerVersion: version.Current.String(),
}
}
func checkCommonAPIInfoAttrs(c *gc.C, apiInfo *api.Info, opts api.DialOpts) {
opts.DNSCache = nil
c.Check(apiInfo.Tag, gc.Equals, names.NewUserTag("admin"))
c.Check(apiInfo.CACert, gc.Equals, "certificate")
c.Check(apiInfo.Password, gc.Equals, "hunter2")
c.Check(opts, gc.DeepEquals, api.DefaultDialOpts())
}
// newClientStore returns a client store that contains information
// based on the given controller name and info.
func newClientStore(c *gc.C, controllerName string) *jujuclient.MemStore {
store := jujuclient.NewMemStore()
err := store.AddController(controllerName, jujuclient.ControllerDetails{
ControllerUUID: fakeUUID,
CACert: "certificate",
APIEndpoints: []string{"0.1.2.3:5678"},
})
c.Assert(err, jc.ErrorIsNil)
err = store.UpdateModel(controllerName, "admin/admin", jujuclient.ModelDetails{
ModelUUID: fakeUUID, ModelType: model.IAAS,
})
c.Assert(err, jc.ErrorIsNil)
// Models belong to accounts, so we must have an account even
// if "creds" is not initialised. If it is, it may overwrite
// this one.
err = store.UpdateAccount(controllerName, jujuclient.AccountDetails{
User: "admin",
Password: "hunter2",
})
c.Assert(err, jc.ErrorIsNil)
return store
}
func newAPIConnectionFromNames(
c *gc.C,
controller, model string,
store jujuclient.ClientStore,
apiOpen api.OpenFunc,
) (api.Connection, error) {
args := juju.NewAPIConnectionParams{
Store: store,
ControllerName: controller,
DialOpts: api.DefaultDialOpts(),
OpenAPI: apiOpen,
}
accountDetails, err := store.AccountDetails(controller)
if !errors.IsNotFound(err) {
c.Assert(err, jc.ErrorIsNil)
args.AccountDetails = accountDetails
}
if model != "" {
modelDetails, err := store.ModelByName(controller, model)
c.Assert(err, jc.ErrorIsNil)
args.ModelUUID = modelDetails.ModelUUID
}
return juju.NewAPIConnection(args)
}
type ipAddrResolverFunc func(ctx context.Context, host string) ([]net.IPAddr, error)
func (f ipAddrResolverFunc) LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error) {
return f(ctx, host)
}