Limit scripted fields to painless and expression langs (#9172)

We made a mistake in opening up Kibana scripted fields to any and all
langs enabled in Elasticsearch. Kibana needs to do some magic to get
certain scripted field features to work
(https://github.com/elastic/kibana/pull/9171) and we can't commit to
supporting anything beyond expression and painless scripts. On top of
that, the other languages are being removed in ES 6.0 anyway. This commit
makes that stance explicit by disallowing anything other than those two
choices.
This commit is contained in:
Matt Bargar 2016-12-12 16:32:22 -05:00 committed by GitHub
parent 0c736724b0
commit 8eed97b69f
3 changed files with 36 additions and 7 deletions

View file

@ -1,4 +1,13 @@
[[breaking-changes-6.0]]
== Breaking changes in 6.0
There are not yet any breaking changes in Kibana 6.0
This section discusses the changes that you need to be aware of when migrating
your application to Kibana 6.0.
[float]
=== Removed option to use unsupported scripting languages
*Details:* Kibana 5.x allowed users to create scripted fields using any scripting language enabled in Elasticsearch.
Kibana 6.0 will only support Painless and Lucene expression based scripts.
*Impact:* You will need to migrate your groovy, python, javascript, etc. scripted fields to Painless or Lucene expressions.

View file

@ -10,12 +10,14 @@ import chrome from 'ui/chrome';
import IndexPatternsCastMappingTypeProvider from 'ui/index_patterns/_cast_mapping_type';
import { scriptedFields as docLinks } from '../documentation_links/documentation_links';
import './field_editor.less';
import { GetEnabledScriptingLanguagesProvider, getSupportedScriptingLanguages } from '../scripting_languages';
uiModules
.get('kibana', ['colorpicker.module'])
.directive('fieldEditor', function (Private, $sce) {
let fieldFormats = Private(RegistryFieldFormatsProvider);
let Field = Private(IndexPatternsFieldProvider);
let getEnabledScriptingLanguages = Private(GetEnabledScriptingLanguagesProvider);
const fieldTypesByLang = {
painless: ['number', 'string', 'date', 'boolean'],
@ -37,7 +39,7 @@ uiModules
self.docLinks = docLinks;
getScriptingLangs().then((langs) => {
self.scriptingLangs = langs;
self.scriptingLangs = _.intersection(langs, ['expression', 'painless']);
if (!_.includes(self.scriptingLangs, self.field.lang)) {
self.field.lang = undefined;
}
@ -159,11 +161,9 @@ uiModules
}
function getScriptingLangs() {
return $http.get(chrome.addBasePath('/api/kibana/scripts/languages'))
.then((res) => res.data)
.catch(() => {
notify.error('Error getting available scripting languages from Elasticsearch');
return [];
return getEnabledScriptingLanguages()
.then((enabledLanguages) => {
return _.intersection(enabledLanguages, getSupportedScriptingLanguages());
});
}

View file

@ -0,0 +1,20 @@
import chrome from 'ui/chrome';
import Notifier from 'ui/notify/notifier';
import { intersection } from 'lodash';
const notify = new Notifier({ location: 'Scripting Language Service' });
export function getSupportedScriptingLanguages() {
return ['expression', 'painless'];
}
export function GetEnabledScriptingLanguagesProvider($http) {
return () => {
return $http.get(chrome.addBasePath('/api/kibana/scripts/languages'))
.then((res) => res.data)
.catch(() => {
notify.error('Error getting available scripting languages from Elasticsearch');
return [];
});
};
}