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] Replace OutputType enum with separate type and runtime object #82230

Merged
merged 3 commits into from
Nov 3, 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
10 changes: 7 additions & 3 deletions x-pack/plugins/ingest_manager/common/constants/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { OutputType } from '../types';
import { NewOutput } from '../types';

export const OUTPUT_SAVED_OBJECT_TYPE = 'ingest-outputs';

export const DEFAULT_OUTPUT = {
export const outputType = {
Elasticsearch: 'elasticsearch',
} as const;

export const DEFAULT_OUTPUT: NewOutput = {
name: 'default',
is_default: true,
type: OutputType.Elasticsearch,
type: outputType.Elasticsearch,
hosts: [''],
};
9 changes: 5 additions & 4 deletions x-pack/plugins/ingest_manager/common/types/models/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
* you may not use this file except in compliance with the Elastic License.
*/

export enum OutputType {
Elasticsearch = 'elasticsearch',
}
import { outputType } from '../../constants';
import type { ValueOf } from '../index';

export type OutputType = typeof outputType;

export interface NewOutput {
is_default: boolean;
name: string;
type: OutputType;
type: ValueOf<OutputType>;
hosts?: string[];
ca_sha256?: string;
api_key?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
createNewActionsSharedObservable,
} from './state_new_actions';
import { getNewActionsSince } from '../actions';
import { OutputType, Agent, AgentAction, AgentPolicyAction } from '../../../types';
import { Agent, AgentAction, AgentPolicyAction } from '../../../types';
import { outputType } from '../../../../common/constants';

jest.mock('../../app_context', () => ({
appContextService: {
Expand Down Expand Up @@ -128,7 +129,7 @@ describe('test agent checkin new action services', () => {
id: 'policy1',
outputs: {
default: {
type: OutputType.Elasticsearch,
type: outputType.Elasticsearch,
hosts: [],
ca_sha256: undefined,
api_key: undefined,
Expand Down
7 changes: 2 additions & 5 deletions x-pack/plugins/ingest_manager/server/types/models/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { schema } from '@kbn/config-schema';

export enum OutputType {
Elasticsearch = 'elasticsearch',
}
import { outputType } from '../../../common/constants';

const OutputBaseSchema = {
name: schema.string(),
type: schema.oneOf([schema.literal(OutputType.Elasticsearch)]),
type: schema.oneOf([schema.literal(outputType.Elasticsearch)]),
hosts: schema.maybe(schema.arrayOf(schema.string())),
api_key: schema.maybe(schema.string()),
fleet_enroll_username: schema.maybe(schema.string()),
Expand Down