Skip to content
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

Merged
merged 1 commit into from
Dec 21, 2018

Conversation

shawn-hurley
Copy link

  • Allow the user to specify in the options how to create the client,
    cache, and how to construct the delegating client.

fixes #226

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 29, 2018
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 29, 2018
// Functions to all for a user to customize the values that will be injected.
NewCache NewCacheFunc
NewClient NewClientFunc
NewDelegatingClient NewDelegatingClientFunc
Copy link
Contributor

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.

Copy link
Author

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?

Copy link
Contributor

@DirectXMan12 DirectXMan12 Dec 4, 2018

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,
    }
}

Copy link
Author

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!

Copy link
Contributor

@DirectXMan12 DirectXMan12 left a 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
Copy link
Contributor

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
@shawn-hurley
Copy link
Author

@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?

@shawn-hurley
Copy link
Author

@DirectXMan12 LMK if there is anything else?

@DirectXMan12
Copy link
Contributor

@shawn-hurley sounds fine to me.

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 21, 2018
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 21, 2018
@DirectXMan12
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overriding Values in Manager
3 participants