-
Notifications
You must be signed in to change notification settings - Fork 40.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
adds dynamic lister #68748
adds dynamic lister #68748
Conversation
/assign @deads2k |
} | ||
if !exists { | ||
// TODO (p0lyn0mial): figure out how to construct proper Resource for the given object | ||
return nil, errors.NewNotFound(schema.GroupResource{Resource: "unstructured"}, name) |
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.
not sure how we could make it more informative.
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.
not sure how we could make it more informative.
Ah, I read top to bottom. Just got here. See my comment above.
/cc @jpbetz |
// Lister helps list resources. | ||
type Lister interface { | ||
// List lists all resources in the indexer. | ||
List(selector labels.Selector) (ret []*unstructured.Unstructured, err error) |
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.
not sure if we want to provide a way to list all items or only the ones from a namespace.
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.
not sure if we want to provide a way to list all items or only the ones from a namespace.
I think we have to provide both in this lister since we don't know which is applicable. We probably need a top level Get too.
} | ||
|
||
// NewDynamicLister returns a new Lister. | ||
func NewDynamicLister(indexer cache.Indexer) Lister { |
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 we require a GVR be provided here? It is implicit for all other listers, but this one doesn't natively know which resource it is dealing with. You'll need it for errors.
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.
sure
"k8s.io/client-go/tools/cache" | ||
) | ||
|
||
func TestNamespaceGetMethod(t *testing.T) { |
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'd like to a second test for a top level get method too. I'm particularly interested in being sure that it does the right thing (not found) when used on namespaced resources.
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.
np
This looks like a solid start. A few comments. @p0lyn0mial Once they are fixed, any particular reason to avoid merging it? |
], | ||
) | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = [ | ||
"interface.go", | ||
"lister.go", |
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 you place these in a subpackage? client-go/dynamic/dynamiclister
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.
how about client-go/dynamic/lister
?
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.
how about
client-go/dynamic/lister
?
dynamiclister will autocomplete in IDEs without conflict. Think http/httptest
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.
oh, nice! Since there is more than one lister
in the system it makes sense.
sgtm, originally I wanted to add the informer too but I can prepare a separate pull for it. |
return nil, err | ||
} | ||
if !exists { | ||
return nil, errors.NewNotFound(schema.GroupResource{Group: l.gvr.Group, Resource: l.gvr.Resource}, name) |
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.
nit: l.gvr.GroupResource()
return nil, err | ||
} | ||
if !exists { | ||
return nil, errors.NewNotFound(schema.GroupResource{Group: l.gvr.Group, Resource: l.gvr.Resource}, name) |
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.
as above
Looks like you need to regenerate bazel. Then squash down. /lgtm holding so the bot doesn't endlessly retest on bad bazel. Remove the hold after you update bazel. |
8665d5b
to
fe805d6
Compare
fe805d6
to
01be525
Compare
/hold cancel |
/lgtm |
01be525
to
8b43a00
Compare
|
/test pull-kubernetes-e2e-kops-aws |
@deads2k please retag the pull. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, p0lyn0mial 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 |
/kind feature |
/retest |
What this PR does / why we need it: creates a dynamic lister that returns
runtime.Unstructured
objects.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: