Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into implement/bet…
Browse files Browse the repository at this point in the history
…terWarningForUrlLength
  • Loading branch information
spalger committed Apr 15, 2016
2 parents e308db9 + 176d271 commit 121e4f2
Show file tree
Hide file tree
Showing 559 changed files with 4,636 additions and 4,449 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ Then sit back and wait. There will probably be discussion about the pull request

After a pull is submitted, it needs to get to review. If you have commit permission on the Kibana repo you will probably perform these steps while submitting your pull request. If not, a member of the elastic organization will do them for you, though you can help by suggesting a reviewer for your changes if you've interacted with someone while working on the issue.

1. Assign the `review` tag. This signals to the team that someone needs to give this attention.
1. Assign version tags. If the pull is related to an existing issue (and it should be!), that issue probably has a version tag (eg `4.0.1`) on it. Assign the same version tag to your pull. You may end up with 2 or more version tags if the changes requires backporting
1. Assign the `review` label. This signals to the team that someone needs to give this attention.
1. Do **not** assign a version label. Someone from Elastic staff will assign a version label, if necessary, when your pull request is ready to be merged.
1. Find someone to review your pull. Don't just pick any yahoo, pick the right person. The right person might be the original reporter of the issue, but it might also be the person most familiar with the code you've changed. If neither of those things apply, or your change is small in scope, try to find someone on the Kibana team without a ton of existing reviews on their plate. As a rule, most pulls will require 2 reviewers, but the first reviewer will pick the 2nd.

### Review engaged
Expand Down
2 changes: 0 additions & 2 deletions docs/area.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ include::color-picker.asciidoc[]
You can click the *Advanced* link to display more customization options for your metrics or bucket aggregation:

*Exclude Pattern*:: Specify a pattern in this field to exclude from the results.
*Exclude Pattern Flags*:: A standard set of Java flags for the exclusion pattern.
*Include Pattern*:: Specify a pattern in this field to include in the results.
*Include Pattern Flags*:: A standard set of Java flags for the inclusion pattern.
*JSON Input*:: A text field where you can add specific JSON-formatted properties to merge with the aggregation
definition, as in the following example:

Expand Down
2 changes: 0 additions & 2 deletions docs/datatable.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ Enter a string in the *Custom Label* field to change the display label.
You can click the *Advanced* link to display more customization options for your metrics or bucket aggregation:

*Exclude Pattern*:: Specify a pattern in this field to exclude from the results.
*Exclude Pattern Flags*:: A standard set of Java flags for the exclusion pattern.
*Include Pattern*:: Specify a pattern in this field to include in the results.
*Include Pattern Flags*:: A standard set of Java flags for the inclusion pattern.
*JSON Input*:: A text field where you can add specific JSON-formatted properties to merge with the aggregation
definition, as in the following example:

Expand Down
2 changes: 0 additions & 2 deletions docs/pie.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ Enter a string in the *Custom Label* field to change the display label.
You can click the *Advanced* link to display more customization options for your metrics or bucket aggregation:

*Exclude Pattern*:: Specify a pattern in this field to exclude from the results.
*Exclude Pattern Flags*:: A standard set of Java flags for the exclusion pattern.
*Include Pattern*:: Specify a pattern in this field to include in the results.
*Include Pattern Flags*:: A standard set of Java flags for the inclusion pattern.
*JSON Input*:: A text field where you can add specific JSON-formatted properties to merge with the aggregation
definition, as in the following example:

Expand Down
2 changes: 0 additions & 2 deletions docs/tilemap.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ Enter a string in the *Custom Label* field to change the display label.
You can click the *Advanced* link to display more customization options for your metrics or bucket aggregation:

*Exclude Pattern*:: Specify a pattern in this field to exclude from the results.
*Exclude Pattern Flags*:: A standard set of Java flags for the exclusion pattern.
*Include Pattern*:: Specify a pattern in this field to include in the results.
*Include Pattern Flags*:: A standard set of Java flags for the inclusion pattern.
*JSON Input*:: A text field where you can add specific JSON-formatted properties to merge with the aggregation
definition, as in the following example:

Expand Down
2 changes: 0 additions & 2 deletions docs/vertbar.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ Enter a string in the *Custom Label* field to change the display label.
You can click the *Advanced* link to display more customization options for your metrics or bucket aggregation:

*Exclude Pattern*:: Specify a pattern in this field to exclude from the results.
*Exclude Pattern Flags*:: A standard set of Java flags for the exclusion pattern.
*Include Pattern*:: Specify a pattern in this field to include in the results.
*Include Pattern Flags*:: A standard set of Java flags for the inclusion pattern.
*JSON Input*:: A text field where you can add specific JSON-formatted properties to merge with the aggregation
definition, as in the following example:

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"number": 8467,
"sha": "6cb7fec4e154faa0a4a3fee4b33dfef91b9870d9"
},
"main": "src/server/KbnServer.js",
"homepage": "https://www.elastic.co/products/kibana",
"bugs": {
"url": "http://github.com/elastic/kibana/issues"
Expand Down Expand Up @@ -144,7 +143,7 @@
"wreck": "6.2.0"
},
"devDependencies": {
"@elastic/eslint-config-kibana": "0.0.2",
"@elastic/eslint-config-kibana": "0.0.3",
"Nonsense": "0.1.2",
"angular-mocks": "1.4.7",
"auto-release-sinon": "1.0.3",
Expand Down
48 changes: 48 additions & 0 deletions src/cli/serve/__tests__/deprecated_config.js
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);
});
});
});
1 change: 1 addition & 0 deletions src/cli/serve/__tests__/fixtures/deprecated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
server.xsrf.token: token
1 change: 1 addition & 0 deletions src/cli/serve/__tests__/fixtures/legacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kibana_index: indexname
2 changes: 2 additions & 0 deletions src/cli/serve/__tests__/fixtures/one.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
foo: 1
bar: true
2 changes: 2 additions & 0 deletions src/cli/serve/__tests__/fixtures/two.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
foo: 2
baz: bonkers
28 changes: 28 additions & 0 deletions src/cli/serve/__tests__/legacy_config.js
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/);
});
});
102 changes: 102 additions & 0 deletions src/cli/serve/__tests__/read_yaml_config.js
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();
});
});
});
});
16 changes: 16 additions & 0 deletions src/cli/serve/deprecated_config.js
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;
}
47 changes: 47 additions & 0 deletions src/cli/serve/legacy_config.js
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;
}
}, {});
}
Loading

0 comments on commit 121e4f2

Please sign in to comment.