[ResponseOps][Alerting] create new logger with tag for rule/connector type, for logger given to executors (#142121)

* Updating connector logger

* Updating rule logger

* Fixing type failure

* Fixing failing tests

* Fixing other type failure

* Fixing types

* Fixing more types

* Making logger optional

* Removing change

* Fixing errors

* Fixing preview routes

* Fixing tests and types

* Updating substrings

* Use logger in runRule function

* Fixing task runner tests

* Updating logger in constructor

* Linting fix

* Fixing action logger
This commit is contained in:
doakalexi 2022-10-17 12:33:06 -07:00 committed by GitHub
parent 227288e726
commit b00f3b0ab9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 256 additions and 317 deletions

View file

@ -35,7 +35,9 @@ const executeParams = {
};
const spacesMock = spacesServiceMock.createStartContract();
const loggerMock = loggingSystemMock.create().get();
const loggerMock: ReturnType<typeof loggingSystemMock.createLogger> =
loggingSystemMock.createLogger();
const getActionsClientWithRequest = jest.fn();
actionExecutor.initialize({
logger: loggerMock,
@ -52,6 +54,7 @@ beforeEach(() => {
jest.resetAllMocks();
spacesMock.getSpaceId.mockReturnValue('some-namespace');
getActionsClientWithRequest.mockResolvedValue(actionsClient);
loggerMock.get.mockImplementation(() => loggerMock);
});
test('successfully executes', async () => {
@ -109,6 +112,7 @@ test('successfully executes', async () => {
baz: true,
},
params: { foo: true },
logger: loggerMock,
});
expect(loggerMock.debug).toBeCalledWith('executing action test:1: 1');
@ -482,6 +486,7 @@ test('should not throws an error if actionType is preconfigured', async () => {
baz: true,
},
params: { foo: true },
logger: loggerMock,
});
});

View file

@ -121,7 +121,6 @@ export class ActionExecutor {
},
async (span) => {
const {
logger,
spaces,
getServices,
encryptedSavedObjectsClient,
@ -144,6 +143,9 @@ export class ActionExecutor {
);
const { actionTypeId, name, config, secrets } = actionInfo;
const loggerId = actionTypeId.startsWith('.') ? actionTypeId.substring(1) : actionTypeId;
let { logger } = this.actionExecutorContext!;
logger = logger.get(loggerId);
if (!this.actionInfo || this.actionInfo.actionId !== actionId) {
this.actionInfo = actionInfo;
@ -228,6 +230,7 @@ export class ActionExecutor {
isEphemeral,
taskInfo,
configurationUtilities,
logger,
});
} catch (err) {
if (err.reason === ActionExecutionErrorReason.Validation) {

View file

@ -65,6 +65,7 @@ describe('Executor', () => {
secrets,
services,
configurationUtilities: mockedActionsConfig,
logger,
});
expect(res).toEqual({
@ -86,6 +87,7 @@ describe('Executor', () => {
secrets,
services,
configurationUtilities: mockedActionsConfig,
logger,
});
expect(res).toEqual({
@ -107,6 +109,7 @@ describe('Executor', () => {
secrets,
services,
configurationUtilities: mockedActionsConfig,
logger,
});
expect(res).toEqual({
@ -126,6 +129,7 @@ describe('Executor', () => {
secrets,
services,
configurationUtilities: mockedActionsConfig,
logger,
});
expect(res).toEqual({
@ -146,6 +150,7 @@ describe('Executor', () => {
secrets,
services,
configurationUtilities: mockedActionsConfig,
logger,
})
).rejects.toThrowError('You should register at least one subAction for your connector type');
});
@ -161,6 +166,7 @@ describe('Executor', () => {
secrets,
services,
configurationUtilities: mockedActionsConfig,
logger,
})
).rejects.toThrowError(
'Sub action "not-exist" is not registered. Connector id: test-action-id. Connector name: Test. Connector type: .test'
@ -178,6 +184,7 @@ describe('Executor', () => {
secrets,
services,
configurationUtilities: mockedActionsConfig,
logger,
})
).rejects.toThrowError(
'Method "not-exist" does not exists in service. Sub action: "testUrl". Connector id: test-action-id. Connector name: Test. Connector type: .test'
@ -195,6 +202,7 @@ describe('Executor', () => {
secrets,
services,
configurationUtilities: mockedActionsConfig,
logger,
})
).rejects.toThrowError(
'Method "notAFunction" must be a function. Connector id: test-action-id. Connector name: Test. Connector type: .test'
@ -212,6 +220,7 @@ describe('Executor', () => {
secrets,
services,
configurationUtilities: mockedActionsConfig,
logger,
})
).rejects.toThrowError(
'Request validation failed (Error: [id]: expected value of type [string] but got [undefined])'

View file

@ -14,6 +14,7 @@ import {
ElasticsearchClient,
CustomRequestHandlerContext,
SavedObjectReference,
Logger,
} from '@kbn/core/server';
import { ActionTypeRegistry } from './action_type_registry';
import { PluginSetupContract, PluginStartContract } from './plugin';
@ -60,6 +61,7 @@ export interface ActionTypeExecutorOptions<Config, Secrets, Params> {
config: Config;
secrets: Secrets;
params: Params;
logger: Logger;
isEphemeral?: boolean;
taskInfo?: TaskInfo;
configurationUtilities: ActionsConfigurationUtilities;

View file

@ -202,6 +202,7 @@ describe('Task Runner', () => {
alertingEventLogger.getStartAndDuration.mockImplementation(() => ({ start: new Date() }));
(AlertingEventLogger as jest.Mock).mockImplementation(() => alertingEventLogger);
logger.get.mockImplementation(() => logger);
});
test('successfully executes the task', async () => {

View file

@ -136,7 +136,8 @@ export class TaskRunner<
inMemoryMetrics: InMemoryMetrics
) {
this.context = context;
this.logger = context.logger;
const loggerId = ruleType.id.startsWith('.') ? ruleType.id.substring(1) : ruleType.id;
this.logger = context.logger.get(loggerId);
this.usageCounter = context.usageCounter;
this.ruleType = ruleType;
this.ruleConsumer = null;
@ -392,6 +393,7 @@ export class TaskRunner<
throttle,
notifyWhen,
},
logger: this.logger,
})
);

View file

@ -64,6 +64,7 @@ let fakeTimer: sinon.SinonFakeTimers;
const mockUsageCountersSetup = usageCountersServiceMock.createSetupContract();
const mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test');
const alertingEventLogger = alertingEventLoggerMock.create();
const logger: ReturnType<typeof loggingSystemMock.createLogger> = loggingSystemMock.createLogger();
describe('Task Runner Cancel', () => {
let mockedTaskInstance: ConcreteTaskInstance;
@ -110,7 +111,7 @@ describe('Task Runner Cancel', () => {
actionsPlugin: actionsMock.createStart(),
getRulesClientWithRequest: jest.fn().mockReturnValue(rulesClient),
encryptedSavedObjectsClient,
logger: loggingSystemMock.create().get(),
logger,
executionContext: executionContextServiceMock.createInternalStartContract(),
spaceIdToNamespace: jest.fn().mockReturnValue(undefined),
basePathService: httpServiceMock.createBasePath(),
@ -170,6 +171,7 @@ describe('Task Runner Cancel', () => {
taskRunnerFactoryInitializerParams.actionsPlugin.isActionExecutable.mockReturnValue(true);
alertingEventLogger.getStartAndDuration.mockImplementation(() => ({ start: new Date() }));
(AlertingEventLogger as jest.Mock).mockImplementation(() => alertingEventLogger);
logger.get.mockImplementation(() => logger);
});
test('updates rule saved object execution status and writes to event log entry when task is cancelled mid-execution', async () => {
@ -186,7 +188,6 @@ describe('Task Runner Cancel', () => {
await taskRunner.cancel();
await promise;
const logger = taskRunnerFactoryInitializerParams.logger;
expect(logger.debug).toHaveBeenNthCalledWith(
3,
`Aborting any in-progress ES searches for rule type test with id 1`
@ -390,7 +391,6 @@ describe('Task Runner Cancel', () => {
});
function testLogger() {
const logger = taskRunnerFactoryInitializerParams.logger;
expect(logger.debug).toHaveBeenCalledTimes(7);
expect(logger.debug).nthCalledWith(1, 'executing rule test:1 at 1970-01-01T00:00:00.000Z');
expect(logger.debug).nthCalledWith(

View file

@ -17,6 +17,7 @@ import {
IScopedClusterClient,
SavedObjectAttributes,
SavedObjectsClientContract,
Logger,
} from '@kbn/core/server';
import type { PublicMethodsOf } from '@kbn/utility-types';
import { RuleTypeRegistry as OrigruleTypeRegistry } from './rule_type_registry';
@ -103,6 +104,7 @@ export interface RuleExecutorOptions<
tags: string[];
createdBy: string | null;
updatedBy: string | null;
logger: Logger;
}
export interface RuleParamsAndRefs<Params extends RuleTypeParams> {

View file

@ -55,6 +55,19 @@ const initialRuleState: TestRuleState = {
groups: [],
};
const fakeLogger = <Meta extends LogMeta = LogMeta>(msg: string, meta?: Meta) => {};
const logger = {
trace: fakeLogger,
debug: fakeLogger,
info: fakeLogger,
warn: fakeLogger,
error: fakeLogger,
fatal: fakeLogger,
log: () => void 0,
get: () => logger,
} as unknown as Logger;
const mockOptions = {
alertId: '',
executionId: '',
@ -99,6 +112,7 @@ const mockOptions = {
ruleTypeId: '',
ruleTypeName: '',
},
logger,
};
const setEvaluationResults = (response: Array<Record<string, Evaluation>>) => {
@ -1607,19 +1621,6 @@ const createMockStaticConfiguration = (sources: any) => ({
sources,
});
const fakeLogger = <Meta extends LogMeta = LogMeta>(msg: string, meta?: Meta) => {};
const logger = {
trace: fakeLogger,
debug: fakeLogger,
info: fakeLogger,
warn: fakeLogger,
error: fakeLogger,
fatal: fakeLogger,
log: () => void 0,
get: () => logger,
} as unknown as Logger;
const mockLibs: any = {
sources: new InfraSources({
config: createMockStaticConfiguration({}),

View file

@ -49,6 +49,7 @@ describe('createLifecycleExecutor', () => {
createDefaultAlertExecutorOptions({
params: {},
state: { wrapped: initialRuleState, trackedAlerts: {} },
logger,
})
);
@ -83,6 +84,7 @@ describe('createLifecycleExecutor', () => {
createDefaultAlertExecutorOptions({
params: {},
state: { wrapped: initialRuleState, trackedAlerts: {} },
logger,
})
);
@ -198,6 +200,7 @@ describe('createLifecycleExecutor', () => {
},
},
},
logger,
})
);
@ -313,6 +316,7 @@ describe('createLifecycleExecutor', () => {
},
},
},
logger,
})
);
@ -372,6 +376,7 @@ describe('createLifecycleExecutor', () => {
params: {},
state: { wrapped: initialRuleState, trackedAlerts: {} },
shouldWriteAlerts: false,
logger,
})
);
@ -401,6 +406,7 @@ describe('createLifecycleExecutor', () => {
params: {},
state: { wrapped: initialRuleState, trackedAlerts: {} },
shouldWriteAlerts: false,
logger,
})
)
).rejects.toThrowErrorMatchingInlineSnapshot(`"error initializing!"`);

View file

@ -131,6 +131,7 @@ function createRule(shouldWriteAlerts: boolean = true) {
updatedBy: 'updatedBy',
namespace: 'namespace',
executionId: 'b33f65d7-6e8b-4aae-8d20-c93613dec9f9',
logger: loggerMock.create(),
})) ?? {}) as Record<string, any>;
previousStartedAt = startedAt;

View file

@ -18,6 +18,7 @@ import {
} from '@kbn/alerting-plugin/server';
import { alertsMock } from '@kbn/alerting-plugin/server/mocks';
import { searchSourceCommonMock } from '@kbn/data-plugin/common/search/search_source/mocks';
import { Logger } from '@kbn/logging';
export const createDefaultAlertExecutorOptions = <
Params extends RuleTypeParams = never,
@ -30,6 +31,7 @@ export const createDefaultAlertExecutorOptions = <
ruleName = 'ALERT_RULE_NAME',
params,
state,
logger,
createdAt = new Date(),
startedAt = new Date(),
updatedAt = new Date(),
@ -39,6 +41,7 @@ export const createDefaultAlertExecutorOptions = <
ruleName?: string;
params: Params;
state: State;
logger: Logger;
createdAt?: Date;
startedAt?: Date;
updatedAt?: Date;
@ -83,4 +86,5 @@ export const createDefaultAlertExecutorOptions = <
previousStartedAt: null,
namespace: undefined,
executionId: 'b33f65d7-6e8b-4aae-8d20-c93613deb33f',
logger,
});

View file

@ -70,6 +70,7 @@ describe('legacyRules_notification_alert_type', () => {
throttle: null,
notifyWhen: null,
},
logger,
};
alert = legacyRulesNotificationAlertType({

View file

@ -7,7 +7,7 @@
import moment from 'moment';
import uuid from 'uuid';
import { transformError } from '@kbn/securitysolution-es-utils';
import type { StartServicesAccessor } from '@kbn/core/server';
import type { Logger, StartServicesAccessor } from '@kbn/core/server';
import type { IRuleDataClient } from '@kbn/rule-registry-plugin/server';
import type {
AlertInstanceContext,
@ -64,7 +64,8 @@ export const previewRulesRoute = async (
ruleOptions: CreateRuleOptions,
securityRuleTypeOptions: CreateSecurityRuleTypeWrapperProps,
previewRuleDataClient: IRuleDataClient,
getStartServices: StartServicesAccessor<StartPlugins>
getStartServices: StartServicesAccessor<StartPlugins>,
logger: Logger
) => {
router.post(
{
@ -251,6 +252,7 @@ export const previewRulesRoute = async (
state: statePreview,
tags: [],
updatedBy: rule.updatedBy,
logger,
})) as TState;
const errors = loggedStatusChanges

View file

@ -114,6 +114,7 @@ export const createRuleTypeMocks = (
params,
alertId: v4(),
state: {},
logger: loggerMock,
}),
runOpts: {
completeRule: getCompleteRuleMock(params as QueryRuleParams),

View file

@ -118,7 +118,8 @@ export const initRoutes = (
ruleOptions,
securityRuleTypeOptions,
previewRuleDataClient,
getStartServices
getStartServices,
logger
);
createRuleExceptionsRoute(router);

View file

@ -6,7 +6,7 @@
*/
import { sha256 } from 'js-sha256';
import { i18n } from '@kbn/i18n';
import { CoreSetup, Logger } from '@kbn/core/server';
import { CoreSetup } from '@kbn/core/server';
import { parseDuration } from '@kbn/alerting-plugin/server';
import { addMessages, EsQueryRuleActionContext } from './action_context';
import { ComparatorFns, getHumanReadableComparator } from '../lib';
@ -18,13 +18,9 @@ import { fetchSearchSourceQuery } from './lib/fetch_search_source_query';
import { Comparator } from '../../../common/comparator_types';
import { isEsQueryRule } from './util';
export async function executor(
logger: Logger,
core: CoreSetup,
options: ExecutorOptions<EsQueryRuleParams>
) {
export async function executor(core: CoreSetup, options: ExecutorOptions<EsQueryRuleParams>) {
const esQueryRule = isEsQueryRule(options.params.searchType);
const { alertId: ruleId, name, services, params, state, spaceId } = options;
const { alertId: ruleId, name, services, params, state, spaceId, logger } = options;
const { alertFactory, scopedClusterClient, searchSourceClient } = services;
const currentTimestamp = new Date().toISOString();
const publicBaseUrl = core.http.basePath.publicBaseUrl ?? '';

View file

@ -5,17 +5,16 @@
* 2.0.
*/
import { CoreSetup, Logger } from '@kbn/core/server';
import { CoreSetup } from '@kbn/core/server';
import { AlertingSetup } from '../../types';
import { getRuleType } from './rule_type';
interface RegisterParams {
logger: Logger;
alerting: AlertingSetup;
core: CoreSetup;
}
export function register(params: RegisterParams) {
const { logger, alerting, core } = params;
alerting.registerType(getRuleType(logger, core));
const { alerting, core } = params;
alerting.registerType(getRuleType(core));
}

View file

@ -27,7 +27,7 @@ import { Comparator } from '../../../common/comparator_types';
const logger = loggingSystemMock.create().get();
const coreSetup = coreMock.createSetup();
const ruleType = getRuleType(logger, coreSetup);
const ruleType = getRuleType(coreSetup);
describe('ruleType', () => {
it('rule type creation structure is the expected value', async () => {
@ -678,5 +678,6 @@ async function invokeExecutor({
throttle: null,
notifyWhen: null,
},
logger,
});
}

View file

@ -6,7 +6,7 @@
*/
import { i18n } from '@kbn/i18n';
import { CoreSetup, Logger } from '@kbn/core/server';
import { CoreSetup } from '@kbn/core/server';
import { extractReferences, injectReferences } from '@kbn/data-plugin/common';
import { RuleType } from '../../types';
import { ActionContext } from './action_context';
@ -23,7 +23,6 @@ import { executor } from './executor';
import { isEsQueryRule } from './util';
export function getRuleType(
logger: Logger,
core: CoreSetup
): RuleType<
EsQueryRuleParams,
@ -184,7 +183,7 @@ export function getRuleType(
minimumLicenseRequired: 'basic',
isExportable: true,
executor: async (options: ExecutorOptions<EsQueryRuleParams>) => {
return await executor(logger, core, options);
return await executor(core, options);
},
producer: STACK_ALERTS_FEATURE_ID,
doesSetRecoveryContext: true,

View file

@ -7,7 +7,7 @@
import { i18n } from '@kbn/i18n';
import { schema } from '@kbn/config-schema';
import { Logger, SavedObjectReference } from '@kbn/core/server';
import { SavedObjectReference } from '@kbn/core/server';
import {
RuleType,
RuleTypeState,
@ -214,7 +214,7 @@ export function injectEntityAndBoundaryIds(
} as GeoContainmentParams;
}
export function getAlertType(logger: Logger): GeoContainmentAlertType {
export function getAlertType(): GeoContainmentAlertType {
const alertTypeName = i18n.translate('xpack.stackAlerts.geoContainment.alertTypeTitle', {
defaultMessage: 'Tracking containment',
});
@ -238,7 +238,7 @@ export function getAlertType(logger: Logger): GeoContainmentAlertType {
},
doesSetRecoveryContext: true,
defaultActionGroupId: ActionGroupId,
executor: getGeoContainmentExecutor(logger),
executor: getGeoContainmentExecutor(),
producer: STACK_ALERTS_FEATURE_ID,
validate: {
params: ParamsSchema,

View file

@ -6,7 +6,6 @@
*/
import _ from 'lodash';
import { Logger } from '@kbn/core/server';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { RuleExecutorServices } from '@kbn/alerting-plugin/server';
import { executeEsQueryFactory, getShapesFilters, OTHER_CATEGORY } from './es_query_builder';
@ -138,7 +137,7 @@ export function getEntitiesAndGenerateAlerts(
return { activeEntities, inactiveEntities };
}
export const getGeoContainmentExecutor = (log: Logger): GeoContainmentAlertType['executor'] =>
export const getGeoContainmentExecutor = (): GeoContainmentAlertType['executor'] =>
async function ({
previousStartedAt: windowStart,
startedAt: windowEnd,
@ -146,6 +145,7 @@ export const getGeoContainmentExecutor = (log: Logger): GeoContainmentAlertType[
params,
alertId,
state,
logger,
}): Promise<GeoContainmentState> {
const { shapesFilters, shapesIdsNamesMap } = state.shapesFilters
? state
@ -154,7 +154,7 @@ export const getGeoContainmentExecutor = (log: Logger): GeoContainmentAlertType[
params.boundaryGeoField,
params.geoField,
services.scopedClusterClient.asCurrentUser,
log,
logger,
alertId,
params.boundaryNameField,
params.boundaryIndexQuery
@ -163,14 +163,14 @@ export const getGeoContainmentExecutor = (log: Logger): GeoContainmentAlertType[
const executeEsQuery = await executeEsQueryFactory(
params,
services.scopedClusterClient.asCurrentUser,
log,
logger,
shapesFilters
);
// Start collecting data only on the first cycle
let currentIntervalResults: estypes.SearchResponse<unknown> | undefined;
if (!windowStart) {
log.debug(`alert ${GEO_CONTAINMENT_ID}:${alertId} alert initialized. Collecting data`);
logger.debug(`alert ${GEO_CONTAINMENT_ID}:${alertId} alert initialized. Collecting data`);
// Consider making first time window configurable?
const START_TIME_WINDOW = 1;
const tempPreviousEndTime = new Date(windowEnd);
@ -213,7 +213,7 @@ export const getGeoContainmentExecutor = (log: Logger): GeoContainmentAlertType[
recoveredAlert.setContext(context);
}
} catch (e) {
log.warn(`Unable to set alert context for recovered alert, error: ${e.message}`);
logger.warn(`Unable to set alert context for recovered alert, error: ${e.message}`);
}
}

View file

@ -5,7 +5,6 @@
* 2.0.
*/
import { Logger } from '@kbn/core/server';
import { AlertingSetup } from '../../types';
import {
GeoContainmentState,
@ -19,12 +18,11 @@ import {
import { GeoContainmentExtractedParams, GeoContainmentParams } from './alert_type';
interface RegisterParams {
logger: Logger;
alerting: AlertingSetup;
}
export function register(params: RegisterParams) {
const { logger, alerting } = params;
const { alerting } = params;
alerting.registerType<
GeoContainmentParams,
GeoContainmentExtractedParams,
@ -33,5 +31,5 @@ export function register(params: RegisterParams) {
GeoContainmentInstanceContext,
typeof ActionGroupId,
typeof RecoveryActionGroupId
>(getAlertType(logger));
>(getAlertType());
}

View file

@ -5,7 +5,6 @@
* 2.0.
*/
import { loggingSystemMock } from '@kbn/core/server/mocks';
import {
getAlertType,
injectEntityAndBoundaryIds,
@ -14,9 +13,7 @@ import {
} from '../alert_type';
describe('alertType', () => {
const logger = loggingSystemMock.create().get();
const alertType = getAlertType(logger);
const alertType = getAlertType();
it('alert type creation structure is the expected value', async () => {
expect(alertType.id).toBe('.geo-containment');

View file

@ -6,7 +6,7 @@
*/
import _ from 'lodash';
import { loggingSystemMock, elasticsearchServiceMock } from '@kbn/core/server/mocks';
import { elasticsearchServiceMock } from '@kbn/core/server/mocks';
import { RuleExecutorServicesMock, alertsMock } from '@kbn/alerting-plugin/server/mocks';
import sampleAggsJsonResponse from './es_sample_response.json';
import sampleShapesJsonResponse from './es_sample_response_shapes.json';
@ -505,7 +505,6 @@ describe('geo_containment', () => {
},
];
const testAlertActionArr: unknown[] = [];
const mockLogger = loggingSystemMock.createLogger();
const previousStartedAt = new Date('2021-04-27T16:56:11.923Z');
const startedAt = new Date('2021-04-29T16:56:11.923Z');
const geoContainmentParams: GeoContainmentParams = {
@ -560,7 +559,7 @@ describe('geo_containment', () => {
});
it('should query for shapes if state does not contain shapes', async () => {
const executor = await getGeoContainmentExecutor(mockLogger);
const executor = await getGeoContainmentExecutor();
// @ts-ignore
const executionResult = await executor({
previousStartedAt,
@ -580,7 +579,7 @@ describe('geo_containment', () => {
});
it('should not query for shapes if state contains shapes', async () => {
const executor = await getGeoContainmentExecutor(mockLogger);
const executor = await getGeoContainmentExecutor();
// @ts-ignore
const executionResult = await executor({
previousStartedAt,
@ -599,7 +598,7 @@ describe('geo_containment', () => {
});
it('should carry through shapes filters in state to next call unmodified', async () => {
const executor = await getGeoContainmentExecutor(mockLogger);
const executor = await getGeoContainmentExecutor();
// @ts-ignore
const executionResult = await executor({
previousStartedAt,
@ -635,7 +634,7 @@ describe('geo_containment', () => {
},
],
};
const executor = await getGeoContainmentExecutor(mockLogger);
const executor = await getGeoContainmentExecutor();
// @ts-ignore
const executionResult = await executor({
previousStartedAt,

View file

@ -5,7 +5,6 @@
* 2.0.
*/
import { Logger } from '@kbn/core/server';
import { AlertingSetup, StackAlertsStartDeps } from '../../types';
import { getRuleType } from './rule_type';
@ -15,12 +14,11 @@ export const MAX_GROUPS = 1000;
export const DEFAULT_GROUPS = 100;
interface RegisterParams {
logger: Logger;
data: Promise<StackAlertsStartDeps['triggersActionsUi']['data']>;
alerting: AlertingSetup;
}
export function register(params: RegisterParams) {
const { logger, data, alerting } = params;
alerting.registerType(getRuleType(logger, data));
const { data, alerting } = params;
alerting.registerType(getRuleType(data));
}

View file

@ -26,7 +26,7 @@ describe('ruleType', () => {
};
const alertServices: RuleExecutorServicesMock = alertsMock.createRuleExecutorServices();
const ruleType = getRuleType(logger, Promise.resolve(data));
const ruleType = getRuleType(Promise.resolve(data));
beforeAll(() => {
fakeTimer = sinon.useFakeTimers();
@ -220,6 +220,7 @@ describe('ruleType', () => {
throttle: null,
notifyWhen: null,
},
logger,
});
expect(alertServices.alertFactory.create).toHaveBeenCalledWith('all documents');
@ -286,6 +287,7 @@ describe('ruleType', () => {
throttle: null,
notifyWhen: null,
},
logger,
});
expect(customAlertServices.alertFactory.create).not.toHaveBeenCalled();
@ -352,6 +354,7 @@ describe('ruleType', () => {
throttle: null,
notifyWhen: null,
},
logger,
});
expect(customAlertServices.alertFactory.create).not.toHaveBeenCalled();
@ -417,6 +420,7 @@ describe('ruleType', () => {
throttle: null,
notifyWhen: null,
},
logger,
});
expect(data.timeSeriesQuery).toHaveBeenCalledWith(

View file

@ -6,7 +6,6 @@
*/
import { i18n } from '@kbn/i18n';
import { Logger } from '@kbn/core/server';
import {
CoreQueryParamsSchemaProperties,
TimeSeriesQuery,
@ -23,7 +22,6 @@ export const ID = '.index-threshold';
export const ActionGroupId = 'threshold met';
export function getRuleType(
logger: Logger,
data: Promise<StackAlertsStartDeps['triggersActionsUi']['data']>
): RuleType<Params, never, {}, {}, ActionContext, typeof ActionGroupId> {
const ruleTypeName = i18n.translate('xpack.stackAlerts.indexThreshold.alertTypeTitle', {
@ -136,7 +134,7 @@ export function getRuleType(
async function executor(
options: RuleExecutorOptions<Params, {}, {}, ActionContext, typeof ActionGroupId>
) {
const { alertId: ruleId, name, services, params } = options;
const { alertId: ruleId, name, services, params, logger } = options;
const { alertFactory, scopedClusterClient } = services;
const alertLimit = alertFactory.alertLimit.getValue();

View file

@ -5,8 +5,6 @@
* 2.0.
*/
import { curry } from 'lodash';
import { Logger } from '@kbn/core/server';
import type {
ActionType as ConnectorType,
ActionTypeExecutorOptions as ConnectorTypeExecutorOptions,
@ -35,11 +33,7 @@ const supportedSubActions: string[] = ['pushToService'];
export type ActionParamsType = CasesWebhookActionParamsType;
export const ConnectorTypeId = '.cases-webhook';
// connector type definition
export function getConnectorType({
logger,
}: {
logger: Logger;
}): ConnectorType<
export function getConnectorType(): ConnectorType<
CasesWebhookPublicConfigurationType,
CasesWebhookSecretConfigurationType,
ExecutorParams,
@ -63,23 +57,21 @@ export function getConnectorType({
},
connector: validate.connector,
},
executor: curry(executor)({ logger }),
executor,
supportedFeatureIds: [CasesConnectorFeatureId],
};
}
// action executor
export async function executor(
{ logger }: { logger: Logger },
execOptions: ConnectorTypeExecutorOptions<
CasesWebhookPublicConfigurationType,
CasesWebhookSecretConfigurationType,
CasesWebhookActionParamsType
>
): Promise<ConnectorTypeExecutorResult<CasesWebhookExecutorResultData>> {
const actionId = execOptions.actionId;
const configurationUtilities = execOptions.configurationUtilities;
const { subAction, subActionParams } = execOptions.params;
const { actionId, configurationUtilities, params, logger } = execOptions;
const { subAction, subActionParams } = params;
let data: CasesWebhookExecutorResultData | undefined;
const externalService = createExternalService(

View file

@ -5,10 +5,8 @@
* 2.0.
*/
import { curry } from 'lodash';
import { TypeOf } from '@kbn/config-schema';
import { Logger } from '@kbn/core/server';
import type {
ActionType as ConnectorType,
ActionTypeExecutorOptions as ConnectorTypeExecutorOptions,
@ -43,9 +41,6 @@ import {
import * as i18n from './translations';
export type ActionParamsType = TypeOf<typeof ExecutorParamsSchema>;
interface GetConnectorTypeParams {
logger: Logger;
}
const supportedSubActions: string[] = [
'getFields',
@ -59,15 +54,12 @@ const supportedSubActions: string[] = [
export const ConnectorTypeId = '.jira';
// connector type definition
export function getConnectorType(
params: GetConnectorTypeParams
): ConnectorType<
export function getConnectorType(): ConnectorType<
JiraPublicConfigurationType,
JiraSecretConfigurationType,
ExecutorParams,
JiraExecutorResultData | {}
> {
const { logger } = params;
return {
id: ConnectorTypeId,
minimumLicenseRequired: 'gold',
@ -91,20 +83,19 @@ export function getConnectorType(
schema: ExecutorParamsSchema,
},
},
executor: curry(executor)({ logger }),
executor,
};
}
// action executor
async function executor(
{ logger }: { logger: Logger },
execOptions: ConnectorTypeExecutorOptions<
JiraPublicConfigurationType,
JiraSecretConfigurationType,
ExecutorParams
>
): Promise<ConnectorTypeExecutorResult<JiraExecutorResultData | {}>> {
const { actionId, config, params, secrets, configurationUtilities } = execOptions;
const { actionId, config, params, secrets, configurationUtilities, logger } = execOptions;
const { subAction, subActionParams } = params as ExecutorParams;
let data: JiraExecutorResultData | null = null;

View file

@ -5,10 +5,8 @@
* 2.0.
*/
import { curry } from 'lodash';
import { TypeOf } from '@kbn/config-schema';
import { Logger } from '@kbn/core/server';
import type {
ActionType as ConnectorType,
ActionTypeExecutorOptions as ConnectorTypeExecutorOptions,
@ -41,23 +39,16 @@ import * as i18n from './translations';
export type ActionParamsType = TypeOf<typeof ExecutorParamsSchema>;
interface GetConnectorTypeParams {
logger: Logger;
}
const supportedSubActions: string[] = ['getFields', 'pushToService', 'incidentTypes', 'severity'];
export const ConnectorTypeId = '.resilient';
// connector type definition
export function getConnectorType(
params: GetConnectorTypeParams
): ConnectorType<
export function getConnectorType(): ConnectorType<
ResilientPublicConfigurationType,
ResilientSecretConfigurationType,
ExecutorParams,
ResilientExecutorResultData | {}
> {
const { logger } = params;
return {
id: ConnectorTypeId,
minimumLicenseRequired: 'platinum',
@ -80,20 +71,19 @@ export function getConnectorType(
schema: ExecutorParamsSchema,
},
},
executor: curry(executor)({ logger }),
executor,
};
}
// action executor
async function executor(
{ logger }: { logger: Logger },
execOptions: ConnectorTypeExecutorOptions<
ResilientPublicConfigurationType,
ResilientSecretConfigurationType,
ExecutorParams
>
): Promise<ConnectorTypeExecutorResult<ResilientExecutorResultData | {}>> {
const { actionId, config, params, secrets, configurationUtilities } = execOptions;
const { actionId, config, params, secrets, configurationUtilities, logger } = execOptions;
const { subAction, subActionParams } = params as ExecutorParams;
let data: ResilientExecutorResultData | null = null;

View file

@ -49,9 +49,7 @@ describe('ServiceNow', () => {
describe('ServiceNow ITSM', () => {
let connectorType: ServiceNowConnectorType<ServiceNowPublicConfigurationType, ExecutorParams>;
beforeAll(() => {
connectorType = getServiceNowITSMConnectorType({
logger: mockedLogger,
});
connectorType = getServiceNowITSMConnectorType();
});
describe('execute()', () => {
@ -67,6 +65,7 @@ describe('ServiceNow', () => {
secrets,
params,
services,
logger: mockedLogger,
} as unknown as ServiceNowConnectorTypeExecutorOptions<
ServiceNowPublicConfigurationType,
ExecutorParams

View file

@ -8,7 +8,6 @@
import { curry } from 'lodash';
import { TypeOf } from '@kbn/config-schema';
import { Logger } from '@kbn/core/server';
import type {
ActionType as ConnectorType,
ActionTypeExecutorOptions as ConnectorTypeExecutorOptions,
@ -55,10 +54,6 @@ export { ServiceNowITSMConnectorTypeId, serviceNowITSMTable };
export type ActionParamsType = TypeOf<typeof ExecutorParamsSchemaITSM>;
interface GetConnectorTypeParams {
logger: Logger;
}
export type ServiceNowConnectorType<
C extends Record<string, unknown> = ServiceNowPublicConfigurationBaseType,
T extends Record<string, unknown> = ExecutorParams
@ -70,10 +65,10 @@ export type ServiceNowConnectorTypeExecutorOptions<
> = ConnectorTypeExecutorOptions<C, ServiceNowSecretConfigurationType, T>;
// connector type definition
export function getServiceNowITSMConnectorType(
params: GetConnectorTypeParams
): ServiceNowConnectorType<ServiceNowPublicConfigurationType, ExecutorParams> {
const { logger } = params;
export function getServiceNowITSMConnectorType(): ServiceNowConnectorType<
ServiceNowPublicConfigurationType,
ExecutorParams
> {
return {
id: ServiceNowITSMConnectorTypeId,
minimumLicenseRequired: 'platinum',
@ -99,7 +94,6 @@ export function getServiceNowITSMConnectorType(
},
},
executor: curry(executor)({
logger,
actionTypeId: ServiceNowITSMConnectorTypeId,
createService: createExternalService,
api: apiITSM,
@ -111,12 +105,10 @@ export function getServiceNowITSMConnectorType(
const supportedSubActions: string[] = ['getFields', 'pushToService', 'getChoices', 'getIncident'];
async function executor(
{
logger,
actionTypeId,
createService,
api,
}: {
logger: Logger;
actionTypeId: string;
createService: ServiceFactory;
api: ExternalServiceAPI;
@ -126,7 +118,8 @@ async function executor(
ExecutorParams
>
): Promise<ConnectorTypeExecutorResult<ServiceNowExecutorResultData | {}>> {
const { actionId, config, params, secrets, services, configurationUtilities } = execOptions;
const { actionId, config, params, secrets, services, configurationUtilities, logger } =
execOptions;
const { subAction, subActionParams } = params;
const connectorTokenClient = services.connectorTokenClient;
const externalServiceConfig = snExternalServiceConfig[actionTypeId];

View file

@ -50,9 +50,7 @@ describe('ServiceNow', () => {
let connectorType: ServiceNowConnectorType<ServiceNowPublicConfigurationType, ExecutorParams>;
beforeAll(() => {
connectorType = getServiceNowSIRConnectorType({
logger: mockedLogger,
});
connectorType = getServiceNowSIRConnectorType();
});
describe('execute()', () => {
@ -68,6 +66,7 @@ describe('ServiceNow', () => {
secrets,
params,
services,
logger: mockedLogger,
} as unknown as ServiceNowConnectorTypeExecutorOptions<
ServiceNowPublicConfigurationType,
ExecutorParams

View file

@ -8,7 +8,6 @@
import { curry } from 'lodash';
import { TypeOf } from '@kbn/config-schema';
import { Logger } from '@kbn/core/server';
import type {
ActionType as ConnectorType,
ActionTypeExecutorOptions as ConnectorTypeExecutorOptions,
@ -54,10 +53,6 @@ export { ServiceNowSIRConnectorTypeId, serviceNowSIRTable };
export type ActionParamsType = TypeOf<typeof ExecutorParamsSchemaSIR>;
interface GetConnectorTypeParams {
logger: Logger;
}
export type ServiceNowConnectorType<
C extends Record<string, unknown> = ServiceNowPublicConfigurationBaseType,
T extends Record<string, unknown> = ExecutorParams
@ -69,10 +64,10 @@ export type ServiceNowConnectorTypeExecutorOptions<
> = ConnectorTypeExecutorOptions<C, ServiceNowSecretConfigurationType, T>;
// connector type definition
export function getServiceNowSIRConnectorType(
params: GetConnectorTypeParams
): ServiceNowConnectorType<ServiceNowPublicConfigurationType, ExecutorParams> {
const { logger } = params;
export function getServiceNowSIRConnectorType(): ServiceNowConnectorType<
ServiceNowPublicConfigurationType,
ExecutorParams
> {
return {
id: ServiceNowSIRConnectorTypeId,
minimumLicenseRequired: 'platinum',
@ -97,7 +92,6 @@ export function getServiceNowSIRConnectorType(
},
},
executor: curry(executor)({
logger,
actionTypeId: ServiceNowSIRConnectorTypeId,
createService: createExternalService,
api: apiSIR,
@ -109,12 +103,10 @@ export function getServiceNowSIRConnectorType(
const supportedSubActions: string[] = ['getFields', 'pushToService', 'getChoices', 'getIncident'];
async function executor(
{
logger,
actionTypeId,
createService,
api,
}: {
logger: Logger;
actionTypeId: string;
createService: ServiceFactory;
api: ExternalServiceAPI;
@ -124,7 +116,8 @@ async function executor(
ExecutorParams
>
): Promise<ConnectorTypeExecutorResult<ServiceNowExecutorResultData | {}>> {
const { actionId, config, params, secrets, services, configurationUtilities } = execOptions;
const { actionId, config, params, secrets, services, configurationUtilities, logger } =
execOptions;
const { subAction, subActionParams } = params;
const connectorTokenClient = services.connectorTokenClient;
const externalServiceConfig = snExternalServiceConfig[actionTypeId];

View file

@ -5,9 +5,7 @@
* 2.0.
*/
import { curry } from 'lodash';
import { i18n } from '@kbn/i18n';
import { Logger } from '@kbn/logging';
import type {
ActionType as ConnectorType,
ActionTypeExecutorOptions as ConnectorTypeExecutorOptions,
@ -34,23 +32,15 @@ import {
import { createExternalService } from './service';
import { api } from './api';
interface GetConnectorTypeParams {
logger: Logger;
}
const supportedSubActions: string[] = ['pushToService'];
// connector type definition
export function getConnectorType(
params: GetConnectorTypeParams
): ConnectorType<
export function getConnectorType(): ConnectorType<
SwimlanePublicConfigurationType,
SwimlaneSecretConfigurationType,
ExecutorParams,
SwimlaneExecutorResultData | {}
> {
const { logger } = params;
return {
id: '.swimlane',
minimumLicenseRequired: 'gold',
@ -75,19 +65,18 @@ export function getConnectorType(
schema: ExecutorParamsSchema,
},
},
executor: curry(executor)({ logger }),
executor,
};
}
async function executor(
{ logger }: { logger: Logger },
execOptions: ConnectorTypeExecutorOptions<
SwimlanePublicConfigurationType,
SwimlaneSecretConfigurationType,
ExecutorParams
>
): Promise<ConnectorTypeExecutorResult<SwimlaneExecutorResultData | {}>> {
const { actionId, config, params, secrets, configurationUtilities } = execOptions;
const { actionId, config, params, secrets, configurationUtilities, logger } = execOptions;
const { subAction, subActionParams } = params as ExecutorParams;
let data: SwimlaneExecutorResultData | null = null;

View file

@ -6,8 +6,6 @@
*/
import { registerConnectorTypes } from '.';
import { Logger } from '@kbn/core/server';
import { loggingSystemMock } from '@kbn/core/server/mocks';
import { actionsMock } from '@kbn/actions-plugin/server/mocks';
const ACTION_TYPE_IDS = [
@ -22,7 +20,6 @@ const ACTION_TYPE_IDS = [
'.xmatters',
];
const logger = loggingSystemMock.create().get() as jest.Mocked<Logger>;
const mockedActions = actionsMock.createSetup();
beforeEach(() => {
@ -32,7 +29,6 @@ beforeEach(() => {
describe('registers connectors', () => {
test('calls registerType with expected connector types', () => {
registerConnectorTypes({
logger,
actions: mockedActions,
});
ACTION_TYPE_IDS.forEach((id) =>

View file

@ -5,7 +5,6 @@
* 2.0.
*/
import { Logger } from '@kbn/core/server';
import { PluginSetupContract as ActionsPluginSetupContract } from '@kbn/actions-plugin/server';
import {
getEmailConnectorType,
@ -65,27 +64,25 @@ export {
export function registerConnectorTypes({
actions,
logger,
publicBaseUrl,
}: {
actions: ActionsPluginSetupContract;
logger: Logger;
publicBaseUrl?: string;
}) {
actions.registerType(getEmailConnectorType({ logger, publicBaseUrl }));
actions.registerType(getIndexConnectorType({ logger }));
actions.registerType(getPagerDutyConnectorType({ logger }));
actions.registerType(getSwimlaneConnectorType({ logger }));
actions.registerType(getServerLogConnectorType({ logger }));
actions.registerType(getSlackConnectorType({ logger }));
actions.registerType(getWebhookConnectorType({ logger }));
actions.registerType(getCasesWebhookConnectorType({ logger }));
actions.registerType(getXmattersConnectorType({ logger }));
actions.registerType(getServiceNowITSMConnectorType({ logger }));
actions.registerType(getServiceNowSIRConnectorType({ logger }));
actions.registerType(getServiceNowITOMConnectorType({ logger }));
actions.registerType(getJiraConnectorType({ logger }));
actions.registerType(getResilientConnectorType({ logger }));
actions.registerType(getTeamsConnectorType({ logger }));
actions.registerType(getEmailConnectorType({ publicBaseUrl }));
actions.registerType(getIndexConnectorType());
actions.registerType(getPagerDutyConnectorType());
actions.registerType(getSwimlaneConnectorType());
actions.registerType(getServerLogConnectorType());
actions.registerType(getSlackConnectorType({}));
actions.registerType(getWebhookConnectorType());
actions.registerType(getCasesWebhookConnectorType());
actions.registerType(getXmattersConnectorType());
actions.registerType(getServiceNowITSMConnectorType());
actions.registerType(getServiceNowSIRConnectorType());
actions.registerType(getServiceNowITOMConnectorType());
actions.registerType(getJiraConnectorType());
actions.registerType(getResilientConnectorType());
actions.registerType(getTeamsConnectorType());
actions.registerSubActionConnectorType(getOpsgenieConnectorType());
}

View file

@ -42,9 +42,7 @@ let configurationUtilities: jest.Mocked<ActionsConfigurationUtilities>;
beforeEach(() => {
jest.resetAllMocks();
configurationUtilities = actionsConfigMock.create();
connectorType = getConnectorType({
logger: mockedLogger,
});
connectorType = getConnectorType({});
});
describe('connector registration', () => {
@ -522,6 +520,7 @@ describe('execute()', () => {
secrets,
services,
configurationUtilities: actionsConfigMock.create(),
logger: mockedLogger,
};
test('ensure parameters are as expected', async () => {
@ -741,7 +740,6 @@ describe('execute()', () => {
test('provides a footer link to Kibana when publicBaseUrl is defined', async () => {
const connectorTypeWithPublicUrl = getConnectorType({
logger: mockedLogger,
publicBaseUrl: 'https://localhost:1234/foo/bar',
});
@ -760,7 +758,6 @@ describe('execute()', () => {
test('allows to generate a deep link into Kibana when publicBaseUrl is defined', async () => {
const connectorTypeWithPublicUrl = getConnectorType({
logger: mockedLogger,
publicBaseUrl: 'https://localhost:1234/foo/bar',
});

View file

@ -10,7 +10,6 @@ import { i18n } from '@kbn/i18n';
import { schema, TypeOf } from '@kbn/config-schema';
import nodemailerGetService from 'nodemailer/lib/well-known';
import SMTPConnection from 'nodemailer/lib/smtp-connection';
import { Logger } from '@kbn/core/server';
import type {
ActionType as ConnectorType,
ActionTypeExecutorOptions as ConnectorTypeExecutorOptions,
@ -192,7 +191,6 @@ function validateParams(paramsObject: unknown, validatorServices: ValidatorServi
}
interface GetConnectorTypeParams {
logger: Logger;
publicBaseUrl?: string;
}
@ -218,7 +216,7 @@ function validateConnector(
// connector type definition
export const ConnectorTypeId = '.email';
export function getConnectorType(params: GetConnectorTypeParams): EmailConnectorType {
const { logger, publicBaseUrl } = params;
const { publicBaseUrl } = params;
return {
id: ConnectorTypeId,
minimumLicenseRequired: 'gold',
@ -245,7 +243,7 @@ export function getConnectorType(params: GetConnectorTypeParams): EmailConnector
connector: validateConnector,
},
renderParameterTemplates,
executor: curry(executor)({ logger, publicBaseUrl }),
executor: curry(executor)({ publicBaseUrl }),
};
}
@ -265,20 +263,15 @@ function renderParameterTemplates(
async function executor(
{
logger,
publicBaseUrl,
}: {
logger: GetConnectorTypeParams['logger'];
publicBaseUrl: GetConnectorTypeParams['publicBaseUrl'];
},
execOptions: EmailConnectorTypeExecutorOptions
): Promise<ConnectorTypeExecutorResult<unknown>> {
const actionId = execOptions.actionId;
const config = execOptions.config;
const secrets = execOptions.secrets;
const params = execOptions.params;
const configurationUtilities = execOptions.configurationUtilities;
const connectorTokenClient = execOptions.services.connectorTokenClient;
const { actionId, config, secrets, params, configurationUtilities, services, logger } =
execOptions;
const connectorTokenClient = services.connectorTokenClient;
const emails = params.to.concat(params.cc).concat(params.bcc);
let invalidEmailsMessage = configurationUtilities.validateEmailAddresses(emails);

View file

@ -31,9 +31,7 @@ let configurationUtilities: ActionsConfigurationUtilities;
beforeEach(() => {
jest.resetAllMocks();
configurationUtilities = actionsConfigMock.create();
connectorType = getConnectorType({
logger: mockedLogger,
});
connectorType = getConnectorType();
});
describe('connector registration', () => {
@ -186,6 +184,7 @@ describe('execute()', () => {
params,
services,
configurationUtilities,
logger: mockedLogger,
};
const scopedClusterClient = elasticsearchClientMock
.createClusterClient()
@ -223,7 +222,15 @@ describe('execute()', () => {
indexOverride: null,
};
executorOptions = { actionId, config, secrets, params, services, configurationUtilities };
executorOptions = {
actionId,
config,
secrets,
params,
services,
configurationUtilities,
logger: mockedLogger,
};
scopedClusterClient.bulk.mockClear();
await connectorType.executor({
...executorOptions,
@ -265,7 +272,15 @@ describe('execute()', () => {
indexOverride: null,
};
executorOptions = { actionId, config, secrets, params, services, configurationUtilities };
executorOptions = {
actionId,
config,
secrets,
params,
services,
configurationUtilities,
logger: mockedLogger,
};
scopedClusterClient.bulk.mockClear();
await connectorType.executor({
@ -301,7 +316,15 @@ describe('execute()', () => {
indexOverride: null,
};
executorOptions = { actionId, config, secrets, params, services, configurationUtilities };
executorOptions = {
actionId,
config,
secrets,
params,
services,
configurationUtilities,
logger: mockedLogger,
};
scopedClusterClient.bulk.mockClear();
await connectorType.executor({
...executorOptions,
@ -612,6 +635,7 @@ describe('execute()', () => {
params,
services,
configurationUtilities,
logger: mockedLogger,
})
).toMatchInlineSnapshot(`
Object {

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { curry, find } from 'lodash';
import { find } from 'lodash';
import { i18n } from '@kbn/i18n';
import { schema, TypeOf } from '@kbn/config-schema';
import { Logger } from '@kbn/core/server';
@ -70,7 +70,7 @@ const ParamsSchema = schema.object({
export const ConnectorTypeId = '.index';
// connector type definition
export function getConnectorType({ logger }: { logger: Logger }): ESIndexConnectorType {
export function getConnectorType(): ESIndexConnectorType {
return {
id: ConnectorTypeId,
minimumLicenseRequired: 'basic',
@ -90,7 +90,7 @@ export function getConnectorType({ logger }: { logger: Logger }): ESIndexConnect
schema: ParamsSchema,
},
},
executor: curry(executor)({ logger }),
executor,
renderParameterTemplates,
};
}
@ -98,14 +98,9 @@ export function getConnectorType({ logger }: { logger: Logger }): ESIndexConnect
// action executor
async function executor(
{ logger }: { logger: Logger },
execOptions: ESIndexConnectorTypeExecutorOptions
): Promise<ConnectorTypeExecutorResult<unknown>> {
const actionId = execOptions.actionId;
const config = execOptions.config;
const params = execOptions.params;
const services = execOptions.services;
const { actionId, config, params, services, logger } = execOptions;
const index = params.indexOverride || config.index;
const bulkBody = [];

View file

@ -34,9 +34,7 @@ let configurationUtilities: jest.Mocked<ActionsConfigurationUtilities>;
beforeEach(() => {
configurationUtilities = actionsConfigMock.create();
connectorType = getConnectorType({
logger: mockedLogger,
});
connectorType = getConnectorType();
});
describe('get()', () => {
@ -75,9 +73,7 @@ describe('validateConfig()', () => {
expect(url).toEqual('https://events.pagerduty.com/v2/enqueue');
},
};
connectorType = getConnectorType({
logger: mockedLogger,
});
connectorType = getConnectorType();
expect(
validateConfig(
@ -95,9 +91,7 @@ describe('validateConfig()', () => {
throw new Error(`target url is not added to allowedHosts`);
},
};
connectorType = getConnectorType({
logger: mockedLogger,
});
connectorType = getConnectorType();
expect(() => {
validateConfig(
@ -274,6 +268,7 @@ describe('execute()', () => {
secrets,
services,
configurationUtilities,
logger: mockedLogger,
};
const actionResponse = await connectorType.executor(executorOptions);
const { apiUrl, data, headers } = postPagerdutyMock.mock.calls[0][0];
@ -335,6 +330,7 @@ describe('execute()', () => {
secrets,
services,
configurationUtilities,
logger: mockedLogger,
};
const actionResponse = await connectorType.executor(executorOptions);
const { apiUrl, data, headers } = postPagerdutyMock.mock.calls[0][0];
@ -401,6 +397,7 @@ describe('execute()', () => {
secrets,
services,
configurationUtilities,
logger: mockedLogger,
};
const actionResponse = await connectorType.executor(executorOptions);
const { apiUrl, data, headers } = postPagerdutyMock.mock.calls[0][0];
@ -458,6 +455,7 @@ describe('execute()', () => {
secrets,
services,
configurationUtilities,
logger: mockedLogger,
};
const actionResponse = await connectorType.executor(executorOptions);
const { apiUrl, data, headers } = postPagerdutyMock.mock.calls[0][0];
@ -500,6 +498,7 @@ describe('execute()', () => {
secrets,
services,
configurationUtilities,
logger: mockedLogger,
};
const actionResponse = await connectorType.executor(executorOptions);
expect(actionResponse).toMatchInlineSnapshot(`
@ -529,6 +528,7 @@ describe('execute()', () => {
secrets,
services,
configurationUtilities,
logger: mockedLogger,
};
const actionResponse = await connectorType.executor(executorOptions);
expect(actionResponse).toMatchInlineSnapshot(`
@ -558,6 +558,7 @@ describe('execute()', () => {
secrets,
services,
configurationUtilities,
logger: mockedLogger,
};
const actionResponse = await connectorType.executor(executorOptions);
expect(actionResponse).toMatchInlineSnapshot(`
@ -587,6 +588,7 @@ describe('execute()', () => {
secrets,
services,
configurationUtilities,
logger: mockedLogger,
};
const actionResponse = await connectorType.executor(executorOptions);
expect(actionResponse).toMatchInlineSnapshot(`
@ -626,6 +628,7 @@ describe('execute()', () => {
secrets,
services,
configurationUtilities,
logger: mockedLogger,
};
const actionResponse = await connectorType.executor(executorOptions);
const { apiUrl, data, headers } = postPagerdutyMock.mock.calls[0][0];
@ -688,6 +691,7 @@ describe('execute()', () => {
secrets,
services,
configurationUtilities,
logger: mockedLogger,
};
const actionResponse = await connectorType.executor(executorOptions);
const { apiUrl, data, headers } = postPagerdutyMock.mock.calls[0][0];
@ -753,6 +757,7 @@ describe('execute()', () => {
secrets,
services,
configurationUtilities,
logger: mockedLogger,
};
const actionResponse = await connectorType.executor(executorOptions);
const { apiUrl, data, headers } = postPagerdutyMock.mock.calls[0][0];
@ -817,6 +822,7 @@ describe('execute()', () => {
secrets,
services,
configurationUtilities,
logger: mockedLogger,
};
const actionResponse = await connectorType.executor(executorOptions);
const { apiUrl, data, headers } = postPagerdutyMock.mock.calls[0][0];

View file

@ -5,11 +5,10 @@
* 2.0.
*/
import { curry, isUndefined, pick, omitBy } from 'lodash';
import { isUndefined, pick, omitBy } from 'lodash';
import { i18n } from '@kbn/i18n';
import { schema, TypeOf } from '@kbn/config-schema';
import moment from 'moment';
import { Logger } from '@kbn/core/server';
import type {
ActionType as ConnectorType,
ActionTypeExecutorOptions as ConnectorTypeExecutorOptions,
@ -138,7 +137,7 @@ function validateParams(paramsObject: unknown): string | void {
export const ConnectorTypeId = '.pagerduty';
// connector type definition
export function getConnectorType({ logger }: { logger: Logger }): PagerDutyConnectorType {
export function getConnectorType(): PagerDutyConnectorType {
return {
id: ConnectorTypeId,
minimumLicenseRequired: 'gold',
@ -162,7 +161,7 @@ export function getConnectorType({ logger }: { logger: Logger }): PagerDutyConne
schema: ParamsSchema,
},
},
executor: curry(executor)({ logger }),
executor,
};
}
@ -192,15 +191,10 @@ function getPagerDutyApiUrl(config: ConnectorTypeConfigType): string {
// action executor
async function executor(
{ logger }: { logger: Logger },
execOptions: PagerDutyConnectorTypeExecutorOptions
): Promise<ConnectorTypeExecutorResult<unknown>> {
const actionId = execOptions.actionId;
const config = execOptions.config;
const secrets = execOptions.secrets;
const params = execOptions.params;
const services = execOptions.services;
const configurationUtilities = execOptions.configurationUtilities;
const { actionId, config, secrets, params, services, configurationUtilities, logger } =
execOptions;
const apiUrl = getPagerDutyApiUrl(config);
const headers = {

View file

@ -20,9 +20,7 @@ let configurationUtilities: jest.Mocked<ActionsConfigurationUtilities>;
beforeEach(() => {
configurationUtilities = actionsConfigMock.create();
connectorType = getConnectorType({
logger: mockedLogger,
});
connectorType = getConnectorType();
});
describe('connectorType', () => {
@ -108,6 +106,7 @@ describe('execute()', () => {
config: {},
secrets: {},
configurationUtilities,
logger: mockedLogger,
};
await connectorType.executor(executorOptions);
expect(mockedLogger.info).toHaveBeenCalledWith('Server log: message text here');

View file

@ -5,7 +5,6 @@
* 2.0.
*/
import { curry } from 'lodash';
import { i18n } from '@kbn/i18n';
import { schema, TypeOf } from '@kbn/config-schema';
@ -49,7 +48,7 @@ const ParamsSchema = schema.object({
export const ConnectorTypeId = '.server-log';
// connector type definition
export function getConnectorType({ logger }: { logger: Logger }): ServerLogConnectorType {
export function getConnectorType(): ServerLogConnectorType {
return {
id: ConnectorTypeId,
minimumLicenseRequired: 'basic',
@ -62,18 +61,16 @@ export function getConnectorType({ logger }: { logger: Logger }): ServerLogConne
schema: ParamsSchema,
},
},
executor: curry(executor)({ logger }),
executor,
};
}
// action executor
async function executor(
{ logger }: { logger: Logger },
execOptions: ServerLogConnectorTypeExecutorOptions
): Promise<ConnectorTypeExecutorResult<void>> {
const actionId = execOptions.actionId;
const params = execOptions.params;
const { actionId, params, logger } = execOptions;
const sanitizedMessage = withoutControlCharacters(params.message);
try {

View file

@ -7,7 +7,6 @@
import { curry } from 'lodash';
import { Logger } from '@kbn/core/server';
import type {
ActionType as ConnectorType,
ActionTypeExecutorOptions as ConnectorTypeExecutorOptions,
@ -47,10 +46,6 @@ import { createServiceWrapper } from '../../lib/servicenow/create_service_wrappe
export { ServiceNowITOMConnectorTypeId };
interface GetConnectorTypeParams {
logger: Logger;
}
export type ServiceNowConnectorType<
C extends Record<string, unknown> = ServiceNowPublicConfigurationBaseType,
T extends Record<string, unknown> = ExecutorParamsITOM
@ -62,10 +57,10 @@ export type ServiceNowConnectorTypeExecutorOptions<
> = ConnectorTypeExecutorOptions<C, ServiceNowSecretConfigurationType, T>;
// connector type definition
export function getServiceNowITOMConnectorType(
params: GetConnectorTypeParams
): ServiceNowConnectorType<ServiceNowPublicConfigurationBaseType, ExecutorParamsITOM> {
const { logger } = params;
export function getServiceNowITOMConnectorType(): ServiceNowConnectorType<
ServiceNowPublicConfigurationBaseType,
ExecutorParamsITOM
> {
return {
id: ServiceNowITOMConnectorTypeId,
minimumLicenseRequired: 'platinum',
@ -86,7 +81,6 @@ export function getServiceNowITOMConnectorType(
},
},
executor: curry(executorITOM)({
logger,
actionTypeId: ServiceNowITOMConnectorTypeId,
createService: createExternalService,
api: apiITOM,
@ -98,12 +92,10 @@ export function getServiceNowITOMConnectorType(
const supportedSubActionsITOM = ['addEvent', 'getChoices'];
async function executorITOM(
{
logger,
actionTypeId,
createService,
api,
}: {
logger: Logger;
actionTypeId: string;
createService: ServiceFactory<ExternalServiceITOM>;
api: ExternalServiceApiITOM;
@ -113,7 +105,7 @@ async function executorITOM(
ExecutorParamsITOM
>
): Promise<ConnectorTypeExecutorResult<ServiceNowExecutorResultData | {}>> {
const { actionId, config, params, secrets, configurationUtilities } = execOptions;
const { actionId, config, params, secrets, configurationUtilities, logger } = execOptions;
const { subAction, subActionParams } = params;
const connectorTokenClient = execOptions.services.connectorTokenClient;
const externalServiceConfig = snExternalServiceConfig[actionTypeId];

View file

@ -42,7 +42,6 @@ beforeEach(() => {
async executor(options) {
return { status: 'ok', actionId: options.actionId };
},
logger: mockedLogger,
});
});
@ -170,7 +169,6 @@ describe('execute()', () => {
connectorType = getConnectorType({
executor: mockSlackExecutor,
logger: mockedLogger,
});
});
@ -182,6 +180,7 @@ describe('execute()', () => {
secrets: { webhookUrl: 'http://example.com' },
params: { message: 'this invocation should succeed' },
configurationUtilities,
logger: mockedLogger,
});
expect(response).toMatchInlineSnapshot(`
Object {
@ -201,6 +200,7 @@ describe('execute()', () => {
secrets: { webhookUrl: 'http://example.com' },
params: { message: 'failure: this invocation should fail' },
configurationUtilities,
logger: mockedLogger,
})
).rejects.toThrowErrorMatchingInlineSnapshot(
`"slack mockExecutor failure: this invocation should fail"`
@ -217,9 +217,7 @@ describe('execute()', () => {
proxyBypassHosts: undefined,
proxyOnlyHosts: undefined,
});
const connectorTypeProxy = getConnectorType({
logger: mockedLogger,
});
const connectorTypeProxy = getConnectorType({});
await connectorTypeProxy.executor({
actionId: 'some-id',
services,
@ -227,6 +225,7 @@ describe('execute()', () => {
secrets: { webhookUrl: 'http://example.com' },
params: { message: 'this invocation should succeed' },
configurationUtilities: configUtils,
logger: mockedLogger,
});
expect(mockedLogger.debug).toHaveBeenCalledWith(
'IncomingWebhook was called with proxyUrl https://someproxyhost'
@ -244,9 +243,7 @@ describe('execute()', () => {
proxyBypassHosts: new Set(['example.com']),
proxyOnlyHosts: undefined,
});
const connectorTypeProxy = getConnectorType({
logger: mockedLogger,
});
const connectorTypeProxy = getConnectorType({});
await connectorTypeProxy.executor({
actionId: 'some-id',
services,
@ -254,6 +251,7 @@ describe('execute()', () => {
secrets: { webhookUrl: 'http://example.com' },
params: { message: 'this invocation should succeed' },
configurationUtilities: configUtils,
logger: mockedLogger,
});
expect(mockedLogger.debug).not.toHaveBeenCalledWith(
'IncomingWebhook was called with proxyUrl https://someproxyhost'
@ -271,9 +269,7 @@ describe('execute()', () => {
proxyBypassHosts: new Set(['not-example.com']),
proxyOnlyHosts: undefined,
});
const connectorTypeProxy = getConnectorType({
logger: mockedLogger,
});
const connectorTypeProxy = getConnectorType({});
await connectorTypeProxy.executor({
actionId: 'some-id',
services,
@ -281,6 +277,7 @@ describe('execute()', () => {
secrets: { webhookUrl: 'http://example.com' },
params: { message: 'this invocation should succeed' },
configurationUtilities: configUtils,
logger: mockedLogger,
});
expect(mockedLogger.debug).toHaveBeenCalledWith(
'IncomingWebhook was called with proxyUrl https://someproxyhost'
@ -298,9 +295,7 @@ describe('execute()', () => {
proxyBypassHosts: undefined,
proxyOnlyHosts: new Set(['example.com']),
});
const connectorTypeProxy = getConnectorType({
logger: mockedLogger,
});
const connectorTypeProxy = getConnectorType({});
await connectorTypeProxy.executor({
actionId: 'some-id',
services,
@ -308,6 +303,7 @@ describe('execute()', () => {
secrets: { webhookUrl: 'http://example.com' },
params: { message: 'this invocation should succeed' },
configurationUtilities: configUtils,
logger: mockedLogger,
});
expect(mockedLogger.debug).toHaveBeenCalledWith(
'IncomingWebhook was called with proxyUrl https://someproxyhost'
@ -325,9 +321,7 @@ describe('execute()', () => {
proxyBypassHosts: undefined,
proxyOnlyHosts: new Set(['not-example.com']),
});
const connectorTypeProxy = getConnectorType({
logger: mockedLogger,
});
const connectorTypeProxy = getConnectorType({});
await connectorTypeProxy.executor({
actionId: 'some-id',
services,
@ -335,6 +329,7 @@ describe('execute()', () => {
secrets: { webhookUrl: 'http://example.com' },
params: { message: 'this invocation should succeed' },
configurationUtilities: configUtils,
logger: mockedLogger,
});
expect(mockedLogger.debug).not.toHaveBeenCalledWith(
'IncomingWebhook was called with proxyUrl https://someproxyhost'

View file

@ -6,7 +6,6 @@
*/
import { URL } from 'url';
import { curry } from 'lodash';
import HttpProxyAgent from 'http-proxy-agent';
import { HttpsProxyAgent } from 'https-proxy-agent';
import { i18n } from '@kbn/i18n';
@ -14,7 +13,6 @@ import { schema, TypeOf } from '@kbn/config-schema';
import { IncomingWebhook, IncomingWebhookResult } from '@slack/webhook';
import { pipe } from 'fp-ts/lib/pipeable';
import { map, getOrElse } from 'fp-ts/lib/Option';
import { Logger } from '@kbn/core/server';
import type {
ActionType as ConnectorType,
ActionTypeExecutorOptions as ConnectorTypeExecutorOptions,
@ -65,10 +63,8 @@ const ParamsSchema = schema.object({
export const ConnectorTypeId = '.slack';
// customizing executor is only used for tests
export function getConnectorType({
logger,
executor = curry(slackExecutor)({ logger }),
executor = slackExecutor,
}: {
logger: Logger;
executor?: ExecutorType<{}, ConnectorTypeSecretsType, ActionParamsType, unknown>;
}): SlackConnectorType {
return {
@ -138,13 +134,9 @@ function validateConnectorTypeConfig(
// action executor
async function slackExecutor(
{ logger }: { logger: Logger },
execOptions: SlackConnectorTypeExecutorOptions
): Promise<ConnectorTypeExecutorResult<unknown>> {
const actionId = execOptions.actionId;
const secrets = execOptions.secrets;
const params = execOptions.params;
const configurationUtilities = execOptions.configurationUtilities;
const { actionId, secrets, params, configurationUtilities, logger } = execOptions;
let result: IncomingWebhookResult;
const { webhookUrl } = secrets;

View file

@ -37,9 +37,7 @@ let configurationUtilities: jest.Mocked<ActionsConfigurationUtilities>;
beforeEach(() => {
configurationUtilities = actionsConfigMock.create();
connectorType = getConnectorType({
logger: mockedLogger,
});
connectorType = getConnectorType();
});
describe('connector registration', () => {
@ -168,6 +166,7 @@ describe('execute()', () => {
secrets: { webhookUrl: 'http://example.com' },
params: { message: 'this invocation should succeed' },
configurationUtilities,
logger: mockedLogger,
});
delete requestMock.mock.calls[0][0].configurationUtilities;
expect(requestMock.mock.calls[0][0]).toMatchInlineSnapshot(`
@ -222,6 +221,7 @@ describe('execute()', () => {
secrets: { webhookUrl: 'http://example.com' },
params: { message: 'this invocation should succeed' },
configurationUtilities,
logger: mockedLogger,
});
delete requestMock.mock.calls[0][0].configurationUtilities;
expect(requestMock.mock.calls[0][0]).toMatchInlineSnapshot(`

View file

@ -6,13 +6,12 @@
*/
import { URL } from 'url';
import { curry, isString } from 'lodash';
import { isString } from 'lodash';
import axios, { AxiosError, AxiosResponse } from 'axios';
import { i18n } from '@kbn/i18n';
import { schema, TypeOf } from '@kbn/config-schema';
import { pipe } from 'fp-ts/lib/pipeable';
import { map, getOrElse } from 'fp-ts/lib/Option';
import { Logger } from '@kbn/core/server';
import type {
ActionType as ConnectorType,
ActionTypeExecutorOptions as ConnectorTypeExecutorOptions,
@ -59,7 +58,7 @@ const ParamsSchema = schema.object({
export const ConnectorTypeId = '.teams';
// connector type definition
export function getConnectorType({ logger }: { logger: Logger }): TeamsConnectorType {
export function getConnectorType(): TeamsConnectorType {
return {
id: ConnectorTypeId,
minimumLicenseRequired: 'gold',
@ -80,7 +79,7 @@ export function getConnectorType({ logger }: { logger: Logger }): TeamsConnector
schema: ParamsSchema,
},
},
executor: curry(teamsExecutor)({ logger }),
executor: teamsExecutor,
};
}
@ -117,13 +116,9 @@ function validateConnectorTypeConfig(
// action executor
async function teamsExecutor(
{ logger }: { logger: Logger },
execOptions: TeamsConnectorTypeExecutorOptions
): Promise<ConnectorTypeExecutorResult<unknown>> {
const actionId = execOptions.actionId;
const secrets = execOptions.secrets;
const params = execOptions.params;
const configurationUtilities = execOptions.configurationUtilities;
const { actionId, secrets, params, configurationUtilities, logger } = execOptions;
const { webhookUrl } = secrets;
const { message } = params;
const data = { text: message };

View file

@ -46,9 +46,7 @@ let configurationUtilities: jest.Mocked<ActionsConfigurationUtilities>;
beforeEach(() => {
configurationUtilities = actionsConfigMock.create();
connectorType = getConnectorType({
logger: mockedLogger,
});
connectorType = getConnectorType();
});
describe('connectorType', () => {
@ -271,6 +269,7 @@ describe('execute()', () => {
secrets: { user: 'abc', password: '123' },
params: { body: 'some data' },
configurationUtilities,
logger: mockedLogger,
});
delete requestMock.mock.calls[0][0].configurationUtilities;
@ -336,6 +335,7 @@ describe('execute()', () => {
secrets: { user: 'abc', password: '123' },
params: { body: 'some data' },
configurationUtilities,
logger: mockedLogger,
});
expect(mockedLogger.error).toBeCalledWith(
'error on some-id webhook event: maxContentLength size of 1000000 exceeded'
@ -359,6 +359,7 @@ describe('execute()', () => {
secrets,
params: { body: 'some data' },
configurationUtilities,
logger: mockedLogger,
});
delete requestMock.mock.calls[0][0].configurationUtilities;

View file

@ -6,12 +6,11 @@
*/
import { i18n } from '@kbn/i18n';
import { curry, isString } from 'lodash';
import { isString } from 'lodash';
import axios, { AxiosError, AxiosResponse } from 'axios';
import { schema, TypeOf } from '@kbn/config-schema';
import { pipe } from 'fp-ts/lib/pipeable';
import { map, getOrElse } from 'fp-ts/lib/Option';
import { Logger } from '@kbn/core/server';
import type {
ActionType as ConnectorType,
ActionTypeExecutorOptions as ConnectorTypeExecutorOptions,
@ -84,7 +83,7 @@ const ParamsSchema = schema.object({
export const ConnectorTypeId = '.webhook';
// connector type definition
export function getConnectorType({ logger }: { logger: Logger }): WebhookConnectorType {
export function getConnectorType(): WebhookConnectorType {
return {
id: ConnectorTypeId,
minimumLicenseRequired: 'gold',
@ -109,7 +108,7 @@ export function getConnectorType({ logger }: { logger: Logger }): WebhookConnect
},
},
renderParameterTemplates,
executor: curry(executor)({ logger }),
executor,
};
}
@ -158,13 +157,11 @@ function validateConnectorTypeConfig(
// action executor
export async function executor(
{ logger }: { logger: Logger },
execOptions: WebhookConnectorTypeExecutorOptions
): Promise<ConnectorTypeExecutorResult<unknown>> {
const actionId = execOptions.actionId;
const { method, url, headers = {}, hasAuth } = execOptions.config;
const { body: data } = execOptions.params;
const configurationUtilities = execOptions.configurationUtilities;
const { actionId, config, params, configurationUtilities, logger } = execOptions;
const { method, url, headers = {}, hasAuth } = config;
const { body: data } = params;
const secrets: ConnectorTypeSecretsType = execOptions.secrets;
const basicAuth =

View file

@ -38,9 +38,7 @@ let configurationUtilities: jest.Mocked<ActionsConfigurationUtilities>;
beforeEach(() => {
configurationUtilities = actionsConfigMock.create();
connectorType = getConnectorType({
logger: mockedLogger,
});
connectorType = getConnectorType();
});
describe('connectorType', () => {
@ -414,6 +412,7 @@ describe('execute()', () => {
tags: 'test1, test2',
},
configurationUtilities,
logger: mockedLogger,
});
expect(postxMattersMock.mock.calls[0][0]).toMatchInlineSnapshot(`
@ -462,6 +461,7 @@ describe('execute()', () => {
tags: 'test1, test2',
},
configurationUtilities,
logger: mockedLogger,
});
expect(mockedLogger.warn).toBeCalledWith(
'Error thrown triggering xMatters workflow: maxContentLength size of 1000000 exceeded'
@ -493,6 +493,7 @@ describe('execute()', () => {
tags: 'test1, test2',
},
configurationUtilities,
logger: mockedLogger,
});
expect(postxMattersMock.mock.calls[0][0]).toMatchInlineSnapshot(`

View file

@ -5,10 +5,9 @@
* 2.0.
*/
import { curry, isString } from 'lodash';
import { isString } from 'lodash';
import { i18n } from '@kbn/i18n';
import { schema, TypeOf } from '@kbn/config-schema';
import { Logger } from '@kbn/core/server';
import type {
ActionType as ConnectorType,
ActionTypeExecutorOptions as ConnectorTypeExecutorOptions,
@ -60,7 +59,7 @@ const ParamsSchema = schema.object({
export const ConnectorTypeId = '.xmatters';
// connector type definition
export function getConnectorType({ logger }: { logger: Logger }): XmattersConnectorType {
export function getConnectorType(): XmattersConnectorType {
return {
id: ConnectorTypeId,
minimumLicenseRequired: 'gold',
@ -82,7 +81,7 @@ export function getConnectorType({ logger }: { logger: Logger }): XmattersConnec
},
connector: validateConnector,
},
executor: curry(executor)({ logger }),
executor,
};
}
@ -243,13 +242,11 @@ function validateConnectorTypeSecrets(
// action executor
export async function executor(
{ logger }: { logger: Logger },
execOptions: XmattersConnectorTypeExecutorOptions
): Promise<ConnectorTypeExecutorResult<unknown>> {
const actionId = execOptions.actionId;
const configurationUtilities = execOptions.configurationUtilities;
const { configUrl, usesBasic } = execOptions.config;
const data = getPayloadForRequest(execOptions.params);
const { actionId, configurationUtilities, config, params, logger } = execOptions;
const { configUrl, usesBasic } = config;
const data = getPayloadForRequest(params);
const secrets: ConnectorTypeSecretsType = execOptions.secrets;
const basicAuth =

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { PluginInitializerContext, Plugin, CoreSetup, Logger } from '@kbn/core/server';
import { PluginInitializerContext, Plugin, CoreSetup } from '@kbn/core/server';
import { PluginSetupContract as ActionsPluginSetupContract } from '@kbn/actions-plugin/server';
import { registerConnectorTypes } from './connector_types';
import { getWellKnownEmailServiceRoute } from './routes';
@ -18,11 +18,7 @@ export interface ConnectorsPluginsStart {
}
export class StackConnectorsPlugin implements Plugin<void, void> {
private readonly logger: Logger;
constructor(context: PluginInitializerContext) {
this.logger = context.logger.get();
}
constructor(context: PluginInitializerContext) {}
public setup(core: CoreSetup<ConnectorsPluginsStart>, plugins: ConnectorsPluginsSetup) {
const router = core.http.createRouter();
@ -31,7 +27,6 @@ export class StackConnectorsPlugin implements Plugin<void, void> {
getWellKnownEmailServiceRoute(router);
registerConnectorTypes({
logger: this.logger,
actions,
publicBaseUrl: core.http.basePath.publicBaseUrl,
});