Skip to content

Commit d860bb8

Browse files
authored
Include datasource UUID in agent config yaml, adjust overflow height of yaml view (#64027) (#64084)
1 parent 2e97a9b commit d860bb8

File tree

4 files changed

+38
-11
lines changed

4 files changed

+38
-11
lines changed

x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.test.ts

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
import { NewDatasource, DatasourceInput } from '../types';
6+
import { Datasource, NewDatasource, DatasourceInput } from '../types';
77
import { storedDatasourceToAgentDatasource } from './datasource_to_agent_datasource';
88

99
describe('Ingest Manager - storedDatasourceToAgentDatasource', () => {
10-
const mockDatasource: NewDatasource = {
10+
const mockNewDatasource: NewDatasource = {
1111
name: 'mock-datasource',
1212
description: '',
1313
config_id: '',
@@ -17,6 +17,12 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => {
1717
inputs: [],
1818
};
1919

20+
const mockDatasource: Datasource = {
21+
...mockNewDatasource,
22+
id: 'some-uuid',
23+
revision: 1,
24+
};
25+
2026
const mockInput: DatasourceInput = {
2127
type: 'test-logs',
2228
enabled: true,
@@ -70,7 +76,8 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => {
7076

7177
it('returns agent datasource config for datasource with no inputs', () => {
7278
expect(storedDatasourceToAgentDatasource(mockDatasource)).toEqual({
73-
id: 'mock-datasource',
79+
id: 'some-uuid',
80+
name: 'mock-datasource',
7481
namespace: 'default',
7582
enabled: true,
7683
use_output: 'default',
@@ -87,7 +94,8 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => {
8794
},
8895
})
8996
).toEqual({
90-
id: 'mock-datasource',
97+
id: 'some-uuid',
98+
name: 'mock-datasource',
9199
namespace: 'default',
92100
enabled: true,
93101
use_output: 'default',
@@ -99,9 +107,21 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => {
99107
});
100108
});
101109

110+
it('uses name for id when id is not provided in case of new datasource', () => {
111+
expect(storedDatasourceToAgentDatasource(mockNewDatasource)).toEqual({
112+
id: 'mock-datasource',
113+
name: 'mock-datasource',
114+
namespace: 'default',
115+
enabled: true,
116+
use_output: 'default',
117+
inputs: [],
118+
});
119+
});
120+
102121
it('returns agent datasource config with flattened input and package stream', () => {
103122
expect(storedDatasourceToAgentDatasource({ ...mockDatasource, inputs: [mockInput] })).toEqual({
104-
id: 'mock-datasource',
123+
id: 'some-uuid',
124+
name: 'mock-datasource',
105125
namespace: 'default',
106126
enabled: true,
107127
use_output: 'default',
@@ -140,7 +160,8 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => {
140160
],
141161
})
142162
).toEqual({
143-
id: 'mock-datasource',
163+
id: 'some-uuid',
164+
name: 'mock-datasource',
144165
namespace: 'default',
145166
enabled: true,
146167
use_output: 'default',
@@ -169,7 +190,8 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => {
169190
inputs: [{ ...mockInput, enabled: false }],
170191
})
171192
).toEqual({
172-
id: 'mock-datasource',
193+
id: 'some-uuid',
194+
name: 'mock-datasource',
173195
namespace: 'default',
174196
enabled: true,
175197
use_output: 'default',

x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export const storedDatasourceToAgentDatasource = (
1212
const { name, namespace, enabled, package: pkg, inputs } = datasource;
1313

1414
const fullDatasource: FullAgentConfigDatasource = {
15-
id: name,
15+
id: 'id' in datasource ? datasource.id : name,
16+
name,
1617
namespace,
1718
enabled,
1819
use_output: DEFAULT_OUTPUT.name, // TODO: hardcoded to default output for now

x-pack/plugins/ingest_manager/common/types/models/agent_config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ export interface AgentConfig extends NewAgentConfig, SavedObjectAttributes {
3434
revision: number;
3535
}
3636

37-
export type FullAgentConfigDatasource = Pick<Datasource, 'namespace' | 'enabled'> & {
38-
id: string;
37+
export type FullAgentConfigDatasource = Pick<
38+
Datasource,
39+
'id' | 'name' | 'namespace' | 'enabled'
40+
> & {
3941
package?: Pick<DatasourcePackage, 'name' | 'version'>;
4042
use_output: string;
4143
inputs: Array<

x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/yaml/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ import { Loading } from '../../../../../components';
2727

2828
const CONFIG_KEYS_ORDER = [
2929
'id',
30+
'name',
3031
'revision',
32+
'type',
3133
'outputs',
3234
'datasources',
3335
'enabled',
@@ -52,7 +54,7 @@ export const ConfigYamlView = memo<{ config: AgentConfig }>(({ config }) => {
5254
return (
5355
<EuiFlexGroup>
5456
<EuiFlexItem grow={7}>
55-
<EuiCodeBlock language="yaml" isCopyable>
57+
<EuiCodeBlock language="yaml" isCopyable overflowHeight={500}>
5658
{dump(fullConfigRequest.data.item, {
5759
sortKeys: (keyA: string, keyB: string) => {
5860
const indexA = CONFIG_KEYS_ORDER.indexOf(keyA);

0 commit comments

Comments
 (0)