@@ -21,20 +21,21 @@ import (
21
21
"fmt"
22
22
23
23
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
24
- ctrl "sigs.k8s.io/controller-runtime "
24
+ "github.com/open-feature/open-feature-operator/apis/core/v1alpha2/common "
25
25
"sigs.k8s.io/controller-runtime/pkg/conversion"
26
26
)
27
27
28
- func (ffc * FeatureFlagConfiguration ) SetupWebhookWithManager (mgr ctrl.Manager ) error {
29
- return ctrl .NewWebhookManagedBy (mgr ).
30
- For (ffc ).
31
- Complete ()
32
- }
33
-
34
28
func (src * FeatureFlagConfiguration ) ConvertTo (dstRaw conversion.Hub ) error {
35
- dst := dstRaw .(* v1alpha1.FeatureFlagConfiguration )
29
+ dst , ok := dstRaw .(* v1alpha1.FeatureFlagConfiguration )
30
+
31
+ if ! ok {
32
+ return fmt .Errorf ("type %T %w" , dstRaw , common .ErrCannotCastFeatureFlagConfiguration )
33
+ }
36
34
35
+ // Copy equal stuff to new object
36
+ // DO NOT COPY TypeMeta
37
37
dst .ObjectMeta = src .ObjectMeta
38
+
38
39
if src .Spec .ServiceProvider != nil {
39
40
dst .Spec .ServiceProvider = & v1alpha1.FeatureFlagServiceProvider {
40
41
Name : src .Spec .ServiceProvider .Name ,
@@ -67,9 +68,16 @@ func (src *FeatureFlagConfiguration) ConvertTo(dstRaw conversion.Hub) error {
67
68
}
68
69
69
70
func (dst * FeatureFlagConfiguration ) ConvertFrom (srcRaw conversion.Hub ) error {
70
- src := srcRaw .(* v1alpha1.FeatureFlagConfiguration )
71
+ src , ok := srcRaw .(* v1alpha1.FeatureFlagConfiguration )
72
+
73
+ if ! ok {
74
+ return fmt .Errorf ("type %T %w" , srcRaw , common .ErrCannotCastFeatureFlagConfiguration )
75
+ }
71
76
77
+ // Copy equal stuff to new object
78
+ // DO NOT COPY TypeMeta
72
79
dst .ObjectMeta = src .ObjectMeta
80
+
73
81
if src .Spec .ServiceProvider != nil {
74
82
dst .Spec .ServiceProvider = & FeatureFlagServiceProvider {
75
83
Name : src .Spec .ServiceProvider .Name ,
0 commit comments