diff options
author | Scott Dodson <sdodson@redhat.com> | 2017-08-15 12:50:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-15 12:50:15 -0400 |
commit | 9edfc0f8b2f18db18e9652f4281ca85224b33358 (patch) | |
tree | c70c2080c3ae445e77d8ac4bcec237630a423d8e /roles | |
parent | 2a3c43a9632c16465582fb8e468646caab5cfc0f (diff) | |
parent | 46075e0645e87e90fa864aadacbff920437f256a (diff) | |
download | openshift-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')
-rw-r--r-- | roles/lib_openshift/library/oc_obj.py | 11 | ||||
-rw-r--r-- | roles/lib_openshift/src/class/oc_obj.py | 11 |
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']) |