Skip to content

Commit

Permalink
refactor(Variables): Support custom sources in internal resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Dec 20, 2021
1 parent 352553e commit 365a7f1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/configuration/variables/index.js
Expand Up @@ -9,7 +9,7 @@ const ServerlessError = require('../../serverless-error');
const resolveMeta = require('./resolve-meta');
const resolve = require('./resolve');

const sources = {
const defaultSources = {
env: require('./sources/env'),
file: require('./sources/file'),
opt: require('./sources/opt'),
Expand All @@ -33,7 +33,7 @@ const reportEventualErrors = (variablesMeta) => {
);
};

module.exports = async ({ serviceDir, servicePath, configuration, options }) => {
module.exports = async ({ serviceDir, servicePath, configuration, options, sources = null }) => {
// TODO: Remove support for `servicePath` with next major
serviceDir = ensureString(serviceDir || servicePath);
ensurePlainObject(configuration);
Expand All @@ -42,13 +42,14 @@ module.exports = async ({ serviceDir, servicePath, configuration, options }) =>
const variablesMeta = resolveMeta(configuration);
reportEventualErrors(variablesMeta);

if (!sources) sources = defaultSources;
await resolve({
serviceDir,
configuration,
variablesMeta,
sources,
options,
fulfilledSources: new Set(['env', 'file', 'opt', 'self', 'strToBool']),
fulfilledSources: new Set(Object.keys(sources)),
});

reportEventualErrors(variablesMeta);
Expand Down

0 comments on commit 365a7f1

Please sign in to comment.