-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
⚠️ Convert client.List to use functional options #294
Conversation
@grantr would be great if you can take a quick look. |
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.
lgtm modulo one minor detail
pkg/client/interfaces.go
Outdated
// cl.List(ctx, list, client.UseListOptions(lo.InNamespace(ns).MatchingLabels(labels))) | ||
func UseListOptions(newOpts *ListOptions) ListOptionFunc { | ||
return func(opts *ListOptions) { | ||
opts.LabelSelector = newOpts.LabelSelector |
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.
can this just be *opts = *newOpts
?
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.
Done.
Replaces: List(ctx, ListOptions, list) with: List(ctx, list, ...option) This matches the upcoming functional options signature of client.Delete. To use the previous builder options, use the UseListOptions functional option: lo := &client.ListOptions{} client.List(ctx, list, client.UseListOptions( lo.InNamespace(ns).MatchingLabels(labels) )) Ported kubernetes-sigs#106 PR
/lgtm |
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.
Thanks @droot! LGTM.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12, droot, grantr 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 |
Replaces:
List(ctx, ListOptions, list)
with:
List(ctx, list, ...Option)
This matches the functional options signature of
client.Delete
in #94.A few examples (I tried formatting these as a table but it wasn't wide enough):
Select all:
Filter by namespace:
Filter by namespace and labels:
To assemble a
ListOptions
with the builder methods or some other strategy, use theUseListOptions
functional option:Note: This PR was contributed by @grantr but we couldn't get it merged because of the breaking changes, but now we are ready for a major revision
0.2.0
, so I manually ported #106