Skip to content

Commit

Permalink
reduce unnecessary unmarshal (argoproj#17187)
Browse files Browse the repository at this point in the history
Signed-off-by: Wilson Wang <wilson.wang@bytedance.com>
  • Loading branch information
wilsonwang371 authored and Hariharasuthan99 committed Jun 16, 2024
1 parent 95fbc6d commit e239215
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions controller/appcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,13 +510,13 @@ func (ctrl *ApplicationController) getResourceTree(a *appv1.Application, managed
if err != nil {
return nil, fmt.Errorf("failed to unmarshal live state of managed resources: %w", err)
}
var target = &unstructured.Unstructured{}
err = json.Unmarshal([]byte(managedResource.TargetState), &target)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal target state of managed resources: %w", err)
}

if live == nil {
var target = &unstructured.Unstructured{}
err = json.Unmarshal([]byte(managedResource.TargetState), &target)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal target state of managed resources: %w", err)
}
nodes = append(nodes, appv1.ResourceNode{
ResourceRef: appv1.ResourceRef{
Version: target.GroupVersionKind().Version,
Expand Down

0 comments on commit e239215

Please sign in to comment.