Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

Adding ability to set kube config from a dict. #195

Merged
merged 7 commits into from
Jun 19, 2020

Conversation

vishnu667
Copy link
Contributor

Added a function called load_kube_config_from_dict(), adding the ability to set the ~/.kube/config file from a dict.

Required where kubeconfig is stored externally and saving to disk is not an option.

Usage

import yaml
import kubernetes
from os.path import expanduser
config_dict = yaml.load(expanduser("~") + "/.kube/config")
kubernetes.config.load_kube_config_from_dict(config_dict)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 14, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @vishnu667!

It looks like this is your first PR to kubernetes-client/python-base 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/python-base has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 14, 2020
@vishnu667
Copy link
Contributor Author

/assign @yliaog

@yliaog
Copy link
Contributor

yliaog commented May 14, 2020

please add tests for the change to kube_config_test.py

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 15, 2020
@codecov-io
Copy link

codecov-io commented May 15, 2020

Codecov Report

Merging #195 into master will decrease coverage by 0.14%.
The diff coverage is 84.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #195      +/-   ##
==========================================
- Coverage   92.69%   92.54%   -0.15%     
==========================================
  Files          13       13              
  Lines        1519     1557      +38     
==========================================
+ Hits         1408     1441      +33     
- Misses        111      116       +5     
Impacted Files Coverage Δ
config/__init__.py 100.00% <ø> (ø)
config/kube_config.py 83.29% <76.19%> (-0.20%) ⬇️
config/kube_config_test.py 95.41% <92.00%> (-0.18%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49ec060...c6e8194. Read the comment docs.

@vishnu667
Copy link
Contributor Author

@yliaog I've added Some test cases, they are similar to the load_kube_config test cases.
Instead of passing the yaml files I've passed them as a dictionary.

@codecov-commenter
Copy link

codecov-commenter commented May 21, 2020

Codecov Report

Merging #195 into master will decrease coverage by 0.03%.
The diff coverage is 87.80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #195      +/-   ##
==========================================
- Coverage   92.69%   92.65%   -0.04%     
==========================================
  Files          13       13              
  Lines        1519     1552      +33     
==========================================
+ Hits         1408     1438      +30     
- Misses        111      114       +3     
Impacted Files Coverage Δ
config/__init__.py 100.00% <ø> (ø)
config/kube_config.py 83.29% <76.19%> (-0.20%) ⬇️
config/kube_config_test.py 95.76% <100.00%> (+0.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49ec060...9181235. Read the comment docs.

@roycaihw
Copy link
Member

roycaihw commented Jun 8, 2020

/cc @yliaog

@k8s-ci-robot k8s-ci-robot requested a review from yliaog June 8, 2020 16:32
config/kube_config.py Outdated Show resolved Hide resolved
@yliaog
Copy link
Contributor

yliaog commented Jun 19, 2020

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 19, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vishnu667, yliaog

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 19, 2020
@k8s-ci-robot k8s-ci-robot merged commit a6a6273 into kubernetes-client:master Jun 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants