Descriptionstate/apiserver/*: use RegisterStandardFacade
Lots of changes, mostly all mechanical.
The items that aren't trivially mechanical are:
1) agent/agent.go wasn't taking a Resources, made it take one to be
the same as the others.
2) common/registry_test.go This is the attempt to reintroduce the "no
unknown methods" checks. It currently fails because we have to pass in
id="" which isn't a known Id for the Watcher Facades. Otherwise it
works just like the old one. I need to sort out what to do here. (add
Watchers with id ""?)
3) state/apiserver/facades.go just imports all the types that used to
be inlined in state/apiserver/root.go
We could name it something else like "all", but we'll want a file like
this somewhere, I think.
4) root.go MethodCaller implementation
The biggest thing here is that the Client facade is not like the
others. I have plans to clean that up, but that will be done in a
different branch.
5) upgrader.go I probably shouldn't call this a fully special
snowflake, because it isn't *as* special as Client is. But it is the
only Facade that actually has 2 implementations, and which
implementation gets returned is decided by the tagKind of the caller.
It *is* special in that it doesn't use RegisterStandardFacade, though.
6) usermanager/usermanager.go also didn't take a Resources parameter.
I'm leaving it for now to show off what bespoke func registries look
like. I'll happily come back later to add Resources to
NewUserManagerAPI and switch it to RegisterStandardFacade.
7) AllWatcher. I filed a bug about this, but we have no tests in the
code base that the AllWatcher API facade actually exists. I believe we
have coverage of the underlying MegaWatcher behavior. But since the
juju CLI never used the AllWatcher, we don't even have a smoke test
for things like "Clients can see the AllWatcher, but Agents cannot". I
didn't improve that here, but hopefully I didn't screw up the auth
semantics.
8) A bunch of the watchers were using direct methods from
srvRoot, rather than the Authorizer + Resources paradigm. So I changed
them from using "r.requireAgent() err" to using
!isAgent(Authorizer) bool.
Also, all of the new*Watcher functions fit FactoryFacade directly,
because I had to write them anyway, and the don't fit
RegisterStandardFacade (because they actually make use of the id
parameter).
There is clearly a *lot* of boilerplate between these functions, but
AFAICT every other line uses a concrete type so it would be a lot of
reflect work to have them share code.
isAgent is also different now, instead of doing !Client, it does (Unit
|| Machine). Mostly because that lets us create an Authorizer which can
do *anything*, whereas the negative logic means that something which is
a Client and an Agent would sometimes not be an Agent. (Used in the
"grab a copy of all facades and introspect them" test.)
9) isAgent helper changes from being something directly asking state to
being a wrapper around the Authorizer code. And AuthClient changes from
being !isAgent to just checking directly for whether this entity
isUser.
https://code.launchpad.net/~jameinel/juju-core/api-use-register-standard-facade/+merge/219670
Requires: https://code.launchpad.net/~jameinel/juju-core/api-register-standard-facade/+merge/219660
(do not edit description out of merge proposal)
Patch Set 1 #Patch Set 2 : state/apiserver/*: use RegisterStandardFacade #
Total comments: 6
Patch Set 3 : state/apiserver/*: use RegisterStandardFacade #Patch Set 4 : state/apiserver/*: use RegisterStandardFacade #Patch Set 5 : state/apiserver/*: use RegisterStandardFacade #Patch Set 6 : state/apiserver/*: use RegisterStandardFacade #
MessagesTotal messages: 10
|