Skip to content

Commit

Permalink
Allow kibana_settings collector to return nothing (#22091) (#22159)
Browse files Browse the repository at this point in the history
* Fix kibana_settings collector to return nothing when no settings data is found

* make code more clear
  • Loading branch information
tsullivan authored Aug 17, 2018
1 parent 0c2120a commit 07559c1
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function getSettingsCollector(server, kbnServer) {
return collectorSet.makeStatsCollector({
type: KIBANA_SETTINGS_TYPE,
async fetch(callCluster) {
let kibanaSettingsData;
let kibanaSettingsData = null;
const defaultAdminEmail = await checkForEmailValue(config, callCluster);

// skip everything if defaultAdminEmail === undefined
Expand All @@ -79,10 +79,16 @@ export function getSettingsCollector(server, kbnServer) {
// remember the current email so that we can mark it as successful if the bulk does not error out
shouldUseNull = !!defaultAdminEmail;

return {
kibana: getKibanaInfoForStats(server, kbnServer),
...kibanaSettingsData
};
// return nothing when there was no result
let settingsDoc;
if (kibanaSettingsData !== null) {
settingsDoc = {
kibana: getKibanaInfoForStats(server, kbnServer),
...kibanaSettingsData
};
}

return settingsDoc;
}
});
}

0 comments on commit 07559c1

Please sign in to comment.