-
Notifications
You must be signed in to change notification settings - Fork 145
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
Reimplement list kinds to be more generic #240
Conversation
126962a
to
88b8b0a
Compare
@willthames or @asetty any reservations about this one going in? |
@@ -916,7 +987,7 @@ def main(): | |||
item = {} | |||
item[key] = {k: v for k, v in resource.__dict__.items() if k not in ('client', 'subresources', 'resource')} | |||
if isinstance(resource, ResourceList): | |||
item[key]["resource"] = '{}.{}'.format(resource.resource.group_version, resource.resource.kind) | |||
item[key]["resource"] = '{}.{}'.format(resource.group_version, resource.kind) |
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.
Should this be resource.base_kind
instead of resource.kind
?
Maybe you don't need this at all because base_kind is already an attribute of the resource.
openshift/dynamic/client.py
Outdated
@@ -738,7 +809,7 @@ def __iter__(self): | |||
prefix, group, version, rg.preferred) | |||
self._cache['resources'][prefix][group][version] = rg | |||
self.__update_cache = True | |||
for resource in rg.resources: | |||
for _, resource in rg.resources.items(): |
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.
Good catch. Maybe use iteritems
instead so you get an iterator rather than create a list.
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 think this is a good change so ResourceLists can be treated more like an actual Resource.
Looks good to me overall, commented on a couple things I noticed.
* Reimplement list kinds to generically support typed and untyped lists * Fix various issues from rebase * Use iteritems from six
* Reimplement list kinds to generically support typed and untyped lists * Fix various issues from rebase * Use iteritems from six
This implementation will support both typed and untyped List kinds, and we now automatically add the fake
v1.List
resource during discovery.Should fix one of the issues brought up in redhat-cop/openshift-applier#39, also recorded in ansible/ansible#49100, and will close #209