Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ansible/rebuild_module.digest
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c63964b8473c9baa3b224e2de1b50b28 -
151eb1208a9e21d260757c0218150029 -

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions packages/openshift/base_verbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1610,3 +1610,37 @@ def node_ssh_client_exec(apiobj_node_name_or_qname=None,
return_code = ssh_stdout.channel.recv_exit_status()

return return_code, stdout, stderr


"""
There is a small number of APIs that appear in an API Group that is specified as only
an unclassified version, like "v1". This is something specific to OpenShift V4, but
to be consistent, Im adding logic that handles this across versions.
"""
SUPPORTED_SINGULAR_API_GROUP_SUFFIXES = ["v1"]


def _is_singular_api_group(group):
for suffix in SUPPORTED_SINGULAR_API_GROUP_SUFFIXES:
if group.endswith('.{}'.format(suffix)):
return True
return False


def get_gettable_kinds():
"""
Returns a list of the 'gettable' (i.e. oc get <kind> will work) kinds known to openshift-client-python.
You can run `oc.update_api_resources` first if this needs to be exact for a cluster.
:return: list<string> where each entry is a valid kind
"""
kinds = []
for kind in naming.get_api_resources_kinds():
if '/' in kind:
kinds.append(kind.split('/')[0])
else:
if _is_singular_api_group(kind):
kinds.append(kind.split('.')[0])
else:
kinds.append(kind)

return kinds
4 changes: 2 additions & 2 deletions packages/openshift/naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def _process_api_value(value, handle_apiversion):
if '/' in value:
group = value.split('/')[0]
return group
else:
return None
return value
return None

Expand Down Expand Up @@ -67,7 +65,9 @@ def get_api_resources_kinds():
ungettable = set()
ungettable.update("""
rangeallocations.security.openshift.io
rangeallocations.security.openshift.io/v1
useridentitymappings.user.openshift.io
useridentitymappings.user.openshift.io/v1
""".strip().split())

return kinds.difference(ungettable)
Expand Down