openshift/openshift-restclient-python

Documentation should mention use of singular_name if resource search/get.

GrahamDumpleton opened this issue · 6 comments

The docs use the example:

dyn_client.resources.get(api_version='v1', kind='ServiceList')

for looking up the resource object.

Problem is that there can be multiple names that map to the same type, which can result in a failure when one would not expect it.

>>> dyn_client.resources.get(api_version='template.openshift.io/v1', kind="Template")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/graham/Python/openshift/lib/python3.6/site-packages/openshift/dynamic/client.py", line 643, in get
    raise ResourceNotUniqueError('Multiple matches found for {}: {}'.format(kwargs, results))
openshift.dynamic.exceptions.ResourceNotUniqueError: Multiple matches found for {'api_version': 'template.openshift.io/v1', 'kind': 'Template'}: [<Resource(template.openshift.io/v1/processedtemplates)>, <Resource(template.openshift.io/v1/templates)>]

More prominence should be given in the documentation to using singular_name instead of kind when doing the look up.

>>> dyn_client.resources.get(api_version='template.openshift.io/v1', singular_name="template")
<Resource(template.openshift.io/v1/templates)>

Should also be highlighted though that singular name should be lower case though.

If singular name is also not guaranteed to be unique, the example should use both kind and singular_name.

>>> dyn_client.resources.get(api_version='template.openshift.io/v1', kind='Template', singular_name="template")
<Resource(template.openshift.io/v1/templates)>

Yes, resources from different kinds can have same name.

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

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.