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

Enable list option modification when create list watch #57508

Conversation

chechiachang
Copy link
Contributor

What this PR does / why we need it:
metav1.ListOptions support both field selector and label selector, but the current NewListWatchFromClient in client-go only support field selector.
It would be helpful to use label selector in client-go.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Release note:

None

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 21, 2017
@chechiachang
Copy link
Contributor Author

/assign @ncdc
Any advice and suggestions will be greatly appreciated

@ncdc
Copy link
Member

ncdc commented Dec 22, 2017

Seems reasonable to me.
/lgtm

@deads2k @liggitt @sttts @kubernetes/sig-api-machinery-pr-reviews

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Dec 22, 2017
@ncdc
Copy link
Member

ncdc commented Dec 22, 2017

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Dec 22, 2017
@chechiachang
Copy link
Contributor Author

/joke

@k8s-ci-robot
Copy link
Contributor

@chechiachang: Why do bees hum? Because they don't know the words.

In response to this:

/joke

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kairen
Copy link
Contributor

kairen commented Dec 25, 2017

@chechiachang This is very helpful for me!!

@chechiachang
Copy link
Contributor Author

@kairen Glad to help:)

@chechiachang
Copy link
Contributor Author

@ncdc Could you take another look at this PR? Thanks.
Let me know if there is anything I can do.

}

// NewListWatchFromClientWithSelectors creates a new ListWatch from the specified client, resource, namespace, field selector, and label selector.
func NewListWatchFromClientWithSelectors(c Getter, resource string, namespace string, fieldSelector fields.Selector, labelSelector labels.Selector) *ListWatch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a decorator like WithSelectors(NewListWatchFromClient(...))? All these ListOptions modifications are orthogonal to the actual ListWatch construction. ListOptions have even more fields. We don't want to add yet another constructor after this one. Decorators are more natural.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds much better. Let me rewrite this function. @sttts thanks

@chechiachang chechiachang force-pushed the enable-label-selector-for-client-go-listwatch branch from c940778 to d171b3f Compare January 2, 2018 10:04
@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 2, 2018
@chechiachang chechiachang force-pushed the enable-label-selector-for-client-go-listwatch branch from d171b3f to 8d9d993 Compare January 3, 2018 06:10
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 3, 2018
@chechiachang chechiachang changed the title Enable label select when create list watch Enable list option modification when create list watch Jan 3, 2018
@chechiachang chechiachang force-pushed the enable-label-selector-for-client-go-listwatch branch from 8d9d993 to 4f45d0c Compare January 3, 2018 10:11
@chechiachang
Copy link
Contributor Author

@sttts Could you take another look at this PR? Any comment will be very appreciated.

@caesarxuchao caesarxuchao self-assigned this Jan 4, 2018
// NewListWatchFromClientWithSelectors creates a new ListWatch from the specified client, resource, namespace, and option modifier.
// Option modifier is a function takes a ListOptions and modifies the consumed ListOptions. Provide customized modifier function
// to apply modification to ListOptions with a field selector, a label selector, or any other desired options.
func NewListWatchFromClientWithModifier(c Getter, resource string, namespace string, optionsModifier func(options *metav1.ListOptions)) *ListWatch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be inline with the naming of filtered informers (NewFilteredSharedInformerFactory), let's call it NewFilteredListWatchFromClient.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise lgtm

@chechiachang chechiachang force-pushed the enable-label-selector-for-client-go-listwatch branch from 4f45d0c to 5fa2263 Compare January 5, 2018 10:01
@chechiachang chechiachang force-pushed the enable-label-selector-for-client-go-listwatch branch from 5fa2263 to 2780b8f Compare January 5, 2018 10:04
@spiffxp
Copy link
Member

spiffxp commented Jan 7, 2018

/lgtm

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

sttts commented Jan 8, 2018

/approve no-issue

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chechiachang, ncdc, spiffxp, sttts

