From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Filip Zrůst <128540+f4z4on@users.noreply.github.com>
Date: Fri, 16 Jun 2023 18:06:47 +0200
Subject: Fix validation of source for spec.router.instances
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This field is sourced from value “routerInstances” or
“router.instances”. If “router.instances” is set, we check if it is the
same as “routerInstances”.

We do this with “ne” Helm function. This function cannot compare
different types. This is is quite typical when mixing values from
different sources (for example default values.yaml file and command-line
arguments).

Perhaps more strangely, when values YAML file contains an integer value,
it is treated as float64 by Helm, so even when we use default
values.yaml and set “router.instances” on command line, we get a
strangely looking error message as a result of “printf” trying to print
float64 as int64 (on the lastest version Helm as of this
writing—3.12.1).

We solve both issues by converting both values to strings.
---
 helm/mysql-innodbcluster/templates/deployment_cluster.yaml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/helm/mysql-innodbcluster/templates/deployment_cluster.yaml b/helm/mysql-innodbcluster/templates/deployment_cluster.yaml
index bcf150e..36289af 100644
--- a/helm/mysql-innodbcluster/templates/deployment_cluster.yaml
+++ b/helm/mysql-innodbcluster/templates/deployment_cluster.yaml
@@ -6,8 +6,8 @@
 {{- $imagePullPolicies := list "ifnotpresent" "always" "never" }}
 {{- $serverVersion := .Values.serverVersion | default .Chart.AppVersion }}
 {{- if and ((.Values).routerInstances) (((.Values).router).instances) }}
-  {{- if ne ((.Values).routerInstances) (((.Values).router).instances) }}
-    {{- $err := printf "routerInstances and router.instances both are specified and have different values %d and %d. Use only one" ((.Values).routerInstances) (((.Values).router).instances) }}
+  {{- if ne (toString ((.Values).routerInstances)) (toString (((.Values).router).instances)) }}
+    {{- $err := printf "routerInstances and router.instances both are specified and have different values %s and %s. Use only one" (toString ((.Values).routerInstances)) (toString (((.Values).router).instances)) }}
     {{- fail $err }}
   {{- end }}
 {{- end }}
