Skip to content

Commit

Permalink
Fix logic when calling get index endpoint with empty array
Browse files Browse the repository at this point in the history
Also remove unused translations
  • Loading branch information
jloleysens committed May 14, 2020
1 parent 9ca7880 commit 956d511
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
21 changes: 14 additions & 7 deletions x-pack/plugins/index_management/server/lib/fetch_indices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,17 @@ async function fetchIndicesCall(
callAsCurrentUser: CallAsCurrentUser,
indexNames?: string[]
): Promise<Index[]> {
let indexNamesCSV: string;
if (indexNames && indexNames.length) {
indexNamesCSV = indexNames.join(',');
} else {
indexNamesCSV = '*';
}

// This call retrieves alias and settings (incl. hidden status) information about indices
const indices: GetIndicesResponse = await callAsCurrentUser('transport.request', {
method: 'GET',
path: `/${indexNames ? indexNames : '*'}`,
path: `/${indexNamesCSV}`,
query: {
expand_wildcards: 'hidden,all',
},
Expand All @@ -57,18 +65,17 @@ async function fetchIndicesCall(
format: 'json',
h: 'health,status,index,uuid,pri,rep,docs.count,sth,store.size',
expand_wildcards: 'hidden,all',
index: indexNamesCSV,
};

if (indexNames) {
catQuery.index = indexNames.join(',');
}

// This call retrieves health and other high-level information about indices.
const catHits: Hit[] = await callAsCurrentUser('transport.request', {
method: 'GET',
path: '/_cat/indices',
query: catQuery,
});

// The two responses should be equal in the number of indices returned
return catHits.map(hit => {
const index = indices[hit.index];
const aliases = Object.keys(index.aliases);
Expand All @@ -94,6 +101,6 @@ export const fetchIndices = async (
indexDataEnricher: IndexDataEnricher,
indexNames?: string[]
) => {
const response = await fetchIndicesCall(callAsCurrentUser, indexNames);
return await indexDataEnricher.enrichIndices(response, callAsCurrentUser);
const indices = await fetchIndicesCall(callAsCurrentUser, indexNames);
return await indexDataEnricher.enrichIndices(indices, callAsCurrentUser);
};
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -6736,7 +6736,6 @@
"xpack.idxMgmt.indexTable.serverErrorTitle": "インデックスの読み込み中にエラーが発生",
"xpack.idxMgmt.indexTable.systemIndicesSearchIndicesAriaLabel": "インデックスの検索",
"xpack.idxMgmt.indexTable.systemIndicesSearchInputPlaceholder": "検索",
"xpack.idxMgmt.indexTable.systemIndicesSwitchLabel": "システムインデックスを含める",
"xpack.idxMgmt.indexTemplatesList.emptyPrompt.noIndexTemplatesTitle": "まだテンプレートがありません",
"xpack.idxMgmt.indexTemplatesList.loadingIndexTemplatesDescription": "テンプレートを読み込み中…",
"xpack.idxMgmt.indexTemplatesList.loadingIndexTemplatesErrorMessage": "テンプレートの読み込み中にエラーが発生",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -6741,7 +6741,6 @@
"xpack.idxMgmt.indexTable.serverErrorTitle": "加载索引时出错",
"xpack.idxMgmt.indexTable.systemIndicesSearchIndicesAriaLabel": "搜索索引",
"xpack.idxMgmt.indexTable.systemIndicesSearchInputPlaceholder": "搜索",
"xpack.idxMgmt.indexTable.systemIndicesSwitchLabel": "包括系统索引",
"xpack.idxMgmt.indexTemplatesList.emptyPrompt.noIndexTemplatesTitle": "您尚未有任何模板",
"xpack.idxMgmt.indexTemplatesList.loadingIndexTemplatesDescription": "正在加载模板……",
"xpack.idxMgmt.indexTemplatesList.loadingIndexTemplatesErrorMessage": "加载模板时出错",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export default function({ getService }) {
const { body } = await list().expect(200);
const expectedKeys = [
'health',
'hidden',
'status',
'name',
'uuid',
Expand Down Expand Up @@ -214,6 +215,7 @@ export default function({ getService }) {
const { body } = await reload().expect(200);
const expectedKeys = [
'health',
'hidden',
'status',
'name',
'uuid',
Expand Down

0 comments on commit 956d511

Please sign in to comment.