Skip to content

Commit 3466bcc

Browse files
authored
Merge pull request #143 from fabianvf/fix-intorstr-object
Add object to primitives, treat as string for now
2 parents 7ad3c28 + e2b2fb2 commit 3466bcc

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

openshift/ansiblegen/docstrings.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def add_option(pname, pdict, descr=None):
141141
for path in param_dict['property_path']:
142142
path = PYTHON_KEYWORD_MAPPING.get(path, path)
143143
kind = model_class.swagger_types[path]
144-
if kind in ('str', 'bool', 'int', 'IntstrIntOrString', 'datetime', 'object', 'float') or \
144+
if kind in ('str', 'bool', 'int', 'datetime', 'object', 'float') or \
145145
kind.startswith('dict(') or \
146146
kind.startswith('list['):
147147
docs = inspect.getdoc(getattr(model_class, path))
@@ -260,6 +260,11 @@ def __get_attributes(self, model_class, doc_key=None):
260260
doc_key[attribute]['description'] = string_list
261261
doc_key[attribute]['type'] = 'complex'
262262
doc_key[attribute]['contains'] = CommentedMap()
263+
elif kind == 'object':
264+
doc_key[attribute] = CommentedMap()
265+
doc_key[attribute]['description'] = string_list
266+
doc_key[attribute]['type'] = 'complex'
267+
doc_key[attribute]['contains'] = CommentedMap()
263268
else:
264269
doc_key[attribute] = CommentedMap()
265270
doc_key[attribute]['description'] = string_list

openshift/helper/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
import re
55

6-
PRIMITIVES = ('str', 'int', 'bool', 'float', 'IntstrIntOrString')
6+
PRIMITIVES = ('str', 'int', 'bool', 'float', 'object')
77
VERSION_RX = re.compile(".*V\d((alpha|beta)\d)?")

openshift/helper/ansible.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def __compare_obj_list(self, src_value, request_value, obj_class, param_name):
517517
obj_type = item_kind.replace('list[', '').replace(']', '')
518518
if getattr(obj, snake_key) is None:
519519
setattr(obj, snake_key, [])
520-
if obj_type not in ('str', 'int', 'bool'):
520+
if obj_type not in ('str', 'int', 'bool', 'object'):
521521
self.__compare_obj_list(getattr(obj, snake_key), value, obj_type, param_name)
522522
else:
523523
# Straight list comparison
@@ -608,7 +608,7 @@ def __transform_properties(self, properties, prefix='', path=None, alternate_pre
608608
:return: dict
609609
"""
610610
parent_property_classes = parent_property_classes or set()
611-
primitive_types = list(PRIMITIVES) + ['list', 'dict', 'object']
611+
primitive_types = list(PRIMITIVES) + ['list', 'dict']
612612
args = {}
613613

614614
if path is None:
@@ -710,7 +710,7 @@ def add_meta(prop_name, prop_prefix, prop_alt_prefix):
710710
paths.append(prop)
711711

712712
property_type = prop_attributes['class'].__name__
713-
if property_type == 'IntstrIntOrString':
713+
if property_type == 'object':
714714
property_type = 'str'
715715

716716
args[arg_prefix + prop] = {

openshift/helper/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ def fix_serialization(self, obj):
167167
port.target_port = int(port.target_port)
168168
except ValueError:
169169
pass
170+
elif obj and obj.kind == "Route" and obj.spec.port:
171+
try:
172+
obj.spec.port.target_port = int(obj.spec.port.target_port)
173+
except ValueError:
174+
pass
170175
return obj
171176

172177
def get_object(self, name=None, namespace=None):

0 commit comments

Comments
 (0)