Skip to content

Commit e05fb3a

Browse files
Document charm-user in charmcraft.yaml reference.
1 parent 2ccd8f3 commit e05fb3a

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

docs/reference/files/charmcraft-sample-charm.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ charm-libs:
4343
version: "1"
4444
- lib: mysql.mysql
4545
version: "0.5"
46+
charm-user: sudoer
4647
config:
4748
options:
4849
name:

docs/reference/files/charmcraft-yaml-file.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,42 @@ and the lib version (in ``"<api version>[.<patch version>]"`` string format).
346346

347347
.. literalinclude:: charmcraft-sample-charm.yaml
348348
:start-at: charm-libs:
349+
:end-before: charm-user:
350+
351+
352+
.. _charmcraft-yaml-key-charm-user:
353+
354+
``charm-user``
355+
--------------
356+
357+
.. important::
358+
359+
``charm-user`` was added in Juju 3.6.0. Currently only supported on Kubernetes
360+
charms and has no effect on machine charms.
361+
362+
**Status:** Optional. Recommended for Kubernetes charms.
363+
364+
**Purpose:** The ``charm-user`` key allows charm authors to specify that their charm
365+
hook code does not need to be run as root. This key, in addition to ``uid`` + ``uid``
366+
fields in ``containers``, allows charms to be run rootless. The value of ``root``
367+
ensures the charm runs as root. Both ``sudoer`` and ``non-root`` will run as a user
368+
other than root. In the case of the value ``sudoer``, the charm will be run as a user
369+
with access to sudo to elevate its privileges.
370+
371+
**Structure:** The key consists of a single value. One of ``root``, ``sudoer`` or
372+
``non-root``.
373+
374+
.. code-block:: yaml
375+
376+
# (Optional) What kind of user is required to run the charm code.
377+
# It can be one of root, sudoer or non-root.
378+
# Added in Juju 3.6.0. If not specified, root is assumed.
379+
charm-user: <one of root, sudoer or non-root>
380+
381+
**Example:**
382+
383+
.. literalinclude:: charmcraft-sample-charm.yaml
384+
:start-at: charm-user:
349385
:end-before: config:
350386

351387

docs/reference/files/metadata-yaml-file.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ Examples:
431431

432432
.. important::
433433

434-
``charm-user`` was added in Juju 3.6.0. Currently is only supported on Kubernetes
434+
``charm-user`` was added in Juju 3.6.0. Currently only supported on Kubernetes
435435
charms and has no effect on machine charms.
436436

437437
**Status:** Optional. Recommended for Kubernetes charms.
@@ -441,7 +441,7 @@ hook code does not need to be run as root. This key, in addition to ``uid`` + ``
441441
fields in ``containers``, allows charms to be run rootless. The value of ``root``
442442
ensures the charm runs as root. Both ``sudoer`` and ``non-root`` will run as a user
443443
other than root. In the case of the value ``sudoer``, the charm will be run as a user
444-
with access to sudo to elevate it's privileges.
444+
with access to sudo to elevate its privileges.
445445

446446
**Structure:** The key consists of a single value. One of ``root``, ``sudoer`` or
447447
``non-root``.

0 commit comments

Comments
 (0)