MCPcopy Index your code
hub / github.com/argoproj/argo-cd / normalizeApplication

Method normalizeApplication

controller/appcontroller.go:2093–2110  ·  view source on GitHub ↗

normalizeApplication normalizes an application.spec and additionally persists updates if it changed

(app *appv1.Application)

Source from the content-addressed store, hash-verified

2091
2092// normalizeApplication normalizes an application.spec and additionally persists updates if it changed
2093func (ctrl *ApplicationController) normalizeApplication(app *appv1.Application) {
2094 orig := app.DeepCopy()
2095 app.Spec = *argo.NormalizeApplicationSpec(&app.Spec)
2096 logCtx := log.WithFields(applog.GetAppLogFields(app))
2097
2098 patch, modified, err := diff.CreateTwoWayMergePatch(orig, app, appv1.Application{})
2099
2100 if err != nil {
2101 logCtx.WithError(err).Error("error constructing app spec patch")
2102 } else if modified {
2103 _, err := ctrl.PatchAppWithWriteBack(context.Background(), app.Name, app.Namespace, types.MergePatchType, patch, metav1.PatchOptions{})
2104 if err != nil {
2105 logCtx.WithError(err).Error("Error persisting normalized application spec")
2106 } else {
2107 logCtx.Infof("Normalized app spec: %s", string(patch))
2108 }
2109 }
2110}
2111
2112func createMergePatch(orig, newV any) ([]byte, bool, error) {
2113 origBytes, err := json.Marshal(orig)

Callers 1

Calls 4

PatchAppWithWriteBackMethod · 0.95
NormalizeApplicationSpecFunction · 0.92
DeepCopyMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected