From 76b99082bddf9f8e24063e5d2553b144e13d5984 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Wed, 8 Feb 2017 09:42:08 -0500 Subject: Adding code to copy kubeconfig before running oc commands. --- roles/lib_openshift/src/lib/base.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'roles/lib_openshift/src') 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. @@ -305,6 +305,17 @@ class Utils(object): atexit.register(Utils.cleanup, [tmp]) 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 ''' -- cgit v1.2.3