Skip to content

HELM-763: Add secrets for Helm release upgrade#16787

Open
sowmya-sl wants to merge 7 commits into
openshift:mainfrom
sowmya-sl:add-secrets-helm-upgrade
Open

HELM-763: Add secrets for Helm release upgrade#16787
sowmya-sl wants to merge 7 commits into
openshift:mainfrom
sowmya-sl:add-secrets-helm-upgrade

Conversation

@sowmya-sl

@sowmya-sl sowmya-sl commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Analysis / Root cause:

Kubernetes Secret object is used to store username and password for authentication when trying to create a Helm release. If a Helm release is created using a URL and selecting a particular secret for authentication, the users are unable to change the secrets during upgrade. This poses a problem if the secret's name has been changed or removed.

Solution description:

Create a dropdown where the secret can be entered during upgrade. If no secret is entered, it will go with the existing secret name if it exists, otherwise the new secret will override the old one.
Screenshots / screen recording:

https://docs.google.com/document/d/1LDRXScwr_jOnvdWU0siqW1gBMM8hrhm3D0oz831gUPA/edit?tab=t.mcv80hqh092h#heading=h.2jo1jtiyytic
Test setup:

An OCI registry and a Helm repository requiring authentication via username and password.

Additional Information:
Rebased on #16676

Reviewers and assignees:

Summary by CodeRabbit

  • New Features
    • Added Basic Auth Secret selection for Helm chart install/upgrade from URLs, including fuzzy autocomplete, “Create Secret” actions, and inline missing-Secret warnings.
    • Added a modal to create kubernetes.io/basic-auth Secrets with required validation and reserved-name protection, integrated into the wizard flow.
  • Bug Fixes
    • Improved unauthorized/401 chart URL failures to explicitly request a Secret containing username and password.
    • Refined upgrade handling for auth-secret/annotations, including __none__ clearing and more defensive annotation copying.
  • Documentation
    • Expanded and clarified localized Basic Auth Secret wizard text and error messages.
  • Tests
    • Added UI tests for the create-secret modal and extended upgrade/auth-secret coverage.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a806eb34-a614-44a8-b7be-1915ee912cbe

📥 Commits

Reviewing files that changed from the base of the PR and between cdb0587 and 453eaf5.

📒 Files selected for processing (5)
  • frontend/packages/helm-plugin/locales/en/helm-plugin.json
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmURLChartForm.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmURLInstallForm.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/useBasicAuthSecretDropdown.ts
💤 Files with no reviewable changes (1)
  • frontend/packages/helm-plugin/locales/en/helm-plugin.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/packages/helm-plugin/src/components/forms/url-chart/useBasicAuthSecretDropdown.ts
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmURLChartForm.tsx
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx

Walkthrough

Helm URL installations and upgrades now support selecting or creating Kubernetes basic-auth Secrets. Secret names flow from chart annotations through frontend forms and handlers into Helm actions, which add authentication-specific errors and explicit Secret-clearing behavior.

Changes

Helm URL basic-auth flow

