Skip to content

Commit

Permalink
Upgrade to openshift client 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Houseknecht committed Feb 12, 2018
1 parent a0bb193 commit c819007
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 15 deletions.
18 changes: 9 additions & 9 deletions lib/ansible/module_utils/k8s/helper.py
Expand Up @@ -381,7 +381,7 @@ def __compare_obj_list(self, src_value, request_value, obj_class, param_name):
if not request_value:
return

sample_obj = self.model_class_from_name(obj_class)()
model_class = self.model_class_from_name(obj_class)

# Try to determine the unique key for the array
key_names = [
Expand All @@ -390,7 +390,7 @@ def __compare_obj_list(self, src_value, request_value, obj_class, param_name):
]
key_name = None
for key in key_names:
if hasattr(sample_obj, key):
if hasattr(model_class, key):
key_name = key
break

Expand Down Expand Up @@ -421,14 +421,14 @@ def __compare_obj_list(self, src_value, request_value, obj_class, param_name):
found = True
for key, value in iteritems(item):
snake_key = self.attribute_to_snake(key)
item_kind = sample_obj.swagger_types.get(snake_key)
item_kind = model_class.swagger_types.get(snake_key)
if item_kind and item_kind in PRIMITIVES or type(value).__name__ in PRIMITIVES:
setattr(obj, snake_key, value)
elif item_kind and item_kind.startswith('list['):
obj_type = item_kind.replace('list[', '').replace(']', '')
if getattr(obj, snake_key) is None:
setattr(obj, snake_key, [])
if obj_type not in ('str', 'int', 'bool'):
if obj_type not in ('str', 'int', 'bool', 'object'):
self.__compare_obj_list(getattr(obj, snake_key), value, obj_type, param_name)
else:
# Straight list comparison
Expand Down Expand Up @@ -462,7 +462,7 @@ def __compare_obj_list(self, src_value, request_value, obj_class, param_name):
)
if not found:
# Requested item not found. Adding.
obj = self.__update_object_properties(self.model_class_from_name(obj_class)(), item)
obj = self.model_class_from_name(obj_class)(**item)
src_value.append(obj)
else:
# There isn't a key, or we don't know what it is, so check for all properties to match
Expand All @@ -480,7 +480,7 @@ def __compare_obj_list(self, src_value, request_value, obj_class, param_name):
found = True
break
if not found:
obj = self.__update_object_properties(self.model_class_from_name(obj_class)(), item)
obj = self.model_class_from_name(obj_class)(**item)
src_value.append(obj)

def __update_object_properties(self, obj, item):
Expand Down Expand Up @@ -512,7 +512,7 @@ def __transform_properties(self, properties, prefix='', path=None, alternate_pre
"""
Convert a list of properties to an argument_spec dictionary
:param properties: List of properties from self.properties_from_model_obj()
:param properties: List of properties from self.properties_from_model_class()
:param prefix: String to prefix to argument names.
:param path: List of property names providing the recursive path through the model to the property
:param alternate_prefix: a more minimal version of prefix
Expand Down Expand Up @@ -598,7 +598,7 @@ def add_meta(prop_name, prop_prefix, prop_alt_prefix):
}
args.update(self.__transform_properties(sub_props, prefix=p, path=paths, alternate_prefix=a))
else:
sub_props = self.properties_from_model_obj(prop_attributes['class']())
sub_props = self.properties_from_model_class(prop_attributes['class'])
args.update(self.__transform_properties(sub_props, prefix=p, path=paths, alternate_prefix=a))
else:
# Adds a primitive property
Expand All @@ -608,7 +608,7 @@ def add_meta(prop_name, prop_prefix, prop_alt_prefix):
paths.append(prop)

property_type = prop_attributes['class'].__name__
if property_type == 'IntstrIntOrString':
if property_type == 'object':
property_type = 'str'

args[arg_prefix + prop] = {
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/modules/clustering/k8s/k8s_raw.py
Expand Up @@ -39,7 +39,7 @@
requirements:
- "python >= 2.7"
- "openshift >= 0.3"
- "openshift == 0.4.1"
- "PyYAML >= 3.11"
'''

Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/modules/clustering/k8s/k8s_scale.py
Expand Up @@ -35,7 +35,7 @@
requirements:
- "python >= 2.7"
- "openshift >= 0.3"
- "openshift == 0.4.1"
- "PyYAML >= 3.11"
'''

Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/modules/clustering/openshift/openshift_raw.py
Expand Up @@ -49,7 +49,7 @@
requirements:
- "python >= 2.7"
- "openshift >= 0.3"
- "openshift == 0.4.1"
- "PyYAML >= 3.11"
'''

Expand Down
Expand Up @@ -35,7 +35,7 @@
requirements:
- "python >= 2.7"
- "openshift >= 0.3"
- "openshift == 0.4.1"
- "PyYAML >= 3.11"
'''

Expand Down
5 changes: 5 additions & 0 deletions lib/ansible/plugins/inventory/k8s.py
Expand Up @@ -73,6 +73,11 @@
description:
- List of namespaces. If not specified, will fetch all containers for all namespaces user is authorized
to access.
requirements:
- "python >= 2.7"
- "openshift == 0.4.1"
- "PyYAML >= 3.11"
'''

EXAMPLES = '''
Expand Down
5 changes: 5 additions & 0 deletions lib/ansible/plugins/inventory/openshift.py
Expand Up @@ -74,6 +74,11 @@
description:
- List of namespaces. If not specified, will fetch all containers for all namespaces user is authorized
to access.
requirements:
- "python >= 2.7"
- "openshift == 0.4.1"
- "PyYAML >= 3.11"
'''

EXAMPLES = '''
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/plugins/lookup/k8s.py
Expand Up @@ -115,7 +115,7 @@
requirements:
- "python >= 2.7"
- "openshift >= 0.3"
- "openshift == 0.4.1"
- "PyYAML >= 3.11"
notes:
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/plugins/lookup/openshift.py
Expand Up @@ -115,7 +115,7 @@
requirements:
- "python >= 2.7"
- "openshift >= 0.3"
- "openshift == 0.4.1"
- "PyYAML >= 3.11"
notes:
Expand Down

0 comments on commit c819007

Please sign in to comment.