Skip to content

Conversation

@cappyzawa
Copy link
Member

@cappyzawa cappyzawa commented Jul 25, 2025

Summary

Refactors HelmRepository client options generation to use explicit configuration pattern. The previous implementation had hidden mutable side effects where ClientOpts was modified through configuration functions, making the code harder to reason about.

Changes

  • Replace hidden mutation functions with explicit configuration pattern
  • Add CertsTempDir field to ClientOpts and update GetClientOpts signature to return (*ClientOpts, error) instead of (*ClientOpts, string, error)
    • Update all callers to use clientOpts.CertsTempDir
  • Improve error messages to include namespace/name for better debugging

Related

Addresses similar error message clarity issues identified in #1852 (comment)

Replace hidden mutation functions with explicit configuration
pattern to eliminate side effects where ClientOpts was modified
through configuration functions. Adds CertsTempDir field to ClientOpts struct.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
@cappyzawa cappyzawa force-pushed the refactor/helm-repository-client-opts-option-pattern branch from 8f8ad70 to df06de9 Compare July 25, 2025 04:39
@cappyzawa cappyzawa changed the title refactor: use builder pattern in HelmRepository client opts refactor: eliminate hidden mutations in HelmRepository client opts Jul 25, 2025
@stefanprodan
Copy link
Member

@cappyzawa can you please rebase and solve conflicts, would be great to get this merged.

@stefanprodan stefanprodan added the area/helm Helm related issues and pull requests label Sep 1, 2025
@cappyzawa
Copy link
Member Author

Previously, I discussed refactoring with @matheuscscp once helm/helm#31076 was merged and available, but I forgot to mention it here—sorry about that.

Since it looks like helm/helm#31076 is still planned only for Helm 4 and there haven’t been any updates, I suppose any improvements to this PR will have to wait until then.

@cappyzawa cappyzawa added the hold Issues and pull requests put on hold label Sep 1, 2025
@matheuscscp
Copy link
Member

Yeah I think we can wait until we can remove this tmp dir altogether to merge this one

@matheuscscp
Copy link
Member

@cappyzawa The initial (and probably most substantial) Helm 4 PR has been merged:

#1953

Feel free to check if this one is still relevant 👌

@matheuscscp matheuscscp removed the hold Issues and pull requests put on hold label Jan 12, 2026
@cappyzawa
Copy link
Member Author

Thanks for the ping @matheuscscp!

I checked how the Helm 4 migration addressed the issues this PR was trying to solve:

Goal Status
Eliminate hidden mutations ✅ Solved - main now uses explicit argument passing (configureAuthentication(opts *ClientOpts)) instead of the functional option pattern
Add CertsTempDir to ClientOpts ✅ No longer needed - Helm 4's LoginOptTLSClientConfigFromConfig(*tls.Config) allows passing TLS config in memory, so temp files are gone entirely
Improve error messages with namespace/name Partially addressed in main

Since the Helm 4 + ORAS v2 migration solved these issues with a cleaner architecture, I'll close this PR.

@cappyzawa cappyzawa closed this Jan 13, 2026
@cappyzawa cappyzawa deleted the refactor/helm-repository-client-opts-option-pattern branch January 13, 2026 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/helm Helm related issues and pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants