Skip to content

Commit

Permalink
[BUGFIX] fix panic when fetching dashbaords
Browse files Browse the repository at this point in the history
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
  • Loading branch information
ibakshay committed Oct 30, 2024
1 parent 3499701 commit d3bfaa3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions api/v1alpha1/perses_dashboard.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package v1alpha1

import (
"github.com/barkimedes/go-deepcopy"
"encoding/json"

persesv1 "github.com/perses/perses/pkg/model/api/v1"
)

type Dashboard struct {
persesv1.DashboardSpec `json:",inline"`
}

// DeepCopyInto is a manually implemented deep copy function and this is required because:
// 1. The embedded persesv1.DashboardSpec from the Perses project doesn't implement DeepCopyInto
// 2. controller-gen can't automatically generate DeepCopy methods for types it doesn't own
func (in *Dashboard) DeepCopyInto(out *Dashboard) {
temp, err := deepcopy.Anything(in)

if err != nil {
panic(err)
}

*out = *(temp.(*Dashboard))
*out = *in
// Create a deep copy of the embedded DashboardSpec
outSpec := persesv1.DashboardSpec{}
bytes, _ := json.Marshal(in.DashboardSpec)
_ = json.Unmarshal(bytes, &outSpec)
out.DashboardSpec = outSpec
}

0 comments on commit d3bfaa3

Please sign in to comment.