feat: support inline kubeconfig in config_path#354
Open
Abhi011999 wants to merge 2 commits intoturbot:mainfrom
Open
feat: support inline kubeconfig in config_path#354Abhi011999 wants to merge 2 commits intoturbot:mainfrom
config_path#354Abhi011999 wants to merge 2 commits intoturbot:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for providing an inline kubeconfig (YAML) directly via the config_path connection argument, avoiding disk I/O and file-watcher timing issues.
Changes:
- Added
pathOrContentsto classifyconfig_pathas either an on-disk path or inline content. - Added
tryInlineKubeconfigto parse inline kubeconfig YAML viaclientcmd.NewClientConfigFromBytes, with optional context override. - Updated
getK8ConfigandgetK8ConfigRawto attempt inline parsing before falling back to the standard file-based loader.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use positive YAML check (newlines + apiVersion key) to identify inline content instead of "everything that isn't a path" heuristic, preventing relative filenames from being misclassified as inline YAML - Surface real os.Stat errors (e.g., permission denied) instead of silently falling through to inline classification - Let missing file paths fall through to the standard loader for proper error messages and in-cluster config fallback, fixing a backwards-compat break where ~/.kube/config (missing) would hard-error instead of allowing fallback - Move overrides allocation inside configContext block where it's used Made-with: Cursor
Author
|
@rajlearner17 made the updates |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue: #353
Changes
kubernetes/utils.gopathOrContents(poc string)— mirrors GCP plugin's helper. ReturnsisInline=trueif the value is not a path that exists on disk and doesn't look like an absolute path.tryInlineKubeconfig(configPath string, configContext *string)— ifconfig_pathis inline YAML, parses it directly viaclientcmd.NewClientConfigFromByteswith optional context override. Returnsok=falseto let the caller fall through to the standard file-loader path.getK8ConfigandgetK8ConfigRawto calltryInlineKubeconfigbefore the existingClientConfigLoadingRulesloader, so file-path usage is fully backwards-compatible.Behaviour
config_pathvalue/home/user/.kube/config(exists)apiVersion: v1\nkind: Config\n...(YAML string)/tmp/missing(absolute, missing)no such file or directoryTesting
Verified end-to-end with EKS kubeconfig passed inline. Ran 10 concurrent queries across 2 EKS clusters, all of them passing correctly.
(Code written by Opus 4.6)