Closed pauloborges closed 7 months ago
Hey!
Thanks for reporting this. It should be fixed by https://github.com/grafana/cog/pull/242 :)
Awesome, thanks!
Forgot to ask in my previous message, but I think you can trigger a new code generation and update the branches?
Definitely, I plan on doing it today :)
Hello! First of all, thanks for the SDK!
I'm trying to add mappings to a stat panel using
Mappings()
[1]. This function accepts a slice ofdashboard.ValueMapping
type.This type wraps an internal struct called
ValueMapOrRangeMapOrRegexMapOrSpecialValueMap
. The internal struct correctly marshals itself by unnesting the internal mapping [3], but only if the receiver is a pointer!But this doesn't happen with
dashboard.ValueMapping
. When this type is marshaled, we get a nested object, for example:Due to that, Grafana ignores these mappings.
[1] https://github.com/grafana/grafana-foundation-sdk/blob/v10.2.x%2Bcog-v0.0.x/go/stat/panel_builder_gen.go#L294-L301 [2] https://github.com/grafana/grafana-foundation-sdk/blob/v10.2.x%2Bcog-v0.0.x/go/dashboard/types_gen.go#L385 [3] https://github.com/grafana/grafana-foundation-sdk/blob/v10.2.x%2Bcog-v0.0.x/go/dashboard/types_json_marshalling_gen.go#L372-L387
Here are a few tests that illustrate the issue, notice that the marshaling behavior also changes depending if we give a pointer to it or not: