Skip to content

Commit

Permalink
Exclude version from package config attributes that are copied, add…
Browse files Browse the repository at this point in the history
… safeguard to package config bulk create
  • Loading branch information
jen-huang committed Jul 23, 2020
1 parent f4bc846 commit 20eb153
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 5 additions & 7 deletions x-pack/plugins/ingest_manager/server/services/agent_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,14 @@ class AgentConfigService {
if (baseAgentConfig.package_configs.length) {
const newPackageConfigs = (baseAgentConfig.package_configs as PackageConfig[]).map(
(packageConfig: PackageConfig) => {
const { id: packageConfigId, ...newPackageConfig } = packageConfig;
const { id: packageConfigId, version, ...newPackageConfig } = packageConfig;
return newPackageConfig;
}
);
await packageConfigService.bulkCreate(
soClient,
newPackageConfigs,
newAgentConfig.id,
options
);
await packageConfigService.bulkCreate(soClient, newPackageConfigs, newAgentConfig.id, {
...options,
bumpConfigRevision: false,
});
}

// Get updated config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class PackageConfigService {
options?: { user?: AuthenticatedUser; bumpConfigRevision?: boolean }
): Promise<PackageConfig[]> {
const isoDate = new Date().toISOString();
const { saved_objects: newSos } = await soClient.bulkCreate<PackageConfigSOAttributes>(
const { saved_objects } = await soClient.bulkCreate<PackageConfigSOAttributes>(
packageConfigs.map((packageConfig) => ({
type: SAVED_OBJECT_TYPE,
attributes: {
Expand All @@ -136,6 +136,9 @@ class PackageConfigService {
}))
);

// Filter out invalid SOs
const newSos = saved_objects.filter((so) => !so.error && so.attributes);

// Assign it to the given agent config
await agentConfigService.assignPackageConfigs(
soClient,
Expand Down

0 comments on commit 20eb153

Please sign in to comment.