Skip to content

Conversation

@upalatucci
Copy link
Member

@upalatucci upalatucci commented Feb 9, 2026

Summary

Adds optional TLS certificate support when creating a bootable volume from an HTTP URL for HTTPS sources with a custom or self-signed CA.

Changes

  • TLS certificate section (URL source): TLS certificate required checkbox; Use existing / Add new (horizontal). Use existing: Project + TLS certificate dropdowns. Add new: FileUpload (upload or paste PEM).
  • Validation: Save disabled when TLS required but no cert selected or provided.
  • Backend: TLS cert ConfigMap created in destination project; DataSource, DataVolume and ConfigMap use explicit namespace; cross-namespace cert copy supported.
  • Error handling: Orphaned TLS ConfigMap is cleaned up if DataVolume creation fails after the ConfigMap was already created.
  • Error handling: Error from useTlsCertConfigMaps is now surfaced to the user via an inline alert instead of showing an empty dropdown.
  • Terminology: Unified label from "TLS certification" to "TLS certificate" across the UI.
  • Code cleanup: Destructured TLS fields at the top of TlsCertificateSection for readability. Used TLS_CERT_FIELD_NAMES consts in setBootableVolumeField calls. Reset tlsCertSource to "Use existing" when the TLS checkbox is toggled on.

Jira: https://issues.redhat.com/browse/CNV-79324

Demo

Screen.Recording.2026-02-09.at.18.02.58.mov
Screen.Recording.2026-02-09.at.18.06.54.mov

Summary by CodeRabbit

  • New Features

    • TLS certificate management when adding bootable volumes: upload PEM certificates or choose existing cluster certificates for HTTPS sources.
    • Improved form validation for bootable volume creation (affects submit enablement and TLS requirement flows).
  • Localization

    • Added translation strings for TLS/certificate prompts and guidance in English, Spanish, French, Japanese, Korean, and Chinese.

@openshift-ci openshift-ci bot requested review from batyana and pcbailey February 9, 2026 15:19
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 9, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: upalatucci

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

@openshift-ci openshift-ci bot added the approved This issue is something we want to fix label Feb 9, 2026
@upalatucci upalatucci changed the title feat(Add bootable volume): TLS certificate for HTTP URL source CNV-79324: TLS certificate for HTTP URL source Feb 9, 2026
@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Feb 9, 2026

@upalatucci: This pull request references CNV-79324 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target either version "4.22." or "openshift-4.22.", but it targets "CNV v4.22.0" instead.

Details

In response to this:

Summary

Adds optional TLS certification when creating a bootable volume from an HTTP URL for HTTPS sources with a custom or self-signed CA.

Changes

  • TLS certification section (URL source): TLS certificate required checkbox; Use existing / Add new (horizontal). Use existing: Project + TLS certification dropdowns. Add new: FileUpload (upload or paste PEM).
  • Validation: Save disabled when TLS required but no cert selected or provided.
  • Backend: TLS cert ConfigMap created in destination project; DataSource, DataVolume and ConfigMap use explicit namespace; cross-namespace cert copy supported

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.

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Feb 9, 2026

@upalatucci: This pull request references CNV-79324 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target either version "4.22." or "openshift-4.22.", but it targets "CNV v4.22.0" instead.

Details

In response to this:

Summary

Adds optional TLS certification when creating a bootable volume from an HTTP URL for HTTPS sources with a custom or self-signed CA.

Changes

  • TLS certification section (URL source): TLS certificate required checkbox; Use existing / Add new (horizontal). Use existing: Project + TLS certification dropdowns. Add new: FileUpload (upload or paste PEM).
  • Validation: Save disabled when TLS required but no cert selected or provided.
  • Backend: TLS cert ConfigMap created in destination project; DataSource, DataVolume and ConfigMap use explicit namespace; cross-namespace cert copy supported

DEMO

Screen.Recording.2026-02-09.at.18.02.58.mov

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.

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Feb 9, 2026

