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

[Ingest Manager] Update dataset.* to data_stream.* in package config SO attributes #74414

Merged
merged 2 commits into from
Aug 6, 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 @@ -10,6 +10,7 @@ const CONFIG_KEYS_ORDER = [
'id',
'name',
'revision',
'dataset',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be data_stream? I think I miss how this works.

Copy link
Contributor Author

@jen-huang jen-huang Aug 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just for ordering of yaml keys in the UI. I added this so that data_stream.dataset displays above data_stream.type (the same way as before when dataset.name displayed before dataset.type)

image

'type',
'outputs',
'agent',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Ingest Manager - storedPackageConfigsToAgentInputs', () => {
{
id: 'test-logs-foo',
enabled: true,
dataset: { name: 'foo', type: 'logs' },
data_stream: { dataset: 'foo', type: 'logs' },
vars: {
fooVar: { value: 'foo-value' },
fooVar2: { value: [1, 2] },
Expand All @@ -52,7 +52,7 @@ describe('Ingest Manager - storedPackageConfigsToAgentInputs', () => {
{
id: 'test-logs-bar',
enabled: true,
dataset: { name: 'bar', type: 'logs' },
data_stream: { dataset: 'bar', type: 'logs' },
vars: {
barVar: { value: 'bar-value' },
barVar2: { value: [1, 2] },
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('Ingest Manager - storedPackageConfigsToAgentInputs', () => {
id: 'some-uuid',
name: 'mock-package-config',
type: 'test-logs',
dataset: { namespace: 'default' },
data_stream: { namespace: 'default' },
use_output: 'default',
meta: {
package: {
Expand All @@ -129,13 +129,13 @@ describe('Ingest Manager - storedPackageConfigsToAgentInputs', () => {
streams: [
{
id: 'test-logs-foo',
dataset: { name: 'foo', type: 'logs' },
data_stream: { dataset: 'foo', type: 'logs' },
fooKey: 'fooValue1',
fooKey2: ['fooValue2'],
},
{
id: 'test-logs-bar',
dataset: { name: 'bar', type: 'logs' },
data_stream: { dataset: 'bar', type: 'logs' },
},
],
},
Expand All @@ -160,12 +160,12 @@ describe('Ingest Manager - storedPackageConfigsToAgentInputs', () => {
id: 'some-uuid',
name: 'mock-package-config',
type: 'test-logs',
dataset: { namespace: 'default' },
data_stream: { namespace: 'default' },
use_output: 'default',
streams: [
{
id: 'test-logs-foo',
dataset: { name: 'foo', type: 'logs' },
data_stream: { dataset: 'foo', type: 'logs' },
fooKey: 'fooValue1',
fooKey2: ['fooValue2'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const storedPackageConfigsToAgentInputs = (
id: packageConfig.id || packageConfig.name,
name: packageConfig.name,
type: input.type,
dataset: {
data_stream: {
namespace: packageConfig.namespace || 'default',
},
use_output: DEFAULT_OUTPUT.name,
Expand All @@ -37,7 +37,7 @@ export const storedPackageConfigsToAgentInputs = (
.map((stream) => {
const fullStream: FullAgentConfigInputStream = {
id: stream.id,
dataset: stream.dataset,
data_stream: stream.data_stream,
...stream.compiled_stream,
...Object.entries(stream.config || {}).reduce((acc, [key, { value }]) => {
acc[key] = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ describe('Ingest Manager - packageToConfig', () => {
{
type: 'foo',
enabled: true,
streams: [{ id: 'foo-foo', enabled: true, dataset: { name: 'foo', type: 'logs' } }],
streams: [
{ id: 'foo-foo', enabled: true, data_stream: { dataset: 'foo', type: 'logs' } },
],
},
{
type: 'bar',
enabled: true,
streams: [
{ id: 'bar-bar', enabled: true, dataset: { name: 'bar', type: 'logs' } },
{ id: 'bar-bar2', enabled: true, dataset: { name: 'bar2', type: 'logs' } },
{ id: 'bar-bar', enabled: true, data_stream: { dataset: 'bar', type: 'logs' } },
{ id: 'bar-bar2', enabled: true, data_stream: { dataset: 'bar2', type: 'logs' } },
],
},
]);
Expand Down Expand Up @@ -141,7 +143,7 @@ describe('Ingest Manager - packageToConfig', () => {
{
id: 'foo-foo',
enabled: true,
dataset: { name: 'foo', type: 'logs' },
data_stream: { dataset: 'foo', type: 'logs' },
vars: { 'var-name': { value: 'foo-var-value' } },
},
],
Expand All @@ -153,13 +155,13 @@ describe('Ingest Manager - packageToConfig', () => {
{
id: 'bar-bar',
enabled: true,
dataset: { name: 'bar', type: 'logs' },
data_stream: { dataset: 'bar', type: 'logs' },
vars: { 'var-name': { type: 'text', value: 'bar-var-value' } },
},
{
id: 'bar-bar2',
enabled: true,
dataset: { name: 'bar2', type: 'logs' },
data_stream: { dataset: 'bar2', type: 'logs' },
vars: { 'var-name': { type: 'yaml', value: 'bar2-var-value' } },
},
],
Expand Down Expand Up @@ -257,7 +259,7 @@ describe('Ingest Manager - packageToConfig', () => {
{
id: 'foo-foo',
enabled: true,
dataset: { name: 'foo', type: 'logs' },
data_stream: { dataset: 'foo', type: 'logs' },
vars: {
'var-name': { value: 'foo-var-value' },
},
Expand All @@ -275,15 +277,15 @@ describe('Ingest Manager - packageToConfig', () => {
{
id: 'bar-bar',
enabled: true,
dataset: { name: 'bar', type: 'logs' },
data_stream: { dataset: 'bar', type: 'logs' },
vars: {
'var-name': { value: 'bar-var-value' },
},
},
{
id: 'bar-bar2',
enabled: true,
dataset: { name: 'bar2', type: 'logs' },
data_stream: { dataset: 'bar2', type: 'logs' },
vars: {
'var-name': { value: 'bar2-var-value' },
},
Expand All @@ -297,15 +299,15 @@ describe('Ingest Manager - packageToConfig', () => {
{
id: 'with-disabled-streams-disabled',
enabled: false,
dataset: { name: 'disabled', type: 'logs' },
data_stream: { dataset: 'disabled', type: 'logs' },
vars: {
'var-name': { value: [] },
},
},
{
id: 'with-disabled-streams-disabled2',
enabled: false,
dataset: { name: 'disabled2', type: 'logs' },
data_stream: { dataset: 'disabled2', type: 'logs' },
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ import {
const getStreamsForInputType = (
inputType: string,
packageInfo: PackageInfo
): Array<RegistryStream & { dataset: { type: string; name: string } }> => {
const streams: Array<RegistryStream & { dataset: { type: string; name: string } }> = [];
): Array<RegistryStream & { data_stream: { type: string; dataset: string } }> => {
const streams: Array<RegistryStream & { data_stream: { type: string; dataset: string } }> = [];

(packageInfo.datasets || []).forEach((dataset) => {
(dataset.streams || []).forEach((stream) => {
if (stream.input === inputType) {
streams.push({
...stream,
dataset: {
data_stream: {
type: dataset.type,
name: dataset.name,
dataset: dataset.name,
},
});
}
Expand Down Expand Up @@ -76,12 +76,9 @@ export const packageToPackageConfigInputs = (packageInfo: PackageInfo): PackageC
packageInfo
).map((packageStream) => {
const stream: PackageConfigInputStream = {
id: `${packageInput.type}-${packageStream.dataset.name}`,
id: `${packageInput.type}-${packageStream.data_stream.dataset}`,
enabled: packageStream.enabled === false ? false : true,
dataset: {
name: packageStream.dataset.name,
type: packageStream.dataset.type,
},
data_stream: packageStream.data_stream,
};
if (packageStream.vars && packageStream.vars.length) {
stream.vars = packageStream.vars.reduce(varsReducer, {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export type AgentConfigSOAttributes = Omit<AgentConfig, 'id'>;

export interface FullAgentConfigInputStream {
id: string;
dataset: {
name: string;
data_stream: {
dataset: string;
type: string;
};
[key: string]: any;
Expand All @@ -43,7 +43,7 @@ export interface FullAgentConfigInput {
id: string;
name: string;
type: string;
dataset: { namespace: string };
data_stream: { namespace: string };
use_output: string;
meta?: {
package?: Pick<PackageConfigPackage, 'name' | 'version'>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export type PackageConfigConfigRecord = Record<string, PackageConfigConfigRecord
export interface NewPackageConfigInputStream {
id: string;
enabled: boolean;
dataset: {
name: string;
data_stream: {
dataset: string;
type: string;
};
vars?: PackageConfigConfigRecord;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ShortenedHorizontalRule = styled(EuiHorizontalRule)`

const shouldShowStreamsByDefault = (
packageInput: RegistryInput,
packageInputStreams: Array<RegistryStream & { dataset: { name: string } }>,
packageInputStreams: Array<RegistryStream & { data_stream: { dataset: string } }>,
packageConfigInput: PackageConfigInput
): boolean => {
return (
Expand All @@ -52,7 +52,7 @@ const shouldShowStreamsByDefault = (
hasInvalidButRequiredVar(
stream.vars,
packageConfigInput.streams.find(
(pkgStream) => stream.dataset.name === pkgStream.dataset.name
(pkgStream) => stream.data_stream.dataset === pkgStream.data_stream.dataset
)?.vars
)
)
Expand All @@ -62,7 +62,7 @@ const shouldShowStreamsByDefault = (

export const PackageConfigInputPanel: React.FunctionComponent<{
packageInput: RegistryInput;
packageInputStreams: Array<RegistryStream & { dataset: { name: string } }>;
packageInputStreams: Array<RegistryStream & { data_stream: { dataset: string } }>;
packageConfigInput: PackageConfigInput;
updatePackageConfigInput: (updatedInput: Partial<PackageConfigInput>) => void;
inputValidationResults: PackageConfigInputValidationResults;
Expand Down Expand Up @@ -90,7 +90,7 @@ export const PackageConfigInputPanel: React.FunctionComponent<{
return {
packageInputStream,
packageConfigInputStream: packageConfigInput.streams.find(
(stream) => stream.dataset.name === packageInputStream.dataset.name
(stream) => stream.data_stream.dataset === packageInputStream.data_stream.dataset
),
};
})
Expand Down Expand Up @@ -201,7 +201,8 @@ export const PackageConfigInputPanel: React.FunctionComponent<{
updatedStream: Partial<PackageConfigInputStream>
) => {
const indexOfUpdatedStream = packageConfigInput.streams.findIndex(
(stream) => stream.dataset.name === packageInputStream.dataset.name
(stream) =>
stream.data_stream.dataset === packageInputStream.data_stream.dataset
);
const newStreams = [...packageConfigInput.streams];
newStreams[indexOfUpdatedStream] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const validatePackageConfig = (
if (stream.vars) {
const streamVarsByName = (
(
registryStreamsByDataset[stream.dataset.name].find(
registryStreamsByDataset[stream.data_stream.dataset].find(
(registryStream) => registryStream.input === input.type
) || {}
).vars || []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe('Ingest Manager - validatePackageConfig()', () => {
streams: [
{
id: 'foo-foo',
dataset: { name: 'foo', type: 'logs' },
data_stream: { dataset: 'foo', type: 'logs' },
enabled: true,
vars: { 'var-name': { value: 'test_yaml: value', type: 'yaml' } },
},
Expand All @@ -175,13 +175,13 @@ describe('Ingest Manager - validatePackageConfig()', () => {
streams: [
{
id: 'bar-bar',
dataset: { name: 'bar', type: 'logs' },
data_stream: { dataset: 'bar', type: 'logs' },
enabled: true,
vars: { 'var-name': { value: 'test_yaml: value', type: 'yaml' } },
},
{
id: 'bar-bar2',
dataset: { name: 'bar2', type: 'logs' },
data_stream: { dataset: 'bar2', type: 'logs' },
enabled: true,
vars: { 'var-name': { value: undefined, type: 'text' } },
},
Expand All @@ -198,13 +198,13 @@ describe('Ingest Manager - validatePackageConfig()', () => {
streams: [
{
id: 'with-disabled-streams-disabled',
dataset: { name: 'disabled', type: 'logs' },
data_stream: { dataset: 'disabled', type: 'logs' },
enabled: false,
vars: { 'var-name': { value: undefined, type: 'text' } },
},
{
id: 'with-disabled-streams-disabled-without-vars',
dataset: { name: 'disabled2', type: 'logs' },
data_stream: { dataset: 'disabled2', type: 'logs' },
enabled: false,
},
],
Expand All @@ -218,7 +218,7 @@ describe('Ingest Manager - validatePackageConfig()', () => {
streams: [
{
id: 'with-no-stream-vars-bar',
dataset: { name: 'bar', type: 'logs' },
data_stream: { dataset: 'bar', type: 'logs' },
enabled: true,
},
],
Expand All @@ -241,7 +241,7 @@ describe('Ingest Manager - validatePackageConfig()', () => {
streams: [
{
id: 'foo-foo',
dataset: { name: 'foo', type: 'logs' },
data_stream: { dataset: 'foo', type: 'logs' },
enabled: true,
vars: { 'var-name': { value: 'invalidyaml: test\n foo bar:', type: 'yaml' } },
},
Expand All @@ -257,13 +257,13 @@ describe('Ingest Manager - validatePackageConfig()', () => {
streams: [
{
id: 'bar-bar',
dataset: { name: 'bar', type: 'logs' },
data_stream: { dataset: 'bar', type: 'logs' },
enabled: true,
vars: { 'var-name': { value: ' \n\n', type: 'yaml' } },
},
{
id: 'bar-bar2',
dataset: { name: 'bar2', type: 'logs' },
data_stream: { dataset: 'bar2', type: 'logs' },
enabled: true,
vars: { 'var-name': { value: undefined, type: 'text' } },
},
Expand All @@ -280,7 +280,7 @@ describe('Ingest Manager - validatePackageConfig()', () => {
streams: [
{
id: 'with-disabled-streams-disabled',
dataset: { name: 'disabled', type: 'logs' },
data_stream: { dataset: 'disabled', type: 'logs' },
enabled: false,
vars: {
'var-name': {
Expand All @@ -291,7 +291,7 @@ describe('Ingest Manager - validatePackageConfig()', () => {
},
{
id: 'with-disabled-streams-disabled-without-vars',
dataset: { name: 'disabled2', type: 'logs' },
data_stream: { dataset: 'disabled2', type: 'logs' },
enabled: false,
},
],
Expand All @@ -305,7 +305,7 @@ describe('Ingest Manager - validatePackageConfig()', () => {
streams: [
{
id: 'with-no-stream-vars-bar',
dataset: { name: 'bar', type: 'logs' },
data_stream: { dataset: 'bar', type: 'logs' },
enabled: true,
},
],
Expand Down
Loading