') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); fix cfg is none, load kube config error by ACXLM · Pull Request #198 · kubernetes-client/python-base · GitHub
Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

fix cfg is none, load kube config error - #198

Merged
k8s-ci-robot merged 2 commits into
kubernetes-client:masterfrom
ACXLM:fix/load-kube-config
Jun 25, 2020
Merged

fix cfg is none, load kube config error#198
k8s-ci-robot merged 2 commits into
kubernetes-client:masterfrom
ACXLM:fix/load-kube-config

Conversation

@ACXLM

@ACXLMACXLM commented Jun 2, 2020

Copy link
Copy Markdown
Contributor

This PR fixed
kubernetes/kubernetes#84503 changed the behaviour of kubectl config unset slightly that if no users left in kubeconfig after user run kubectl config unset users., the value of users field in kubeconfig would be set to null rather than [].

since users set to null, kubernetes.config.kube_config.load_kube_config() can't work, this pr set a default empty list to users

Which issue(s) this PR fixes:

Try to fixes
#183
#181

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

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.


Details

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.

@k8s-ci-robotk8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jun 2, 2020
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Welcome @ACXLM!

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/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 2, 2020
@codecov-commenter

codecov-commenter commented Jun 2, 2020

Copy link
Copy Markdown

Codecov Report

Merging #198 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@ Coverage Diff @@## master #198 +/- ##
=======================================
Coverage 92.69% 92.69% =======================================
Files 13 13 Lines 1519 1519 =======================================
Hits 1408 1408 Misses 111 111 
Impacted FilesCoverage Δ
config/kube_config_test.py95.59% <ø> (ø)
config/kube_config.py83.48% <100.00%> (ø)

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...2108e57. Read the comment docs.

@ACXLM
ACXLMforce-pushed the fix/load-kube-config branch 3 times, most recently from f7a1363 to b76029cCompareJune 2, 2020 05:42
Signed-off-by: zhu hui <hui.zhu@daocloud.io>
@ACXLM
ACXLMforce-pushed the fix/load-kube-config branch from b76029c to 3ff79daCompareJune 2, 2020 05:56
@k8s-ci-robotk8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jun 2, 2020
@ACXLM

ACXLM commented Jun 3, 2020

Copy link
Copy Markdown
ContributorAuthor

/assign @roycaihw

@roycaihw

Copy link
Copy Markdown
Member

Could you add a unit test for this behavior? Thanks

@ACXLM

ACXLM commented Jun 9, 2020

Copy link
Copy Markdown
ContributorAuthor

Could you add a unit test for this behavior? Thanks

since users set to None, load_config() run like the following error:

.....................config/kube_config_test.py:1345: DeprecationWarning: Please use assertEqual instead.
self.assertEquals(actual._config_persister.__name__, "save_changes")
....................................EEE...
======================================================================
ERROR: test_list_kube_config_contexts (__main__.TestKubeConfigMerger)
----------------------------------------------------------------------
Traceback (most recent call last):
File "config/kube_config_test.py", line 1545, in test_list_kube_config_contexts
contexts, active_context = list_kube_config_contexts(
File "/home/ac/Project/PythonWorksPaces/python-base/config/kube_config.py", line 714, in list_kube_config_contexts
loader = _get_kube_config_loader_for_yaml_file(config_file)
File "/home/ac/Project/PythonWorksPaces/python-base/config/kube_config.py", line 694, in _get_kube_config_loader_for_yaml_file
kcfg = KubeConfigMerger(filename)
File "/home/ac/Project/PythonWorksPaces/python-base/config/kube_config.py", line 650, in __init__
self.load_config(path)
File "/home/ac/Project/PythonWorksPaces/python-base/config/kube_config.py", line 667, in load_config
self._merge(item, config.get(item, []), path)
File "/home/ac/Project/PythonWorksPaces/python-base/config/kube_config.py", line 671, in _merge
for new_item in add_cfg:
TypeError: 'NoneType' object is not iterable

this PR can fix this error

Comment threadconfig/kube_config_test.py Outdated
@ACXLM
ACXLMforce-pushed the fix/load-kube-config branch from 2108e57 to b08556bCompareJune 23, 2020 02:24
@k8s-ci-robotk8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 23, 2020
@roycaihw

Copy link
Copy Markdown
Member

/lgtm
/hold
LGTM once the pycodestyle failure is fixed: https://travis-ci.org/github/kubernetes-client/python-base/jobs/701111762

@k8s-ci-robotk8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Jun 24, 2020
@ACXLM
ACXLMforce-pushed the fix/load-kube-config branch from b08556b to 5565d32CompareJune 24, 2020 08:18
@k8s-ci-robotk8s-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jun 24, 2020
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

@ACXLM: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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.

@ACXLM

Copy link
Copy Markdown
ContributorAuthor

/lgtm
/hold
LGTM once the pycodestyle failure is fixed: https://travis-ci.org/github/kubernetes-client/python-base/jobs/701111762

fixed pycodestyle test failure

@ACXLM
ACXLMforce-pushed the fix/load-kube-config branch from 5565d32 to 30d9e2aCompareJune 25, 2020 12:53
@k8s-ci-robotk8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 25, 2020
@ACXLM
ACXLM requested a review from roycaihwJune 25, 2020 17:03
@roycaihw

Copy link
Copy Markdown
Member

/lgtm
/approve
/hold cancel

@k8s-ci-robotk8s-ci-robot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 25, 2020
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ACXLM, roycaihw

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 25, 2020
@k8s-ci-robot
k8s-ci-robot merged commit 3ea8003 into kubernetes-client:masterJun 25, 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/SDenotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@ACXLM@k8s-ci-robot@codecov-commenter@roycaihw