diff --git a/pkg/registry/apis/dashboard/large.go b/pkg/registry/apis/dashboard/large.go index 9530b247d2f..e54b4d252cb 100644 --- a/pkg/registry/apis/dashboard/large.go +++ b/pkg/registry/apis/dashboard/large.go @@ -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 }, } } diff --git a/pkg/registry/apis/dashboard/large_test.go b/pkg/registry/apis/dashboard/large_test.go index 45510304a65..c5d65fa8f5f 100644 --- a/pkg/registry/apis/dashboard/large_test.go +++ b/pkg/registry/apis/dashboard/large_test.go @@ -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)