@upalatucci: This pull request references CNV-79324 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target either version "4.22." or "openshift-4.22.", but it targets "CNV v4.22.0" instead.

Details

In response to this:

Summary

Adds optional TLS certification when creating a bootable volume from an HTTP URL for HTTPS sources with a custom or self-signed CA.

Changes

  • TLS certification section (URL source): TLS certificate required checkbox; Use existing / Add new (horizontal). Use existing: Project + TLS certification dropdowns. Add new: FileUpload (upload or paste PEM).
  • Validation: Save disabled when TLS required but no cert selected or provided.
  • Backend: TLS cert ConfigMap created in destination project; DataSource, DataVolume and ConfigMap use explicit namespace; cross-namespace cert copy supported

DEMO

Screen.Recording.2026-02-09.at.18.02.58.mov
Screen.Recording.2026-02-09.at.18.06.54.mov

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.

const { registryCredentials, registryURL } = bootableVolume;
const { password, username } = registryCredentials || {};

const credentialsValid = (username && password) || (!username && !password);
Copy link
Member

Choose a reason for hiding this comment

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

I think the type of credentialsValid should be a boolean, therefor its name should be
areCredentialsValid
We can use areCredentialsValid = !username === !password

Copy link
Member Author

Choose a reason for hiding this comment

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

i don't like !username === !password as its difficult to read and understand but i'll do something different

@upalatucci upalatucci force-pushed the feature/add-bootable-volume-tls-certificate branch from c570648 to 88588a4 Compare February 10, 2026 09:19
@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Adds TLS certificate support to AddBootableVolumeModal: new UI components for selecting/uploading certificates, new hooks for validation and fetching TLS ConfigMaps, constants and utils to create/resolve TLS ConfigMaps, and localization strings across multiple locales.

Changes

