@idoconfig/provider-folder
Version:
Provider for idoconfig that reads values from files within a folder Useful for Docker Secrets.
36 lines (35 loc) • 1.51 kB
TypeScript
import { ConfigurationProviderAbstract } from "@idoconfig/base";
import { IFolderConfigurationValueProviderOptions } from "./interfaces/i-folder-provider-options";
/**
* Read files (content) from a folder. Filenames are mangled through filters which (may)
* transform the filename into ENV_VAR_SYNTAX (or something entirely different).
*
* Default filename filters remove the file extension and enforce ALL_CAPS_STYLE, so
* "my-secret-file.txt" becomes "MY_SECRET_FILE". Additional filename filters may be
* inserted via dependency injection.
*/
export declare class FolderConfigurationValueProvider extends ConfigurationProviderAbstract {
protected options: IFolderConfigurationValueProviderOptions;
protected filenameFilters?: Array<(v: string) => string>;
constructor(options?: IFolderConfigurationValueProviderOptions, additionalFilters?: Array<(v: string) => string>);
/**
* Try to get cached value first. Upon cache miss read file directly
* @param key
*/
getValue(key: string): any;
/**
* When given path starts with PATH_SEP it is absolute. Don't perform
* any other action. If it is relative prepend the current path.
*
* @param unsafePath
*/
private normalizePath;
/**
* Return trimmed value of requested file
* @param file
*/
private getValueFromFile;
private applyFiltersToFilename;
private removeExtension;
}
export default FolderConfigurationValueProvider;