mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
UniStore Big Objects: Fix spec rebuilding (#100183)
* Fix big object spec rebuilding and associated test --------- Co-authored-by: Jean-Philippe Quémémer <jeanphilippe.quemener@grafana.com>
This commit is contained in:
parent
d16f2315a4
commit
d62c490af5
@ -51,7 +51,16 @@ func NewDashboardLargeObjectSupport(scheme *runtime.Scheme) *apistore.BasicLarge
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal(blob, &dash.Spec)
|
||||
|
||||
if err := json.Unmarshal(blob, &dash.Spec); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal blob into spec: %w", err)
|
||||
}
|
||||
|
||||
if err := scheme.Convert(dash, obj, nil); err != nil {
|
||||
return fmt.Errorf("failed to update original object: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -59,11 +59,17 @@ func TestLargeDashboardSupport(t *testing.T) {
|
||||
}`, string(small))
|
||||
|
||||
// Now make it big again
|
||||
err = largeObject.RebuildSpec(dash, f)
|
||||
rehydratedDash := &dashboardv0alpha1.Dashboard{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: "test",
|
||||
Namespace: "test",
|
||||
},
|
||||
}
|
||||
err = largeObject.RebuildSpec(rehydratedDash, f)
|
||||
require.NoError(t, err)
|
||||
|
||||
// check that all panels exist again
|
||||
panels, found, err = unstructured.NestedSlice(dash.Spec.Object, "panels")
|
||||
panels, found, err = unstructured.NestedSlice(rehydratedDash.Spec.Object, "panels")
|
||||
require.NoError(t, err)
|
||||
require.True(t, found)
|
||||
require.Len(t, panels, expectedPanelCount)
|
||||
|
Loading…
Reference in New Issue
Block a user