Skip to content

Commit

Permalink
fix: convert float64s to integers (#127)
Browse files Browse the repository at this point in the history
If a large integer is specifed in values.yaml, it is parsed by Helm
as a float64. For example:

```
couchdbConfig:
  chttpd:
    timeout: 5184000
```

If this is converted to a string, it produces `5.184e+06` instead of
the expected `5184000`.

Given we never expect floats to be specified as configuration values
to CouchDB, we can workaround this erroneus type conversion by
casting the float64 back to an integer when rendering the ini file.

This then correctly outputs:

```
inifile: |
    [chttpd]
    timeout = 5184000
```

Note this will break any genuine uses of float64 types in the
configuration, though I can't think of any cases where this would be
valid.
  • Loading branch information
willholley authored Jul 14, 2023
1 parent 3b071e2 commit d340b1e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion couchdb/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: couchdb
version: 4.4.1
version: 4.4.2
appVersion: 3.3.2
description: A database featuring seamless multi-master sync, that scales from
big data to mobile, with an intuitive HTTP/JSON API and designed for
Expand Down
5 changes: 4 additions & 1 deletion couchdb/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ data:
{{- range $section, $settings := $couchdbConfig -}}
{{ printf "[%s]" $section }}
{{ range $key, $value := $settings -}}
{{ printf "%s = %s" $key ($value | toString) }}
{{- if kindIs "float64" $value }}
{{ $value = (int $value) }}
{{ end -}}
{{ printf "%s = %v" $key $value }}
{{ end }}
{{ end }}
Expand Down

0 comments on commit d340b1e

Please sign in to comment.