Add a regression case exercising float64(0), float64(-7), and the
negative fractional float64(-3.25) so the normalization is exercised
across the full int64 range (not just positive values) and so negative
fractional floats are shown to still round-trip as TOML floats.
Requested by @TerryHowe on #32040.
Signed-off-by: barry3406 <duan3406@gmail.com>
Helm values round-trip through JSON, so every YAML number enters the
template engine as a float64 regardless of whether the source was written
as "9" or "9.0". The BurntSushi TOML encoder inspects the Go type via
reflection and writes float64(9) as "9.0", which surprises users whose
values look like integers. encoding/json already omits the trailing ".0"
for whole-number float64 values, so toJson does not exhibit the same
issue; this change brings toToml in line with toJson.
The fix normalizes whole-number float64 values to int64 inside toToml
only, leaving NaN, Inf, non-whole floats, and out-of-range values
untouched. Scoping the change to the encoding path preserves the
in-template type of values returned by typeOf/typeIs, avoiding the
ecosystem regression that caused #13533 to be reverted in #30884.
Closes#32035
Signed-off-by: barry3406 <duan3406@gmail.com>
The toTOML doc comment said "returns empty string on marshal error"
but the implementation actually returns err.Error(). Fix the comment
to match the real behavior. Also mention mustToToml as the strict
alternative.
Signed-off-by: Ilya Kiselev <kis-ilya-a@yandex.ru>
Add `mustToToml` that panics on marshal error, consistent with
`mustToYaml` and `mustToJson`. This makes it possible for chart authors
to get a hard failure when TOML serialization fails, rather than having
to inspect the output manually.
`toToml` behavior is unchanged in this commit.
Closes#31430
Signed-off-by: Ilya Kiselev <kis-ilya-a@yandex.ru>
The rangeint suggestion is faster.
The maps.Copy and slices.Contains are just syntatic sugar.
Signed-off-by: Mads Jensen <atombrella@users.noreply.github.com>
Building the same chart into an archive multiple times will have
the same sha256 hash.
Perviously, the time in the headers for a file was time.Now() which
changed each time. The time is now collected from the operating
system when the file is loaded and this time is used.
Fixes: #3612
Signed-off-by: Matt Farina <matt.farina@suse.com>
Linting is specific to the chart versions. A v2 and v3 chart will
lint differently.
To accomplish this, packages like engine need to be able to handle
different chart versions. This was accomplished by some changes:
1. The introduction of a Charter interface for charts
2. The ChartAccessor which is able to accept a chart and then
provide access to its data via an interface. There is an
interface, factory, and implementation for each version of
chart.
3. Common packages were moved to a common and util packages.
Due to some package loops, there are 2 packages which may
get some consolidation in the future.
The new interfaces provide the foundation to move the actions
and cmd packages to be able to handle multiple apiVersions of
charts.
Signed-off-by: Matt Farina <matt.farina@suse.com>