canonical / pebble

Take control of your internal daemons!
https://canonical-pebble.readthedocs-hosted.com/
GNU General Public License v3.0
143 stars 54 forks source link

feat: implement PEBBLE_IMPORT to load layers from other locations #343

Closed hpidcock closed 7 months ago

hpidcock commented 8 months ago

This PR proposes a way for Pebble to load layers from multiple sources first, before then loading from the $PEBBLE directory. This is required when pebble is run as a non-root user in a container with pebble layers already defined at the default $PEBBLE location of /var/lib/pebble/default.

By setting $PEBBLE to a directory writeable by a non-root user, while also setting $PEBBLE_IMPORT to /var/lib/pebble/default, the pebble daemon is able to load layers previously defined in the default directory by a container image author.

$PEBBLE_IMPORT can be a colon (:) delimited ordered list of paths to directories in the format of the pebble data directory ($PEBBLE). Each directory will have a layers/ sub-directory.

It is expected that the following pebble invocation, PEBBLE=/var/lib/pebble/charm PEBBLE_IMPORT=/var/lib/pebble/default:/var/lib/pebble/intermediate pebble run; would load layers like so:

NOTE: order numbers can be re-used globally, but labels must be unique globally.

For tooling to determine where configuration originated from, see https://github.com/canonical/pebble/pull/342

JU090