Add deprecation warning if setting server.host to "0" (#87471)

This commit is contained in:
Thomas Watson 2021-01-06 16:07:29 +01:00 committed by GitHub
parent 00bf2363bc
commit 00c3b18b93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View file

@ -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({

View file

@ -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,
@ -159,4 +169,5 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({
rewriteBasePathDeprecation,
cspRulesDeprecation,
mapManifestServiceUrlDeprecation,
serverHostZeroDeprecation,
];