Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions openshift/helper/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from kubernetes import config
from kubernetes.client import models as k8s_models
from kubernetes.client import apis as k8s_apis
from kubernetes.client import ApiClient, ConfigurationObject

from . import VERSION_RX
from .base import BaseObjectHelper
Expand All @@ -13,6 +14,8 @@
class KubernetesObjectHelper(BaseObjectHelper):
@staticmethod
def client_from_config(config_file, context):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems strange to me to put the logic for handling non-config based client creation in the client_from_config function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to put it here because the logic for client_from_config is in this library. Otherwise, I think I would have had to put the kubernetes specific logic in the kubernetes library and the rest somewhere in openshift-restclient-python. This would be inconsistent and I honestly don't think new_client_from_config would be a good place for it :(

I think it's fine to have this code here (based on my very limited knowledge of this codebase). Do you think there's a better place for it? Where would you put it? thnx

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're probably right, for now best to leave it here. Would you mind adding a TODO over this code branch to look at splitting the non-config logic out of client_from_config. Likely would be a larger refactor, I just want to be reminded whenever I grep the TODOs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added them myself, thanks for the patch!

if not config_file:
return ApiClient(config=ConfigurationObject())
return config.new_client_from_config(config_file, context)

@classmethod
Expand Down
3 changes: 3 additions & 0 deletions openshift/helper/openshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
from .. import config
from ..client import models as openshift_models
from ..client import apis as openshift_apis
from ..client import ApiClient, ConfigurationObject
from .base import BaseObjectHelper
from .exceptions import OpenShiftException


class OpenShiftObjectHelper(BaseObjectHelper):
@staticmethod
def client_from_config(config_file, context):
if not config_file:
return ApiClient(config=ConfigurationObject())
return config.new_client_from_config(config_file, context)

@classmethod
Expand Down