-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Allow user to define how create managed objects #227
Conversation
pkg/manager/manager.go
Outdated
// Functions to all for a user to customize the values that will be injected. | ||
NewCache NewCacheFunc | ||
NewClient NewClientFunc | ||
NewDelegatingClient NewDelegatingClientFunc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... we try to avoid exposing a difference between these two at this level. What's the usecase for separating them? It's probably better/clearer to just have NewClient
, which means NewDelegatingClient
, and not leak the fact that we have a difference to the user/require the user to have that distinction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use case is that I want to not use the DelegatingReader
for my client. I would like my client to use the cache for unstructured types.
Because there is no other way to override this client this is the only way that I can think of to update it. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but there's not really a use for NewClient
except as a step in constructing the delegating client (unless I've missed something/am misremembering something), so we can just elide that and have:
type Options struct {
...
NewClient func(...) client.Client
...
}
func defaultNewClient(...) client.Client {
directClient := newClient(...)
return &DelegatingClient{
Writer: directClient,
Reader: cacheClient,
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was still thinking about them as two things but I think you are completely correct, I will update now!
c71ff3f
to
cc79493
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing godoc, otherwise looks awesome
@@ -118,15 +118,27 @@ type Options struct { | |||
// for serving prometheus metrics | |||
MetricsBindAddress string | |||
|
|||
// Functions to all for a user to customize the values that will be injected. | |||
NewCache NewCacheFunc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs godoc
* Allow the user to specify in the options how to create the client, cache, and how to construct the delegating client. fixes kubernetes-sigs#226
cc79493
to
8fba660
Compare
@DirectXMan12 I will take as a follow up to update the kubebuilder book around the manager. It looks like there is no section on the options to the manager, WDYT about a new section that describes the fields and examples on how to use them? |
@DirectXMan12 LMK if there is anything else? |
@shawn-hurley sounds fine to me. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12, shawn-hurley The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
When we get our new general dep injection story solve, we may end up tweaking this slightly, but this seems to solve a real usecase right now, and isn't particularly onerous. @pwittrock FYI |
cache, and how to construct the delegating client.
fixes #226