Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request juju#16434 from jack-w-shaw/JUJU-4779_fix_charm_or…
…igin_switching juju#16434 Local charm origins can not include hashes, ids or channels. However, when switching from a charmhub charm to a local one these attributes were accidentally copies over Ensure these attributes are droped when constructing the new charm origin Similarly with the revision, a new revision would not be set, meaning the revision of the original charm would be kept. Make sure the revision is updated as well There is a slight nuance here, simply deploying a local charm does not fill in a revision, but switching to a local charm will fill in a revision. This is not a problem, as ideally we would have a revision for local charms. This is, in fact, something added in a later version anyway This will require an equivalent change to python-libjuju ## Checklist - [x] Code style: imports ordered, good names, simple structure, etc - ~[ ] Comments saying why design decisions were made~ - [x] Go unit tests, with comments saying what you're testing - [ ] [Integration tests](https://github.com/juju/juju/tree/main/tests), with comments saying what you're testing - ~[ ] [doc.go](https://discourse.charmhub.io/t/readme-in-packages/451) added or updated in changed packages~ ## QA steps Run the refresh integration test ``` $ juju deploy ubuntu ubuntu-switch $ juju deploy ~/charms/ubuntu $ juju refresh ubuntu --switch ~/charms/ubuntu $ juju mongo db.applications.find().pretty() { "_id" : "cf0a16b4-b3f6-4d3f-8b78-77a4c4556841:ubuntu-switch", "name" : "ubuntu-switch", "model-uuid" : "cf0a16b4-b3f6-4d3f-8b78-77a4c4556841", "series" : "focal", "subordinate" : false, "charmurl" : "local:focal/ubuntu-12", "cs-channel" : "", "charm-origin" : { "source" : "local", "id" : "", "hash" : "", "revision" : 12, "platform" : { "architecture" : "amd64", "os" : "ubuntu", "series" : "focal" } }, "charmmodifiedversion" : 1, "forcecharm" : false, "life" : 0, "unitcount" : 1, "relationcount" : 0, "minunits" : 0, "txn-revno" : NumberLong(5), "metric-credentials" : BinData(0,""), "exposed" : false, "scale" : 0, "passwordhash" : "", "provisioning-state" : null, "txn-queue" : [ "6529679a9dc55c1aef137bfe_56f7652c" ] } { "_id" : "cf0a16b4-b3f6-4d3f-8b78-77a4c4556841:ubuntu", "name" : "ubuntu", "model-uuid" : "cf0a16b4-b3f6-4d3f-8b78-77a4c4556841", "series" : "bionic", "subordinate" : false, "charmurl" : "local:bionic/ubuntu-12", "cs-channel" : "", "charm-origin" : { "source" : "local", "id" : "", "hash" : "", "platform" : { "architecture" : "amd64", "os" : "ubuntu", "series" : "bionic" } }, "charmmodifiedversion" : 0, "forcecharm" : false, "life" : 0, "unitcount" : 1, "relationcount" : 0, "minunits" : 0, "txn-revno" : NumberLong(6), "metric-credentials" : BinData(0,""), "exposed" : false, "scale" : 0, "passwordhash" : "", "provisioning-state" : null, "txn-queue" : [ "652967dd9dc55c1aef137c51_5ab0fbc7" ] } ``` Notice the id, hash, channel are absent in both charms
- Loading branch information