Skip to content

Commit 5241902

Browse files
Merge pull request #117 from bradmwilliams/api-group-versions-fix
Adding support for V4 style APIGroups
2 parents f7a8a92 + 6786796 commit 5241902

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

ansible/rebuild_module.digest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c63964b8473c9baa3b224e2de1b50b28 -
1+
151eb1208a9e21d260757c0218150029 -

ansible/roles/openshift_client_python/library/openshift_client_python.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openshift/base_verbs.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,3 +1610,37 @@ def node_ssh_client_exec(apiobj_node_name_or_qname=None,
16101610
return_code = ssh_stdout.channel.recv_exit_status()
16111611

16121612
return return_code, stdout, stderr
1613+
1614+
1615+
"""
1616+
There is a small number of APIs that appear in an API Group that is specified as only
1617+
an unclassified version, like "v1". This is something specific to OpenShift V4, but
1618+
to be consistent, Im adding logic that handles this across versions.
1619+
"""
1620+
SUPPORTED_SINGULAR_API_GROUP_SUFFIXES = ["v1"]
1621+
1622+
1623+
def _is_singular_api_group(group):
1624+
for suffix in SUPPORTED_SINGULAR_API_GROUP_SUFFIXES:
1625+
if group.endswith('.{}'.format(suffix)):
1626+
return True
1627+
return False
1628+
1629+
1630+
def get_gettable_kinds():
1631+
"""
1632+
Returns a list of the 'gettable' (i.e. oc get <kind> will work) kinds known to openshift-client-python.
1633+
You can run `oc.update_api_resources` first if this needs to be exact for a cluster.
1634+
:return: list<string> where each entry is a valid kind
1635+
"""
1636+
kinds = []
1637+
for kind in naming.get_api_resources_kinds():
1638+
if '/' in kind:
1639+
kinds.append(kind.split('/')[0])
1640+
else:
1641+
if _is_singular_api_group(kind):
1642+
kinds.append(kind.split('.')[0])
1643+
else:
1644+
kinds.append(kind)
1645+
1646+
return kinds

packages/openshift/naming.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ def _process_api_value(value, handle_apiversion):
3737
if '/' in value:
3838
group = value.split('/')[0]
3939
return group
40-
else:
41-
return None
4240
return value
4341
return None
4442

@@ -67,7 +65,9 @@ def get_api_resources_kinds():
6765
ungettable = set()
6866
ungettable.update("""
6967
rangeallocations.security.openshift.io
68+
rangeallocations.security.openshift.io/v1
7069
useridentitymappings.user.openshift.io
70+
useridentitymappings.user.openshift.io/v1
7171
""".strip().split())
7272

7373
return kinds.difference(ungettable)

0 commit comments

Comments
 (0)