Skip to content

Commit 13d5d86

Browse files
committed
Don't require a config file for k8s/openshift
It's possible to interact with the Kubernetes/OpenShift API without auth or even without a configuration file. This patch allows for creating an ApiClient instance without loading it from a configuration file if it is not set.
1 parent d892a72 commit 13d5d86

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

openshift/helper/kubernetes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from kubernetes import config
55
from kubernetes.client import models as k8s_models
66
from kubernetes.client import apis as k8s_apis
7+
from kubernetes.client import ApiClient, ConfigurationObject
78

89
from . import VERSION_RX
910
from .base import BaseObjectHelper
@@ -13,6 +14,8 @@
1314
class KubernetesObjectHelper(BaseObjectHelper):
1415
@staticmethod
1516
def client_from_config(config_file, context):
17+
if not config_file:
18+
return ApiClient(config=ConfigurationObject())
1619
return config.new_client_from_config(config_file, context)
1720

1821
@classmethod

openshift/helper/openshift.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
from .. import config
1313
from ..client import models as openshift_models
1414
from ..client import apis as openshift_apis
15+
from ..client import ApiClient, ConfigurationObject
1516
from .base import BaseObjectHelper
1617
from .exceptions import OpenShiftException
1718

1819

1920
class OpenShiftObjectHelper(BaseObjectHelper):
2021
@staticmethod
2122
def client_from_config(config_file, context):
23+
if not config_file:
24+
return ApiClient(config=ConfigurationObject())
2225
return config.new_client_from_config(config_file, context)
2326

2427
@classmethod

0 commit comments

Comments
 (0)