A flexible and lightweight configuration data management library for the Clojure mount ecosystem.
It supports consistent loading and a unified view of the common sources of such data:
- environment variables
- resources folder
- file
A variety of runtime arguments provide a high degree of flexibility and accessor functions for each source of configuration data through a single namespace.
Additionally the missinterpret.mount-configuration.file
namespace has primitive editing
functions with file save capabilities and the missinterpret.mount-configuration.env
namespace
supports safe auto-edn parsing.
Leiningen dependency information:
[io.github.missinterpret/mount-configuration "0.1.1"]
Deps dependency information:
io.github.missinterpret/mount-configuration {:mvn/version "0.1.1"}
To use the configuration component in a project add this to the namespace which loads earliest:
[missinterpret.mount-configuration.core :refer [config]]
The missinterpret.mount-configuration.core namespace provides a unified view of all those sources that is consistent across runtimes. Accessor functions to access that view as well as each source's runtime data independently via a single interface is also provided.
The unified data view provides consistency between runtimes by imposing a loading order on the sources and merging loaded data in that order to create the unified view.
Order:
edn -> resource -> file
The start functions will attempt to bootstrap off of the loaded data if no runtime argument is provided.
- The resource namespace checks the environment variables as a source for its data.
- The file namespace first checks the env and then the resource namespace
The source of environment configuration data.
Variables are parsed into edn if possible. If they can't be parsed they are converted to strings.
The namespace's start function takes the following mount/start
runtime variables as
keys under the :mount-configuration.env
namespace:
vars
- A set of the names of the variables as a keyword:#{:PATH}
skip-missing
- Skip any variables in the set which aren't available at runtime instead of throwing an exception.throw-parse-failed
-Throw an exception if the edn parsing fails.
A file in the resources folder as the source of configuration data. It does not by default attempt to load a resource.
The namespace's start function takes the following mount/start
runtime variables as
keys under the :mount-configuration.resource
namespace:
path
- The path in the resources folderthrow-if-missing
- Throw an exception if there is nopath
argument at runtime.
A file on the file system as a source of configuration data. It does not by default
attempt to load a file. If any of the editing functions are used changes will be saved
on stop
by default.
The namespace's start function takes the following mount/start
runtime variables as
keys under the :mount-configuration.file
namespace:
path
- the file paththrow-if-missing
- throw an exception if the file cant be loaded or parsed to edndont-bootstrap
- Skip bootstrapping and only usemount/args
to loaddont-save-on-stop
- If editing has happened, don't save on stop
Lackadaisically maintained, please submit feedback via GitHub issues.