Selaa lähdekoodia

palworld - all inputs are strings and must be regex matched (#2122)

* palworld - all inputs are strings and must be regex matched

* fix ci
Stavros Kois 1 vuosi sitten
vanhempi
commit
977f9df34c

+ 1 - 1
library/ix-dev/community/palworld/Chart.yaml

@@ -3,7 +3,7 @@ description: Palworld is a multiplayer, open-world survival crafting game where
 annotations:
   title: Palworld
 type: application
-version: 1.0.3
+version: 1.0.4
 apiVersion: v2
 appVersion: palworld
 kubeVersion: '>=1.16.0-0'

+ 4 - 4
library/ix-dev/community/palworld/ci/basic-values.yaml

@@ -20,12 +20,12 @@ palworldConfig:
     keep: 3
   iniKeys:
     - key: PlayerDamageRateAttack
-      value: 1.000000
+      value: "1.000000"
     - key: DropItemMaxNum
-      value: 4000
+      value: "4000"
     - key: Region
       value: ""
     - key: PalEggDefaultHatchingTime
-      value: 72.450000
+      value: "72.450000"
     - key: bEnablePlayerToPlayerDamage
-      value: true
+      value: "True"

+ 13 - 8
library/ix-dev/community/palworld/templates/_palworld.tpl

@@ -125,15 +125,20 @@ workload:
               set_ini_value "AdminPassword" {{ .Values.palworldConfig.adminPassword | squote }} true false
 
               {{- range $item := .Values.palworldConfig.iniKeys }}
-                {{- if mustHas (kindOf $item.value) (list "int" "int64" "float64") }}
-                  echo "Key {{ $item.key }} is a {{ kindOf $item.value }}, setting without quotes..."
-                  set_ini_value "{{ $item.key }}" {{ $item.value }}
-                {{- else if or (eq ((toString $item.value) | lower) "true") (eq ((toString $item.value) | lower) "false") }}
-                  echo "Key {{ $item.key }} is a boolean, setting without quotes..."
-                  set_ini_value "{{ $item.key }}" {{ (toString $item.value) | camelcase }}
+                {{- $k := $item.key -}}
+                {{- $v := $item.value | toString -}}
+                {{- $numRegex := "^[0-9]+([.][0-9]+)?$" -}}
+                {{- $boolRegex := "^(true|false)$" -}}
+
+                {{- if (mustRegexMatch $numRegex $v) }}
+                  echo "Key [{{ $k }}] is a number, setting without quotes..."
+                  set_ini_value "{{ $k }}" {{ $v }}
+                {{- else if (mustRegexMatch $boolRegex ($v | lower)) }}
+                  echo "Key [{{ $k }}] is a boolean, setting without quotes..."
+                  set_ini_value "{{ $k }}" {{ (toString $v) | camelcase }}
                 {{- else }}
-                  echo "Key {{ $item.key }} is a {{ kindOf $item.value }}, setting with quotes..."
-                  set_ini_value "{{ $item.key }}" {{ $item.value | quote }} true
+                  echo "Key [{{ $k }}] is a string, setting with quotes..."
+                  set_ini_value "{{ $k }}" {{ $v | quote }} true
                 {{- end }}
               {{- end }}