summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorIvan Horvath <ihorvath@redhat.com>2017-08-04 15:22:20 -0400
committerIvan Horvath <ihorvath@redhat.com>2017-08-09 10:29:17 -0400
commit46075e0645e87e90fa864aadacbff920437f256a (patch)
treeb2d3f8dcd1fa17bfbc7e7992ddc39716a7b1c5fa /roles
parentf964fae7e6a59a80567608f8bad3763b4b10eb32 (diff)
downloadopenshift-46075e0645e87e90fa864aadacbff920437f256a.tar.gz
openshift-46075e0645e87e90fa864aadacbff920437f256a.tar.bz2
openshift-46075e0645e87e90fa864aadacbff920437f256a.tar.xz
openshift-46075e0645e87e90fa864aadacbff920437f256a.zip
adding check to a yaml dump to work properly with new ruamel lib
Diffstat (limited to 'roles')
-rw-r--r--roles/lib_openshift/library/oc_obj.py11
-rw-r--r--roles/lib_openshift/src/class/oc_obj.py11
2 files changed, 20 insertions, 2 deletions
diff --git a/roles/lib_openshift/library/oc_obj.py b/roles/lib_openshift/library/oc_obj.py
index 9b0c0e0e4..7d9392af9 100644
--- a/roles/lib_openshift/library/oc_obj.py
+++ b/roles/lib_openshift/library/oc_obj.py
@@ -1478,7 +1478,16 @@ class OCObject(OpenShiftCLI):
if files:
return self._create(files[0])
- content['data'] = yaml.dump(content['data'])
+ # pylint: disable=no-member
+ # The purpose of this change is twofold:
+ # - we need a check to only use the ruamel specific dumper if ruamel is loaded
+ # - the dumper or the flow style change is needed so openshift is able to parse
+ # the resulting yaml, at least until gopkg.in/yaml.v2 is updated
+ if hasattr(yaml, 'RoundTripDumper'):
+ content['data'] = yaml.dump(content['data'], Dumper=yaml.RoundTripDumper)
+ else:
+ content['data'] = yaml.safe_dump(content['data'], default_flow_style=False)
+
content_file = Utils.create_tmp_files_from_contents(content)[0]
return self._create(content_file['path'])
diff --git a/roles/lib_openshift/src/class/oc_obj.py b/roles/lib_openshift/src/class/oc_obj.py
index 5e423bea9..68f7818e4 100644
--- a/roles/lib_openshift/src/class/oc_obj.py
+++ b/roles/lib_openshift/src/class/oc_obj.py
@@ -50,7 +50,16 @@ class OCObject(OpenShiftCLI):
if files:
return self._create(files[0])
- content['data'] = yaml.dump(content['data'])
+ # pylint: disable=no-member
+ # The purpose of this change is twofold:
+ # - we need a check to only use the ruamel specific dumper if ruamel is loaded
+ # - the dumper or the flow style change is needed so openshift is able to parse
+ # the resulting yaml, at least until gopkg.in/yaml.v2 is updated
+ if hasattr(yaml, 'RoundTripDumper'):
+ content['data'] = yaml.dump(content['data'], Dumper=yaml.RoundTripDumper)
+ else:
+ content['data'] = yaml.safe_dump(content['data'], default_flow_style=False)
+
content_file = Utils.create_tmp_files_from_contents(content)[0]
return self._create(content_file['path'])