-
Notifications
You must be signed in to change notification settings - Fork 185
Support file-ish objects in config loading #208
Support file-ish objects in config loading #208
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Welcome @ryphon! |
File attached of a python console loading a config from local file into a StringIO fileish object, and then that string being used as config for the api client. This should work just fine with actual file objects as well, rather than a path. |
/assign @yliaog |
config/kube_config.py
Outdated
if hasattr(paths, 'read'): | ||
self.load_config_from_fileish(paths) | ||
else: | ||
for path in paths.split(ENV_KUBECONFIG_PATH_SEPARATOR): | ||
if path: | ||
path = os.path.expanduser(path) | ||
if os.path.exists(path): | ||
self.paths.append(path) | ||
self.load_config(path) | ||
self.config_saved = copy.deepcopy(self.config_files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about pushing the code path for paths to a separate internal function (say _load_config_from_file_path
) as well? I think readability will increase that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this as well, will get this in shortly as well!
config/kube_config.py
Outdated
|
||
@property | ||
def config(self): | ||
return self.config_merged | ||
|
||
def load_config_from_fileish(self, string): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does renaming the method to _load_config_from_file_like_object
sound? (_
since this is not supposed to be used externally)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a great point, will get that in shortly.
/assign |
There is a test failure https://travis-ci.org/github/kubernetes-client/python-base/builds/722838842:
Please take a look. LGTM otherwise. /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: roycaihw, ryphon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Ah silly me, I didn't realize I also had to write for 2.7. I'll get another commit in the next couple days to address. |
Not sure why travis isn't reporting, but the tests now pass. @roycaihw @palnabarun @yliaog |
/lgtm |
Closes #207