charm push output is confusing : mismatch between promulgated and non-promulgated revnos
axinojolais opened this issue · comments
Hi,
I just published changes to the nrpe charm today. Here's what I did :
$ charm push . cs:~nrpe-charmers/nrpe
url: cs:~nrpe-charmers/nrpe-40
channel: unpublished
$ charm release cs:~nrpe-charmers/nrpe-40 --channel candidate
url: cs:~nrpe-charmers/nrpe-40
channel: candidate
$ charm release cs:~nrpe-charmers/nrpe-40 --channel stable
url: cs:~nrpe-charmers/nrpe-40
channel: stable
What's confusing there is that this is actually cs:nrpe-49, not -40. The confusion exists because cs:~nrpe-charmers/nrpe-40 is cs:nrpe-49. I guess perhaps if we push/release to a "promulgated" charm, the charm command should (also) display the promulgated version ?
Is there even a way to map cs:~nrpe-charmers/nrpe-40 to cs:nrpe-49 today ?
Thanks
Versions used :
charm 2.2.2
charm-tools 2.2.3
This is a dupe of #75.
I agree that it's confusing, but this is the intended behavior. This is because the promulgated charm ID tracks its revisions independently from the owner charm ID. And that is because the owner for the promulgated charm could change, which would cause the charm revision to potentially go backwards. To ensure monotonically increasing charm revisions so as not to break updates, the decision was made to split them.
It's actually fairly easy to find the promulgated rev, though, because the promulgated ID always tracks the latest rev of the stable channel of the owner namespaced charm ID, so if cs:~nrpe-charmers/nrpe
is promulgated, the promulgated URL will always be just cs:nrpe
and you can get the specific rev with:
charm show cs:nrpe
# or, if you have jq and want just the rev:
charm show cs:nrpe --format=json | jq -r '."id-revision".Revision
It's a bit harder to go the other way, but not impossible. This will give you the info about the owner ("upstream") charm from a promulgated charm (requires jq
; snap install jq
):
function charm-show-owner-rev() {
charm=${1#cs:}
shift
owner="$(charm show "cs:$charm" --format=json | jq -r '.owner.User')"
owner_rev="$(charm show "cs:~$owner/$charm" --format=json | jq -r '."id-revision".Revision')"
owner_url="cs:~$owner/$charm-$owner_rev"
#echo "$owner_url"
charm show "$owner_url" "$@"
}
That said, it would still definitely be nice if the output of charm release
indicated the promulgated rev straight away and if the output of charm show
had an url
field in the owner
section with this info.