source-controller icon indicating copy to clipboard operation
source-controller copied to clipboard

refactor: eliminate hidden mutations in HelmRepository client opts

Open cappyzawa opened this issue 5 months ago • 3 comments

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 https://github.com/fluxcd/source-controller/pull/1852#discussion_r2224416104

cappyzawa avatar Jul 25 '25 03:07 cappyzawa

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

stefanprodan avatar Sep 01 '25 09:09 stefanprodan

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 avatar Sep 01 '25 14:09 cappyzawa

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

matheuscscp avatar Sep 01 '25 14:09 matheuscscp