-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:elastic/kibana into implement/bet…
…terWarningForUrlLength
- Loading branch information
Showing
559 changed files
with
4,636 additions
and
4,449 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import expect from 'expect.js'; | ||
import { set } from 'lodash'; | ||
import { checkForDeprecatedConfig } from '../deprecated_config'; | ||
import sinon from 'auto-release-sinon'; | ||
|
||
describe('cli/serve/deprecated_config', function () { | ||
it('passes original config through', function () { | ||
const config = {}; | ||
set(config, 'server.xsrf.token', 'xxtokenxx'); | ||
const output = checkForDeprecatedConfig(config); | ||
expect(output).to.be(config); | ||
expect(output.server).to.be(config.server); | ||
expect(output.server.xsrf).to.be(config.server.xsrf); | ||
expect(output.server.xsrf.token).to.be(config.server.xsrf.token); | ||
}); | ||
|
||
it('logs warnings about deprecated config values', function () { | ||
const log = sinon.stub(); | ||
const config = {}; | ||
set(config, 'server.xsrf.token', 'xxtokenxx'); | ||
checkForDeprecatedConfig(config, log); | ||
sinon.assert.calledOnce(log); | ||
expect(log.firstCall.args[0]).to.match(/server\.xsrf\.token.+deprecated/); | ||
}); | ||
|
||
describe('does not support compound.keys', function () { | ||
it('ignores fully compound keys', function () { | ||
const log = sinon.stub(); | ||
const config = { 'server.xsrf.token': 'xxtokenxx' }; | ||
checkForDeprecatedConfig(config, log); | ||
sinon.assert.notCalled(log); | ||
}); | ||
|
||
it('ignores partially compound keys', function () { | ||
const log = sinon.stub(); | ||
const config = { server: { 'xsrf.token': 'xxtokenxx' } }; | ||
checkForDeprecatedConfig(config, log); | ||
sinon.assert.notCalled(log); | ||
}); | ||
|
||
it('ignores partially compound keys', function () { | ||
const log = sinon.stub(); | ||
const config = { 'server.xsrf': { token: 'xxtokenxx' } }; | ||
checkForDeprecatedConfig(config, log); | ||
sinon.assert.notCalled(log); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
server.xsrf.token: token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
kibana_index: indexname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
foo: 1 | ||
bar: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
foo: 2 | ||
baz: bonkers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import expect from 'expect.js'; | ||
import { rewriteLegacyConfig } from '../legacy_config'; | ||
import sinon from 'auto-release-sinon'; | ||
|
||
describe('cli/serve/legacy_config', function () { | ||
it('returns a clone of the input', function () { | ||
const file = {}; | ||
const output = rewriteLegacyConfig(file); | ||
expect(output).to.not.be(file); | ||
}); | ||
|
||
it('rewrites legacy config values with literal path replacement', function () { | ||
const file = { port: 4000, host: 'kibana.com' }; | ||
const output = rewriteLegacyConfig(file); | ||
expect(output).to.not.be(file); | ||
expect(output).to.eql({ | ||
'server.port': 4000, | ||
'server.host': 'kibana.com', | ||
}); | ||
}); | ||
|
||
it('logs warnings when legacy config properties are encountered', function () { | ||
const log = sinon.stub(); | ||
rewriteLegacyConfig({ port: 5555 }, log); | ||
sinon.assert.calledOnce(log); | ||
expect(log.firstCall.args[0]).to.match(/port.+deprecated.+server\.port/); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import expect from 'expect.js'; | ||
import { join, relative, resolve } from 'path'; | ||
import readYamlConfig from '../read_yaml_config'; | ||
import sinon from 'auto-release-sinon'; | ||
|
||
function fixture(name) { | ||
return resolve(__dirname, 'fixtures', name); | ||
} | ||
|
||
describe('cli/serve/read_yaml_config', function () { | ||
it('reads a single config file', function () { | ||
const config = readYamlConfig(fixture('one.yml')); | ||
|
||
expect(readYamlConfig(fixture('one.yml'))).to.eql({ | ||
foo: 1, | ||
bar: true, | ||
}); | ||
}); | ||
|
||
it('reads and merged mulitple config file', function () { | ||
const config = readYamlConfig([ | ||
fixture('one.yml'), | ||
fixture('two.yml') | ||
]); | ||
|
||
expect(config).to.eql({ | ||
foo: 2, | ||
bar: true, | ||
baz: 'bonkers' | ||
}); | ||
}); | ||
|
||
context('different cwd()', function () { | ||
const oldCwd = process.cwd(); | ||
const newCwd = join(oldCwd, '..'); | ||
|
||
before(function () { | ||
process.chdir(newCwd); | ||
}); | ||
|
||
it('resolves relative files based on the cwd', function () { | ||
const relativePath = relative(newCwd, fixture('one.yml')); | ||
const config = readYamlConfig(relativePath); | ||
expect(config).to.eql({ | ||
foo: 1, | ||
bar: true, | ||
}); | ||
}); | ||
|
||
it('fails to load relative paths, not found because of the cwd', function () { | ||
expect(function () { | ||
readYamlConfig(relative(oldCwd, fixture('one.yml'))); | ||
}).to.throwException(/ENOENT/); | ||
}); | ||
|
||
after(function () { | ||
process.chdir(oldCwd); | ||
}); | ||
}); | ||
|
||
context('stubbed stdout', function () { | ||
let stub; | ||
|
||
beforeEach(function () { | ||
stub = sinon.stub(process.stdout, 'write'); | ||
}); | ||
|
||
context('deprecated settings', function () { | ||
it('warns about deprecated settings', function () { | ||
readYamlConfig(fixture('deprecated.yml')); | ||
sinon.assert.calledOnce(stub); | ||
expect(stub.firstCall.args[0]).to.match(/deprecated/); | ||
stub.restore(); | ||
}); | ||
|
||
it('only warns once about deprecated settings', function () { | ||
readYamlConfig(fixture('deprecated.yml')); | ||
readYamlConfig(fixture('deprecated.yml')); | ||
readYamlConfig(fixture('deprecated.yml')); | ||
sinon.assert.notCalled(stub); // already logged in previous test | ||
stub.restore(); | ||
}); | ||
}); | ||
|
||
context('legacy settings', function () { | ||
it('warns about deprecated settings', function () { | ||
readYamlConfig(fixture('legacy.yml')); | ||
sinon.assert.calledOnce(stub); | ||
expect(stub.firstCall.args[0]).to.match(/has been replaced/); | ||
stub.restore(); | ||
}); | ||
|
||
it('only warns once about legacy settings', function () { | ||
readYamlConfig(fixture('legacy.yml')); | ||
readYamlConfig(fixture('legacy.yml')); | ||
readYamlConfig(fixture('legacy.yml')); | ||
sinon.assert.notCalled(stub); // already logged in previous test | ||
stub.restore(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { forOwn, has, noop } from 'lodash'; | ||
|
||
// deprecated settings are still allowed, but will be removed at a later time. They | ||
// are checked for after the config object is prepared and known, so legacySettings | ||
// will have already been transformed. | ||
export const deprecatedSettings = new Map([ | ||
[['server', 'xsrf', 'token'], 'server.xsrf.token is deprecated. It is no longer used when providing xsrf protection.'] | ||
]); | ||
|
||
// check for and warn about deprecated settings | ||
export function checkForDeprecatedConfig(object, log = noop) { | ||
for (const [key, msg] of deprecatedSettings.entries()) { | ||
if (has(object, key)) log(msg); | ||
} | ||
return object; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { noop, transform } from 'lodash'; | ||
|
||
// legacySettings allow kibana 4.2+ to accept the same config file that people | ||
// used for kibana 4.0 and 4.1. These settings are transformed to their modern | ||
// equivalents at the very begining of the process | ||
export const legacySettings = { | ||
// server | ||
port: 'server.port', | ||
host: 'server.host', | ||
pid_file: 'pid.file', | ||
ssl_cert_file: 'server.ssl.cert', | ||
ssl_key_file: 'server.ssl.key', | ||
|
||
// logging | ||
log_file: 'logging.dest', | ||
|
||
// kibana | ||
kibana_index: 'kibana.index', | ||
default_app_id: 'kibana.defaultAppId', | ||
|
||
// es | ||
ca: 'elasticsearch.ssl.ca', | ||
elasticsearch_preserve_host: 'elasticsearch.preserveHost', | ||
elasticsearch_url: 'elasticsearch.url', | ||
kibana_elasticsearch_client_crt: 'elasticsearch.ssl.cert', | ||
kibana_elasticsearch_client_key: 'elasticsearch.ssl.key', | ||
kibana_elasticsearch_password: 'elasticsearch.password', | ||
kibana_elasticsearch_username: 'elasticsearch.username', | ||
ping_timeout: 'elasticsearch.pingTimeout', | ||
request_timeout: 'elasticsearch.requestTimeout', | ||
shard_timeout: 'elasticsearch.shardTimeout', | ||
startup_timeout: 'elasticsearch.startupTimeout', | ||
verify_ssl: 'elasticsearch.ssl.verify', | ||
}; | ||
|
||
// transform legacy options into new namespaced versions | ||
export function rewriteLegacyConfig(object, log = noop) { | ||
return transform(object, (clone, val, key) => { | ||
if (legacySettings.hasOwnProperty(key)) { | ||
const replacement = legacySettings[key]; | ||
log(`Config key "${key}" is deprecated. It has been replaced with "${replacement}"`); | ||
clone[replacement] = val; | ||
} else { | ||
clone[key] = val; | ||
} | ||
}, {}); | ||
} |
Oops, something went wrong.