Skip to content

Commit

Permalink
Support filtering roles that contain a path
Browse files Browse the repository at this point in the history
  • Loading branch information
dblackhall-tyro committed Jun 11, 2024
1 parent 19e1ff7 commit 6244369
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/js/lib/target_profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function retrieveTargetProfilesFromDB(ctx) {
const complexTargetItems = await dbTable.query(`${matchedComplexSrc.name};`);
let targets = complexTargetItems.map(it => convertComplexTarget(it, matchedComplexSrc));
if (filterByTargetRole) {
targets = targets.filter(it => it.role_name === filterByTargetRole);
targets = targets.filter(it => targetRoleNameMatches(it, filterByTargetRole));
}
results.push(...targets)
}
Expand Down Expand Up @@ -72,10 +72,14 @@ async function retrieveTargetProfilesFromLztext(ctx) {
if (matchedComplexSrc) {
let targets = matchedComplexSrc.targets;
if (filterByTargetRole) {
targets = targets.filter(it => it.role_name === filterByTargetRole);
targets = targets.filter(it => targetRoleNameMatches(it, filterByTargetRole));
}
results.push(...targets)
}

return results;
}

function targetRoleNameMatches(it, filterByTargetRole) {
return it.role_name === filterByTargetRole || it.role_name.substring(it.role_name.lastIndexOf('/') + 1) === filterByTargetRole;
}

0 comments on commit 6244369

Please sign in to comment.