Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Ingest Manager] Support updated package output structure (#69864) #70263

Merged
merged 1 commit into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const CONFIG_KEYS_ORDER = [
'inputs',
'enabled',
'use_output',
'package',
'meta',
'input',
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => {
{
id: 'test-logs-foo',
enabled: true,
dataset: 'foo',
dataset: { name: 'foo', type: 'logs' },
vars: {
fooVar: { value: 'foo-value' },
fooVar2: { value: [1, 2] },
Expand All @@ -52,7 +52,7 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => {
{
id: 'test-logs-bar',
enabled: true,
dataset: 'bar',
dataset: { name: 'bar', type: 'logs' },
vars: {
barVar: { value: 'bar-value' },
barVar2: { value: [1, 2] },
Expand Down Expand Up @@ -101,23 +101,41 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => {
});

it('returns agent inputs', () => {
expect(storedDatasourcesToAgentInputs([{ ...mockDatasource, inputs: [mockInput] }])).toEqual([
expect(
storedDatasourcesToAgentInputs([
{
...mockDatasource,
package: {
name: 'mock-package',
title: 'Mock package',
version: '0.0.0',
},
inputs: [mockInput],
},
])
).toEqual([
{
id: 'some-uuid',
name: 'mock-datasource',
type: 'test-logs',
dataset: { namespace: 'default' },
use_output: 'default',
meta: {
package: {
name: 'mock-package',
version: '0.0.0',
},
},
streams: [
{
id: 'test-logs-foo',
dataset: { name: 'foo' },
dataset: { name: 'foo', type: 'logs' },
fooKey: 'fooValue1',
fooKey2: ['fooValue2'],
},
{
id: 'test-logs-bar',
dataset: { name: 'bar' },
dataset: { name: 'bar', type: 'logs' },
},
],
},
Expand Down Expand Up @@ -147,7 +165,7 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => {
streams: [
{
id: 'test-logs-foo',
dataset: { name: 'foo' },
dataset: { name: 'foo', type: 'logs' },
fooKey: 'fooValue1',
fooKey2: ['fooValue2'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export const storedDatasourcesToAgentInputs = (
id: datasource.id || datasource.name,
name: datasource.name,
type: input.type,
dataset: { namespace: datasource.namespace || 'default' },
dataset: {
namespace: datasource.namespace || 'default',
},
use_output: DEFAULT_OUTPUT.name,
...Object.entries(input.config || {}).reduce((acc, [key, { value }]) => {
acc[key] = value;
Expand All @@ -35,7 +37,7 @@ export const storedDatasourcesToAgentInputs = (
.map((stream) => {
const fullStream: FullAgentConfigInputStream = {
id: stream.id,
dataset: { name: stream.dataset },
dataset: stream.dataset,
...stream.agent_stream,
...Object.entries(stream.config || {}).reduce((acc, [key, { value }]) => {
acc[key] = value;
Expand All @@ -50,9 +52,11 @@ export const storedDatasourcesToAgentInputs = (
};

if (datasource.package) {
fullInput.package = {
name: datasource.package.name,
version: datasource.package.version,
fullInput.meta = {
package: {
name: datasource.package.name,
version: datasource.package.version,
},
};
}

Expand Down
Loading