https://github.com/bsless/aero.extensions
https://github.com/bsless/aero.extensions
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/bsless/aero.extensions
- Owner: bsless
- License: epl-1.0
- Created: 2024-04-03T07:53:32.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-04T06:27:58.000Z (about 2 years ago)
- Last Synced: 2025-03-08T19:34:36.819Z (about 1 year ago)
- Language: Clojure
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://clojars.org/io.github.bsless/aero.extensions)
[](https://clojars.org/io.github.bsless/aero.extensions)
[](https://cljdoc.org/d/io.github.bsless/aero.extensions)

# bsless/aero.extensions
Aero is awesome
Still, it lacks about three features which would make it **shine**:
Another profile dimension, secrets, and secret readers
## Usage
Use aero normally and also load this extension library
```clojure
(require '[aero.core :as aero] '[bsless.aero.extensions])
```
### New tags
#### `ext/mode`
Works exactly like profile, for when you need it
#### `ext/secret`
Wraps the content in an opaque `deref`-able object.
This way printing the loaded configuration won't leak a secret
#### `ext/read-secret`
Having secrets in a config file is convenient, but how can we get them there?
```clojure
#ext/read-secret "path/to/secret"
;; or
#ext/read-secret [:just/whatever "path/to/secret"]
```
Pass a `:secret-reader` to `aero.core/read-config` and let it resolve
the secret according to the specified value at resolution time.
Example - vault client, reader for encryped files
#### `malli/schema`
When some value in your configuration has to conform to a schema
```clojure
#malli/schema [:int 1] ;; pass
#malli/schema [:int "1"] ;; fail
#malli/schema [[:int {:min 2}] 1] ;; fail
```
Use a vector of `[schema value]`.
Optionally pass a `:malli/transformer` when reading the configuration to coerce values.
The second example would pass with
```clojure
(read-config "config.edn" {:malli/transformer mt/string-transformer})
```
Important note: malli isn't included on the class path. Bring it in as an extra dependency.
### Example
Given the config
```clojure
#ext/mode {:fizz #ext/read-secret #profile {:bar "foo/bar" :baz "foo/baz"}
:buzz #profile {:bar 1 :baz 2}}
```
It will resolve to:
```clojure
(read-config config {:profile :bar :mode :fizz :secret-reader {"foo/bar" :foo}})
;; =>
(Secret. :foo)
```
Keep in mind the secret will print as ``
## License
Copyright © 2024 Ben Sless
Distributed under the Eclipse Public License version 1.0.