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] Switch DefaultPackage enum to approach from #82188 #82512

Merged
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 @@ -3,7 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { AgentPolicy, DefaultPackages } from '../types';
import { defaultPackages } from './epm';
import { AgentPolicy } from '../types';
export const AGENT_POLICY_SAVED_OBJECT_TYPE = 'ingest-agent-policies';

export const agentPolicyStatuses = {
Expand All @@ -24,4 +25,4 @@ export const DEFAULT_AGENT_POLICY: Omit<
monitoring_enabled: ['logs', 'metrics'] as Array<'logs' | 'metrics'>,
};

export const DEFAULT_AGENT_POLICIES_PACKAGES = [DefaultPackages.system];
export const DEFAULT_AGENT_POLICIES_PACKAGES = [defaultPackages.System];
3 changes: 3 additions & 0 deletions x-pack/plugins/ingest_manager/common/constants/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const requiredPackages = {
Endpoint: 'endpoint',
} as const;

// these are currently identical. we can separate if they later diverge
export const defaultPackages = requiredPackages;

export const agentAssetTypes = {
Input: 'input',
} as const;
Expand Down
6 changes: 2 additions & 4 deletions x-pack/plugins/ingest_manager/common/types/models/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { SavedObject, SavedObjectAttributes, SavedObjectReference } from 'src/co
import {
agentAssetTypes,
dataTypes,
defaultPackages,
installationStatuses,
requiredPackages,
} from '../../constants';
Expand Down Expand Up @@ -278,10 +279,7 @@ export type EsAssetReference = Pick<SavedObjectReference, 'id'> & {

export type RequiredPackage = typeof requiredPackages;

export enum DefaultPackages {
system = 'system',
endpoint = 'endpoint',
}
export type DefaultPackages = typeof defaultPackages;

export interface IndexTemplateMappings {
properties: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
DeleteAgentPolicyRequestSchema,
GetFullAgentPolicyRequestSchema,
AgentPolicy,
DefaultPackages,
NewPackagePolicy,
} from '../../types';
import {
Expand All @@ -31,6 +30,7 @@ import {
CopyAgentPolicyResponse,
DeleteAgentPolicyResponse,
GetFullAgentPolicyResponse,
defaultPackages,
} from '../../../common';
import { defaultIngestErrorHandler } from '../../errors';

Expand Down Expand Up @@ -117,7 +117,7 @@ export const createAgentPolicyHandler: RequestHandler<
// successfully
withSysMonitoring
? packagePolicyService
.buildPackagePolicyFromPackage(soClient, DefaultPackages.system)
.buildPackagePolicyFromPackage(soClient, defaultPackages.System)
.catch(() => undefined)
: undefined,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import { SavedObject, SavedObjectsClientContract } from 'src/core/server';
import semver from 'semver';
import Boom from '@hapi/boom';
import { UnwrapPromise } from '@kbn/utility-types';
import { BulkInstallPackageInfo, InstallSource } from '../../../../common';
import { BulkInstallPackageInfo, InstallSource, defaultPackages } from '../../../../common';
import { PACKAGES_SAVED_OBJECT_TYPE, MAX_TIME_COMPLETE_INSTALL } from '../../../constants';
import {
AssetReference,
Installation,
CallESAsCurrentUser,
DefaultPackages,
AssetType,
KibanaAssetReference,
EsAssetReference,
Expand Down Expand Up @@ -65,7 +64,7 @@ export async function ensureInstalledDefaultPackages(
const installations = [];
const bulkResponse = await bulkInstallPackages({
savedObjectsClient,
packagesToUpgrade: Object.values(DefaultPackages),
packagesToUpgrade: Object.values(defaultPackages),
callCluster,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
AGENT_SAVED_OBJECT_TYPE,
AGENT_EVENT_SAVED_OBJECT_TYPE,
} from './../../../../ingest_manager/common/constants/agent';
import { Agent, DefaultPackages as FleetDefaultPackages } from '../../../../ingest_manager/common';
import { Agent, defaultPackages as FleetDefaultPackages } from '../../../../ingest_manager/common';

export const FLEET_ENDPOINT_PACKAGE_CONSTANT = FleetDefaultPackages.endpoint;
export const FLEET_ENDPOINT_PACKAGE_CONSTANT = FleetDefaultPackages.Endpoint;

export const getFleetSavedObjectsMetadata = async (savedObjectsClient: ISavedObjectsRepository) =>
savedObjectsClient.find<Agent>({
Expand Down