Associated issue requirement bypassed by: sttts

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your 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 Jan 8, 2018
@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 8504591 into kubernetes:master Jan 8, 2018
@chechiachang chechiachang deleted the enable-label-selector-for-client-go-listwatch branch January 8, 2018 09:57
@caesarxuchao
Copy link
Member

lgtm. Thank you!

asymmetric pushed a commit to kinvolk-archives/habitat-operator that referenced this pull request Apr 24, 2018
The `NewFilteredListWatchFromClient` function introduced in client-go
v7.0.0 allows us to filter based on custom fields/labels, therefore we
don't need our custom implementation of this functionality.

The function was introduced
[here](kubernetes/kubernetes#57508)

Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
asymmetric pushed a commit to kinvolk-archives/habitat-operator that referenced this pull request Apr 24, 2018
The `NewFilteredListWatchFromClient` function introduced in client-go
v7.0.0 allows us to filter based on custom fields/labels, therefore we
don't need our custom implementation of this functionality.

The function was introduced
[here](kubernetes/kubernetes#57508)

Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
asymmetric pushed a commit to kinvolk-archives/habitat-operator that referenced this pull request Apr 24, 2018
The `NewFilteredListWatchFromClient` function introduced in client-go
v7.0.0 allows us to filter based on custom fields/labels, therefore we
don't need our custom implementation of this functionality.

The function was introduced
[here](kubernetes/kubernetes#57508)

Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
asymmetric pushed a commit to kinvolk-archives/habitat-operator that referenced this pull request Apr 24, 2018
The `NewFilteredListWatchFromClient` function introduced in client-go
v7.0.0 allows us to filter based on custom fields/labels, therefore we
don't need our custom implementation of this functionality.

The function was introduced
[here](kubernetes/kubernetes#57508)

Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
asymmetric pushed a commit to kinvolk-archives/habitat-operator that referenced this pull request Apr 24, 2018
The `NewFilteredListWatchFromClient` function introduced in client-go
v7.0.0 allows us to filter based on custom fields/labels, therefore we
don't need our custom implementation of this functionality.

The function was introduced
[here](kubernetes/kubernetes#57508)

Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
asymmetric pushed a commit to kinvolk-archives/habitat-operator that referenced this pull request Apr 25, 2018
The `NewFilteredListWatchFromClient` function introduced in client-go
v7.0.0 allows us to filter based on custom fields/labels, therefore we
don't need our custom implementation of this functionality.

The function was introduced
[here](kubernetes/kubernetes#57508)

Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
asymmetric pushed a commit to kinvolk-archives/habitat-operator that referenced this pull request Apr 25, 2018
The `NewFilteredListWatchFromClient` function introduced in client-go
v7.0.0 allows us to filter based on custom fields/labels, therefore we
don't need our custom implementation of this functionality.

The function was introduced
[here](kubernetes/kubernetes#57508)

Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
asymmetric pushed a commit to kinvolk-archives/habitat-operator that referenced this pull request May 2, 2018
The `NewFilteredListWatchFromClient` function introduced in client-go
v7.0.0 allows us to filter based on custom fields/labels, therefore we
don't need our custom implementation of this functionality.

The function was introduced
[here](kubernetes/kubernetes#57508)

Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
asymmetric pushed a commit to kinvolk-archives/habitat-operator that referenced this pull request May 2, 2018
The `NewFilteredListWatchFromClient` function introduced in client-go
v7.0.0 allows us to filter based on custom fields/labels, therefore we
don't need our custom implementation of this functionality.

The function was introduced
[here](kubernetes/kubernetes#57508)

Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
asymmetric pushed a commit to kinvolk-archives/habitat-operator that referenced this pull request May 7, 2018
The `NewFilteredListWatchFromClient` function introduced in client-go
v7.0.0 allows us to filter based on custom fields/labels, therefore we
don't need our custom implementation of this functionality.

The function was introduced
[here](kubernetes/kubernetes#57508)

Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
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. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants