Skip to content

Commit

Permalink
Update current policy maintaining its name
Browse files Browse the repository at this point in the history
  • Loading branch information
criamico committed Oct 29, 2021
1 parent 24ffaeb commit 2f158d3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions x-pack/plugins/fleet/server/services/package_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,14 @@ class PackagePolicyService {
if (!oldPackagePolicy) {
throw new Error('Package policy not found');
}

// Check that the name does not exist already but exclude the current policy
const existingPoliciesWithName = await this.list(soClient, {
perPage: 1,
kuery: `${PACKAGE_POLICY_SAVED_OBJECT_TYPE}.name: "${packagePolicy.name}"`,
});
const filtered = (existingPoliciesWithName?.items || []).filter((p) => p.id !== id);

// Check that the name does not exist already
if ((existingPoliciesWithName?.items || []).length > 0) {
if (filtered.length > 0) {
throw new IngestManagerError('There is already a package with the same name');
}

Expand Down

0 comments on commit 2f158d3

Please sign in to comment.