Skip to content

feat: support SourceHydrator applications for image updates#1475

Open
julianderks wants to merge 3 commits intoargoproj-labs:masterfrom
julianderks:fix/source-hydrator-support
Open

feat: support SourceHydrator applications for image updates#1475
julianderks wants to merge 3 commits intoargoproj-labs:masterfrom
julianderks:fix/source-hydrator-support

Conversation

@julianderks
Copy link
Copy Markdown

@julianderks julianderks commented Feb 8, 2026

Summary

Fix image update processing for Argo CD Applications using spec.sourceHydrator.

Fixes #1403

Motivation

Applications using spec.sourceHydrator were not processed correctly for image updates. The DrySource fields (Helm, Kustomize, etc.) were not being propagated into the ApplicationSource, causing image updates to fail.

Implementation

  • getApplicationSource(): return a full ApplicationSource from all DrySource fields (RepoURL, Path, TargetRevision, Helm, Kustomize, Directory, Plugin) for SourceHydrator apps
  • getApplicationSourceType(): detect source type from DrySource Helm/Kustomize/Plugin fields instead of relying on Status.SourceType
  • marshalParamsOverride(): handle nil Helm field safely so the custom values file write-back path does not silently return empty

Tests

  • Unit tests added for all three changes covering SourceHydrator scenarios
  • make lint and make test pass
  • Manually tested E2E on GKE cluster: verified image tag updates are written back via git write-back for a SourceHydrator application

Summary by CodeRabbit

  • New Features

    • Improved application source detection for SourceHydrator-enabled apps, better recognizing Helm, Kustomize, Directory and Plugin sources.
  • Bug Fixes

    • Made parameter handling nil-safe and added safe early-exit for certain Helm cases to avoid errors when source data is absent.
  • Tests

    • Added unit tests for source-hydration and type detection, plus end-to-end tests (including Helm + git write-back) and Helm chart fixtures.

Signed-off-by: Julian Derks <derks_julian@hotmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 8, 2026

Walkthrough

Adds SourceHydrator-aware source type detection and ApplicationSource construction, and makes Helm parameter handling nil-safe so Image Updater can perform write-back for Argo CD Applications that use spec.sourceHydrator.drySource; includes unit and e2e tests and a small Helm chart for testing.

Changes

Cohort / File(s) Summary
Core SourceHydrator logic
pkg/argocd/argocd.go
Extend getApplicationSourceType and getApplicationSource to inspect spec.sourceHydrator.drySource when resolving source type (Helm/Kustomize/Plugin/Directory) and to build an ApplicationSource from the DrySource.
Helm write-back nil-safety
pkg/argocd/update.go
Make marshalParamsOverride nil-safe by copying helmParams when appSource.Helm may be nil, and add early return for Helm-targeted write-back when Helm data is absent.
Unit tests (argocd)
pkg/argocd/argocd_test.go
Add tests covering SourceHydrator-driven source type detection and GetApplicationSource behavior for Helm/Kustomize/Plugin and precedence/TargetRevision cases.
Unit tests (update)
pkg/argocd/update_test.go
Add tests verifying marshalParamsOverride behavior for SourceHydrator apps: fallback when Helm is nil and when DrySource includes Helm parameters.
E2E test (Ginkgo)
test/ginkgo/parallel/1-007-source-hydrator-helm_test.go
New end-to-end test exercising SourceHydrator Helm-backed Application with git write-back and Image Updater interactions, asserting image/version propagation to Helm values.
Test Helm chart
test/ginkgo/prereqs/containers/git/testdata/1-007-source-hydrator-helm-test/helm/Chart.yaml, .../templates/deployment.yaml, .../values.yaml
Add minimal Helm chart and values used by the e2e test to validate Helm values file write-back.
Go modules
go.mod
Small manifest changes (non-functional metadata updates).

Sequence Diagram

