I’ve a method which should get the different types , how it’s suggested to solve this instead duplicate functions that doing basically the same… (I want to avoid creating wrapper struct....)
type A1 struct {
Spec A1Spec `json:"spec,omitempty"`
Status A1Status `json:"status,omitempty"`
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
}
type B1 struct {
Spec B1Spec `json:"spec,omitempty"`
Status B1Status `json:"status,omitempty"`
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
}
func ExecuteA1(ctx context.Context, a1 A1, Client client.Client) error {
if a1.Spec.Type == "test" {….
}}
func ExecuteB1(ctx context.Context, b1 B1, Client client.Client) error {
if b1.Spec.Type == "test" {….
}
….}
Both functions are doing the same but get different type, I want to avoid creating two functions, how its suggested to solve this?