Skip to content

Conversation

@sowmya-sl
Copy link
Contributor

@sowmya-sl sowmya-sl commented Jan 16, 2026

OCI-based Helm charts were failing to install because the action configuration lacked a registry client. This change:

  • Add GetDefaultOCIRegistry() to create and attach a registry client to the Helm action configuration
  • Integrate registry client initialization into all Helm handlers: install, upgrade, uninstall, rollback, and chart get operations
  • Add unit tests for the new registry client function
  • Update older tests to use mock registry Client function

Without a registry client, operations on OCI charts (oci://) would fail with errors about missing registry support.

Fixes: HELM-611
Original PR on #15830

Steps to test:

  1. Create a helmrepository object in the cluster. The helmrepository object can be either cluster or namespaced, it does not matter.
  2. Add repo link as https://charts.bitnami.com/bitnami . Bitnami has many OCI helm charts.
  3. Once added, go to Releases and create a Helm release.
  4. Sort by the newly added bitnami repository. Select nginx as the chart.
  5. Click on create. Wait for the release to create and verify when created.

Summary by CodeRabbit

  • New Features

    • Automatically fetches and initializes the OCI registry before Helm operations (install, upgrade, chart fetch, rollback), improving pre-validation and reliability.
    • Handlers now return clear Bad Gateway-style errors when registry retrieval fails.
  • Tests

    • Added tests for successful registry initialization, nil-configuration handling, various TLS/HTTP option combinations, and client-creation error paths to ensure robust behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

OCI-based Helm charts were failing to install because the action
configuration lacked a registry client. This change:

- Add GetDefaultOCIRegistry() to create and attach a registry client
  to the Helm action configuration
- Integrate registry client initialization into all Helm handlers:
  install, upgrade, uninstall, rollback, and chart get operations
- Add unit tests for the new registry client function
- Update older tests to use mock registry Client function

Without a registry client, operations on OCI charts (oci://) would fail
with errors about missing registry support.

Fixes: HELM-611
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Jan 16, 2026

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

Details

In response to this:

OCI-based Helm charts were failing to install because the action configuration lacked a registry client. This change:

  • Add GetDefaultOCIRegistry() to create and attach a registry client to the Helm action configuration
  • Integrate registry client initialization into all Helm handlers: install, upgrade, uninstall, rollback, and chart get operations
  • Add unit tests for the new registry client function
  • Update older tests to use mock registry Client function

Without a registry client, operations on OCI charts (oci://) would fail with errors about missing registry support.

Fixes: HELM-611

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 openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jan 16, 2026
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 16, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 16, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Jan 16, 2026

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

Details

In response to this:

OCI-based Helm charts were failing to install because the action configuration lacked a registry client. This change:

  • Add GetDefaultOCIRegistry() to create and attach a registry client to the Helm action configuration
  • Integrate registry client initialization into all Helm handlers: install, upgrade, uninstall, rollback, and chart get operations
  • Add unit tests for the new registry client function
  • Update older tests to use mock registry Client function

Without a registry client, operations on OCI charts (oci://) would fail with errors about missing registry support.

Fixes: HELM-611

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
Copy link

coderabbitai bot commented Jan 16, 2026

Walkthrough

Adds OCI registry client creation utilities and integrates a default OCI registry retrieval into Helm action configuration and multiple HTTP handlers. Handlers now pre-invoke the registry retrieval and return a Bad Gateway on failure; tests and a test seam for client creation were added.

Changes

Cohort / File(s) Summary
OCI Registry Utilities
pkg/helm/actions/get_registry.go, pkg/helm/actions/get_registry_test.go
Add GetDefaultOCIRegistry(conf *action.Configuration) error and GetOCIRegistry(conf *action.Configuration, skipTLSVerify bool, plainHTTP bool) error. Build registry client options (plainHTTP, skip TLS), create client via newRegistryClient, assign to conf.RegistryClient. Include tests for success, nil-config, option combinations, and client-creation error; introduce package-level test seam for newRegistryClient.
Config Initialization
pkg/helm/actions/config.go
After initializing conf, call GetDefaultOCIRegistry(conf). On error, log a debug-level message and continue; returned conf unchanged.
Handler Integration
pkg/helm/handlers/handlers.go, pkg/helm/handlers/handler_test.go
Add getDefaultOCIRegistry func(*action.Configuration) error to helmHandlers and wire to actions.GetDefaultOCIRegistry in New. Pre-invoke this hook in handlers (Install, InstallAsync, ChartGet, UpgradeRelease, UpgradeReleaseAsync, RollbackRelease, GetChart); handlers return Bad Gateway if the hook errors. Tests updated with a no-op fake for the hook.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main change: adding OCI registry client functionality for Helm chart operations, which is the core purpose of this PR.

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

✨ Finishing touches
  • 📝 Generate docstrings

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

@openshift-ci openshift-ci bot added the component/backend Related to backend label Jan 16, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 16, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sowmya-sl

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 Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 16, 2026
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Jan 16, 2026

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

Details

In response to this:

OCI-based Helm charts were failing to install because the action configuration lacked a registry client. This change:

  • Add GetDefaultOCIRegistry() to create and attach a registry client to the Helm action configuration
  • Integrate registry client initialization into all Helm handlers: install, upgrade, uninstall, rollback, and chart get operations
  • Add unit tests for the new registry client function
  • Update older tests to use mock registry Client function

Without a registry client, operations on OCI charts (oci://) would fail with errors about missing registry support.

Fixes: HELM-611
Original PR on #15830

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 sowmya-sl marked this pull request as ready for review January 20, 2026 10:18
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 20, 2026
@openshift-ci openshift-ci bot requested review from baijum and martinszuc January 20, 2026 10:19
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Jan 20, 2026

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

Details

In response to this:

OCI-based Helm charts were failing to install because the action configuration lacked a registry client. This change:

  • Add GetDefaultOCIRegistry() to create and attach a registry client to the Helm action configuration
  • Integrate registry client initialization into all Helm handlers: install, upgrade, uninstall, rollback, and chart get operations
  • Add unit tests for the new registry client function
  • Update older tests to use mock registry Client function

Without a registry client, operations on OCI charts (oci://) would fail with errors about missing registry support.

Fixes: HELM-611
Original PR on #15830

Steps to test:

  1. Create a helmrepository object in the cluster. The helmrepository object can be either cluster or namespaced, it does not matter.
  2. Add repo link as https://charts.bitnami.com/bitnami . Bitnami has many OCI helm charts.
  3. Once added, go to Releases and create a Helm release.
  4. Sort by the newly added bitnami repository. Select nginx as the chart.
  5. Click on create. Wait for the release to create and verify when created.

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
Contributor

openshift-ci-robot commented Jan 20, 2026

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

Details

In response to this:

OCI-based Helm charts were failing to install because the action configuration lacked a registry client. This change:

  • Add GetDefaultOCIRegistry() to create and attach a registry client to the Helm action configuration
  • Integrate registry client initialization into all Helm handlers: install, upgrade, uninstall, rollback, and chart get operations
  • Add unit tests for the new registry client function
  • Update older tests to use mock registry Client function

Without a registry client, operations on OCI charts (oci://) would fail with errors about missing registry support.

Fixes: HELM-611
Original PR on #15830

Steps to test:

  1. Create a helmrepository object in the cluster. The helmrepository object can be either cluster or namespaced, it does not matter.
  2. Add repo link as https://charts.bitnami.com/bitnami . Bitnami has many OCI helm charts.
  3. Once added, go to Releases and create a Helm release.
  4. Sort by the newly added bitnami repository. Select nginx as the chart.
  5. Click on create. Wait for the release to create and verify when created.

Summary by CodeRabbit

  • New Features

  • OCI registry is now automatically initialized when performing Helm operations such as installation, upgrades, and chart retrieval.

  • Enhanced error handling provides descriptive feedback when registry configuration fails.

  • Tests

  • Added comprehensive test coverage for OCI registry initialization and error handling.

✏️ Tip: You can customize this high-level summary in your review settings.

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: 1

🤖 Fix all issues with AI agents
In `@pkg/helm/actions/get_registry.go`:
- Around line 17-26: GetOCIRegistry currently ignores insecure and plainHTTP;
fix by passing registry.ClientOptPlainHTTP() when plainHTTP is true, and handle
insecure by constructing an *http.Client with a custom
tls.Config{InsecureSkipVerify: true} and passing it to newRegistryClient via
registry.ClientOptHTTPClient(httpClient); update GetOCIRegistry to call
newRegistryClient with the appropriate options (plainHTTP and/or HTTP client)
and add imports for crypto/tls and net/http so the custom HTTP client can be
created and supplied to the registry client.
🧹 Nitpick comments (2)
pkg/helm/actions/config.go (1)

53-56: Redundant registry initialization across config and handlers.

This call to GetDefaultOCIRegistry is non-blocking (logs and continues), while handlers.go calls the same function and does fail the request on error. The redundancy means the registry client may be initialized twice per request when the first call succeeds.

Consider removing this call from config initialization since handlers.go already performs the authoritative check with proper error handling. If the intent is a "best-effort early init," the pattern is fine but should be documented.

pkg/helm/handlers/handler_test.go (1)

205-207: Consider adding test coverage for registry initialization failures.

The fake always returns nil, which is fine for happy-path testing. However, since handlers now return BadGateway when getDefaultOCIRegistry fails, consider adding at least one test case that injects a failing getDefaultOCIRegistry to verify the error response path.

func fakeGetDefaultOCIRegistryError(conf *action.Configuration) error {
    return errors.New("mock registry error")
}

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Jan 20, 2026

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

Details

In response to this:

OCI-based Helm charts were failing to install because the action configuration lacked a registry client. This change:

  • Add GetDefaultOCIRegistry() to create and attach a registry client to the Helm action configuration
  • Integrate registry client initialization into all Helm handlers: install, upgrade, uninstall, rollback, and chart get operations
  • Add unit tests for the new registry client function
  • Update older tests to use mock registry Client function

Without a registry client, operations on OCI charts (oci://) would fail with errors about missing registry support.

Fixes: HELM-611
Original PR on #15830

Steps to test:

  1. Create a helmrepository object in the cluster. The helmrepository object can be either cluster or namespaced, it does not matter.
  2. Add repo link as https://charts.bitnami.com/bitnami . Bitnami has many OCI helm charts.
  3. Once added, go to Releases and create a Helm release.
  4. Sort by the newly added bitnami repository. Select nginx as the chart.
  5. Click on create. Wait for the release to create and verify when created.

Summary by CodeRabbit

  • New Features

  • OCI registry is now fetched automatically before Helm operations (install, upgrade, chart fetch), improving reliability and pre-validating registry access.

  • Handlers now surface clear error responses if registry retrieval fails.

  • Tests

  • Added tests covering successful registry initialization, nil-configuration errors, and client-creation failures to ensure robust behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

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
Contributor Author

/retest

Copy link

@webbnh webbnh left a comment

Choose a reason for hiding this comment

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

The changes to the code look very nice, now.

However, the tests seem like they could use some more attention. One of them is, I think, mistargeted, but I think it is trivial to fix that. In the second instance, you added a test for the error case but no tests for the normal cases (I've supplied a possible fix for that).

The third omission is understandable, since I couldn't find any testing for the other error cases in those functions, but I'd like to resist using that as a basis for adding more untested code. I'm not asking that you cover the existing omissions (although, I would be pleased if you took a shot at it!), but I do suggest that you include testing to cover the code that you're adding in this PR.

Comment on lines 43 to 47
func TestGetDefaultOCIRegistry_NilConfig(t *testing.T) {
err := GetDefaultOCIRegistry(nil)
require.Error(t, err)
require.Contains(t, err.Error(), "action configuration cannot be nil")
}

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines +48 to +110

func TestGetOCIRegistry_NewClientError(t *testing.T) {

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added this in the test.

Comment on lines +123 to +125
if err != nil {
serverutils.SendResponse(w, http.StatusBadGateway, serverutils.ApiError{Err: fmt.Sprintf("Failed to get default registry: %v", err)})
return
Copy link

Choose a reason for hiding this comment

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

Do we have a unit test scenario which exercises this code? (Ditto for the other changes to this module?)

It looks like we probably don't have tests for any of the error cases in this (or the other) functions...but it would be good if the new code brought with it new tests.... 😇

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No UTs for this right now. But I will check on that.

- Rename insecure param to skipTLSVerify for clarity
- Add TLS skip verification and plainHTTP support
- Use mockable newRegistryClient for testability
- Fix variable naming (registryClient)
- Return nil directly instead of err variable
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Jan 21, 2026

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

Details

In response to this:

OCI-based Helm charts were failing to install because the action configuration lacked a registry client. This change:

  • Add GetDefaultOCIRegistry() to create and attach a registry client to the Helm action configuration
  • Integrate registry client initialization into all Helm handlers: install, upgrade, uninstall, rollback, and chart get operations
  • Add unit tests for the new registry client function
  • Update older tests to use mock registry Client function

Without a registry client, operations on OCI charts (oci://) would fail with errors about missing registry support.

Fixes: HELM-611
Original PR on #15830

Steps to test:

  1. Create a helmrepository object in the cluster. The helmrepository object can be either cluster or namespaced, it does not matter.
  2. Add repo link as https://charts.bitnami.com/bitnami . Bitnami has many OCI helm charts.
  3. Once added, go to Releases and create a Helm release.
  4. Sort by the newly added bitnami repository. Select nginx as the chart.
  5. Click on create. Wait for the release to create and verify when created.

Summary by CodeRabbit

  • New Features

  • Automatically fetches and initializes the OCI registry before Helm operations (install, upgrade, chart fetch, rollback), improving pre-validation and reliability.

  • Handlers now return clear Bad Gateway-style errors when registry retrieval fails.

  • Tests

  • Added tests for successful registry initialization, nil-configuration handling, various TLS/HTTP option combinations, and client-creation error paths to ensure robust behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

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: 1

🤖 Fix all issues with AI agents
In `@pkg/helm/actions/get_registry.go`:
- Around line 29-36: When skipTLSVerify is true, don't create a bare
http.Transport (which loses ProxyFromEnvironment and default timeouts/HTTP2
settings); instead clone the default transport, assert
http.DefaultTransport.(*http.Transport), call Clone() to get a copy, set its
TLSClientConfig.InsecureSkipVerify = true, and use that cloned transport in the
http.Client passed to registry.ClientOptHTTPClient so Proxy and other default
behaviors are preserved.

Comment on lines +29 to +36
if skipTLSVerify {
opts = append(opts, registry.ClientOptHTTPClient(&http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}))
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

🧩 Analysis chain

🏁 Script executed:

git ls-files | head -20

Repository: openshift/console

Length of output: 500


🏁 Script executed:

fd -t f "get_registry.go" -x wc -l {}

Repository: openshift/console

Length of output: 98


🏁 Script executed:

cat -n pkg/helm/actions/get_registry.go | head -50

Repository: openshift/console

Length of output: 1426


🏁 Script executed:

# Check the minimum Go version supported by this project
if [ -f "go.mod" ]; then
  head -5 go.mod
fi

Repository: openshift/console

Length of output: 127


🌐 Web query:

Go http.DefaultTransport http.Transport Clone method

💡 Result:

Yes — http.DefaultTransport is a RoundTripper whose concrete type is *http.Transport, and http.Transport has a Clone method you can use to copy the default transport instead of mutating it.

Example:

  • safe: t := http.DefaultTransport.(*http.Transport).Clone()
  • then modify and use: t.MaxIdleConns = 50; client := &http.Client{Transport: t}

Notes:

  • Do not set fields on http.DefaultTransport directly (that mutates the global). Clone was added to Transport to make copying easy (Go 1.13+). [1][2][3]

Sources:
[1] Stack Overflow — “How to use http.DefaultTransport …” (example using Clone).
[2] Go 1.13 release notes (Transport changes; Clone added).
[3] net/http docs (DefaultTransport is &Transport{...}).


🏁 Script executed:

rg -t go "ClientOptHTTPClient|http\.Client" --context 3 | head -50

Repository: openshift/console

Length of output: 2576


🏁 Script executed:

rg -t go "registry\.NewClient|registry\.Client" --context 2 | head -40

Repository: openshift/console

Length of output: 2575


🏁 Script executed:

cat -n pkg/helm/actions/get_registry_test.go

Repository: openshift/console

Length of output: 4961


🏁 Script executed:

rg -t go "Proxy|proxy|ProxyFromEnvironment" pkg/helm/actions/

Repository: openshift/console

Length of output: 251


🌐 Web query:

http.DefaultTransport ProxyFromEnvironment proxy support Go

💡 Result:

Short answer

  • net/http's DefaultTransport uses ProxyFromEnvironment, so it will honor HTTP_PROXY/http_proxy, HTTPS_PROXY/https_proxy and NO_PROXY/no_proxy (the exact parsing/semantics come from golang.org/x/net/http/httpproxy). [1][2]

Notes / gotchas

  • If you create a Transport with an empty struct (e.g. &http.Transport{}), Proxy is nil and environment proxying won't be used — DefaultTransport sets Proxy: ProxyFromEnvironment for you. [1][3]

Sources

  • DefaultTransport and its Proxy field in net/http docs. [1]
  • httpproxy implementation (FromEnvironment / rules for HTTP(S)_PROXY and NO_PROXY). [2]
  • Common pitfall: empty Transport vs DefaultTransport (discussion/example). [3]

Clone http.DefaultTransport to preserve proxy and timeout settings.

The bare http.Transport loses ProxyFromEnvironment support, breaking registry access in proxied environments when skipTLSVerify is true—a critical gap in enterprise deployments where corporate proxies are standard. Additionally, timeouts and HTTP/2 configuration from the default transport are dropped.

🔧 Proposed fix
-    opts = append(opts, registry.ClientOptHTTPClient(&http.Client{
-        Transport: &http.Transport{
-            TLSClientConfig: &tls.Config{
-                InsecureSkipVerify: true,
-            },
-        },
-    }))
+    transport := http.DefaultTransport.(*http.Transport).Clone()
+    transport.TLSClientConfig = &tls.Config{
+        InsecureSkipVerify: true,
+        // MinVersion: tls.VersionTLS12, // or TLS13 if your registries support it
+    }
+    opts = append(opts, registry.ClientOptHTTPClient(&http.Client{Transport: transport}))
🧰 Tools
🪛 ast-grep (0.40.5)

[warning] 31-33: MinVersionis missing from this TLS configuration. By default, TLS 1.2 is currently used as the minimum when acting as a client, and TLS 1.0 when acting as a server. General purpose web applications should default to TLS 1.3 with all other protocols disabled. Only where it is known that a web server must support legacy clients with unsupported an insecure browsers (such as Internet Explorer 10), it may be necessary to enable TLS 1.0 to provide support. AddMinVersion: tls.VersionTLS13' to the TLS configuration to bump the minimum version to TLS 1.3.
Context: tls.Config{
InsecureSkipVerify: true,
}
Note: [CWE-327]: Use of a Broken or Risky Cryptographic Algorithm [OWASP A03:2017]: Sensitive Data Exposure [OWASP A02:2021]: Cryptographic Failures [REFERENCES]
https://owasp.org/Top10/A02_2021-Cryptographic_Failures

(missing-ssl-minversion-go)

🤖 Prompt for AI Agents
In `@pkg/helm/actions/get_registry.go` around lines 29 - 36, When skipTLSVerify is
true, don't create a bare http.Transport (which loses ProxyFromEnvironment and
default timeouts/HTTP2 settings); instead clone the default transport, assert
http.DefaultTransport.(*http.Transport), call Clone() to get a copy, set its
TLSClientConfig.InsecureSkipVerify = true, and use that cloned transport in the
http.Client passed to registry.ClientOptHTTPClient so Proxy and other default
behaviors are preserved.

Copy link

@webbnh webbnh left a comment

Choose a reason for hiding this comment

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

Looks good, @sowmya-sl; however, there are a couple of new concerns and an old one:

  • The deferral of the restoration of newRegistryClient is being done multiple times (and, as a result, probably doesn't work properly); instead, it should probably be done only once.
  • We need to confirm that the restoration is not done before all of the test scenarios are completed.
  • The unit test coverage for the new error handling (link).
  • And, you should consider taking CodeRabbit's suggestion.

Comment on lines +77 to +81
for _, tt := range tests {
originalNewRegistryClient := newRegistryClient
defer func() {
newRegistryClient = originalNewRegistryClient
}()
Copy link

Choose a reason for hiding this comment

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

I don't think that this is going to work as intended: the defer operation is going to be done four times, since it is inside the loop, and so it will be executed four times when the function returns; however, on each iteration, originalNewRegistryClient will be overwritten with the mock from the previous iteration, and so on each execution of the deferred function, it will restore newRegistryClient to the third iteration's mock.

There is a way to make each deferral restore the previous state, such that, after the last completes, the state is back to the original value, but it would be much easier/simpler/more-effective to simply move lines 78-81 to before the loop.

Also, there is something you should check: since your test is using t.Run() to execute the scenarios in separate go-routines, you should make sure that the deferred function(s) doesn't run before all the scenarios are complete. (That is, can control return from TestGetOCIRegistry_Success() and trigger the deferred actions before all of the t.Run() functions have finished and are no longer using newRegistryClient?...I don't recall that detail.)

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 21, 2026

@sowmya-sl: all tests passed!

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 jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants