Skip to content

Commit

Permalink
[EPM] Allow to read files from fields directory (#51958)
Browse files Browse the repository at this point in the history
This change allows to also extract files from the `fields` directory. Previously this was not possible because it always assumed a service must be there.
  • Loading branch information
ruflin committed Dec 2, 2019
1 parent 7771ec2 commit 9a4e9d8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions x-pack/legacy/plugins/epm/server/registry/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ const testPaths = [
type: 'visualization',
},
},
{
path: 'coredns-1.0.1/dataset/stats/fields/coredns.stats.yml',
assetParts: {
dataset: 'stats',
file: 'coredns.stats.yml',
path: 'coredns-1.0.1/dataset/stats/fields/coredns.stats.yml',
pkgkey: 'coredns-1.0.1',
service: '',
type: 'fields',
},
},
];

test('testPathParts', () => {
Expand Down
7 changes: 7 additions & 0 deletions x-pack/legacy/plugins/epm/server/registry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ export function pathParts(path: string): AssetParts {
[pkgkey, service, type, file] = path.replace(`dataset/${dataset}/`, '').split('/');
}

// This is to cover for the fields.yml files inside the "fields" directory
if (file === undefined && type.endsWith('.yml')) {
file = type;
type = 'fields';
service = '';
}

return {
pkgkey,
service,
Expand Down

0 comments on commit 9a4e9d8

Please sign in to comment.