feat(config): support multi-file KUBECONFIG and honor --context#171
feat(config): support multi-file KUBECONFIG and honor --context#171
Conversation
The --context flag was defined but never plumbed into the Argo client, and
a KUBECONFIG containing multiple files joined by the OS path-list
separator (kubectl convention) was treated as a single literal path.
Switch the kubeconfig loader to use Precedence with filepath.SplitList,
copy Context from internal config into argo.Config, and apply it via
clientcmd.ConfigOverrides{CurrentContext: ...}. Log the resolved context
and cluster at startup so operators can confirm the bound cluster before
running tools.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
WalkthroughThe PR adds kubeconfig context selection and KUBECONFIG environment variable support to the Argo configuration. The ChangesKubeconfig Context and Path Selection
Sequence DiagramsequenceDiagram
participant Env as Environment/<br/>Config
participant Config as argo.Config<br/>Structure
participant Rules as buildLoadingRules<br/>Helper
participant Resolver as logResolvedContext<br/>Helper
participant KubeAPI as Kubernetes<br/>Client
Env->>Config: Read KUBECONFIG env var<br/>and Context field
Config->>Rules: Pass Kubeconfig paths
Rules->>Rules: Split paths (KUBECONFIG style)<br/>or use defaults
Config->>Resolver: Provide loading rules<br/>and context override
Resolver->>Resolver: Resolve kubeconfig<br/>Select context
Resolver->>Resolver: Extract cluster info<br/>and log metadata
Config->>KubeAPI: Build client config<br/>with context override
KubeAPI->>KubeAPI: Initialize API client
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
--contextwas defined but never plumbed into the Argo client — the kubeconfig'scurrent-contextalways won. It now flows throughinternal/config→argo.Config→clientcmd.ConfigOverrides{CurrentContext: ...}.KUBECONFIGcontaining multiple files joined by the OS path-list separator (the kubectl convention, e.g.eks.yaml:k3d.yaml:home.yaml) was being treated as a single literal path. The loader now usesPrecedence: filepath.SplitList(kubeconfig)so each file is merged.Test plan
go test ./...passes (newTestBuildLoadingRulescovers empty / single / multi-path)make lintpassesKUBECONFIG:current-context(e.g.k3d-pipeline-mono)--context=eks-internaloverrides and resolves to the correct cluster🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests