Commit cd49a4f
authored
Merge pull request #971 from jack-w-shaw/JUJU-4829_fix_refresh_bug-master
#971
Port forward #968
Check if the switch param is pointing to a local charm. If it is, run local_refresh as if it were provided
This is how the Juju CLI works, which was missing from pylibjuju. Replicate this.
Also push url parsing of switch kwarg behind a check if it's local charm, meaning we avoid the possibility where we attempt to parse a path as if it were a url
Resolves #963
### QA Steps
```
tox -e integration -- tests/integration/test_application.py::test_refresh_charmhub_to_local
```
All CI tests need to pass.
Verify the following example script runs successfully:
```
from juju import jasyncio
from juju.model import Model
async def main():
model = Model()
print('Connecting to model')
await model.connect()
try:
print('path="/home/jack/charms/ubuntu"')
await depl(model, path="/home/jack/charms/ubuntu")
print('switch="/home/jack/charms/ubuntu"')
await depl(model, switch="/home/jack/charms/ubuntu")
print('switch="local:/home/jack/charms/ubuntu"')
await depl(model, switch="local:/home/jack/charms/ubuntu")
finally:
print('Disconnecting from model')
await model.disconnect()
async def depl(model, **kwargs):
try:
app = await model.deploy("ubuntu")
await model.block_until(lambda: all(u[0].workload_status == 'active' for u in app.units))
await app.refresh(**kwargs)
finally:
await app.remove()
await model.block_until(lambda: not len(model.applications))
if __name__ == '__main__':
jasyncio.run(main())
```3 files changed
Lines changed: 40 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
| 664 | + | |
| 665 | + | |
664 | 666 | | |
665 | 667 | | |
666 | 668 | | |
| |||
677 | 679 | | |
678 | 680 | | |
679 | 681 | | |
680 | | - | |
681 | 682 | | |
682 | 683 | | |
683 | | - | |
| 684 | + | |
684 | 685 | | |
685 | | - | |
| 686 | + | |
686 | 687 | | |
687 | 688 | | |
688 | 689 | | |
689 | 690 | | |
690 | 691 | | |
| 692 | + | |
| 693 | + | |
691 | 694 | | |
692 | 695 | | |
693 | 696 | | |
| |||
733 | 736 | | |
734 | 737 | | |
735 | 738 | | |
736 | | - | |
737 | | - | |
738 | 739 | | |
739 | 740 | | |
740 | 741 | | |
| |||
808 | 809 | | |
809 | 810 | | |
810 | 811 | | |
811 | | - | |
812 | | - | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
813 | 815 | | |
814 | 816 | | |
815 | 817 | | |
816 | 818 | | |
817 | 819 | | |
818 | 820 | | |
819 | | - | |
820 | | - | |
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
824 | 824 | | |
825 | | - | |
826 | | - | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
827 | 828 | | |
828 | 829 | | |
829 | 830 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
222 | 237 | | |
223 | 238 | | |
224 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
0 commit comments