mirror of
https://github.com/ansible/awx.git
synced 2026-03-10 14:09:28 -02:30
Compare facts in both directions, not just one way
This commit is contained in:
@@ -11,6 +11,15 @@ export function compareFacts(module, facts) {
|
|||||||
if (module.displayType === 'nested') {
|
if (module.displayType === 'nested') {
|
||||||
return compareNestedFacts(facts);
|
return compareNestedFacts(facts);
|
||||||
} else {
|
} else {
|
||||||
return compareFlatFacts(facts, module.nameKey, module.compareKey, module.factTemplate);
|
// For flat structures we compare left-to-right, then right-to-left to
|
||||||
|
// make sure we get a good comparison between both hosts
|
||||||
|
var compare = _.partialRight(compareFlatFacts, module.nameKey, module.compareKey, module.factTemplate);
|
||||||
|
var leftToRight = compare(facts[0], facts[1]);
|
||||||
|
var rightToLeft = compare(facts[1], facts[0]);
|
||||||
|
|
||||||
|
return _(leftToRight)
|
||||||
|
.concat(rightToLeft)
|
||||||
|
.unique('displayKeyPath')
|
||||||
|
.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,10 +38,7 @@ function slotFactValues(basisPosition, basisValue, comparatorValue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default
|
export default
|
||||||
function flatCompare(facts, nameKey, compareKeys, factTemplate) {
|
function flatCompare(basisFacts, comparatorFacts, nameKey, compareKeys, factTemplate) {
|
||||||
|
|
||||||
var comparatorFacts = facts[0];
|
|
||||||
var basisFacts = facts[1];
|
|
||||||
|
|
||||||
return basisFacts.reduce(function(arr, basisFact) {
|
return basisFacts.reduce(function(arr, basisFact) {
|
||||||
var searcher = {};
|
var searcher = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user