hook name restrictions

William Reade william.reade at canonical.com
Fri Nov 9 22:12:20 UTC 2012


Hey all

Recently I restricted the allowable names in charms' hooks directories,
such that "juju-"-prefixed files were disallowed. It was mentioned at
the time that it would be nice to restrict the names still further, and
it only just crossed my mind that this is trivially easy: the *only*
acceptable hook names are:

  * install
  * start
  * config-changed
  * upgrade-charm
  * stop

...and, for each of the relations defined by the charm:

  * <name>-relation-joined
  * <name>-relation-changed
  * <name>-relation-departed
  * <name>-relation-broken

...and any time we're inspecting a charm, we have access to the metadata
and can easily determine what relation names are in play.

I haven't looked through the charms to see what would be broken by this
restriction, but it honestly feels like a Good Thing to me for the
following reasons:

  * we might want to define new hooks; if we allow charms to keep any
    old junk in their hooks directories, we run the risk of name
    collisions, and that will be a tedious hassle
  * being able to see by inspection what events a charm responds to --
    and, as importantly, what events it does *not* respond to -- is
    valuable, and becomes much easier if readers can guarantee that any
    file in the hooks directory corresponds to an actual hook

Can anyone think of a reason not to make this change?




More information about the Juju-dev mailing list