Skip to content

Commit 595d933

Browse files
committed
add support for comma separated values in runtime annotations
1 parent 113ab7a commit 595d933

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/components/SysdigVMRuntimeFetchComponent/SysdigVMRuntimeFetchComponent.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export const SysdigVMRuntimeFetchComponent = () => {
158158

159159
let uri = backendUrl + API_PROXY_BASE_PATH + API_VULN_RUNTIME;
160160
let filter = '?filter=';
161-
var name;
161+
var names;
162162

163163
const annotations = entity.metadata.annotations;
164164
if (annotations) {
@@ -170,28 +170,28 @@ export const SysdigVMRuntimeFetchComponent = () => {
170170
var filters = []
171171

172172
if (SYSDIG_CLUSTER_NAME_ANNOTATION in annotations) {
173-
name = annotations[SYSDIG_CLUSTER_NAME_ANNOTATION]
174-
filters.push('kubernetes.cluster.name="' + name + '"');
173+
names = annotations[SYSDIG_CLUSTER_NAME_ANNOTATION].split(',').map(w => `"${w.trim()}"`).join(', ');
174+
filters.push(`kubernetes.cluster.name in (${names})`);
175175
}
176176

177177
if (SYSDIG_NAMESPACE_ANNOTATION in annotations) {
178-
name = annotations[SYSDIG_NAMESPACE_ANNOTATION]
179-
filters.push('kubernetes.namespace.name="' + name + '"');
178+
names = annotations[SYSDIG_NAMESPACE_ANNOTATION].split(',').map(w => `"${w.trim()}"`).join(', ');
179+
filters.push(`kubernetes.namespace.name in (${names})`);
180180
}
181181

182182
if (SYSDIG_WORKLOAD_ANNOTATION in annotations) {
183-
name = annotations[SYSDIG_WORKLOAD_ANNOTATION]
184-
filters.push('kubernetes.workload.name="' + name + '"');
183+
names = annotations[SYSDIG_WORKLOAD_ANNOTATION].split(',').map(w => `"${w.trim()}"`).join(', ');
184+
filters.push(`kubernetes.workload.name in (${names})`);
185185
}
186186

187187
if (SYSDIG_WORKLOAD_TYPE_ANNOTATION in annotations) {
188-
name = annotations[SYSDIG_WORKLOAD_TYPE_ANNOTATION]
189-
filters.push('kubernetes.workload.type="' + name + '"');
188+
names = annotations[SYSDIG_WORKLOAD_TYPE_ANNOTATION].split(',').map(w => `"${w.trim()}"`).join(', ');
189+
filters.push(`kubernetes.workload.type in (${names})`);
190190
}
191191

192192
if (SYSDIG_CONTAINER_ANNOTATION in annotations) {
193-
name = annotations[SYSDIG_CONTAINER_ANNOTATION]
194-
filters.push('kubernetes.pod.container.name="' + name + '"');
193+
names = annotations[SYSDIG_CONTAINER_ANNOTATION].split(',').map(w => `"${w.trim()}"`).join(', ');
194+
filters.push(`kubernetes.pod.container.name in (${names})`);
195195
}
196196

197197
if (filters.length == 0) {

src/lib/annotations.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export const SYSDIG_SOURCE_TYPE_ANNOTATION = "sysdigcloud.com/source-type";
8383
* Runtime
8484
*/
8585

86+
// Runtime annotation values also support comma separated values. Example "prod-gke,prod-eks"
87+
8688
// The cluster that will be included in the results. Example: "prod-gke"
8789
export const SYSDIG_CLUSTER_NAME_ANNOTATION = "sysdigcloud.com/kubernetes-cluster-name";
8890

0 commit comments

Comments
 (0)