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

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

Merged
k8s-ci-robot merged 7 commits into
kubernetes-client:masterfrom
vishnu667:kubeConfig_from_dict
Jun 19, 2020
Merged

Adding ability to set kube config from a dict.#195
k8s-ci-robot merged 7 commits into
kubernetes-client:masterfrom
vishnu667:kubeConfig_from_dict

Conversation

@vishnu667

Copy link
Copy Markdown
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-robotk8s-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
Copy Markdown
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-robotk8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 14, 2020
@vishnu667

Copy link
Copy Markdown
ContributorAuthor

/assign @yliaog

@yliaog

Copy link
Copy Markdown
Contributor

please add tests for the change to kube_config_test.py

@k8s-ci-robotk8s-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

codecov-io commented May 15, 2020

Copy link
Copy Markdown

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 FilesCoverage Δ
config/__init__.py100.00% <ø> (ø)
config/kube_config.py83.29% <76.19%> (-0.20%)⬇️
config/kube_config_test.py95.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
vishnu667force-pushed the kubeConfig_from_dict branch from 3ed1f12 to e92495fCompareMay 15, 2020 15:07
@vishnu667

Copy link
Copy Markdown
ContributorAuthor

@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

codecov-commenter commented May 21, 2020

Copy link
Copy Markdown

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 FilesCoverage Δ
config/__init__.py100.00% <ø> (ø)
config/kube_config.py83.29% <76.19%> (-0.20%)⬇️
config/kube_config_test.py95.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
Copy Markdown
Member

/cc @yliaog

@k8s-ci-robot
k8s-ci-robot requested a review from yliaogJune 8, 2020 16:32
Comment threadconfig/kube_config.py Outdated
@vishnu667
vishnu667force-pushed the kubeConfig_from_dict branch from 242e78f to 9181235CompareJune 19, 2020 19:20
@yliaog

Copy link
Copy Markdown
Contributor

/lgtm
/approve

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

Copy link
Copy Markdown
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

Details 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-robotk8s-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:masterJun 19, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

approvedIndicates a PR has been approved by an approver from all required OWNERS files.cncf-cla: yesIndicates the PR's author has signed the CNCF CLA.lgtmIndicates that a PR is ready to be merged.size/LDenotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@vishnu667@k8s-ci-robot@yliaog@codecov-io@codecov-commenter@roycaihw