Skip to content

Commit

Permalink
[EPM] Remove encoding of Kibana objects as not needed anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
ruflin authored and jfsiii committed Nov 26, 2019
1 parent 14bbe8e commit 399bbd3
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions x-pack/legacy/plugins/epm/server/packages/get_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,13 @@ export async function getObjects(
return Array.from(objects.values());
}

// the assets from the registry are malformed
// https://github.com/elastic/package-registry/issues/42
function ensureJsonValues(obj: SavedObjectToBe) {
const { attributes } = obj;
if (
attributes.kibanaSavedObjectMeta &&
typeof attributes.kibanaSavedObjectMeta.searchSourceJSON !== 'string'
) {
attributes.kibanaSavedObjectMeta.searchSourceJSON = JSON.stringify(
attributes.kibanaSavedObjectMeta.searchSourceJSON
);
}

['optionsJSON', 'panelsJSON', 'uiStateJSON', 'visState']
.filter(key => typeof attributes[key] !== 'string')
.forEach(key => (attributes[key] = JSON.stringify(attributes[key])));

return obj;
}

function getObject(key: string) {
const buffer = Registry.getAsset(key);

// cache values are buffers. convert to string / JSON
const json = buffer.toString('utf8');
// convert that to an object & address issues with the formatting of some parts
const asset: ArchiveAsset = ensureJsonValues(JSON.parse(json));
const asset: ArchiveAsset = JSON.parse(json);

const { type, file } = Registry.pathParts(key);
const savedObject: SavedObjectToBe = {
Expand Down

0 comments on commit 399bbd3

Please sign in to comment.