summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/src
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2017-02-08 09:42:08 -0500
committerKenny Woodson <kwoodson@redhat.com>2017-02-08 09:42:08 -0500
commit76b99082bddf9f8e24063e5d2553b144e13d5984 (patch)
treedeaa2dd9e85d15e34148d536a19caddf99896bfc /roles/lib_openshift/src
parentb1565e9e843e99c6b3c0d99518c27249472f57fe (diff)
downloadopenshift-76b99082bddf9f8e24063e5d2553b144e13d5984.tar.gz
openshift-76b99082bddf9f8e24063e5d2553b144e13d5984.tar.bz2
openshift-76b99082bddf9f8e24063e5d2553b144e13d5984.tar.xz
openshift-76b99082bddf9f8e24063e5d2553b144e13d5984.zip
Adding code to copy kubeconfig before running oc commands.
Diffstat (limited to 'roles/lib_openshift/src')
-rw-r--r--roles/lib_openshift/src/lib/base.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/roles/lib_openshift/src/lib/base.py b/roles/lib_openshift/src/lib/base.py
index d0843c03e..31b523e49 100644
--- a/roles/lib_openshift/src/lib/base.py
+++ b/roles/lib_openshift/src/lib/base.py
@@ -20,7 +20,7 @@ class OpenShiftCLI(object):
''' Constructor for OpenshiftCLI '''
self.namespace = namespace
self.verbose = verbose
- self.kubeconfig = kubeconfig
+ self.kubeconfig = Utils.create_tmpfile_copy(kubeconfig)
self.all_namespaces = all_namespaces
# Pylint allows only 5 arguments to be passed.
@@ -306,6 +306,17 @@ class Utils(object):
return tmp
@staticmethod
+ def create_tmpfile_copy(inc_file):
+ '''create a temporary copy of a file'''
+ tmpfile = Utils.create_tmpfile()
+ Utils._write(tmpfile, open(inc_file).read())
+
+ # Cleanup the tmpfile
+ atexit.register(Utils.cleanup, [tmpfile])
+
+ return tmpfile
+
+ @staticmethod
def create_tmpfile(prefix=None):
''' Generates and returns a temporary file name '''