diff --git a/app/src/app.js b/app/src/app.js index 7b38260..42c7264 100644 --- a/app/src/app.js +++ b/app/src/app.js @@ -74,11 +74,22 @@ export default class App { return labels && labels[name] === value } + namespaceMatches(pod, value) { + return pod.namespace === value + } + createMatchesFunctionForQuery(query) { - if (query.includes('=')) { - const labelAndValue = query.split('=', 2) - return pod => this.labelMatches(pod, labelAndValue[0], labelAndValue[1]) - } else { + if (query.startsWith('namespace=')) { + // filter by namespace + const value = query.split('namespace=', 2)[1] + return pod => this.namespaceMatches(pod, value) + } else if (query.includes('=')) { + // filter by label + const [label, value] = query.split('=', 2) + return pod => this.labelMatches(pod, label, value) + } + else { + // filter by name return pod => this.nameMatches(pod, query) } } diff --git a/docs/user-guide.rst b/docs/user-guide.rst index 46ea1aa..ceac838 100644 --- a/docs/user-guide.rst +++ b/docs/user-guide.rst @@ -35,6 +35,7 @@ You can filter by: * name * labels - when query includes ``=``, e.g. ``env=prod`` +* namespace - when query starts with ``namespace``, e.g. ``namespace=default`` The pod filter is persisted in the location bar (``#q=..`` query parameter) which allows to conveniently send the filtered view to other users (e.g. for troubleshooting).