How to add `// +kubebuilder:default=` marker for the nested feilds in the api

4/30/2021

I want to create a default value for the custom resource definition in an automated way using markers for the nested field. As I am using struct type from the opensource library I can not directly create a marker there. So I do have to use nested marker only. I want to use a marker in such a way that it will create a default value for the one field only for that type not for the whole type. As of now, it is defaulting the whole type.

// +kubebuilder:default={{apiGroup: "abc"}}
DataSource corev1.TypedLocalObjectReference `json:"dataSource"`
-- Nitin Goyal
controller
go
kubernetes
operator-sdk

0 Answers