[Management] Handle commas as separations in the query for CCS purposes (#16535)
* Handle commas as separations in the query for CCS purposes * Add tests * Limit this to ccs queries, which just means they contain a :
This commit is contained in:
parent
73de529a00
commit
bf14b4e3e0
|
@ -21,6 +21,11 @@ describe('isQueryAMatch', () => {
|
|||
it('for a pattern that is only a wildcard', () => {
|
||||
expect(isQueryAMatch('*', 'es')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('for a pattern that contains commas', () => {
|
||||
expect(isQueryAMatch('cluster_one:kibana,cluster_two:kibana', 'cluster_one:kibana')).toBeTruthy();
|
||||
expect(isQueryAMatch('cluster_one:k*,cluster_two:kibana', 'cluster_one:kibana')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('returns false', () => {
|
||||
|
@ -31,5 +36,9 @@ describe('isQueryAMatch', () => {
|
|||
it('for a pattern with wildcards but does not remotely match', () => {
|
||||
expect(isQueryAMatch('k*b*', 'es')).toBeFalsy();
|
||||
});
|
||||
|
||||
it('for a pattern that contains commas but is not a CCS query', () => {
|
||||
expect(isQueryAMatch('kibana,es', 'kibana')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
function isCCSQuery(query) {
|
||||
return query.includes(':');
|
||||
}
|
||||
|
||||
export const isQueryAMatch = (query, name) => {
|
||||
if (name === query) {
|
||||
return true;
|
||||
|
@ -20,5 +24,11 @@ export const isQueryAMatch = (query, name) => {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (query.includes(',')) {
|
||||
return query.split(',').reduce((isMatch, subQuery) => {
|
||||
return isMatch || isCCSQuery(subQuery) && isQueryAMatch(subQuery, name);
|
||||
}, false);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue