summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/library/oc_scale.py
diff options
context:
space:
mode:
authorThomas Wiest <twiest@users.noreply.github.com>2017-02-06 17:12:24 -0500
committerGitHub <noreply@github.com>2017-02-06 17:12:24 -0500
commite0a074962abfdaadd177e90c56d186c13d814609 (patch)
tree6b47b62fab751b4007c6627bedc6b362bd1f468b /roles/lib_openshift/library/oc_scale.py
parent41ff6013a19c77fdc35adcf58ad523069f20ee2f (diff)
parentd508ec24877a743c6d79dac0574c859e14d40218 (diff)
downloadopenshift-e0a074962abfdaadd177e90c56d186c13d814609.tar.gz
openshift-e0a074962abfdaadd177e90c56d186c13d814609.tar.bz2
openshift-e0a074962abfdaadd177e90c56d186c13d814609.tar.xz
openshift-e0a074962abfdaadd177e90c56d186c13d814609.zip
Merge pull request #3264 from twiest/oc_serviceaccount_secret
Added oc_serviceaccount_secret to lib_openshift.
Diffstat (limited to 'roles/lib_openshift/library/oc_scale.py')
-rw-r--r--roles/lib_openshift/library/oc_scale.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/roles/lib_openshift/library/oc_scale.py b/roles/lib_openshift/library/oc_scale.py
index 30ddc1801..f2b96b6ad 100644
--- a/roles/lib_openshift/library/oc_scale.py
+++ b/roles/lib_openshift/library/oc_scale.py
@@ -292,6 +292,17 @@ class Yedit(object):
return data
+ @staticmethod
+ def _write(filename, contents):
+ ''' Actually write the file contents to disk. This helps with mocking. '''
+
+ tmp_filename = filename + '.yedit'
+
+ with open(tmp_filename, 'w') as yfd:
+ yfd.write(contents)
+
+ os.rename(tmp_filename, filename)
+
def write(self):
''' write to file '''
if not self.filename:
@@ -300,15 +311,11 @@ class Yedit(object):
if self.backup and self.file_exists():
shutil.copy(self.filename, self.filename + '.orig')
- tmp_filename = self.filename + '.yedit'
- with open(tmp_filename, 'w') as yfd:
- # pylint: disable=no-member
- if hasattr(self.yaml_dict, 'fa'):
- self.yaml_dict.fa.set_block_style()
-
- yfd.write(yaml.dump(self.yaml_dict, Dumper=yaml.RoundTripDumper))
+ # pylint: disable=no-member
+ if hasattr(self.yaml_dict, 'fa'):
+ self.yaml_dict.fa.set_block_style()
- os.rename(tmp_filename, self.filename)
+ Yedit._write(self.filename, yaml.dump(self.yaml_dict, Dumper=yaml.RoundTripDumper))
return (True, self.yaml_dict)