Skip to content

fix(kubeconfig): create new kubeconfig file when none exists (CRW-12054) - #381

Open
adietish wants to merge 3 commits into
redhat-developer:mainfrom
adietish:crw-12054
Open

adietish wants to merge 3 commits into
redhat-developer:mainfrom
adietish:crw-12054

Conversation

@adietish

@adietish adietish commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f38d4b9c-24e9-4907-95c2-772c2b160bc0

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

codecov-commenter commented Oct 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.12088% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.88%. Comparing base (71098f6) to head (bf8ba05).
⚠️ Report is 439 commits behind head on main.

Files with missing lines Patch % Lines
...t/devtools/gateway/auth/tls/KubeConfigTlsWriter.kt 0.00% 9 Missing ⚠️
...at/devtools/gateway/kubeconfig/KubeConfigUpdate.kt 82.05% 2 Missing and 5 partials ⚠️
.../redhat/devtools/gateway/kubeconfig/FileWatcher.kt 93.33% 0 Missing and 1 partial ⚠️
...hat/devtools/gateway/kubeconfig/KubeConfigUtils.kt 94.73% 0 Missing and 1 partial ⚠️
...ools/gateway/view/steps/DevSpacesServerStepView.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            main     #381       +/-   ##
==========================================
+ Coverage   0.00%   40.88%   +40.88%     
==========================================
  Files          4      124      +120     
  Lines         26     5337     +5311     
  Branches       0     1018     +1018     
==========================================
+ Hits           0     2182     +2182     
- Misses        26     2866     +2840     
- Partials       0      289      +289     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

adietish and others added 3 commits October 6, 2026 22:37
…e config lists

Bundle KubeConfig with its source path in a KubeConfigFile data class so
callers carry the file path alongside the parsed config, and replace the
process-wide WeakHashMap path-to-config cache with direct per-call parsing.
All config APIs now return List<KubeConfigFile>, and mechanical type updates
propagate through KubeConfigUtils, KubeConfigUpdate, KubeConfigTlsWriter,
LinkClientBuilder, DevSpacesServerStepView and their tests. No behavior change.

Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Previously, when the user had no kubeconfig at all (no ~/.kube/config and
no KUBECONFIG entries), all config lists were empty and the create-context
operations silently returned without writing anything, so the wizard
appeared to finish but no kubeconfig was ever created.

- KubeConfigUtils: add getDefaultConfig() (always ~/.kube/config),
  getWritableConfig() (first KUBECONFIG entry, defaulting to the standard
  path) and newEmptyConfig(path).
- KubeConfigUpdate: CreateContext and CreateContextWithClientCert now fall
  back to an empty config at the writable path instead of returning;
  saveConfig takes a non-null path and creates missing parent directories.
- getAllConfigFiles no longer filters out a non-existent default path so
  FileWatcher can pick it up once the wizard creates it.
- Add unit tests for the new utils methods and the create-on-empty flows.

Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…rw-12054)

FileWatcher now tracks files whose parent dir doesn't exist and
re-registers the directory once it appears, notifying listeners.
KubeConfigMonitor relies on addFile idempotency instead of
pre-deduplicating paths.

Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

2 participants