Skip to content

Commit 0c425c3

Browse files
committed
fix: Skip commit for kustomize update if nothing changed
Signed-off-by: Fs02 <[email protected]>
1 parent 202f6bf commit 0c425c3

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

pkg/argocd/git.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,32 @@ func writeKustomization(app *v1alpha1.Application, wbc *WriteBackConfig, gitC gi
314314
if err != nil {
315315
return err, false
316316
}
317-
err = kyaml.UpdateFile(filterFunc, kustFile)
317+
318+
y, err := kyaml.ReadFile(kustFile)
319+
if err != nil {
320+
return err, false
321+
}
322+
323+
originalData, err := y.String()
324+
if err != nil {
325+
return err, false
326+
}
327+
328+
if err := y.PipeE(filterFunc); err != nil {
329+
return err, false
330+
}
331+
332+
override, err := y.String()
333+
if err != nil {
334+
return err, false
335+
}
336+
337+
if string(originalData) == string(override) {
338+
logCtx.Debugf("target parameter file and marshaled data are the same, skipping commit.")
339+
return nil, true
340+
}
341+
342+
err = kyaml.WriteFile(y, kustFile)
318343
if err != nil {
319344
return err, false
320345
}

pkg/argocd/update_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ func Test_GetGitCreds(t *testing.T) {
17391739
},
17401740
},
17411741
Spec: v1alpha1.ApplicationSpec{
1742-
Source: v1alpha1.ApplicationSource{
1742+
Source: &v1alpha1.ApplicationSource{
17431743
RepoURL: "https://example-helm-repo.com/example",
17441744
TargetRevision: "main",
17451745
},

0 commit comments

Comments
 (0)