Skip to content

Add kubeconfig and context overrides to the CLI#9

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/add-kubeconfig-and-context-flags
Draft

Add kubeconfig and context overrides to the CLI#9
Copilot wants to merge 3 commits into
mainfrom
copilot/add-kubeconfig-and-context-flags

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

kubectl-ditto always used the default Kubernetes client config, which made it impossible to target a specific kubeconfig file or context on machines with multiple clusters. This change adds explicit CLI overrides and routes client initialization through kube’s kubeconfig-aware config APIs when requested.

  • CLI surface

    • Adds --kubeconfig <PATH> to select a specific kubeconfig file
    • Adds --context <NAME> to select a specific kubeconfig context
    • Keeps existing invocation shape unchanged for users relying on default config resolution
  • Client configuration

    • Preserves kube::Client::try_default() when no override flags are provided
    • Uses Config::from_custom_kubeconfig(...) when --kubeconfig is set
    • Uses Config::from_kubeconfig(...) with KubeConfigOptions { context, .. } when only --context is set
    • Supports combining both flags so context selection applies to an explicit kubeconfig file
  • Docs and coverage

    • Updates README usage to show kubeconfig/context targeting
    • Adds focused CLI parsing tests for the new flags
kubectl ditto deployment my-app \
  --kubeconfig ~/.kube/prod-config \
  --context production

Copilot AI linked an issue Apr 17, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 17, 2026 01:00
Copilot AI changed the title [WIP] Add --kubeconfig and --context CLI flags for kube queries Add kubeconfig and context overrides to the CLI Apr 17, 2026
Copilot AI requested a review from rawkode April 17, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --kubeconfig and --context CLI flags

2 participants