[Ingest] Fix config creation when fleet is not enabled (#65158)

This commit is contained in:
Nicolas Chaulet 2020-05-04 19:59:00 -04:00 committed by GitHub
parent fb79865aa0
commit 418804d6ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,12 +7,19 @@
import { SavedObjectsClientContract } from 'src/core/server';
import { generateEnrollmentAPIKey, deleteEnrollmentApiKeyForConfigId } from './api_keys';
import { updateAgentsForConfigId, unenrollForConfigId } from './agents';
import { outputService } from './output';
export async function agentConfigUpdateEventHandler(
soClient: SavedObjectsClientContract,
action: string,
configId: string
) {
const adminUser = await outputService.getAdminUser(soClient);
// If no admin user fleet is not enabled just skip this hook
if (!adminUser) {
return;
}
if (action === 'created') {
await generateEnrollmentAPIKey(soClient, {
configId,