Setting annotations is already supported via Application.set_annotations() (implementation), but there is not a corresponding way to read annotations, so adding that would be great.
It looks like the code you have in juju-annotation would be easy to integrate into an Application.get_annotations() method. It looks like we already have a model class for Annotation to represent the results, but it is missing any implementation. Honestly, though, annotation data seems simple enough to just model it as a simple Python dictionary; that’s what set_annotations() takes as input anyway.
As for trust, my first thought is that it should go on Application as well, but maybe it makes more sense on Model or Controller.
Looks like Machine.set_annotations() is also available, but neither Unit.set_annotations(), nor Model.set_annotations().
Also, for reference, if any of the facades or newer facade methods were unavailable, the Syncing Upstream Updates docs page describes how to sync against the Juju core code. The process for when this is done needs to be formalized to keep in sync with Juju changes, rather than being ad-hoc, as-needed as it is currently.
I think for trust, we should keep it on the Application, and have it as a property backed by code for setting and getting. There is application config that is added internally to manage trust implementation. So hooking it up should be pretty simple.
That say we should be able to have something like:
And have annotations show up in the show-x calls for things?
juju show-application ubuntu
annotations:
my-field: value
I guess the issue there is the lack of a show-unit call currently.
For the model I’d go the route of -m model for now. I’m hesitant to start to add the @model concept as a special case that only works in annotations.
I’ll provide this in the PR as feedback but my thoughts. It’d also be good to have this supported as extra yaml in the bundle so that at the root of the bundle you could provide the annotations to be added to the model along with a machine. I wonder if there’s a place in there for the unit level ones as well.
the problem is we need to support
juju annotate -m model unit/0 foo=bar
I guess you’re saying that if you leave off any app or unit you end up annotating the model?