sequenceDiagram
    participant App as Application\n(SourceHydrator)
    participant TypeDetect as getApplicationSourceType
    participant SrcConstruct as getApplicationSource
    participant Marshal as marshalParamsOverride
    participant Git as Git Write-Back

    App->>TypeDetect: Request source type
    TypeDetect->>TypeDetect: Inspect spec.sourceHydrator.drySource\n(determine Helm/Kustomize/Plugin/Directory)
    TypeDetect-->>App: Return source type

    App->>SrcConstruct: Build ApplicationSource
    SrcConstruct->>SrcConstruct: Extract fields from drySource\n(preserve Helm/Kustomize/Plugin/Directory)
    SrcConstruct-->>App: Return ApplicationSource

    App->>Marshal: Produce override payload
    Marshal->>Marshal: If appSource.Helm nil -> use nil-safe helmParams\nor early-return for Helm-targeted write-back
    Marshal-->>App: Return marshaled parameters (or empty)

    App->>Git: Perform write-back
    Git->>Git: Use drySource repoURL/targetRevision/path
    Git-->>App: Write-back complete
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: adding SourceHydrator support for image updates in ArgoCD, which is precisely what the changeset implements.
Linked Issues check ✅ Passed All coding requirements from issue #1403 are met: getApplicationSource returns ApplicationSource from DrySource, getApplicationSourceType detects type from DrySource, and marshalParamsOverride safely handles nil Helm for git write-back.
Out of Scope Changes check ✅ Passed All changes directly support SourceHydrator image update functionality as defined in issue #1403; no unrelated modifications detected.

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


No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
test/ginkgo/parallel/1-007-source-hydrator-helm_test.go (2)

124-129: Nit: variable shadowing reduces readability.

depl (string) from the range is shadowed by depl (*appsv1.Deployment) on line 125. It works correctly because the string is consumed in the struct literal before the shadow takes effect, but renaming the inner variable (e.g., deplObj) would make intent clearer.

♻️ Suggested refactor
 		for _, depl := range deploymentsShouldExist {
-			depl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: depl, Namespace: ns.Name}}
-			Eventually(depl).Should(k8sFixture.ExistByName())
-			Eventually(depl).Should(deplFixture.HaveReplicas(1))
-			Eventually(depl, "3m", "3s").Should(deplFixture.HaveReadyReplicas(1), depl.Name+" was not ready")
+			deplObj := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: depl, Namespace: ns.Name}}
+			Eventually(deplObj).Should(k8sFixture.ExistByName())
+			Eventually(deplObj).Should(deplFixture.HaveReplicas(1))
+			Eventually(deplObj, "3m", "3s").Should(deplFixture.HaveReadyReplicas(1), deplObj.Name+" was not ready")
 		}

229-247: Verify external image availability for test stability.

The assertion on line 247 depends on quay.io/dkarpele/my-guestbook:29437546.0 existing in the external registry. If that tag is ever removed or the registry is unreachable, this test will fail with a non-obvious error (empty string vs expected image).

Consider adding a comment near the image constraint (line 212) documenting which tag(s) must exist, or pointing to where the test image is published, so future maintainers can diagnose failures quickly.


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.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.70%. Comparing base (c1674be) to head (f047cd6).
⚠️ Report is 31 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1475      +/-   ##
==========================================
+ Coverage   71.48%   72.70%   +1.22%     
==========================================
  Files          50       51       +1     
  Lines        4667     4916     +249     
==========================================
+ Hits         3336     3574     +238     
- Misses       1133     1140       +7     
- Partials      198      202       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dkarpele dkarpele changed the title fix: support SourceHydrator applications for image updates feat: support SourceHydrator applications for image updates Feb 8, 2026
Copy link
Copy Markdown
Collaborator

@dkarpele dkarpele left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!
Could you please add a sanity test to test/ginkgo/parallel?

Signed-off-by: Julian Derks <derks_julian@hotmail.com>
@julianderks
Copy link
Copy Markdown
Author

@dkarpele

I added 1-007-source-hydrator-helm_test.go but it fails in CI because argocd-operator v0.17.0 (used in test/ginkgo/prereqs/kustomization.yaml) deploys Argo CD v3.1.x, whose CRD doesn't include sourceHydrator.drySource.helm. The API server strips the field (unknown field "spec.sourceHydrator.drySource.helm"), so the app never syncs.

The drySource.helm support was added in argoproj/argo-cd#24277, milestoned to Argo CD v3.3. Once the operator is updated to bundle v3.3+ CRDs, this test should pass.

@dkarpele
Copy link
Copy Markdown
Collaborator

dkarpele commented Feb 9, 2026

@julianderks
Thanks for adding the test. I missed that argocd-operator still uses Argo CD v3.1.
In this case, may I ask you to revert 3a87a6d from this branch (to make CI green again) and create a new PR only with e2e test? We will merge e2e later when argocd-operator get a new version.

Sorry for asking you an extra work.

P.S. argocd-operator in master branch has ArgoCD v3.3.0

…ack"

This reverts commit 3a87a6d.

Signed-off-by: Julian Derks <derks_julian@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Argo CD sourceHydrator Applications in Image Updater (CRD mode)

4 participants