-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] fix panic when fetching dashbaords
Signed-off-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
- Loading branch information
Showing
1 changed file
with
11 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |