From 9d9127cefe059fc42c1489faf4fbc3b2e8724c13 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Thu, 6 Jan 2022 11:15:46 +0100
Subject: [PATCH] OZG-1928: intelliform adapter component fix, fix instance
 value in helpers tpl, fix tests by adding the scrapedisabled value

---
 templates/_helpers.tpl                          | 2 +-
 templates/deployment.yaml                       | 2 +-
 unit-tests/deployment_defaults_labels_test.yaml | 4 +++-
 unit-tests/service_monitor_test.yaml            | 9 +++++++++
 unit-tests/service_test.yaml                    | 2 ++
 5 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl
index cd31289ce..6e6726578 100644
--- a/templates/_helpers.tpl
+++ b/templates/_helpers.tpl
@@ -28,7 +28,7 @@
 
 {{/* Default Labels: Helm recommended best-practice labels https://helm.sh/docs/chart_best_practices/labels/ */}}
 {{- define "app.defaultLabels" }}
-app.kubernetes.io/instance: {{ include "app.name" . }}
+app.kubernetes.io/instance: afm-adapter
 app.kubernetes.io/managed-by: {{ include "app.managedBy" . }}
 app.kubernetes.io/name: {{ include "app.name" . }}
 app.kubernetes.io/part-of: kop
diff --git a/templates/deployment.yaml b/templates/deployment.yaml
index 8bcb19bf9..4088ce25a 100644
--- a/templates/deployment.yaml
+++ b/templates/deployment.yaml
@@ -21,7 +21,7 @@ spec:
     metadata:
       labels:
         {{- include "app.defaultLabels" . | indent 8 }}
-        component: intelliform-adapter
+        component: afm-adapter
     spec:
       topologySpreadConstraints:
       - maxSkew: 1
diff --git a/unit-tests/deployment_defaults_labels_test.yaml b/unit-tests/deployment_defaults_labels_test.yaml
index 59ee67490..df6eaf35f 100644
--- a/unit-tests/deployment_defaults_labels_test.yaml
+++ b/unit-tests/deployment_defaults_labels_test.yaml
@@ -8,10 +8,12 @@ templates:
   - templates/service.yaml
 tests:
   - it: check default labels
+    set:
+      scrapeMetricsDisabled: false
     asserts:
       - equal:
           path: metadata.labels.[app.kubernetes.io/instance]
-          value: intelliform-adapter
+          value: afm-adapter
       - equal:
           path: metadata.labels.[app.kubernetes.io/name]
           value: intelliform-adapter
diff --git a/unit-tests/service_monitor_test.yaml b/unit-tests/service_monitor_test.yaml
index beb6ba56f..00a270046 100644
--- a/unit-tests/service_monitor_test.yaml
+++ b/unit-tests/service_monitor_test.yaml
@@ -6,6 +6,8 @@ templates:
   - templates/service_monitor.yaml
 tests:
   - it: should have the label component with value afm-adapter-service-monitor attached
+    set:
+      scrapeMetricsDisabled: false
     asserts:
       - isKind:
           of: ServiceMonitor
@@ -14,6 +16,7 @@ tests:
           value: afm-adapter-service-monitor
   - it: should have the metrics endpoint configured by default
     set:
+      scrapeMetricsDisabled: false
       env.springProfiles: oc,stage
     asserts:
       - isKind:
@@ -35,16 +38,22 @@ tests:
             port: metrics
             path: /actuator/prometheus
   - it: namespace selector should contain the namespace
+    set:  
+      scrapeMetricsDisabled: false
     asserts:
       - contains:
           path: spec.namespaceSelector.matchNames
           content: sh-helm-test
   - it: selector should contain the component label with the value afm-adapter-service
+    set:
+      scrapeMetricsDisabled: false
     asserts:
       - equal:
           path: spec.selector.matchLabels.[component]
           value: afm-adapter-service
   - it: selector should contain helm recommended labels name and namespace
+    set:
+      scrapeMetricsDisabled: false
     asserts:
       - equal:
           path: spec.selector.matchLabels.[app.kubernetes.io/name]
diff --git a/unit-tests/service_test.yaml b/unit-tests/service_test.yaml
index 4a24297a8..26c9f0d97 100644
--- a/unit-tests/service_test.yaml
+++ b/unit-tests/service_test.yaml
@@ -29,6 +29,8 @@ tests:
         count: 1
         any: true
   - it: ports should contain the metrics port
+    set:
+      scrapeMetricsDisabled: false
     asserts:
       - contains:
           path: spec.ports
-- 
GitLab