-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>
- Loading branch information
Showing
6 changed files
with
44 additions
and
27 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,25 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"github.com/barkimedes/go-deepcopy" | ||
"fmt" | ||
|
||
"github.com/brunoga/deep" | ||
"github.com/perses/perses/pkg/model/api/config" | ||
) | ||
|
||
type PersesConfig struct { | ||
config.Config `json:",inline"` | ||
} | ||
|
||
func (in *PersesConfig) DeepCopyInto(out *PersesConfig) { | ||
temp, err := deepcopy.Anything(in) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
*out = *(temp.(*PersesConfig)) | ||
func (in *PersesConfig) DeepCopyInto(out *PersesConfig) { | ||
if in == nil { | ||
return | ||
} | ||
|
||
copied, err := deep.Copy(in) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to deep copy PersesConfig: %w", err)) | ||
} | ||
*out = *copied | ||
} |
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,23 +1,28 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/brunoga/deep" | ||
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) { | ||
*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 | ||
if in == nil { | ||
return | ||
} | ||
|
||
copied, err := deep.Copy(in) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to deep copy Dashboard: %w", err)) | ||
} | ||
*out = *copied | ||
} | ||
|
||
|
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
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
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
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