summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/src
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2017-08-15 12:50:15 -0400
committerGitHub <noreply@github.com>2017-08-15 12:50:15 -0400
commit9edfc0f8b2f18db18e9652f4281ca85224b33358 (patch)
treec70c2080c3ae445e77d8ac4bcec237630a423d8e /roles/lib_openshift/src
parent2a3c43a9632c16465582fb8e468646caab5cfc0f (diff)
parent46075e0645e87e90fa864aadacbff920437f256a (diff)
downloadopenshift-9edfc0f8b2f18db18e9652f4281ca85224b33358.tar.gz
openshift-9edfc0f8b2f18db18e9652f4281ca85224b33358.tar.bz2
openshift-9edfc0f8b2f18db18e9652f4281ca85224b33358.tar.xz
openshift-9edfc0f8b2f18db18e9652f4281ca85224b33358.zip
Merge pull request #5006 from ivanhorvath/ocobjdumper
adding check to a yaml dump to work properly with new ruamel lib
Diffstat (limited to 'roles/lib_openshift/src')
-rw-r--r--roles/lib_openshift/src/class/oc_obj.py11
1 files changed, 10 insertions, 1 deletions
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'])