forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Automatic Import] Safely output the package manifest (elastic#192316)
## Release note Fixes issues with rendering the package manifest in Automatic Import. ## Summary Previously the multiline output or special symbols in the user-provided strings, like description, were breaking YAML structure of the package manifest. The user would be confronted with a message like this, during the last step, after all the work of generating the integration was completed. The incorrect behavior can be observed in detail with a failing test in the first commit of the PR. In this PR, we change the manifest construction logic from template rendering into TypeScript code. As a result, all user-provided strings are correctly serialized. We keep as close as possible to the original manifest structure, also keeping the parameter names. --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
ea57fb0
commit 521b6ee
Showing
3 changed files
with
159 additions
and
47 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
x-pack/plugins/integration_assistant/server/integration_builder/build_integration.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { Integration } from '../../common'; | ||
import { renderPackageManifestYAML } from './build_integration'; | ||
import yaml from 'js-yaml'; | ||
|
||
describe('renderPackageManifestYAML', () => { | ||
test('generates the package manifest correctly', () => { | ||
const integration: Integration = { | ||
title: 'Sample Integration', | ||
name: 'sample-integration', | ||
description: | ||
' This is a sample integration\n\nWith multiple lines and weird spacing. \n\n And more lines ', | ||
logo: 'some-logo.png', | ||
dataStreams: [ | ||
{ | ||
name: 'data-stream-1', | ||
title: 'Data Stream 1', | ||
description: 'This is data stream 1', | ||
inputTypes: ['filestream'], | ||
rawSamples: ['{field: "value"}'], | ||
pipeline: { | ||
processors: [], | ||
}, | ||
docs: [], | ||
samplesFormat: { name: 'ndjson', multiline: false }, | ||
}, | ||
{ | ||
name: 'data-stream-2', | ||
title: 'Data Stream 2', | ||
description: | ||
'This is data stream 2\nWith multiple lines of description\nBut otherwise, nothing special', | ||
inputTypes: ['aws-cloudwatch'], | ||
pipeline: { | ||
processors: [], | ||
}, | ||
rawSamples: ['field="value"'], | ||
docs: [], | ||
samplesFormat: { name: 'structured' }, | ||
}, | ||
], | ||
}; | ||
|
||
const manifestContent = renderPackageManifestYAML(integration); | ||
|
||
// The manifest content must be parseable as YAML. | ||
const manifest = yaml.safeLoad(manifestContent); | ||
|
||
expect(manifest).toBeDefined(); | ||
expect(manifest.title).toBe(integration.title); | ||
expect(manifest.name).toBe(integration.name); | ||
expect(manifest.type).toBe('integration'); | ||
expect(manifest.description).toBe(integration.description); | ||
expect(manifest.icons).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
x-pack/plugins/integration_assistant/server/templates/manifest/package_manifest.yml.njk
This file was deleted.
Oops, something went wrong.