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

add methods to allow selection and exclusion of resources by gvk #581

Merged

Conversation

natasha41575
Copy link
Contributor

Related to kptdev/kpt#3016

Add methods to the function SDK to allow easily filtering by GVK, name, namespace, labels, annotations, and meta resources.

@natasha41575 natasha41575 changed the title add methods to allow selection and exclusion of resources by gvkn add methods to allow selection and exclusion of resources by gvk May 26, 2022
@natasha41575 natasha41575 force-pushed the SelectAndExclude branch 2 times, most recently from eec9c4f to b022f7a Compare May 26, 2022 23:34
Copy link
Contributor

@justinsb justinsb left a comment

Choose a reason for hiding this comment

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

This looks great - just drive-by naming / API design nits!

go/fn/object.go Outdated Show resolved Hide resolved
go/fn/object.go Outdated Show resolved Hide resolved
go/fn/object.go Outdated Show resolved Hide resolved
go/fn/object.go Outdated
}

// SelectByGvk will return the subset of objects that matches the provided GVK.
func (o KubeObjects) SelectByGvk(apiVersion, kind string) KubeObjects {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This isn't really selecting by GVK :-) I would expect SelectByGVK to take a schema.GroupVersionKind.

Copy link
Contributor Author

@natasha41575 natasha41575 May 31, 2022

Choose a reason for hiding this comment

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

While I agree with the nit, we already have a func (o *KubeObject) IsGVK(apiVersion, kind string) bool here, so I'm trying to keep things consistent. If we're going to change it so that GVK strictly refers to group, version, and kind (rather than apiVersion and kind), we should do that everywhere. WDYT @mengqiy @yuwenma ?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, +1 to take a schema.GroupVersionKind. That's also my original thought, but one thing we need to further discuss is that how we can not duplicate kustomize code and at the same time import as less code as possible. for GVK, I think introducing our own version is good especially to support the SQL style syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to use schema.GroupVersionKind instead of apiVersion

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the "schema.GroupVersionKind" refer to k8s.io/apimachinery/pkg/runtime/schema

go/fn/object.go Outdated Show resolved Hide resolved
@natasha41575 natasha41575 force-pushed the SelectAndExclude branch 2 times, most recently from 1759fa5 to f30773d Compare June 7, 2022 00:20
@natasha41575
Copy link
Contributor Author

@yuwenma I see that you've approved this PR but I've made some more changes that I think should be reviewed before merging, do you mind taking a look?

@natasha41575 natasha41575 requested a review from yuwenma June 7, 2022 00:55
@yuwenma
Copy link
Contributor

yuwenma commented Jun 7, 2022

@yuwenma I see that you've approved this PR but I've made some more changes that I think should be reviewed before merging, do you mind taking a look?

Thank you for the change and overall looks great. One last comment about the schema.GroupVersionKind. I'm totally okay to do that in a follow up PR as well :)

@natasha41575 natasha41575 merged commit 78748f0 into GoogleContainerTools:master Jun 8, 2022
@natasha41575 natasha41575 deleted the SelectAndExclude branch June 8, 2022 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants