-
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.
[es/healthcheck] determine enabled scripting langs in healthcheck (#1…
…2454) * [es/healthcheck] determine enabled scripting langs in healthcheck * add test for "latestHealthCheckResults" exports (cherry picked from commit a533455)
- Loading branch information
Showing
4 changed files
with
58 additions
and
20 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
14 changes: 14 additions & 0 deletions
14
src/core_plugins/elasticsearch/lib/determine_enabled_scripting_langs.js
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,14 @@ | ||
import { get, pick, omit, keys } from 'lodash'; | ||
|
||
export function determineEnabledScriptingLangs(callDataAsKibanaUser) { | ||
return callDataAsKibanaUser('cluster.getSettings', { | ||
include_defaults: true, | ||
filter_path: '**.script.engine.*.inline' | ||
}) | ||
.then((esResponse) => { | ||
const langs = get(esResponse, 'defaults.script.engine', {}); | ||
const inlineLangs = pick(langs, lang => lang.inline === 'true'); | ||
const supportedLangs = omit(inlineLangs, 'mustache'); | ||
return keys(supportedLangs); | ||
}); | ||
} |
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
21 changes: 2 additions & 19 deletions
21
src/core_plugins/kibana/server/routes/api/scripts/register_languages.js
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 |
---|---|---|
@@ -1,27 +1,10 @@ | ||
import _ from 'lodash'; | ||
import handleESError from '../../../lib/handle_es_error'; | ||
|
||
export function registerLanguages(server) { | ||
server.route({ | ||
path: '/api/kibana/scripts/languages', | ||
method: 'GET', | ||
handler: function (request, reply) { | ||
const { callWithRequest } = server.plugins.elasticsearch.getCluster('data'); | ||
|
||
return callWithRequest(request, 'cluster.getSettings', { | ||
include_defaults: true, | ||
filter_path: '**.script.engine.*.inline' | ||
}) | ||
.then((esResponse) => { | ||
const langs = _.get(esResponse, 'defaults.script.engine', {}); | ||
const inlineLangs = _.pick(langs, (lang) => lang.inline === 'true'); | ||
const supportedLangs = _.omit(inlineLangs, 'mustache'); | ||
return _.keys(supportedLangs); | ||
}) | ||
.then(reply) | ||
.catch((error) => { | ||
reply(handleESError(error)); | ||
}); | ||
const { latestHealthCheckResults = {} } = server.plugins.elasticsearch; | ||
reply(latestHealthCheckResults.enabledScriptingLangs || []); | ||
} | ||
}); | ||
} |