Skip to content

Commit

Permalink
Merge pull request #727 from razee-io/annotation_text_search2
Browse files Browse the repository at this point in the history
New: added razee annotations to searchableExpression
  • Loading branch information
rmgraham authored Jan 22, 2021
2 parents 0db0273 + f9fe6db commit b6fadae
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/utils/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,26 @@ const buildSearchableDataForResource = (org, obj, { clusterId }) => {
}
});

var razeeNameFilterFunc = (val, key)=>{
return key.toString().match(/^(razee\.io|satellite\.cloud\.ibm\.com|cpdaas\.cloud\.ibm\.com)/i);
};

var allAnnotations = _.get(obj, 'metadata.annotations', {});
var searchableAnnotationValues = _.filter(allAnnotations , razeeNameFilterFunc);

var allLabels = _.get(obj, 'metadata.labels', {});
var searchableLabelValues = _.filter(allLabels , razeeNameFilterFunc);

var searchableExpressionArr = _.uniq(_.union(
_.map(out, (searchableAttr)=>{
return searchableAttr;
}),
[clusterId]
[clusterId],
searchableAnnotationValues,
searchableLabelValues,
));

// not sure why we're joining by colon instead of space, but thats what was in the original code, so keeping it
out['searchableExpression'] = searchableExpressionArr.join(':');
out['searchableExpression'] = searchableExpressionArr.join(' ');

return out;
};
Expand Down

0 comments on commit b6fadae

Please sign in to comment.