juju/gocharm — pull request #7 by rogpeppe (2014-11-17 11:52:15+00:00)
Title: hook: simplify Context API

Rename Registry.NewRegistry to Registry.Clone.

Remove LocalState entry point, and make local state
an argument to RegisterContext instead.

Remove names for local state and for commands - if you
want different local states, then use Registry.Clone.
This makes it arguably less flexible, because you cannot
create new local states or commands at hook running
time, but I couldn't think of a case where this would actually
matter. You can store maps in local context, and you can
change behaviour based on command arguments.
This means that local state can be verified at registration time,
before the charm is deployed.

Ensure that Clone is called only once for any given name.
Same with RegisterCommand and RegisterContext.

All relation data is now available in the Context, without
the need to call any relation-get commands.
This is potentially bad when there are thousands of units - we
will do more work than necessary, but I think the simiplification
is worth it, and it's all stored in memory in the unit
anyway, so it's not going to be *that* big, and
hooks don't run that often.

We factor Runner and PersistentState out of Context. This
will make it possible for charmbits to unit test without
needing a uniter context.