Layer / File(s) Summary
Create and select authentication Secrets
frontend/packages/helm-plugin/src/components/forms/url-chart/*, frontend/packages/helm-plugin/locales/en/helm-plugin.json
Adds a basic-auth Secret creation modal, dropdown actions, localized fields, validation, and tests.
Form state and submission wiring
frontend/packages/helm-plugin/src/components/forms/install-upgrade/*
Loads chart annotations, enables Secret selection for URL installs, warns about missing Secrets, and conditionally submits the selected Secret name.
Backend authentication and upgrade plumbing
pkg/helm/actions/*, pkg/helm/handlers/*, pkg/helm/actions/upgrade_release_test.go
Propagates Secret names, supports explicit Secret clearing, preserves installation annotations, returns authentication-specific errors, and tests the updated behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HelmInstallUpgradePage
  participant HelmInstallUpgradeForm
  participant HelmHandlers
  participant UpgradeReleaseAsync
  participant HelmRegistry
  HelmInstallUpgradePage->>HelmInstallUpgradeForm: provide URL-install state and Secret name
  HelmInstallUpgradeForm->>HelmHandlers: submit basicAuthSecretName
  HelmHandlers->>UpgradeReleaseAsync: pass Secret name
  UpgradeReleaseAsync->>HelmRegistry: locate chart with authentication
  HelmRegistry-->>UpgradeReleaseAsync: chart or authentication error
Loading

Possibly related PRs

  • openshift/console#16360: Wires basic-auth Secret selection through Helm URL forms, handlers, and chart-fetch actions.

Suggested labels: lgtm, verified

Suggested reviewers: baijum, webbnh

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
Title check ✅ Passed The title is specific and matches the main change: adding Secret selection for Helm release upgrades.
Description check ✅ Passed The description covers the root cause, solution, screenshot link, test setup, and extra info, though test cases and browser conformance are missing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed No Ginkgo-style titles were added; the touched tests use static Test... names and fixed Jest titles with no dynamic values.
Test Structure And Quality ✅ Passed No Ginkgo specs were added or modified; the changed tests are plain Go/Jest unit tests with no BeforeEach/Eventually cluster patterns, so this check is not applicable.
Microshift Test Compatibility ✅ Passed The added tests are unit tests (Jest/Go Test*), not Ginkgo e2e specs, and they don't reference MicroShift-unsupported OpenShift APIs or assumptions.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the changed Go tests are plain unit tests and the frontend spec has no cluster-topology assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed The PR only updates Helm UI/actions and secret-handling logic; no manifests, controllers, or scheduling constraints were added.
Ote Binary Stdout Contract ✅ Passed Patch only changes frontend helm-plugin TS/JSON files; no process-level entrypoints or stdout/logging writes were introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the changed tests are unit/frontend tests using fake clients and localhost, with no IPv4-only parsing or public internet dependencies.
No-Weak-Crypto ✅ Passed No weak crypto primitives, custom crypto, or secret/token comparisons were added; the touched auth code only handles Secrets and error strings.
Container-Privileges ✅ Passed Changed files are only frontend TS/JSON; targeted search found no privileged, hostPID/hostNetwork/hostIPC, SYS_ADMIN, or allowPrivilegeEscalation settings in touched files.
No-Sensitive-Data-In-Logs ✅ Passed No new sensitive logs were introduced; the only logging change removed klog.Errorf calls and the added messages are returned errors, not logs.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci
openshift-ci Bot requested review from baijum and webbnh July 21, 2026 09:25
@openshift-ci openshift-ci Bot added component/backend Related to backend component/helm Related to helm-plugin approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated labels Jul 21, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/helm/actions/install_chart.go (1)

339-347: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Missing "none" sentinel handling — mirrors a gap fixed in upgrade_release.go.

upgrade_release.go's UpgradeReleaseAsync treats basicAuthSecretName == "__none__" as an explicit "no auth" request and clears it before doing anything else. InstallChartFromURL has no equivalent handling, so if a user selects "None" in HelmInstallUpgradeForm.tsx during a fresh Create/install flow (the dropdown's "None" action item isn't gated to Upgrade-only), the literal string "__none__" is sent as basicAuthSecretName here, and GetUserCredentials(coreClient, ns, "__none__") will fail looking up a Secret literally named "__none__" — producing a confusing error instead of the intended "no basic auth" behavior.

🐛 Suggested fix (mirrors upgrade_release.go)
+	if basicAuthSecretName == "__none__" {
+		basicAuthSecretName = ""
+	}
 	if basicAuthSecretName != "" {
 		userCredentials, err := GetUserCredentials(coreClient, ns, basicAuthSecretName)
🤖 Prompt for 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.

In `@pkg/helm/actions/install_chart.go` around lines 339 - 347, Update
InstallChartFromURL before the basic-auth credential lookup to treat
basicAuthSecretName == "__none__" as an explicit no-auth request by clearing it.
Preserve the existing credential retrieval and applyBasicAuthFromUserCredentials
flow for all other non-empty secret names.
🧹 Nitpick comments (2)
pkg/helm/actions/upgrade_release_test.go (1)

703-793: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

No test coverage for the "__none__" explicit-clear sentinel.

TestUpgradeAfterURLInstallWithSecrets verifies the auth-secret annotation is preserved across an upgrade, but there's no test asserting that passing basicAuthSecretName = "__none__" actually clears auth_secret and skips credential lookup (the new explicitlyClearedSecret logic in upgrade_release.go). A regression there would silently restore the old secret via the annotation fallback instead of honoring the user's explicit "None" selection.

🤖 Prompt for 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.

In `@pkg/helm/actions/upgrade_release_test.go` around lines 703 - 793, The test
suite needs coverage for the "__none__" explicit-clear path in
TestUpgradeAfterURLInstallWithSecrets. Add a case that passes
basicAuthSecretName as "__none__", verifies the upgrade does not look up
credentials, and asserts the resulting chart metadata clears auth_secret instead
of restoring the annotated secret through fallback.
pkg/helm/actions/get_chart.go (1)

87-89: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Extract the duplicated "registry requires authentication" detection into a shared helper.

The same strings.Contains(err.Error(), "401") || strings.Contains(err.Error(), "unauthorized") check, guarded by an empty basicAuthSecretName, is copy-pasted into three files. A single isAuthRequiredError(err error) bool (or similar) helper in the actions package would keep the heuristic (and any future refinement, e.g. adding "403"/"forbidden") consistent across all three call sites instead of relying on manual sync.

  • pkg/helm/actions/get_chart.go#L87-L89: replace the inline strings.Contains check in GetChartFromURL with a call to the shared helper.
  • pkg/helm/actions/install_chart.go#L361-L363: replace the inline check in InstallChartFromURL with the same helper.
  • pkg/helm/actions/upgrade_release.go#L225-L241: replace the inline check in UpgradeReleaseAsync with the same helper.
🤖 Prompt for 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.

In `@pkg/helm/actions/get_chart.go` around lines 87 - 89, The
authentication-required error detection is duplicated across three call sites;
extract it into one shared actions-package helper and reuse it while preserving
the existing empty basicAuthSecretName guard. Update GetChartFromURL in
pkg/helm/actions/get_chart.go (lines 87-89), InstallChartFromURL in
pkg/helm/actions/install_chart.go (lines 361-363), and UpgradeReleaseAsync in
pkg/helm/actions/upgrade_release.go (lines 225-241) to call the helper instead
of inline strings.Contains checks.
🤖 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
`@frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx`:
- Around line 83-84: Update the Helm install path to handle the __none__ secret
sentinel consistently with the upgrade path. In the install chart action,
recognize the NONE_SECRET_KEY value and skip secret creation or attachment when
selected, while preserving existing behavior for CREATE_SECRET_KEY and actual
secret keys.

---

Outside diff comments:
In `@pkg/helm/actions/install_chart.go`:
- Around line 339-347: Update InstallChartFromURL before the basic-auth
credential lookup to treat basicAuthSecretName == "__none__" as an explicit
no-auth request by clearing it. Preserve the existing credential retrieval and
applyBasicAuthFromUserCredentials flow for all other non-empty secret names.

---

Nitpick comments:
In `@pkg/helm/actions/get_chart.go`:
- Around line 87-89: The authentication-required error detection is duplicated
across three call sites; extract it into one shared actions-package helper and
reuse it while preserving the existing empty basicAuthSecretName guard. Update
GetChartFromURL in pkg/helm/actions/get_chart.go (lines 87-89),
InstallChartFromURL in pkg/helm/actions/install_chart.go (lines 361-363), and
UpgradeReleaseAsync in pkg/helm/actions/upgrade_release.go (lines 225-241) to
call the helper instead of inline strings.Contains checks.

In `@pkg/helm/actions/upgrade_release_test.go`:
- Around line 703-793: The test suite needs coverage for the "__none__"
explicit-clear path in TestUpgradeAfterURLInstallWithSecrets. Add a case that
passes basicAuthSecretName as "__none__", verifies the upgrade does not look up
credentials, and asserts the resulting chart metadata clears auth_secret instead
of restoring the annotated secret through fallback.
🪄 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: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 048661ba-b60c-46bf-aafa-b785af51ccd5

📥 Commits

Reviewing files that changed from the base of the PR and between 6d0dcf1 and d346f64.

📒 Files selected for processing (11)
  • frontend/packages/helm-plugin/locales/en/helm-plugin.json
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradePage.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmCreateBasicAuthSecretModal.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmURLChartForm.tsx
  • pkg/helm/actions/get_chart.go
  • pkg/helm/actions/install_chart.go
  • pkg/helm/actions/upgrade_release.go
  • pkg/helm/actions/upgrade_release_test.go
  • pkg/helm/handlers/handler_test.go
  • pkg/helm/handlers/handlers.go

@martinszuc

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 21, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@martinszuc martinszuc removed their assignment Jul 21, 2026
@sowmya-sl sowmya-sl changed the title Add secrets for Helm release upgrade HELM-763: Add secrets for Helm release upgrade Jul 22, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 22, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

@sowmya-sl: This pull request references HELM-763 which is a valid jira issue.

Details

In response to this:

Analysis / Root cause:

Kubernetes Secret object is used to store username and password for authentication when trying to create a Helm release. If a Helm release is created using a URL and selecting a particular secret for authentication, the users are unable to change the secrets during upgrade. This poses a problem if the secret's name has been changed or removed.

Solution description:

Create a dropdown where the secret can be entered during upgrade. If no secret is entered, it will go with the existing secret name if it exists, otherwise the new secret will override the old one.
Screenshots / screen recording:

https://docs.google.com/document/d/1LDRXScwr_jOnvdWU0siqW1gBMM8hrhm3D0oz831gUPA/edit?tab=t.mcv80hqh092h#heading=h.2jo1jtiyytic
Test setup:

An OCI registry and a Helm repository requiring authentication via username and password.

Additional Information:
Rebased on #16676

Reviewers and assignees:

Summary by CodeRabbit

  • New Features
  • Added support for selecting or creating Kubernetes Secrets for basic authentication when installing or upgrading Helm charts from URLs.
  • Added a modal to create basic-auth Secrets (username and password/token) and integrated it into the Helm URL/installation flow.
  • Bug Fixes
  • Improved handling and messaging when registries require credentials (e.g., unauthorized/401 scenarios) and when secrets are missing.
  • Preserved and correctly propagated authentication and chart installation annotations during upgrades.
  • Documentation
  • Updated user-facing wizard text ordering and added new localization strings for basic-auth secret creation and labels.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@jhadvig jhadvig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sowmya-sl a few things to address, see inline comments for details.

onClose?: () => void;
}

const HelmCreateBasicAuthSecretModal: OverlayComponent<HelmCreateBasicAuthSecretModalProps> = ({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This modal calls k8sCreate to create Kubernetes Secrets but has no unit tests. Would be good to cover at least:

  • Required field validation (Create button disabled when fields empty)
  • Correct Secret shape passed to k8sCreate (kubernetes.io/basic-auth type, stringData with username/password)
  • save callback invoked with the created secret name on success
  • Error state rendered on k8sCreate failure
  • Cancel/close behavior

Same gap for the secret dropdown + missing-secret warning in HelmInstallUpgradeForm.tsx.... that form already has a test file at __tests__/HelmInstallUpgradeForm.spec.tsx that could be extended.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added unit tests for HelmCreateBasicAuthSecretModal in a new test file at __tests__/HelmCreateBasicAuthSecretModal.spec.tsx

isOpen
onClose={() => closeModal(true)}
title={t('Create authentication Secret')}
variant={ModalVariant.medium}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PF6 Modal doesn't have a title prop, this ends up as an HTML title attribute creating an unwanted browser tooltip on hover. The heading comes from <ModalHeader> below. Remove this prop and add aria-labelledby + labelId on ModalHeader to match codebase convention (see CreateProjectModal, HelmReadmeModal, etc).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added


<FormGroup label={t('Secret username')} isRequired fieldId="helm-secret-username">
<TextInput
id="helm-secret-username"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing isRequired on this TextInput, unlike the Secret name and password fields. The FormGroup shows a required asterisk but without isRequired on the input, screen readers won't announce aria-required. Add it for a11y parity.

const launchHelmCreateBasicAuthSecretModal = useHelmCreateBasicAuthSecretModal();
const [isCreateSecretModalOpen, setIsCreateSecretModalOpen] = useState(false);

const CREATE_SECRET_KEY = 'create-secret';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CREATE_SECRET_KEY and NONE_SECRET_KEY are defined inside the component body, recreated each render. NONE_SECRET_KEY is also used in the secretMissing useMemo without being in the deps array - react-hooks/exhaustive-deps would flag this. Hoist both to module scope.

setFieldValue('basicAuthSecretName', name);
};

const handleSecretChange = (key: string) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handleSecretChange / handleSecretSave / modal-launch logic is nearly identical to HelmURLChartForm.tsx (~25 lines). Consider extracting a shared hook (e.g. useBasicAuthSecretDropdown).... consistent with how useSecretResources was already pulled out.


const handleSecretChange = (key: string) => {
if (key === NONE_SECRET_KEY) {
window.setTimeout(() => setFieldValue('basicAuthSecretName', NONE_SECRET_KEY), 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

window.setTimeout(fn, 0) to race ResourceDropdownField's internal Formik write is a coupling to its implementation detail. If the dropdown ever updates via useEffect or batches differently, this silently breaks. Worth checking if ResourceDropdownField supports a controlled mode or pre-update callback to avoid this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I checked the ResourceDropdownField. Its onChange calls props.Onchange() first and then calls setFieldValue(..) synchronously on the same line. So the setTimeout(..) fires after write.
A cleaner fix would be to add a preventFormikWrite return value or controlled mode to ResourceDropdownField, but that's a change to a shared component and out of scope for this PR.

secretsDriver := driver.NewSecrets(coreClient.Secrets(tt.releaseNamespace))
go func() {
upgradeResult, upgradeErr := UpgradeReleaseAsync(tt.releaseNamespace, tt.releaseName, "", nil, actionConfig, dynamicClient, coreClient, true, "")
upgradeResult, upgradeErr := UpgradeReleaseAsync(tt.releaseNamespace, tt.releaseName, "", nil, actionConfig, dynamicClient, coreClient, true, "", "")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test passes "" as basicAuthSecretName, only exercising the annotation-fallback path. Missing test cases for:

  • Non-empty basicAuthSecretName overriding the annotation value
  • "__none__" sentinel clearing the annotation-based secret
  • The klog.Errorf -> return error change for GetUserCredentials/applyBasicAuthFromUserCredentials failures (behavior change, errors now propagate instead of being silently logged)
  • 401/unauthorized error enrichment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added tests

...(chartURL ? { chart_url: chartURL } : {}), // eslint-disable-line @typescript-eslint/naming-convention
...(indexEntry ? { indexEntry } : { indexEntry: chartIndexEntry }),
...(valuesObj ? { values: valuesObj } : {}),
...(values.isURLInstall ? { basic_auth_secret_name: basicAuthSecretName } : {}), // eslint-disable-line @typescript-eslint/naming-convention

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The auth secret selection/clearing during upgrade has no e2e coverage. The existing Cypress features (install-url-chart.feature) test the general upgrade flow but not the new secret interactions. Worth adding at least a basic scenario.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed this would be valuable. However, adding e2e coverage for the auth secret interactions requires a private chart registry in the test environment (to trigger the auth flow end-to-end), which is new infrastructure not currently available in CI.
I'll file a follow-up ticket to add this once we have a test registry setup.

@openshift-ci openshift-ci Bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed lgtm Indicates that a PR is ready to be merged. labels Jul 23, 2026
sowmya-sl and others added 4 commits July 23, 2026 16:41
…tching

- Pass basicAuthSecretName through UpgradeReleaseAsync to support
  auth credentials during chart upgrades
- Use __none__ sentinel to allow users to explicitly clear a secret
- Preserve installation annotation on upgrade to maintain URL-install
  tracking across revisions
- Return errors instead of logging on auth credential failures so
  the frontend can surface them
- Add 401/unauthorized detection in GetChartFromURL, InstallChartFromURL,
  and UpgradeReleaseAsync with actionable error messages
- Update handler signature, mock, and tests for the new parameter
…orms

- Add HelmCreateBasicAuthSecretModal for creating kubernetes.io/basic-auth
  secrets with username/password from within the Helm forms
- Add auth secret dropdown with 'None' and 'Create Secret' options to
  HelmInstallUpgradeForm, shown when upgrading a URL-installed chart
- Detect URL-installed charts via 'installation' annotation and read
  initial auth secret from 'helm.openshift.io/auth-secret' annotation
- Pass basicAuthSecretName through to the upgrade API payload
- Use __none__ sentinel to allow explicitly clearing a previously set secret
- Show warning when a previously referenced secret no longer exists
- Add auth secret dropdown to HelmURLChartForm for URL-based chart installs
- Make 401/unauthorized error detection case-insensitive across
  get_chart, install_chart, and upgrade_release
- Capitalize 'Basic' in 'Secret for Basic authentication' label
- Extract secretName.trim() to a single variable in the modal
- Remove duplicate locale key for 'Secret for Basic authentication'

Co-authored-by: Cursor <cursoragent@cursor.com>
- Add unit tests for HelmCreateBasicAuthSecretModal covering field
  validation, k8sCreate shape, save callback, error state, and cancel
- Add backend tests for explicit secret override, __none__ sentinel
  clearing, and credential lookup error propagation
- Extract useBasicAuthSecretDropdown shared hook from duplicated logic
  in HelmInstallUpgradeForm and HelmURLChartForm
- Hoist CREATE_SECRET_KEY and NONE_SECRET_KEY to module scope
- Use NONE_SECRET_KEY constant in HelmInstallUpgradePage payload
- Fix PF6 Modal: remove title prop, add aria-labelledby + labelId
- Add missing isRequired on username TextInput for a11y parity
- Export HelmCreateBasicAuthSecretModal for test imports

Co-authored-by: Cursor <cursoragent@cursor.com>
@sowmya-sl
sowmya-sl force-pushed the add-secrets-helm-upgrade branch from 16c16b3 to a90ac5e Compare July 23, 2026 11:13
@openshift-ci openshift-ci Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 23, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/packages/helm-plugin/locales/en/helm-plugin.json (1)

2-42: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Remove the duplicate localization keys.

The inserted blocks redeclare many keys already present later in the same JSON object (None, Select, Next, Chart URL, Helm release, and others). Biome reports these as errors, so the locale file can fail linting and different parsers may retain different values. Keep one definition per key in the canonical locale block.

Also applies to: 55-89

🤖 Prompt for 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.

In `@frontend/packages/helm-plugin/locales/en/helm-plugin.json` around lines 2 -
42, Remove the newly inserted duplicate localization entries from the English
Helm plugin locale object, including keys such as “Chart URL”, “None”, “Select”,
“Next”, and “Helm release” that already exist in the canonical locale block.
Preserve one definition of each key and retain the existing canonical values so
the JSON contains no duplicate keys.

Source: Linters/SAST tools

🤖 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 `@pkg/helm/actions/upgrade_release.go`:
- Around line 109-117: Guard rel.Chart.Metadata before accessing its Annotations
when copying the installation value in both upgrade paths:
pkg/helm/actions/upgrade_release.go lines 109-117 and UpgradeReleaseAsync at
lines 263-265. Preserve the existing chart annotation updates, but only read
rel.Chart.Metadata.Annotations when metadata is non-nil.

---

Outside diff comments:
In `@frontend/packages/helm-plugin/locales/en/helm-plugin.json`:
- Around line 2-42: Remove the newly inserted duplicate localization entries
from the English Helm plugin locale object, including keys such as “Chart URL”,
“None”, “Select”, “Next”, and “Helm release” that already exist in the canonical
locale block. Preserve one definition of each key and retain the existing
canonical values so the JSON contains no duplicate keys.
🪄 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: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bca7a3b0-0889-45d1-a6d8-b6103060270b

📥 Commits

Reviewing files that changed from the base of the PR and between 16c16b3 and a90ac5e.

📒 Files selected for processing (13)
  • frontend/packages/helm-plugin/locales/en/helm-plugin.json
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradePage.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmCreateBasicAuthSecretModal.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmURLChartForm.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/__tests__/HelmCreateBasicAuthSecretModal.spec.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/useBasicAuthSecretDropdown.ts
  • pkg/helm/actions/get_chart.go
  • pkg/helm/actions/install_chart.go
  • pkg/helm/actions/upgrade_release.go
  • pkg/helm/actions/upgrade_release_test.go
  • pkg/helm/handlers/handler_test.go
  • pkg/helm/handlers/handlers.go
🚧 Files skipped from review as they are similar to previous changes (11)
  • pkg/helm/actions/get_chart.go
  • pkg/helm/handlers/handler_test.go
  • frontend/packages/helm-plugin/src/components/forms/url-chart/useBasicAuthSecretDropdown.ts
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmURLChartForm.tsx
  • pkg/helm/handlers/handlers.go
  • pkg/helm/actions/install_chart.go
  • frontend/packages/helm-plugin/src/components/forms/url-chart/tests/HelmCreateBasicAuthSecretModal.spec.tsx
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradePage.tsx
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx
  • pkg/helm/actions/upgrade_release_test.go
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmCreateBasicAuthSecretModal.tsx

Comment thread pkg/helm/actions/upgrade_release.go
Fix i18n locale file. Also add guard for rel.Chart.Metadata reference.
@sowmya-sl
sowmya-sl force-pushed the add-secrets-helm-upgrade branch from db0dfc0 to 03abe52 Compare July 23, 2026 13:21
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 24, 2026
@sowmya-sl

Copy link
Copy Markdown
Contributor Author

/verified by @sowmya-sl

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jul 24, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@sowmya-sl: This PR has been marked as verified by @sowmya-sl.

Details

In response to this:

/verified by @sowmya-sl

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@jhadvig jhadvig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor items from a second pass:

  1. The old i18n key "A secret with \"username\" and \"password\" keys for OCI/HTTP(S) authentication" (line 9 of helm-plugin.json) is orphaned - no code references it anymore after the switch to the {{username}}/{{password}} interpolated variant. Running yarn i18n should clean it up.

  2. See inline comment on useBasicAuthSecretDropdown.ts.

import { useState, useCallback } from 'react';
import { useHelmCreateBasicAuthSecretModal } from './HelmCreateBasicAuthSecretModal';

const CREATE_SECRET_KEY = 'create-secret';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'create-secret' is a valid Kubernetes secret name. If a user happens to have a secret with that exact name, clicking it in the dropdown matches key === CREATE_SECRET_KEY and opens the Create Secret modal instead of selecting the existing secret. NONE_SECRET_KEY avoids this with '__none__'.... same convention here would fix it, e.g. '__create_secret__'.

@webbnh webbnh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good...just one nit for your consideration.

/lgtm

Comment on lines +66 to +67
// "__none__" is a sentinel used by the upgrade path to clear auth; reject it as a secret name.
if (trimmedSecretName === '__none__') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be referencing NONE_SECRET_KEY instead of the literal '__none__'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but we can't import NONE_SECRET_KEY here because it would create a circular dependency

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 24, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@webbnh

webbnh commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews resumed.

@openshift-ci-robot

openshift-ci-robot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@sowmya-sl: This pull request references HELM-763 which is a valid jira issue.

Details

In response to this:

Analysis / Root cause:

Kubernetes Secret object is used to store username and password for authentication when trying to create a Helm release. If a Helm release is created using a URL and selecting a particular secret for authentication, the users are unable to change the secrets during upgrade. This poses a problem if the secret's name has been changed or removed.

Solution description:

Create a dropdown where the secret can be entered during upgrade. If no secret is entered, it will go with the existing secret name if it exists, otherwise the new secret will override the old one.
Screenshots / screen recording:

https://docs.google.com/document/d/1LDRXScwr_jOnvdWU0siqW1gBMM8hrhm3D0oz831gUPA/edit?tab=t.mcv80hqh092h#heading=h.2jo1jtiyytic
Test setup:

An OCI registry and a Helm repository requiring authentication via username and password.

Additional Information:
Rebased on #16676

Reviewers and assignees:

Summary by CodeRabbit

  • New Features
  • Added basic-auth Secret selection for Helm chart install/upgrade from URLs, including fuzzy autocomplete, “Create Secret” actions, and inline missing-Secret warnings.
  • Added a modal to create kubernetes.io/basic-auth Secrets with required validation and reserved-name protection, integrated into the wizard flow.
  • Bug Fixes
  • Improved unauthorized/401 errors to explicitly guide selecting a basic-auth Secret.
  • Refined upgrade auth-secret/annotation behavior, including __none__ clearing and more reliable annotation copying.
  • Documentation
  • Updated localized wizard text for basic-auth Secret labels and error states.
  • Tests
  • Added UI tests for the create-secret modal and expanded upgrade/auth-secret test coverage.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/helm/actions/upgrade_release.go (1)

230-234: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Clean up TLS files on authentication failures.

setUpAuthentication* can populate tlsFiles before these returns, but cleanup is deferred only inside the goroutine at Lines 283-291. With fileCleanUp enabled, credential lookup or application failures therefore leak temporary files. Use a shared cleanup closure for these early returns, while transferring cleanup ownership to the goroutine only after it starts.

🤖 Prompt for 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.

In `@pkg/helm/actions/upgrade_release.go` around lines 230 - 234, Ensure
authentication failures in the upgrade flow clean up any TLS files created by
setUpAuthentication* before returning. Define a shared cleanup closure for the
early credential lookup and applyBasicAuthFromUserCredentials error paths, then
transfer cleanup ownership to the goroutine only after it starts so cleanup
occurs exactly once.
🤖 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.

Outside diff comments:
In `@pkg/helm/actions/upgrade_release.go`:
- Around line 230-234: Ensure authentication failures in the upgrade flow clean
up any TLS files created by setUpAuthentication* before returning. Define a
shared cleanup closure for the early credential lookup and
applyBasicAuthFromUserCredentials error paths, then transfer cleanup ownership
to the goroutine only after it starts so cleanup occurs exactly once.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 792bb7b6-a112-49e2-bea0-91fc8669dc12

📥 Commits

Reviewing files that changed from the base of the PR and between a90ac5e and cdb0587.

📒 Files selected for processing (6)
  • frontend/packages/helm-plugin/locales/en/helm-plugin.json
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmCreateBasicAuthSecretModal.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmURLChartForm.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/useBasicAuthSecretDropdown.ts
  • pkg/helm/actions/upgrade_release.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • frontend/packages/helm-plugin/src/components/forms/url-chart/useBasicAuthSecretDropdown.ts
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmURLChartForm.tsx
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmCreateBasicAuthSecretModal.tsx

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews resumed.

- Fix autocompleteFilter crash when fuzzysearch receives undefined
  haystack for non-React-element items; fall back to string value or key
- Rename CREATE_SECRET_KEY from 'create-secret' to '__create_secret__'
  to prevent collision with a real Kubernetes secret of that name
- Align HelmURLInstallForm help text to use interpolated i18n variant
  and remove orphaned locale key

Co-authored-by: Cursor <cursoragent@cursor.com>
@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Jul 24, 2026
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 24, 2026
@sowmya-sl

Copy link
Copy Markdown
Contributor Author

/verified by @sowmya-sl

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jul 24, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@sowmya-sl: This PR has been marked as verified by @sowmya-sl.

Details

In response to this:

/verified by @sowmya-sl

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@sowmya-sl

Copy link
Copy Markdown
Contributor Author

@jhadvig Addressed your comments. Please check.

@webbnh webbnh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 24, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: martinszuc, sowmya-sl, webbnh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@webbnh

webbnh commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Did you see Coderabbitai's concern?

pkg/helm/actions/upgrade_release.go 230-234: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Clean up TLS files on authentication failures.

setUpAuthentication* can populate tlsFiles before these returns, but cleanup is deferred only inside the goroutine at Lines 283-291. With fileCleanUp enabled, credential lookup or application failures therefore leak temporary files. Use a shared cleanup closure for these early returns, while transferring cleanup ownership to the goroutine only after it starts.

It sounds like some of your additions contribute to this problem.

@webbnh

webbnh commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

/test backend

@sowmya-sl

Copy link
Copy Markdown
Contributor Author

/retest

@sowmya-sl

Copy link
Copy Markdown
Contributor Author

@webbnh The path where we use repository and TLS files and the path where we use authentication secret are mutually exclusive. So there is no fear of TLS files being created and not deleted later.

@openshift-ci

openshift-ci Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@sowmya-sl: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-playwright 453eaf5 link false /test e2e-playwright

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/backend Related to backend component/helm Related to helm-plugin jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants