diff --git a/api/v1beta1/params.go b/api/v1beta1/params.go index 25df872..065ab1a 100644 --- a/api/v1beta1/params.go +++ b/api/v1beta1/params.go @@ -5,38 +5,40 @@ import ( ) // Params represents untyped configuration. +// kubebuilder does not support interface{} member directly, so this struct is a workaround. // +kubebuilder:validation:Type=object type Params struct { // Data holds the parameter keys and values. Data map[string]interface{} `json:"-"` } -func (c *Params) ToMap() map[string]interface{} { - if c == nil { +// ToMap converts the Params to map[string]interface{}. If the receiver is nil, it returns nil. +func (p *Params) ToMap() map[string]interface{} { + if p == nil { return nil } - return c.Data + return p.Data } // MarshalJSON implements the Marshaler interface. -func (c *Params) MarshalJSON() ([]byte, error) { - return json.Marshal(c.Data) +func (p *Params) MarshalJSON() ([]byte, error) { + return json.Marshal(p.Data) } // UnmarshalJSON implements the Unmarshaler interface. -func (c *Params) UnmarshalJSON(data []byte) error { +func (p *Params) UnmarshalJSON(data []byte) error { var out map[string]interface{} err := json.Unmarshal(data, &out) if err != nil { return err } - c.Data = out + p.Data = out return nil } -// DeepCopyInto is a deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (c *Params) DeepCopyInto(out *Params) { - bytes, err := json.Marshal(c.Data) +// DeepCopyInto is a deep copy function, copying the receiver, writing into `out`. `p` must be non-nil. +func (p *Params) DeepCopyInto(out *Params) { + bytes, err := json.Marshal(p.Data) if err != nil { panic(err) }