controller-runtime icon indicating copy to clipboard operation
controller-runtime copied to clipboard

Feature: Allow ManagerOptions to be marshalled

Open ryanmcnamara opened this issue 1 year ago • 0 comments

It would be very nice if the ManagerOptions https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/manager/manager.go#L101 was more easily printable. Example use case: logging on startup to be sure of what config is used.

Using fmt.Sprintf("%#v", options) has been my workaround but it's pretty suboptimal (pointers not followed for example)

Currently using json.Marshal gives an error like

json: unsupported type: func(*rest.Config, *http.Client) (meta.RESTMapper, error)

Failing to marshal this field named MapperProvider

I'd be willing to PR this, what I would do is add the struct tag json:"-" on fields that should not be printed / logged (e.g. MapperProvider) and then use the standard json.Marshal to get my human readable string.

Wanted to gauge interest before making a PR

ryanmcnamara avatar Aug 13 '24 20:08 ryanmcnamara