-
Notifications
You must be signed in to change notification settings - Fork 96
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
Implement GetExternalTags #123
Conversation
I thought I opened the PR but seems like forgot to click the button :( @negz @hasheddan I was thinking about adding the following labels, too, to make it possible do more detailed resource filterin in cloud provider:
What do you guys think? |
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.
This looks pretty good so far! For the other two proposed tags:
- Class tag: I am not sure how much longer are current class structure will be relevant so might hold off on that one.
- Provider tag: Assuming this would be the name of the literal provider object? If so I think that could be useful!
Well, be it
Yes, it's literal object name. |
That sounds fine. Another thing that makes class different is that statically provisioned managed resources do not have a class ref while the other 3 tags are values that are always present. |
Yeah, I imagine we'd just skip class label in that case. I'll circle back to API patterns doc and add these if everyone is onboard. @negz what do you think? |
5de48bc
to
723e831
Compare
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 @muvaf!
pkg/resource/resource.go
Outdated
// resource in provider API. | ||
func GetExternalTags(mg Managed) map[string]string { | ||
tags := map[string]string{ | ||
ExternalResourceKindTagKey: mg.GetObjectKind().GroupVersionKind().GroupKind().String(), |
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 rely on this field always being set? I recall it was being automatically cleared by some clients, apparently intentionally, which is why most of our crossplane-runtime functions that need a GVK require we pass either a GVK or a scheme to determine one. kubernetes-sigs/controller-runtime#528 indicates that the old behaviour I described may now be gone.
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 will test it and write here. I simply relied on the fact that all those functions returned non-pointer objects.
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.
Verified that it does return GVK correctly.
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.
Nice! This might allow us to simplify some of our functions in pkg/meta
(and possibly pkg/resource
?) that assume they can't rely on GetObjectKind
to actually return the kind of an object.
@hasheddan @negz Heads-up, I'm replacing |
Alright, |
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.
@muvaf those sound good to me!
Looks like this needs to be rebased - I'll merge once the branches align. |
…rce controllers to tag their external resources Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
@negz ready to go! I added a small change to make |
Description of your changes
Implement GetExternalTags to return Crossplane tags for managed resource controllers to tag their external resources.
Makes it easier to implement https://github.com/crossplane/crossplane/blob/master/design/one-pager-managed-resource-api-design.md#external-resource-labeling
Checklist
I have:
make reviewable
to ensure this PR is ready for review.clusterrole.yaml
to include any new types.