Skip to content

Commit

Permalink
[config] Deprecate KIBANA_PATH_CONF in favor of KBN_PATH_CONF (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz authored Sep 9, 2021
1 parent 7ee68be commit 3f83259
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/kbn-utils/src/path/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ const isString = (v: any): v is string => typeof v === 'string';

const CONFIG_PATHS = [
process.env.KBN_PATH_CONF && join(process.env.KBN_PATH_CONF, 'kibana.yml'),
process.env.KIBANA_PATH_CONF && join(process.env.KIBANA_PATH_CONF, 'kibana.yml'),
process.env.KIBANA_PATH_CONF && join(process.env.KIBANA_PATH_CONF, 'kibana.yml'), // deprecated
process.env.CONFIG_PATH, // deprecated
join(REPO_ROOT, 'config/kibana.yml'),
'/etc/kibana/kibana.yml',
].filter(isString);

const CONFIG_DIRECTORIES = [
process.env.KBN_PATH_CONF,
process.env.KIBANA_PATH_CONF,
process.env.KIBANA_PATH_CONF, // deprecated
join(REPO_ROOT, 'config'),
'/etc/kibana',
].filter(isString);
Expand Down
18 changes: 18 additions & 0 deletions src/core/server/config/deprecation/core_deprecations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ describe('core deprecations', () => {
});
});

describe('kibanaPathConf', () => {
it('logs a warning if KIBANA_PATH_CONF environ variable is set', () => {
process.env.KIBANA_PATH_CONF = 'somepath';
const { messages } = applyCoreDeprecations();
expect(messages).toMatchInlineSnapshot(`
Array [
"Environment variable \\"KIBANA_PATH_CONF\\" is deprecated. It has been replaced with \\"KBN_PATH_CONF\\" pointing to a config folder",
]
`);
});

it('does not log a warning if KIBANA_PATH_CONF environ variable is unset', () => {
delete process.env.KIBANA_PATH_CONF;
const { messages } = applyCoreDeprecations();
expect(messages).toHaveLength(0);
});
});

describe('dataPath', () => {
it('logs a warning if DATA_PATH environ variable is set', () => {
process.env.DATA_PATH = 'somepath';
Expand Down
14 changes: 14 additions & 0 deletions src/core/server/config/deprecation/core_deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@

import { ConfigDeprecationProvider, ConfigDeprecation } from '@kbn/config';

const kibanaPathConf: ConfigDeprecation = (settings, fromPath, addDeprecation) => {
if (process.env?.KIBANA_PATH_CONF) {
addDeprecation({
message: `Environment variable "KIBANA_PATH_CONF" is deprecated. It has been replaced with "KBN_PATH_CONF" pointing to a config folder`,
correctiveActions: {
manualSteps: [
'Use "KBN_PATH_CONF" instead of "KIBANA_PATH_CONF" to point to a config folder.',
],
},
});
}
};

const configPathDeprecation: ConfigDeprecation = (settings, fromPath, addDeprecation) => {
if (process.env?.CONFIG_PATH) {
addDeprecation({
Expand Down Expand Up @@ -392,6 +405,7 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({ rename, unu
rename('server.xsrf.whitelist', 'server.xsrf.allowlist'),
rewriteCorsSettings,
configPathDeprecation,
kibanaPathConf,
dataPathDeprecation,
rewriteBasePathDeprecation,
cspRulesDeprecation,
Expand Down

0 comments on commit 3f83259

Please sign in to comment.