[Fleet] Add {package}@custom component template support (#213431)

Closes [212086](https://github.com/elastic/kibana/issues/212086)

## Summary


Adds support for `{package}@custom` on component templates in Fleet
installed integrations. Similar to [PR
192731](https://github.com/elastic/kibana/pull/192731).


![image](https://github.com/user-attachments/assets/ffe123e7-f8f6-4a59-8907-496ff0bf0a64)


### Acceptance Criteria

- [x] All index templates for data streams associated with an
integration installed through Fleet include a reference to
{package}@custom in their composed_of array.
- _Example: All index templates for the nginx integration's data streams
should include nginx@custom._

- [x] {package}@custom appears after {type}@custom in the composed_of
array.
- _Example: system@custom should be listed after logs@custom._

- [x] {package}@custom is included in the
ignore_missing_component_templates array since it is optional.


### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

N/A

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Mason Herron 2025-03-10 23:32:26 -06:00 committed by GitHub
parent 0b77522dc1
commit 9d99f821ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 45 additions and 6 deletions

View file

@ -474,6 +474,15 @@ export function buildComponentTemplates(params: {
_meta,
};
}
if (packageName) {
const customTemplateName = `${packageName}${USER_SETTINGS_TEMPLATE_SUFFIX}`;
templatesMap[customTemplateName] = {
template: {
settings: {},
},
_meta,
};
}
// return empty/stub template
templatesMap[userSettingsTemplateName] = {

View file

@ -387,12 +387,16 @@ _meta:
_meta: meta,
composed_of: [
'logs-endpoint.metadata_current-template@package',
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
index_patterns: ['.metrics-endpoint.metadata_united_default'],
priority: 250,
template: { mappings: undefined, settings: undefined },
ignore_missing_component_templates: ['logs-endpoint.metadata_current-template@custom'],
ignore_missing_component_templates: [
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
},
name: 'logs-endpoint.metadata_current-template',
},
@ -673,12 +677,16 @@ _meta:
_meta: meta,
composed_of: [
'logs-endpoint.metadata_current-template@package',
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
index_patterns: ['.metrics-endpoint.metadata_united_default'],
priority: 250,
template: { mappings: undefined, settings: undefined },
ignore_missing_component_templates: ['logs-endpoint.metadata_current-template@custom'],
ignore_missing_component_templates: [
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
},
name: 'logs-endpoint.metadata_current-template',
},
@ -936,12 +944,16 @@ _meta:
_meta: meta,
composed_of: [
'logs-endpoint.metadata_current-template@package',
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
index_patterns: ['.metrics-endpoint.metadata_united_default'],
priority: 250,
template: { mappings: undefined, settings: undefined },
ignore_missing_component_templates: ['logs-endpoint.metadata_current-template@custom'],
ignore_missing_component_templates: [
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
},
name: 'logs-endpoint.metadata_current-template',
},

View file

@ -68,6 +68,12 @@ Array [
"id": "logs@custom",
"type": "component_template",
},
Object {
"appLink": "/app/management/data/index_management/component_templates/all_assets@custom",
"attributes": Object {},
"id": "all_assets@custom",
"type": "component_template",
},
Object {
"appLink": "/app/management/data/index_management/component_templates/logs-all_assets.test_logs@custom",
"attributes": Object {},

View file

@ -97,7 +97,7 @@ export default function (providerContext: FtrProviderContext) {
it('should install a tar archive correctly', async function () {
const res = await uploadPackage();
expect(res.body.items.length).to.be(32);
expect(res.body.items.length).to.be(33);
});
it('should upgrade when uploading a newer zip archive', async () => {
@ -111,7 +111,7 @@ export default function (providerContext: FtrProviderContext) {
.type('application/zip')
.send(buf)
.expect(200);
expect(res.body.items.length).to.be(32);
expect(res.body.items.length).to.be(33);
expect(res.body.items.some((item: any) => item.id.includes(testPkgNewVersion)));
await deletePackage(testPkgName, testPkgNewVersion);
@ -182,7 +182,7 @@ export default function (providerContext: FtrProviderContext) {
.type('application/zip')
.send(buf)
.expect(200);
expect(res.body.items.length).to.be(32);
expect(res.body.items.length).to.be(33);
});
it('should throw an error if the archive is zip but content type is gzip', async function () {

View file

@ -62,6 +62,7 @@ export default function (providerContext: FtrProviderContext) {
`logs@settings`,
`${templateName}@package`,
'logs@custom',
`overrides@custom`,
`${templateName}@custom`,
`ecs@mappings`,
'.fleet_globals-1',

View file

@ -604,6 +604,10 @@ const expectAssetsInstalled = ({
id: 'logs@custom',
type: 'component_template',
},
{
id: 'all_assets@custom',
type: 'component_template',
},
{
id: 'logs-all_assets.test_logs@custom',
type: 'component_template',

View file

@ -429,6 +429,10 @@ export default function (providerContext: FtrProviderContext) {
id: 'logs@custom',
type: 'component_template',
},
{
id: 'all_assets@custom',
type: 'component_template',
},
{
id: 'logs-all_assets.test_logs@custom',
type: 'component_template',

View file

@ -204,6 +204,7 @@ export default function (providerContext: FtrProviderContext) {
{ id: 'logs-dataset1@package', type: 'component_template' },
{ id: 'logs-dataset1@custom', type: 'component_template' },
{ id: 'logs@custom', type: 'component_template' },
{ id: 'input_package_upgrade@custom', type: 'component_template' },
]);
// now check the package component template was created correctly

View file

@ -993,6 +993,7 @@ export default function (providerContext: FtrProviderContext) {
{ id: 'logs-somedataset@package', type: 'component_template' },
{ id: 'logs-somedataset@custom', type: 'component_template' },
{ id: 'logs@custom', type: 'component_template' },
{ id: 'integration_to_input@custom', type: 'component_template' },
]);
const dataset3PkgComponentTemplate = await getComponentTemplate('logs-somedataset@package');

View file

@ -1315,6 +1315,7 @@ export default function (providerContext: FtrProviderContext) {
}
expectedAssets.push({ id: 'logs@custom', type: 'component_template' });
expectedAssets.push({ id: 'integration_to_input@custom', type: 'component_template' });
});
afterEach(async function () {