Cohort / File(s) Summary
Localization
locales/en/plugin__kubevirt-plugin.json, locales/es/plugin__kubevirt-plugin.json, locales/fr/plugin__kubevirt-plugin.json, locales/ja/plugin__kubevirt-plugin.json, locales/ko/plugin__kubevirt-plugin.json, locales/zh/plugin__kubevirt-plugin.json
Added TLS and certificate-related i18n keys and translations (PEM guidance, URL example, TLS certificate labels and prompts).
Modal component
src/utils/components/AddBootableVolumeModal/AddBootableVolumeModal.tsx
Moved form validation into new hook useAddBootableVolumeFormValidation, removed inline useMemo validation and label extraction.
VolumeSource / HTTPSource
src/utils/components/AddBootableVolumeModal/components/VolumeSource/VolumeSource.tsx, src/utils/components/AddBootableVolumeModal/components/VolumeSource/components/HTTPSource.tsx
HTTPSource now receives bootableVolume prop; URL helper text moved inline; integrated TlsCertificateSection into HTTP source UI.
TLS components
src/utils/components/AddBootableVolumeModal/components/VolumeSource/components/TlsCertificate/*
Added TlsCertificateSection, TlsCertificateExisting, TlsCertificateNew, and an index.ts barrel export to provide UI for required TLS certs, selecting existing ConfigMaps, or uploading PEM.
Validation & data hooks
src/utils/components/AddBootableVolumeModal/hooks/useAddBootableVolumeFormValidation.ts, src/utils/components/AddBootableVolumeModal/hooks/useTlsCertConfigMaps.ts
New hook useAddBootableVolumeFormValidation for registry/TLS form validation; useTlsCertConfigMaps fetches and filters ConfigMaps containing TLS data.
Constants & utils
src/utils/components/AddBootableVolumeModal/utils/constants.ts, src/utils/components/AddBootableVolumeModal/utils/utils.ts
Added TLS constants and field names, extended AddBootableVolumeState with TLS fields and defaults, added TLS ConfigMap key, and helpers to create/clone TLS ConfigMaps and wire them into HTTP DataSource creation/cleanup.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

lgtm

Suggested reviewers

  • pcbailey
  • batyana
  • vojtechszocs
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main feature: adding TLS certificate support for HTTP URL sources in bootable volume creation.
Description check ✅ Passed The description provides comprehensive details covering summary, implementation details, validation, backend changes, error handling, terminology changes, code cleanup, and references a Jira ticket with demo videos.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

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

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Feb 10, 2026

@upalatucci: This pull request references CNV-79324 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target either version "4.22." or "openshift-4.22.", but it targets "CNV v4.22.0" instead.

Details

In response to this:

Summary

Adds optional TLS certification when creating a bootable volume from an HTTP URL for HTTPS sources with a custom or self-signed CA.

Changes

  • TLS certification section (URL source): TLS certificate required checkbox; Use existing / Add new (horizontal). Use existing: Project + TLS certification dropdowns. Add new: FileUpload (upload or paste PEM).
  • Validation: Save disabled when TLS required but no cert selected or provided.
  • Backend: TLS cert ConfigMap created in destination project; DataSource, DataVolume and ConfigMap use explicit namespace; cross-namespace cert copy supported

DEMO

Screen.Recording.2026-02-09.at.18.02.58.mov
Screen.Recording.2026-02-09.at.18.06.54.mov

Summary by CodeRabbit

Release Notes

  • New Features
  • TLS certificate management for bootable volumes with HTTPS sources. Users can upload PEM-encoded certificates or select from existing certificate configurations within their cluster.
  • Localization enhancements with new translation keys for TLS certificate handling and configuration dialogs across six languages including English, Spanish, French, Japanese, Korean, and Chinese.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Fix all issues with AI agents
In
`@src/utils/components/AddBootableVolumeModal/components/VolumeSource/components/TlsCertificate/TlsCertificateExisting.tsx`:
- Line 57: The FormGroup label in TlsCertificateExisting.tsx currently uses the
inconsistent translation key t('TLS certification'); update it to the same term
used in TlsCertificateSection by changing the label to t('TLS certificate') (or
the shared translation key used by TlsCertificateSection) so the displayed label
and i18n key match across the TlsCertificate components; locate the FormGroup
instance in TlsCertificateExisting and replace the translation key accordingly.
- Line 29: The component TlsCertificateExisting currently ignores the third
return value from the useTlsCertConfigMaps hook; update the
TlsCertificateExisting component to capture the error (e.g. const
[tlsCertConfigMaps, certMapsLoaded, certMapsError] = useTlsCertConfigMaps(...))
and handle it by either logging (console.error or processLogger) and/or
rendering user-facing feedback (an inline Alert, helper text near the dropdown,
or a disabled dropdown with an error message) so users aren’t shown a silent
empty dropdown when the watch fails; ensure you reference tlsCertConfigMaps,
certMapsLoaded and certMapsError when deciding to show the normal dropdown vs
the error UI.

In
`@src/utils/components/AddBootableVolumeModal/components/VolumeSource/components/TlsCertificate/TlsCertificateSection.tsx`:
- Around line 88-93: The "Add new" radio becomes selected when tlsCertSource is
undefined because useExisting is computed from tlsCertSource; to make "Use
existing" the default initialize tlsCertSource to TLS_CERT_SOURCE_EXISTING or
set it when tlsCertificateRequired is toggled on: update the component state
initialization or the handler that toggles tlsCertificateRequired to assign
tlsCertSource = TLS_CERT_SOURCE_EXISTING (or call the setter used for
tlsCertSource) so useExisting is true by default; relevant symbols:
tlsCertSource, useExisting, tlsCertificateRequired, TLS_CERT_SOURCE_EXISTING,
and the radio with id "tls-add-new".
- Around line 46-49: The UI uses inconsistent wording: the FormGroup label prop
in TlsCertificateSection is "TLS certification" but the checkbox (inside the
same component) reads "TLS certificate required"; update the FormGroup label to
use the standard term "TLS certificate" to match the checkbox and ensure
consistent terminology across the component (look for the FormGroup with
fieldId="tls-certification" and the checkbox label in TlsCertificateSection and
change the label prop accordingly).

In `@src/utils/components/AddBootableVolumeModal/utils/utils.ts`:
- Around line 240-277: getOrCreateTlsCertConfigMapName can create a new TLS
ConfigMap via createTlsCertConfigMap but if subsequent resource creation in
createHTTPDataSource (DataSource/DataVolume) fails the new ConfigMap is
orphaned; update createHTTPDataSource's error handling to track the ConfigMap
name returned by getOrCreateTlsCertConfigMapName and delete that ConfigMap in
the catch/failure path (call the inverse cleanup for createTlsCertConfigMap
using the same cluster/targetNamespace/name), or alternatively ensure
createHTTPDataSource documents that callers must clean up the ConfigMap;
reference getOrCreateTlsCertConfigMapName, createTlsCertConfigMap, and
createHTTPDataSource when making the change.
🧹 Nitpick comments (5)
locales/en/plugin__kubevirt-plugin.json (2)

676-677: Avoid near-duplicate i18n keys that only differ by trailing space.
There are now two keys for the same sentence (one with a trailing space). This increases translation churn and risks inconsistent usage. Please standardize on a single key and update call sites accordingly.


1489-1489: Use “certificate” consistently (avoid “certification”).
“TLS certification” and “Select TLS certification” read like typos given the adjacent “TLS certificate” strings. Align these to “certificate” and reuse existing keys where possible to avoid duplicate terminology.

💡 Suggested cleanup (update call sites + other locales accordingly)
-  "Select TLS certification": "Select TLS certification",
+  "Select TLS certificate": "Select TLS certificate",
@@
-  "TLS certification": "TLS certification",

Also applies to: 1759-1761

src/utils/components/AddBootableVolumeModal/AddBootableVolumeModal.tsx (1)

85-85: Wrap resetDiskSize in useCallback.

This arrow function is recreated every render and passed as a prop to <SourceTypeSelection> (Line 125), which may trigger unnecessary re-renders. As per coding guidelines, use React's memoization tools to avoid unnecessary re-renders.

Proposed fix
-  const resetDiskSize = () => setBootableVolumeField('size')(initialBootableVolumeState.size);
+  const resetDiskSize = useCallback(
+    () => setBootableVolumeField('size')(initialBootableVolumeState.size),
+    [setBootableVolumeField],
+  );
src/utils/components/AddBootableVolumeModal/components/VolumeSource/components/HTTPSource.tsx (1)

22-23: Extract httpSourceHelperURL as a module-level constant.

Per coding guidelines, define constants in utility files with uppercase and underscore-separated naming. This string is also recreated on every render unnecessarily.

Proposed fix
+const HTTP_SOURCE_HELPER_URL =
+  'https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2';
+
 const HTTPSource: FC<HTTPSourceProps> = ({ bootableVolume, setBootableVolumeField }) => {
   const { t } = useKubevirtTranslation();
-
-  const httpSourceHelperURL =
-    'https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2';

Then update the references on Lines 37–38 to use HTTP_SOURCE_HELPER_URL.

src/utils/components/AddBootableVolumeModal/components/VolumeSource/components/TlsCertificate/TlsCertificateExisting.tsx (1)

59-63: getName(cm) is called twice per item — extract to a local variable.

Proposed fix
-              options={tlsCertConfigMaps?.map((cm) => ({
-                children: getName(cm),
-                value: getName(cm),
-              }))}
+              options={tlsCertConfigMaps?.map((cm) => {
+                const name = getName(cm);
+                return { children: name, value: name };
+              })}

@upalatucci
Copy link
Member Author

/retest

1 similar comment
@upalatucci
Copy link
Member Author

/retest

const cluster = bootableVolume?.bootableVolumeCluster;
const tlsCertProject = bootableVolume?.tlsCertProject || bootableVolume?.bootableVolumeNamespace;
const [projectNames, projectsLoaded] = useProjects(cluster);
const [tlsCertConfigMaps, certMapsLoaded] = useTlsCertConfigMaps(tlsCertProject, cluster);
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to use error from useTlsCertConfigMaps?

if (!tlsRequired) return undefined;

const useExisting = bootableVolume?.tlsCertSource === TLS_CERT_SOURCE_EXISTING;
const tlsCertProject = bootableVolume?.tlsCertProject;
Copy link
Member

Choose a reason for hiding this comment

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

You can use the tlsCertProject const (const tlsCertProject = bootableVolume?.[tlsCertProject]

value: name,
}))}
setSelected={(name: string) => {
setBootableVolumeField('tlsCertProject')(name);
Copy link
Member

Choose a reason for hiding this comment

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

You can use the consts you created for tlsCertProject and tlsCertConfigMapName


const useExisting = bootableVolume?.tlsCertSource === TLS_CERT_SOURCE_EXISTING;
const tlsCertProject = bootableVolume?.tlsCertProject;
const tlsCertConfigMapName = bootableVolume?.tlsCertConfigMapName?.trim();
Copy link
Member

Choose a reason for hiding this comment

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

Same here [tlsCertConfigMapName]

if (!bootableVolume?.tlsCertProject && targetNamespace) {
setBootableVolumeField(TLS_CERT_FIELD_NAMES.tlsCertProject)(targetNamespace);
}
}, [targetNamespace, bootableVolume?.tlsCertProject, setBootableVolumeField]);
Copy link
Member

Choose a reason for hiding this comment

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

bootableVolume?.[tlsCertProject]

<FlexItem>
<Radio
onChange={() => {
setBootableVolumeField(TLS_CERT_FIELD_NAMES.tlsCertSource)(
Copy link
Member

Choose a reason for hiding this comment

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

I thing it would be cleaner to destruct tlsCertificate, tlsCertConfigMapName and tlsCertSource in the beginning of the code.

- Use existing: Project + TLS certification (ConfigMap) dropdowns, horizontal layout
- Add new: FileUpload for certificate (upload file or paste PEM)

Co-authored-by: Cursor <[email protected]>
@upalatucci upalatucci force-pushed the feature/add-bootable-volume-tls-certificate branch from 88588a4 to 2033eef Compare February 12, 2026 09:38
@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Feb 12, 2026

@upalatucci: This pull request references CNV-79324 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target either version "4.22." or "openshift-4.22.", but it targets "CNV v4.22.0" instead.

Details

In response to this:

Summary

Adds optional TLS certificate support when creating a bootable volume from an HTTP URL for HTTPS sources with a custom or self-signed CA.

Changes

  • TLS certificate section (URL source): TLS certificate required checkbox; Use existing / Add new (horizontal). Use existing: Project + TLS certificate dropdowns. Add new: FileUpload (upload or paste PEM).
  • Validation: Save disabled when TLS required but no cert selected or provided.
  • Backend: TLS cert ConfigMap created in destination project; DataSource, DataVolume and ConfigMap use explicit namespace; cross-namespace cert copy supported.
  • Error handling: Orphaned TLS ConfigMap is cleaned up if DataVolume creation fails after the ConfigMap was already created.
  • Error handling: Error from useTlsCertConfigMaps is now surfaced to the user via an inline alert instead of showing an empty dropdown.
  • Terminology: Unified label from "TLS certification" to "TLS certificate" across the UI.
  • Code cleanup: Destructured TLS fields at the top of TlsCertificateSection for readability. Used TLS_CERT_FIELD_NAMES consts in setBootableVolumeField calls. Reset tlsCertSource to "Use existing" when the TLS checkbox is toggled on.

Jira: https://issues.redhat.com/browse/CNV-79324

Demo

Screen.Recording.2026-02-09.at.18.02.58.mov
Screen.Recording.2026-02-09.at.18.06.54.mov

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.

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Feb 12, 2026

@upalatucci: This pull request references CNV-79324 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target either version "4.22." or "openshift-4.22.", but it targets "CNV v4.22.0" instead.

Details

In response to this:

Summary

Adds optional TLS certificate support when creating a bootable volume from an HTTP URL for HTTPS sources with a custom or self-signed CA.

Changes

  • TLS certificate section (URL source): TLS certificate required checkbox; Use existing / Add new (horizontal). Use existing: Project + TLS certificate dropdowns. Add new: FileUpload (upload or paste PEM).
  • Validation: Save disabled when TLS required but no cert selected or provided.
  • Backend: TLS cert ConfigMap created in destination project; DataSource, DataVolume and ConfigMap use explicit namespace; cross-namespace cert copy supported.
  • Error handling: Orphaned TLS ConfigMap is cleaned up if DataVolume creation fails after the ConfigMap was already created.
  • Error handling: Error from useTlsCertConfigMaps is now surfaced to the user via an inline alert instead of showing an empty dropdown.
  • Terminology: Unified label from "TLS certification" to "TLS certificate" across the UI.
  • Code cleanup: Destructured TLS fields at the top of TlsCertificateSection for readability. Used TLS_CERT_FIELD_NAMES consts in setBootableVolumeField calls. Reset tlsCertSource to "Use existing" when the TLS checkbox is toggled on.

Jira: https://issues.redhat.com/browse/CNV-79324

Demo

Screen.Recording.2026-02-09.at.18.02.58.mov
Screen.Recording.2026-02-09.at.18.06.54.mov

Summary by CodeRabbit

  • New Features

  • TLS certificate management when adding bootable volumes: upload PEM certificates or choose existing cluster certificates for HTTPS sources.

  • Improved form validation for bootable volume creation (affects submit enablement and TLS requirement flows).

  • Localization

  • Added translation strings for TLS/certificate prompts and guidance in English, Spanish, French, Japanese, Korean, and Chinese.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In
`@src/utils/components/AddBootableVolumeModal/components/VolumeSource/components/TlsCertificate/TlsCertificateNew.tsx`:
- Around line 29-36: The onFileInputChange async callback passed to FileUpload
can reject if file.text() throws, causing an unhandled promise rejection; update
the callback in TlsCertificateNew so you await file.text() inside a try/catch
(not just finally), catch the error, clear or reset the TLS field via
setBootableVolumeField('tlsCertificate')('') and call the existing
error/notification handler (or set an error state) and still ensure
setIsCertLoading(false) runs in finally; reference the onFileInputChange
callback, setIsCertLoading, setBootableVolumeField('tlsCertificate') and
FileUpload when making the change.

In `@src/utils/components/AddBootableVolumeModal/utils/utils.ts`:
- Around line 257-267: The current code silently returns undefined when the
fetched ConfigMap (obtained via kubevirtK8sGet) does not contain
TLS_CERT_CONFIGMAP_KEY, which allows a DataVolume to be created without TLS;
update the function to throw a clear, descriptive error (or at minimum log a
warning and throw) instead of returning undefined, including the config map name
(tlsCertConfigMapName), namespace (tlsCertProject) and the missing key in the
message, and only call createTlsCertConfigMap when certData exists; ensure
callers handle or propagate the thrown error rather than assuming a
possibly-undefined newName.
🧹 Nitpick comments (2)
src/utils/components/AddBootableVolumeModal/utils/utils.ts (1)

322-334: Cleanup deletes are fire-and-forget — failed cleanup is silently swallowed.

Both kubevirtK8sDelete calls (lines 323 and 329) are not awaited. If either fails, the error is lost and orphaned resources remain without any signal. The DataSource delete was pre-existing, but the new ConfigMap delete follows the same pattern.

This is consistent with the existing code style, so flagging as optional — consider await-ing and wrapping in a try/catch with a logged warning for observability.

src/utils/components/AddBootableVolumeModal/components/VolumeSource/components/HTTPSource.tsx (1)

22-23: Consider extracting httpSourceHelperURL as a module-level constant.

This string is recreated on every render. Per coding guidelines, define constants with uppercase naming outside the component (or in a constants file).

+const HTTP_SOURCE_HELPER_URL =
+  'https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2';
+
 const HTTPSource: FC<HTTPSourceProps> = ({ bootableVolume, setBootableVolumeField }) => {
   const { t } = useKubevirtTranslation();
-
-  const httpSourceHelperURL =
-    'https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2';

As per coding guidelines: "Define constants in utility files with uppercase and underscore-separated naming."

Comment on lines +29 to +36
onFileInputChange={async (_, file: File) => {
setIsCertLoading(true);
try {
const text = await file.text();
setBootableVolumeField('tlsCertificate')(text);
} finally {
setIsCertLoading(false);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Unhandled rejection if file.text() fails.

The async callback is invoked by PatternFly's FileUpload, which likely does not await it. If file.text() throws, the error propagates as an unhandled promise rejection. The finally block handles the loading state, but the error itself is lost.

Consider adding a catch to handle the error gracefully (e.g., clear the field or show a notification).

Suggested change
         onFileInputChange={async (_, file: File) => {
           setIsCertLoading(true);
           try {
             const text = await file.text();
             setBootableVolumeField('tlsCertificate')(text);
+          } catch {
+            setBootableVolumeField('tlsCertificate')('');
           } finally {
             setIsCertLoading(false);
           }
         }}
🤖 Prompt for AI Agents
In
`@src/utils/components/AddBootableVolumeModal/components/VolumeSource/components/TlsCertificate/TlsCertificateNew.tsx`
around lines 29 - 36, The onFileInputChange async callback passed to FileUpload
can reject if file.text() throws, causing an unhandled promise rejection; update
the callback in TlsCertificateNew so you await file.text() inside a try/catch
(not just finally), catch the error, clear or reset the TLS field via
setBootableVolumeField('tlsCertificate')('') and call the existing
error/notification handler (or set an error state) and still ensure
setIsCertLoading(false) runs in finally; reference the onFileInputChange
callback, setIsCertLoading, setBootableVolumeField('tlsCertificate') and
FileUpload when making the change.

Comment on lines +257 to +267
const sourceConfigMap = await kubevirtK8sGet<IoK8sApiCoreV1ConfigMap>({
cluster,
model: ConfigMapModel,
name: tlsCertConfigMapName,
ns: tlsCertProject,
});
const certData = sourceConfigMap?.data?.[TLS_CERT_CONFIGMAP_KEY];
if (!certData) return undefined;
const newName = `tls-cert-${getRandomChars()}`;
await createTlsCertConfigMap(cluster, targetNamespace, newName, certData);
return newName;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Silent undefined return when source ConfigMap lacks the expected key.

Line 264: if the user selects an existing ConfigMap but it doesn't contain the ca.pem key, the function silently returns undefined and the DataVolume is created without TLS — no error is surfaced. This could confuse users who believe they configured a certificate.

Consider throwing an error (or at least logging a warning) so the user knows the selected ConfigMap is missing the expected key.

Suggested change
     const certData = sourceConfigMap?.data?.[TLS_CERT_CONFIGMAP_KEY];
-    if (!certData) return undefined;
+    if (!certData) {
+      throw new Error(
+        `ConfigMap "${tlsCertConfigMapName}" in namespace "${tlsCertProject}" does not contain key "${TLS_CERT_CONFIGMAP_KEY}"`,
+      );
+    }
🤖 Prompt for AI Agents
In `@src/utils/components/AddBootableVolumeModal/utils/utils.ts` around lines 257
- 267, The current code silently returns undefined when the fetched ConfigMap
(obtained via kubevirtK8sGet) does not contain TLS_CERT_CONFIGMAP_KEY, which
allows a DataVolume to be created without TLS; update the function to throw a
clear, descriptive error (or at minimum log a warning and throw) instead of
returning undefined, including the config map name (tlsCertConfigMapName),
namespace (tlsCertProject) and the missing key in the message, and only call
createTlsCertConfigMap when certData exists; ensure callers handle or propagate
the thrown error rather than assuming a possibly-undefined newName.

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

Labels

approved This issue is something we want to fix jira/valid-reference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants