Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return more detailed error msg with JsonPatch #1245

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/modules/generators/app_configurations_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,20 @@ func JSONPatch(resources v1.Resources, patcher *v1.Patcher) error {
case v1.MergePatch:
modified, err := jsonpatch.MergePatch([]byte(target), jsonPatcher.Payload)
if err != nil {
return fmt.Errorf("merge patch to:%s failed", id)
return fmt.Errorf("merge patch to:%s failed with error %w", id, err)
}
if err = json.Unmarshal(modified, &res.Attributes); err != nil {
return err
}
case v1.JSONPatch:
patch, err := jsonpatch.DecodePatch(jsonPatcher.Payload)
if err != nil {
return fmt.Errorf("decode json patch:%s failed", jsonPatcher.Payload)
return fmt.Errorf("decode json patch:%s failed with error %w", jsonPatcher.Payload, err)
}

modified, err := patch.Apply([]byte(target))
if err != nil {
return fmt.Errorf("apply json patch to:%s failed", id)
return fmt.Errorf("apply json patch to:%s failed with error %w", id, err)
}
if err = json.Unmarshal(modified, &res.Attributes); err != nil {
return err
Expand Down
Loading