Skip to content

Commit

Permalink
fix: allow file config to override true default values (#4119)
Browse files Browse the repository at this point in the history
  • Loading branch information
csnate authored Jul 31, 2024
1 parent 77b1823 commit 905289e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/config/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ CONFIG_SCHEMA.forEach((def) => {
if (def.envVar && process.env[def.envVar]) {
def.environmentValue = process.env[def.envVar];
def.source = 'environment';
} else if (fileOpts && fileOpts[def.name]) {
} else if (fileOpts && typeof fileOpts[def.name] !== 'undefined') {
def.fileValue = fileOpts[def.name];
def.source = 'file';
}
Expand Down
3 changes: 2 additions & 1 deletion test/start/file/elastic-apm-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
'use strict'

module.exports = {
serviceName: 'from-file'
serviceName: 'from-file',
active: false
}
14 changes: 12 additions & 2 deletions test/start/file/test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ var agent = require('../../..').start({

const tape = require('tape');

tape('from-file serviceName test', function (t) {
t.equals(agent._conf.serviceName, 'from-file');
tape('from-file configuration test', function (t) {
t.equals(
agent._conf.serviceName,
'from-file',
'serviceName comes from config file',
);
t.equals(
agent._conf.active,
false,
'false values from config file override defaults',
);
t.equals(agent._conf.captureBody, 'off', 'existing defaults are preserved');
t.end();
});

0 comments on commit 905289e

Please sign in to comment.