Commit 6aa065e
authored
Merge pull request #984 from cderici/controller-name-lazy-jujudata
#984
#### Description
This moves the computation of the `controller_name` from the `connector` to the `Controller` class, to be lazily evaluated from `jujudata` (and cached). We can move it out of the connector safely because:
1 - `controller_name` is not used within the connector.
2 - the only location that the `controller_name` is returned to, ignores it.
This has the nice consequence of freeing pylibjuju from relying on things like the `controllers.yaml` file (in turn the juju client to be installed) to connect to a controller.
Fixes #983
#### QA Steps
Added a test for lazy computation of `controller_name`.
```sh
$ tox -e integration -- tests/integration/test_controller.py::test_connection_lazy_jujudata
```
But the scenario from the #983 can be tried easily as follows:
```python
# make a new controller and connect it in a normal way:
from juju import controller
c = controller.Controller()
await c.connect()
# get the connection
conn = c.connection()
```
Now go move the `.local/share/juju/controllers.yaml` file temporarily.
```python
# make a new controller
c2 = controller.Controller()
# connect it using the information within the connection we got above
await c2.connect(endpoint=conn.endpoints[0][0], cacert=conn.cacert, username=conn.usertag, password=conn.password)
```
Should succeed without any errors.
Don't forget to move back your `controllers.yaml` back so nothing else on your machine freaks out.
All CI tests need to pass.
#### Notes & Discussion
juju-48914 files changed
Lines changed: 28 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | 41 | | |
43 | 42 | | |
44 | 43 | | |
| |||
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | 85 | | |
92 | 86 | | |
93 | 87 | | |
| |||
132 | 126 | | |
133 | 127 | | |
134 | 128 | | |
135 | | - | |
136 | 129 | | |
137 | 130 | | |
138 | 131 | | |
| |||
188 | 181 | | |
189 | 182 | | |
190 | 183 | | |
191 | | - | |
192 | 184 | | |
193 | | - | |
| 185 | + | |
194 | 186 | | |
195 | 187 | | |
196 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
177 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
178 | 185 | | |
179 | 186 | | |
180 | 187 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
663 | 663 | | |
664 | 664 | | |
665 | 665 | | |
666 | | - | |
| 666 | + | |
667 | 667 | | |
668 | 668 | | |
669 | 669 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
301 | 317 | | |
302 | 318 | | |
303 | 319 | | |
| |||
0 commit comments