[JUJU-4779] Ensure valid charm origin for local charm switches #978
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ensure that we provide the server with a valid charm origin when switching to local charms. Previously, we simply sent back the same charm origin when switching to a local charm.
However, this is not valid, since we don't know where we switched from. If it's a charmhub charm, it's origin will not be valid.
Also, parse the revision from the new charm url the server sends us
This is equivalent to: juju/juju#16434
QA Steps
Edit line 26 of examples/local_refresh.py to point to a local ubuntu charm
NOTE: This doesn't quite work as expected, but this is not a python-libjuju bug, but in juju/juju here:
https://github.com/juju/juju/blob/3.3/state/application.go#L1792-L1840
However, @hmlanigan is working on a fix (juju/juju#16315) that will resolve this, so proposing this change to python-libjuju as a stepping stone towards to complete solution
All CI tests need to pass.