File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import os
1516from .config_exception import ConfigException
1617from .incluster_config import load_incluster_config
1718from .kube_config import (list_kube_config_contexts , load_kube_config ,
18- load_kube_config_from_dict , new_client_from_config )
19+ load_kube_config_from_dict , new_client_from_config , KUBE_CONFIG_DEFAULT_LOCATION )
20+
21+
22+ def load_config (** kwargs ):
23+ """
24+ Wrapper function to load the kube_config.
25+ It will initially try to load_kube_config from provided path, then check if the KUBE_CONFIG_DEFAULT_LOCATION exists
26+ If neither exists- it will fall back to load_incluster_config and inform the user accordingly.
27+ """
28+ if "kube_config_path" in kwargs .keys () or os .path .exists (KUBE_CONFIG_DEFAULT_LOCATION ):
29+ load_kube_config (** kwargs )
30+ else :
31+ print (f"kube_config_path not provided and default location ({ KUBE_CONFIG_DEFAULT_LOCATION } ) does not exist. "
32+ "Using inCluster Config. This might not work." )
33+ load_incluster_config (** kwargs )
You can’t perform that action at this time.
0 commit comments