From d86ef49cfb8a788381d80b4551114b802c683b64 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Henning?= <soeren.henning@email.uni-kiel.de>
Date: Wed, 24 Nov 2021 16:11:00 +0100
Subject: [PATCH] Allow installing benchmarks defined in values.yaml

---
 .../benchmark-resources-config-map.yaml       | 10 ++++----
 .../theodolite/benchmarks/benchmark.yaml      |  7 ++++++
 helm/values.yaml                              | 23 +++++++++++++++++++
 3 files changed, 34 insertions(+), 6 deletions(-)
 create mode 100644 helm/templates/theodolite/benchmarks/benchmark.yaml

diff --git a/helm/templates/theodolite/benchmarks/benchmark-resources-config-map.yaml b/helm/templates/theodolite/benchmarks/benchmark-resources-config-map.yaml
index 16ef86977..2dd355141 100644
--- a/helm/templates/theodolite/benchmarks/benchmark-resources-config-map.yaml
+++ b/helm/templates/theodolite/benchmarks/benchmark-resources-config-map.yaml
@@ -1,12 +1,10 @@
-{{- $processedDict := dict -}}
-{{- range $path, $bytes := .Files.Glob "benchmark-definitions/**/resources/**" }}
-{{- $name := base (dir (dir $path)) }}
-{{- if not (hasKey $processedDict $name) -}}
-{{ $_ := set $processedDict $name "true" }}
+{{- range $configmap, $enabled := .Values.operator.theodoliteBenchmarks.resourceConfigMaps }}
+{{- if $enabled -}}
+{{- $name := kebabcase $configmap }}
 apiVersion: v1
 kind: ConfigMap
 metadata:
-    name: benchmark-resources-{{ $name }}
+  name: benchmark-resources-{{ $name }}
 data:
 {{ ($.Files.Glob (printf "benchmark-definitions/%s/resources/*" $name)).AsConfig | indent 2 }}
 ---
diff --git a/helm/templates/theodolite/benchmarks/benchmark.yaml b/helm/templates/theodolite/benchmarks/benchmark.yaml
new file mode 100644
index 000000000..1c4cb02ea
--- /dev/null
+++ b/helm/templates/theodolite/benchmarks/benchmark.yaml
@@ -0,0 +1,7 @@
+{{- range $benchmark, $enabled := .Values.operator.theodoliteBenchmarks.benchmarks }}
+{{- if $enabled -}}
+{{- $name := kebabcase $benchmark }}
+{{ $.Files.Get (printf "benchmark-definitions/%s/%s-benchmark-operator.yaml" $name $name) }}
+---
+{{- end }}
+{{- end }}
diff --git a/helm/values.yaml b/helm/values.yaml
index 5cdb9ddbd..9de0155cf 100644
--- a/helm/values.yaml
+++ b/helm/values.yaml
@@ -281,6 +281,29 @@ operator:
       imageTag: stable
       imagePullPolicy: IfNotPresent
 
+  theodoliteBenchmarks:
+    resourceConfigMaps:
+      uc1LoadGenerator: true
+      uc1Kstreams: true
+      uc1Flink: true
+      uc2LoadGenerator: true
+      uc2Kstreams: true
+      uc2Flink: true
+      uc3LoadGenerator: true
+      uc3Kstreams: true
+      uc3Flink: true
+      uc4LoadGenerator: true
+      uc4Kstreams: true
+      uc4Flink: true
+    benchmarks:
+      uc1Kstreams: true
+      uc1Flink: true
+      uc2Kstreams: true
+      uc2Flink: true
+      uc3Kstreams: true
+      uc3Flink: true
+      uc4Kstreams: true
+      uc4Flink: true
 
 serviceAccount:
   create: true
-- 
GitLab