Skip to content

Commit

Permalink
Match elastic/package-spec#24 /dataset->/data_stream directory re…
Browse files Browse the repository at this point in the history
…naming
  • Loading branch information
jen-huang committed Sep 28, 2020
1 parent aa81a02 commit 4c5e586
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/ingest_manager/dev_docs/epm.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ When a package is installed or upgraded, certain Kibana and Elasticsearch assets
### Generation

- Index templates are generated from `YAML` files contained in the package.
- There is one index template per dataset.
- For the generation of an index template, all `yml` files contained in the package subdirectory `dataset/DATASET_NAME/fields/` are used.
- There is one index template per data stream.
- For the generation of an index template, all `yml` files contained in the package subdirectory `data_stream/DATASET_NAME/fields/` are used.
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ async function installPipeline({

const isDirectory = ({ path }: Registry.ArchiveEntry) => path.endsWith('/');

const isDataStreamPipeline = (path: string, dataStreamName: string) => {
const isDataStreamPipeline = (path: string, dataStreamDataset: string) => {
const pathParts = Registry.pathParts(path);
return (
!isDirectory({ path }) &&
pathParts.type === ElasticsearchAssetType.ingestPipeline &&
pathParts.dataset !== undefined &&
dataStreamName === pathParts.dataset
dataStreamDataset === pathParts.dataset
);
};
const isPipeline = (path: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ const updateExistingIndex = async ({
}) => {
const { settings, mappings } = indexTemplate.template;

// for now, remove from object so as not to update stream or dataset properties of the index until type and name
// for now, remove from object so as not to update stream or data stream properties of the index until type and name
// are added in https://github.com/elastic/kibana/issues/66551. namespace value we will continue
// to skip updating and assume the value in the index mapping is correct
delete mappings.properties.stream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ describe('test transform install', () => {
],
} as unknown) as RegistryPackage,
[
'endpoint-0.16.0-dev.0/dataset/policy/elasticsearch/ingest_pipeline/default.json',
'endpoint-0.16.0-dev.0/dataset/metadata/elasticsearch/transform/default.json',
'endpoint-0.16.0-dev.0/dataset/metadata_current/elasticsearch/transform/default.json',
'endpoint-0.16.0-dev.0/data_stream/policy/elasticsearch/ingest_pipeline/default.json',
'endpoint-0.16.0-dev.0/data_stream/metadata/elasticsearch/transform/default.json',
'endpoint-0.16.0-dev.0/data_stream/metadata_current/elasticsearch/transform/default.json',
],
legacyScopedClusterClient.callAsCurrentUser,
savedObjectsClient
Expand Down Expand Up @@ -284,7 +284,7 @@ describe('test transform install', () => {
},
],
} as unknown) as RegistryPackage,
['endpoint-0.16.0-dev.0/dataset/metadata_current/elasticsearch/transform/default.json'],
['endpoint-0.16.0-dev.0/data_stream/metadata_current/elasticsearch/transform/default.json'],
legacyScopedClusterClient.callAsCurrentUser,
savedObjectsClient
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const tests = [
{
package: {
assets: [
'/package/coredns/1.0.1/dataset/log/elasticsearch/ingest-pipeline/pipeline-plaintext.json',
'/package/coredns/1.0.1/dataset/log/elasticsearch/ingest-pipeline/pipeline-json.json',
'/package/coredns/1.0.1/data_stream/log/elasticsearch/ingest-pipeline/pipeline-plaintext.json',
'/package/coredns/1.0.1/data_stream/log/elasticsearch/ingest-pipeline/pipeline-json.json',
],
path: '/package/coredns/1.0.1',
},
Expand All @@ -21,15 +21,15 @@ const tests = [
return true;
},
expected: [
'/package/coredns/1.0.1/dataset/log/elasticsearch/ingest-pipeline/pipeline-plaintext.json',
'/package/coredns/1.0.1/dataset/log/elasticsearch/ingest-pipeline/pipeline-json.json',
'/package/coredns/1.0.1/data_stream/log/elasticsearch/ingest-pipeline/pipeline-plaintext.json',
'/package/coredns/1.0.1/data_stream/log/elasticsearch/ingest-pipeline/pipeline-json.json',
],
},
{
package: {
assets: [
'/package/coredns-1.0.1/dataset/log/elasticsearch/ingest-pipeline/pipeline-plaintext.json',
'/package/coredns-1.0.1/dataset/log/elasticsearch/ingest-pipeline/pipeline-json.json',
'/package/coredns-1.0.1/data_stream/log/elasticsearch/ingest-pipeline/pipeline-plaintext.json',
'/package/coredns-1.0.1/data_stream/log/elasticsearch/ingest-pipeline/pipeline-json.json',
],
path: '/package/coredns/1.0.1',
},
Expand All @@ -43,8 +43,8 @@ const tests = [
{
package: {
assets: [
'/package/coredns-1.0.1/dataset/log/elasticsearch/ingest-pipeline/pipeline-plaintext.json',
'/package/coredns-1.0.1/dataset/log/elasticsearch/ingest-pipeline/pipeline-json.json',
'/package/coredns-1.0.1/data_stream/log/elasticsearch/ingest-pipeline/pipeline-plaintext.json',
'/package/coredns-1.0.1/data_stream/log/elasticsearch/ingest-pipeline/pipeline-json.json',
],
},
// Filter which does not exist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import * as Registry from '../registry';
import { ensureCachedArchiveInfo } from '../registry';

// paths from RegistryPackage are routes to the assets on EPR
// e.g. `/package/nginx/1.2.0/dataset/access/fields/fields.yml`
// e.g. `/package/nginx/1.2.0/data_stream/access/fields/fields.yml`
// paths for ArchiveEntry are routes to the assets in the archive
// e.g. `nginx-1.2.0/dataset/access/fields/fields.yml`
// e.g. `nginx-1.2.0/data_stream/access/fields/fields.yml`
// RegistryPackage paths have a `/package/` prefix compared to ArchiveEntry paths
// and different package and version structure
const EPR_PATH_PREFIX = '/package';
Expand All @@ -37,7 +37,7 @@ export function getAssets(

// if dataset, filter for them
if (datasetName) {
const comparePath = `${packageInfo.path}/dataset/${datasetName}/`;
const comparePath = `${packageInfo.path}/data_stream/${datasetName}/`;
if (!path.includes(comparePath)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export async function installPackage({

// currently only the base package has an ILM policy
// at some point ILM policies can be installed/modified
// per dataset and we should then save them
// per data stream and we should then save them
await installILMPolicy(paths, callCluster);

// installs versionized pipelines without removing currently installed ones
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ const testPaths = [
},
},
{
path: 'coredns-1.0.1/dataset/stats/fields/coredns.stats.yml',
path: 'coredns-1.0.1/data_stream/stats/fields/coredns.stats.yml',
assetParts: {
dataset: 'stats',
file: 'coredns.stats.yml',
path: 'coredns-1.0.1/dataset/stats/fields/coredns.stats.yml',
path: 'coredns-1.0.1/data_stream/stats/fields/coredns.stats.yml',
pkgkey: 'coredns-1.0.1',
service: '',
type: 'fields',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ export function pathParts(path: string): AssetParts {

let [pkgkey, service, type, file] = path.split('/');

// if it's a dataset
if (service === 'dataset') {
// if it's a data stream
if (service === 'data_stream') {
// save the dataset name
dataset = type;
// drop the `dataset/dataset-name` portion & re-parse
[pkgkey, service, type, file] = path.replace(`dataset/${dataset}/`, '').split('/');
// drop the `data_stream/dataset-name` portion & re-parse
[pkgkey, service, type, file] = path.replace(`data_stream/${dataset}/`, '').split('/');
}

// This is to cover for the fields.yml files inside the "fields" directory
Expand Down

0 comments on commit 4c5e586

Please sign in to comment.