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

adds dynamic lister #68748

Merged
merged 1 commit into from Sep 26, 2018
Merged

Conversation

p0lyn0mial
Copy link
Contributor

@p0lyn0mial p0lyn0mial commented Sep 17, 2018

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:

creates a dynamic lister that returns `runtime.Unstructured` objects. The new lister is under `client-go/dynamic/dynamiclister`.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Sep 17, 2018
@p0lyn0mial
Copy link
Contributor Author

/assign @deads2k

@p0lyn0mial
Copy link
Contributor Author

@deads2k this pull brings a dynamic lister that returns runtime.Unstructured objects. I hope this is something you have been asking for.

@deads2k I'm working on creating a dynamic informer that will use the dynamic lister.

}
if !exists {
// TODO (p0lyn0mial): figure out how to construct proper Resource for the given object
return nil, errors.NewNotFound(schema.GroupResource{Resource: "unstructured"}, name)
Copy link
Contributor Author

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.

Copy link
Contributor

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.

@wenjiaswe
Copy link
Contributor

/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)
Copy link
Contributor Author

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.

Copy link
Contributor

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

np

@deads2k
Copy link
Contributor

deads2k commented Sep 19, 2018

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",
Copy link
Contributor

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

Copy link
Contributor Author

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 ?

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 client-go/dynamic/lister ?

dynamiclister will autocomplete in IDEs without conflict. Think http/httptest

Copy link
Contributor Author

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.

@p0lyn0mial
Copy link
Contributor Author

@p0lyn0mial Once they are fixed, any particular reason to avoid merging it?

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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

as above

@deads2k
Copy link
Contributor

deads2k commented Sep 20, 2018

Looks like you need to regenerate bazel. Then squash down.

/lgtm
/hold

holding so the bot doesn't endlessly retest on bad bazel. Remove the hold after you update bazel.

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 20, 2018
@p0lyn0mial p0lyn0mial changed the title [WIP] adds dynamic lister adds dynamic lister Sep 20, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 20, 2018
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Sep 20, 2018
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 20, 2018
@p0lyn0mial
Copy link
Contributor Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 20, 2018
@deads2k
Copy link
Contributor

deads2k commented Sep 20, 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 Sep 20, 2018
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 20, 2018
@p0lyn0mial
Copy link
Contributor Author

New changes are detected. LGTM label has been removed.

go fmt update

@p0lyn0mial
Copy link
Contributor Author

/test pull-kubernetes-e2e-kops-aws
/test pull-kubernetes-e2e-gce-device-plugin-gpu

@p0lyn0mial
Copy link
Contributor Author

@deads2k please retag the pull.

@deads2k
Copy link
Contributor

deads2k commented Sep 26, 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 Sep 26, 2018
@k8s-ci-robot
Copy link
Contributor

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

@p0lyn0mial
Copy link
Contributor Author

/kind feature

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Sep 26, 2018
@p0lyn0mial
Copy link
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit 23baf57 into kubernetes:master Sep 26, 2018
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants