Commit Graph

4 Commits

Author SHA1 Message Date
Valentin Rothberg cd2797eb34 pkg/config: use NewSlice, Get and Set where possible
To improve the code and reduce memory allocations.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 10:04:20 +02:00
Valentin Rothberg b103cb9e93 containers.conf: appendable string arrays, Part 1
Commit 395ba05c44 implemented a POC to allow for changing the behavior
when loading multiple container.conf files in sequence.  By default, the
TOML encoder will override existing data/fields with the one specified
in the loaded file.  The POC has demonstrated how this behavior can be
changed to append string slices instead of overriding/replacing them
entirely.

This change is the first step of integrating these appendable string
arrays into containers.conf and starts with enabling the `Env`,
`Mounts`, and `Volumes` fields in the `[Containers]` table.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-24 11:47:46 +02:00
Valentin Rothberg 163f808bdb pkg/config: add (*Config).LoadedModules()
To return absolute paths to modules a config was loaded with.
Knowing the modules is required for conmon's callback to
Podman's cleanup.  Returning them as absolute paths makes
loading the modules a bit faster as it avoids the lookup.

Also drop the attempted performance tune in `Default()` to
accommodate for go's memory model.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-08-14 09:54:50 +02:00
Valentin Rothberg 6847ea48a2 containers.conf: implement modules
Add a new concept to containers.conf called "modules".  A "module" is
a containers.conf file located at a specific directory.  More than one
module can be loaded in the specified order, following existing
override semantics.

There are three directories to load modules from:
 - $CONFIG_HOME/containers/containers.conf.modules
 - /etc/containers/containers.conf.modules
 - /usr/share/containers/containers.conf.modules

With CONFIG_HOME pointing to $HOME/.config or, if set, $XDG_CONFIG_HOME.
Absolute paths will be loaded as is, relative paths will be resolved
relative to the three directories above allowing for admin configs
(/etc/) to override system configs (/usr/share/) and user configs
($CONFIG_HOME) to override admin configs.

Also move some functions from config.go for locality.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-08-14 09:40:27 +02:00