fix: enable/disable 'Save Config' whenever auth means are changed (#23780)#305
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (12)
📝 WalkthroughWalkthroughThis PR centralizes kubeconfig user resolution, maps kube user credentials (token, client cert/key, basic auth) into Cluster, adds haveAuthInputsChanged(saved: Cluster) to auth strategies with concrete implementations, and integrates these checks into DevSpacesServerStepView to compute and enable saving configuration changes. CI test job was updated to run a clean Gradle build with build-cache disabled. ChangesSave Configuration Dirty Detection System
CI Workflow Change
Sequence Diagram(s)sequenceDiagram
participant User
participant View as DevSpacesServerStepView
participant Strategy as AuthenticationStrategy
participant Kubeconfig as KubeConfigUtils
User->>View: Select different cluster
View->>View: getSelectedCluster() resolves effective selection
View->>Strategy: applyFromCluster(cluster) populates auth fields
View->>View: isDirty() checks cluster/CA/URL changes
View->>Strategy: haveAuthInputsChanged(saved) checks auth state
Strategy->>Strategy: Compare inputs vs saved kubeconfig values
Strategy-->>View: true/false (auth changed)
View->>View: kubeMatch() compares against saved entry
View->>View: enableSaveConfigCheckbox() based on isDirty()
View-->>User: Save configuration checkbox enabled/disabled
User->>View: Click save or next step
View->>Kubeconfig: saveKubeconfig() if saveConfig==true
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 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. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/ClientCertificateAuthenticationStrategy.kt`:
- Around line 111-117: The current haveAuthInputsChanged in
ClientCertificateAuthenticationStrategy.kt improperly returns false when either
tfClientCert or tfClientKey is blank, which prevents detecting deletion of
previously saved values; update the method so it always compares the trimmed
current values of tfClientCert.text and tfClientKey.text against
saved.clientCert?.value and saved.clientKey?.value (treating null as empty
string) and return true when either differs — do not short-circuit to false on
blank inputs so clearing a previously saved cert/key is detected as a change.
In
`@src/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/OpenShiftCredentialsAuthenticationStrategy.kt`:
- Around line 135-141: haveAuthInputsChanged currently returns false early when
either tfUsername or tfPassword is empty, which causes clearing fields to be
treated as "unchanged"; update the logic in haveAuthInputsChanged (and the
similar block at the other location) to detect when the user has cleared inputs
by returning true if the saved Cluster (saved.basicUsername or
saved.basicPassword) contains non-empty basic-auth values while the current
tfUsername.text.trim() and/or tfPassword.password are empty; use the existing
helpers/passwordDiffersFromKube and fields tfUsername, tfPassword,
saved.basicUsername, saved.basicPassword to implement this check so clearing
saved credentials is reported as a change.
In
`@src/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesServerStepView.kt`:
- Around line 75-86: The saveConfig boolean drifts out of sync with the UI
because saveConfig is only changed in the saveConfigCheckbox ActionListener;
update code so the checkbox is the single source of truth: whenever you
programmatically call saveConfigCheckbox.isSelected = ... (e.g. in
onClusterSelected) or disable the control in enableSaveConfigCheckbox(), also
set saveConfig = saveConfigCheckbox.isSelected (or explicitly set saveConfig =
false when unchecking/ disabling) so saveConfig always reflects the checkbox
state; adjust references to read from saveConfig (or directly from
saveConfigCheckbox.isSelected) consistently across the class
(saveConfigCheckbox, saveConfig, onClusterSelected, enableSaveConfigCheckbox).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: ac8bbec3-1c23-4bae-b108-acd865d8db08
📒 Files selected for processing (10)
src/main/kotlin/com/redhat/devtools/gateway/kubeconfig/KubeConfigEntries.ktsrc/main/kotlin/com/redhat/devtools/gateway/kubeconfig/KubeConfigUtils.ktsrc/main/kotlin/com/redhat/devtools/gateway/openshift/Cluster.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesServerStepView.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/AbstractAuthenticationStrategy.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/AuthenticationStrategy.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/ClientCertificateAuthenticationStrategy.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/OpenShiftCredentialsAuthenticationStrategy.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/OpenShiftOAuthAuthenticationStrategy.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/TokenAuthenticationStrategy.kt
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #305 +/- ##
==========================================
+ Coverage 0.00% 22.17% +22.17%
==========================================
Files 4 99 +95
Lines 26 4226 +4200
Branches 0 772 +772
==========================================
+ Hits 0 937 +937
- Misses 26 3170 +3144
- Partials 0 119 +119 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 65f36aa6-943f-4591-b230-283ee94208a6
📒 Files selected for processing (11)
.github/workflows/build.ymlsrc/main/kotlin/com/redhat/devtools/gateway/kubeconfig/KubeConfigEntries.ktsrc/main/kotlin/com/redhat/devtools/gateway/kubeconfig/KubeConfigUtils.ktsrc/main/kotlin/com/redhat/devtools/gateway/openshift/Cluster.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesServerStepView.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/AbstractAuthenticationStrategy.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/AuthenticationStrategy.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/ClientCertificateAuthenticationStrategy.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/OpenShiftCredentialsAuthenticationStrategy.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/OpenShiftOAuthAuthenticationStrategy.ktsrc/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/TokenAuthenticationStrategy.kt
✅ Files skipped from review due to trivial changes (1)
- src/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/AbstractAuthenticationStrategy.kt
🚧 Files skipped from review as they are similar to previous changes (8)
- src/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/AuthenticationStrategy.kt
- src/main/kotlin/com/redhat/devtools/gateway/openshift/Cluster.kt
- src/main/kotlin/com/redhat/devtools/gateway/kubeconfig/KubeConfigEntries.kt
- .github/workflows/build.yml
- src/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/ClientCertificateAuthenticationStrategy.kt
- src/main/kotlin/com/redhat/devtools/gateway/kubeconfig/KubeConfigUtils.kt
- src/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesServerStepView.kt
- src/main/kotlin/com/redhat/devtools/gateway/view/steps/auth/OpenShiftCredentialsAuthenticationStrategy.kt
vrubezhny
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks!
…3780) Signed-off-by: Andre Dietisheim <adietish@redhat.com> Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com> co-authored-by: Cursor
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
|
@vrubezhny I now show the "Save configuration" checkbox for all tabs |
fixes eclipse-che/che#23780
"Save Configuration" checkbox should get enabled as soon as:
Using "RH SSO" or "OpenShift OAuth" are not enabling the "Save Configuration" checkbox.