Skip to content

Commit

Permalink
Add deprecation warning if setting server.host to "0" (#87471)
Browse files Browse the repository at this point in the history
  • Loading branch information
watson authored Jan 6, 2021
1 parent 00bf236 commit 00c3b18
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/core/server/config/deprecation/core_deprecations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,26 @@ describe('core deprecations', () => {
});
});

describe('server.host', () => {
it('logs a warning if server.host is set to "0"', () => {
const { messages } = applyCoreDeprecations({
server: { host: '0' },
});
expect(messages).toMatchInlineSnapshot(`
Array [
"Support for setting server.host to \\"0\\" in kibana.yml is deprecated and will be removed in Kibana version 8.0.0. Instead use \\"0.0.0.0\\" to bind to all interfaces.",
]
`);
});
it('does not log a warning if server.host is not set to "0"', () => {
const { migrated, messages } = applyCoreDeprecations({
server: { host: '0.0.0.0' },
});
expect(migrated.server.host).toEqual('0.0.0.0');
expect(messages.length).toBe(0);
});
});

describe('rewriteBasePath', () => {
it('logs a warning is server.basePath is set and server.rewriteBasePath is not', () => {
const { messages } = applyCoreDeprecations({
Expand Down
11 changes: 11 additions & 0 deletions src/core/server/config/deprecation/core_deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ const mapManifestServiceUrlDeprecation: ConfigDeprecation = (settings, fromPath,
return settings;
};

const serverHostZeroDeprecation: ConfigDeprecation = (settings, fromPath, log) => {
if (get(settings, 'server.host') === '0') {
log(
'Support for setting server.host to "0" in kibana.yml is deprecated and will be removed in Kibana version 8.0.0. ' +
'Instead use "0.0.0.0" to bind to all interfaces.'
);
}
return settings;
};

export const coreDeprecationProvider: ConfigDeprecationProvider = ({
unusedFromRoot,
renameFromRoot,
Expand Down Expand Up @@ -159,4 +169,5 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({
rewriteBasePathDeprecation,
cspRulesDeprecation,
mapManifestServiceUrlDeprecation,
serverHostZeroDeprecation,
];

0 comments on commit 00c3b18

Please sign in to comment.