Skip to content

Conversation

@machacekondra
Copy link
Member

@machacekondra machacekondra commented Mar 8, 2019

Previously when creating a resource list, kind was a dictionary meaning
that there could be only one resource for specific kind. But for example
Template kind can have two different resources:

$ oc api-resources | grep Template$
processedtemplates template.openshift.io true Template
templates.         template.openshift.io true Template

So The client previsously found just one resource for kind Template.
In order to work with both resources for that kind this patch introduces
the change that kind will be list by default.

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 8, 2019
@openshift-ci-robot
Copy link

Hi @machacekondra. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@pkliczewski
Copy link

@fabianvf please review

@machacekondra machacekondra force-pushed the resource_kind_list branch 3 times, most recently from 3339632 to a05828f Compare March 8, 2019 09:10
@willthames
Copy link
Contributor

This seems like a massively breaking change - every user of this library would need to change how it dealt with resources.

I'm really not in favour of such a huge change for one tiny use case. I'd rather return a list only when multiple resources are found and let the clients handle that weirdness.

@machacekondra
Copy link
Member Author

machacekondra commented Mar 11, 2019

It does exactly that. It did it even previously. You could construct search which returned multiple object and user got a list, or one object or exception in case of get method.

@willthames
Copy link
Contributor

Thanks @machacekondra, I misunderstood the scope of this change.

@willthames
Copy link
Contributor

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 11, 2019
@fabianvf
Copy link
Member

@machacekondra thanks a ton for the submission!

@willthames did you test this with the Ansible suite already?

@willthames
Copy link
Contributor

I haven't tested it yet - I thought I'd let the CI do the initial testing

elif isinstance(resourcePart, dict):
return self.__search(parts[1:], resourcePart)
else:
if isinstance(resourcePart, ResourceList):
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand what this if block is doing, why would you need to wrap this in a list value only when it's a ResourceList?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's because you add ResourceList to resources as non-list on line 645:

groups[DISCOVERY_PREFIX] = {'': {
            'v1': ResourceGroup(True, resources = {"List": ResourceList(self.client)})
        }}

Maybe it would be more reasonable to remove this condition, and change the 645 line to

groups[DISCOVERY_PREFIX] = {'': {
            'v1': ResourceGroup(True, resources = {"List": [ResourceList(self.client)]})
        }}

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see, that makes sense. I think it would be better to change 645 and have a consistent data structure

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Previously when creating a resource list, kind was a dictionary meaning
that there could be only one resource for specific kind. But for example
Template kind can have to different resources:

$ oc api-resources | grep Template$
processedtemplates template.openshift.io true Template
templates          template.openshift.io true Template

So The client previsously found just one resource for kind Template.
In order to work with both resources for that kind this patch introduces
the change that kind will be list by default.
@fabianvf fabianvf merged commit 7c0949e into openshift:master Mar 14, 2019
@machacekondra
Copy link
Member Author

@fabianvf Any chance this could go to 0.8.x?

mmazur added a commit to mmazur/openshift-restclient-python that referenced this pull request Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants