@hmcts/properties-volume
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -0,1 +1,6 @@ | ||
import * as fs from 'fs'; | ||
export interface Options { | ||
mountPoint?: fs.PathLike; | ||
failOnError?: boolean; | ||
} | ||
export { addTo } from './Properties'; |
@@ -5,2 +5,2 @@ "use strict"; | ||
exports.addTo = Properties_1.addTo; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwyQ0FBb0M7QUFBM0IsNkJBQUEsS0FBSyxDQUFBIn0= | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFPQSwyQ0FBb0M7QUFBM0IsNkJBQUEsS0FBSyxDQUFBIn0= |
@@ -1,2 +0,2 @@ | ||
import * as fs from 'fs'; | ||
export declare function addTo(config: any, mountPoint?: fs.PathLike): any; | ||
import { Options } from './index'; | ||
export declare function addTo(config: any, givenOptions?: Options): any; |
@@ -8,7 +8,22 @@ "use strict"; | ||
const log = nodejs_logging_1.Logger.getLogger('applicationRunner'); | ||
function addTo(config, mountPoint = '/mnt/secrets/') { | ||
log.info(`Reading properties from volume: '${mountPoint}'`); | ||
const prefix = getPrefix(mountPoint.toString()); | ||
const properties = readVaults(mountPoint); | ||
config[prefix] = merge(config[prefix] || {}, properties); | ||
const defaultOptions = { | ||
mountPoint: '/mnt/secrets/', | ||
failOnError: false | ||
}; | ||
function addTo(config, givenOptions) { | ||
const options = merge({}, defaultOptions, givenOptions || {}); | ||
const mountPoint = options.mountPoint; | ||
const failOnError = options.failOnError; | ||
log.info(`Attempting to read properties from volume: '${mountPoint}'`); | ||
try { | ||
const prefix = getPrefix(mountPoint.toString()); | ||
const properties = readVaults(mountPoint); | ||
config[prefix] = merge(config[prefix] || {}, properties); | ||
} | ||
catch (error) { | ||
if (failOnError) { | ||
throw Error(`properties-volume failed with:'${error}`); | ||
} | ||
log.info(`Could not read properties from volume: '${mountPoint}' due to '${error}'`); | ||
} | ||
return config; | ||
@@ -41,2 +56,2 @@ } | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUHJvcGVydGllcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9Qcm9wZXJ0aWVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsMERBQThDO0FBQzlDLHNDQUFzQztBQUN0Qyw2QkFBNEI7QUFDNUIseUJBQXdCO0FBRXhCLE1BQU0sR0FBRyxHQUFHLHVCQUFNLENBQUMsU0FBUyxDQUFDLG1CQUFtQixDQUFDLENBQUE7QUFFakQsZUFBdUIsTUFBVyxFQUFFLGFBQTBCLGVBQWU7SUFDM0UsR0FBRyxDQUFDLElBQUksQ0FBQyxvQ0FBb0MsVUFBVSxHQUFHLENBQUMsQ0FBQTtJQUMzRCxNQUFNLE1BQU0sR0FBRyxTQUFTLENBQUMsVUFBVSxDQUFDLFFBQVEsRUFBRSxDQUFDLENBQUE7SUFDL0MsTUFBTSxVQUFVLEdBQUcsVUFBVSxDQUFDLFVBQVUsQ0FBQyxDQUFBO0lBQ3pDLE1BQU0sQ0FBQyxNQUFNLENBQUMsR0FBRyxLQUFLLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxJQUFJLEVBQUUsRUFBRSxVQUFVLENBQUMsQ0FBQTtJQUN4RCxPQUFPLE1BQU0sQ0FBQTtBQUNmLENBQUM7QUFORCxzQkFNQztBQUVELG1CQUFvQixLQUFhO0lBQy9CLE1BQU0sWUFBWSxHQUFHLElBQ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ault flex volume to express properties integration", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -63,3 +63,3 @@ # properties-volume-nodejs | ||
override the volume mount point. To do this we can supply a value for the defaulted volume folder in the api | ||
i.e `addTo( config, 'some/other/folder/secrets')`. | ||
i.e `addTo( config, {mountPoint:'some/other/folder/secrets'})`. | ||
@@ -72,3 +72,3 @@ - The **last folder name** is used as the prefix for the properties in the configuration | ||
volume that is merged in will override any properties with the same name. | ||
## Quick start | ||
@@ -88,3 +88,15 @@ ```bash | ||
```javascript | ||
config = require('properties-volume').addTo(require('config')) | ||
config = require('@hmcts/properties-volume').addTo(require('config')) | ||
``` | ||
### Options | ||
The properties volume can be supplied with a couple of options via a _js_ like options object. | ||
e.g. | ||
```javascript | ||
const config = require('@hmcts/properties-volume').addTo(require('config'),{mountPoint:'some/properties/mount/point'}) | ||
``` | ||
| Option | Description | Default | | ||
| ------ | ----------- | ------- | | ||
| `mountPoint` | the folder where the properties volume exists. | `/mnt/secrets/`| | ||
| `failOnError` | Should this module throw an exception if mount does not exist or there is an error reading the properties | `false` | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14212
72
100