Read $KUBECONFIG env var in kubectl generator#233
Merged
Conversation
Update kubectl_script() to read the KUBECONFIG environment variable and pass it to kubectl commands when --kubeconfig is not explicitly specified in the command tokens. This enables resource completions for users who set KUBECONFIG in their shell environment (common for multi-cluster setups). The fix applies three levels of kubeconfig resolution: 1. --kubeconfig flag from command tokens (existing behavior) 2. KUBECONFIG from inline command environment variables 3. $KUBECONFIG shell variable fallback for session-level env vars Also adds unit tests for the new behavior. Fixes: warpdotdev/warp#3930 Co-Authored-By: Oz <oz-agent@warp.dev>
APP-3478 [kubectl] Read $KUBECONFIG env var in generator
The kubectl generator currently only forwards Fix: read See GitHub #3930 |
Contributor
Author
Context generator screenshot (--kubeconfig flag)Testing The completions dropdown shows |
Contributor
Author
Contributor
Author
Contributor
Author
Contributor
Author
vkodithala
approved these changes
Apr 3, 2026
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.






Summary
Read
$KUBECONFIGenvironment variable inkubectl_script()and pass it to kubectl commands when--kubeconfigis not explicitly specified in the command tokens. This enables resource completions for users who setKUBECONFIGin their shell environment, which is common for multi-cluster Kubernetes setups.Fixes: warpdotdev/warp#3930
Linear: APP-3478
Changes
Updated
kubectl_script()incommand-signatures/src/generators/kubectl.rsto apply three levels of kubeconfig resolution:--kubeconfigflag from command tokens (existing behavior, highest priority)KUBECONFIGfrom inline command environment variables (e.g.,KUBECONFIG=/path kubectl get pods)$KUBECONFIGshell variable fallback for session-level env vars forwarded to the child processAdded a helper function
env_var_value()to extract values from theKEY=VALUEformatted env vars list.Testing
Context generator with
--kubeconfigflagCompletions dropdown correctly shows
staging-contextandtest-contextfrom the kubeconfig file:Unit Tests
Added 5 unit tests covering:
--kubeconfigflag from tokensKUBECONFIGfrom inline env varsenv_var_value()helper functionAll tests pass:
cargo test -p warp-command-signatures -- kubectl→ 5 passed.script/presubmitpasses (22 total tests).Conversation: https://staging.warp.dev/conversation/53c00fa8-fb8d-4ba9-86c8-249585bbba02
Run: https://oz.staging.warp.dev/runs/019d4b05-7ecc-79df-b704-a3d601a24f4b
This PR was generated with Oz.