haraka-config
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -7,2 +7,7 @@ # Changelog | ||
### [1.4.0] - 2024-05-12 | ||
- doc(README): fix hjson link (#78) | ||
- config: fix json overrides (#77) | ||
### [1.3.0] - 2024-05-02 | ||
@@ -141,3 +146,5 @@ | ||
[1.2.2]: https://github.com/haraka/haraka-config/releases/tag/v1.2.2 | ||
[1.2.3]: https://github.com/haraka/haraka-config/releases/tag/v1.2.3 | ||
[1.2.4]: https://github.com/haraka/haraka-config/releases/tag/v1.2.4 | ||
[1.3.0]: https://github.com/haraka/haraka-config/releases/tag/v1.3.0 | ||
[1.4.0]: https://github.com/haraka/haraka-config/releases/tag/v1.4.0 |
@@ -160,1 +160,4 @@ 'use strict' | ||
} | ||
// JSON overrides needs smtp.(json|yaml) loaded early | ||
module.exports.get('smtp.json') |
@@ -248,3 +248,5 @@ 'use strict' | ||
console.log(`Overriding file ${fn} with config from ${name}`) | ||
this._config_cache[path.join(cp, fn)] = result[key] | ||
const cache_key = path.join(cp, fn) | ||
this._overrides[cache_key] = true | ||
this._config_cache[cache_key] = result[key] | ||
} | ||
@@ -251,0 +253,0 @@ } |
@@ -6,3 +6,3 @@ { | ||
"description": "Haraka's config file loader", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"homepage": "http://haraka.github.io", | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -93,2 +93,3 @@ # haraka-config | ||
config. | ||
- If `smtp.json` or `smtp.yaml` exist, their contents will be loaded before all other config files. You can make use of [JSON Overrides](#json-overrides) here for a single file config. | ||
@@ -247,2 +248,4 @@ ## Examples | ||
### <a name="json-overrides">JSON Overrides</a> | ||
You can use JSON, HJSON or YAML files to override any other file by prefixing the outer variable name with a `!` e.g. | ||
@@ -252,7 +255,19 @@ | ||
{ | ||
"!smtpgreeting": [ 'this is line one', 'this is line two' ] | ||
"!smtpgreeting": ['this is line one', 'this is line two'], | ||
"!smtp.ini": { | ||
main: { | ||
nodes: 0, | ||
}, | ||
headers: { | ||
max_lines: 1000, | ||
max_received: 100, | ||
}, | ||
}, | ||
"!custom-plugin.yaml": { | ||
secret: 'example', | ||
}, | ||
} | ||
``` | ||
If the config/smtpgreeting file did not exist, then this value would replace it. | ||
If the config/smtpgreeting wasn't loaded before, then this value would replace it. Since `smtp.json` is always loaded first, it can be used to override existing config files. | ||
@@ -265,3 +280,3 @@ NOTE: You must ensure that the data type (e.g. Object, Array or String) for the replaced value is correct. This cannot be done automatically. | ||
You can check [Hjson's homepage](https://hjson.org) to get familiar with it and you can [try out its syntax](https://hjson.org/try.html). | ||
You can check [Hjson's homepage](https://hjson.github.io/) to get familiar with it and you can [try out its syntax](https://hjson.github.io/try.html). | ||
@@ -268,0 +283,0 @@ Main features: |
37914
725
322