Skip to content

Commit

Permalink
Patch resource history annotations instead of update
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmadhankumar committed Sep 15, 2023
1 parent ec961f8 commit 3482fd8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/kapp/clusterapply/add_or_update_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package clusterapply

import (
"encoding/json"
"fmt"
"time"

Expand All @@ -12,6 +13,7 @@ import (
ctlres "github.com/vmware-tanzu/carvel-kapp/pkg/kapp/resources"
"github.com/vmware-tanzu/carvel-kapp/pkg/kapp/util"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
)

const (
Expand Down Expand Up @@ -262,7 +264,10 @@ func (c AddOrUpdateChange) recordAppliedResource(savedRes ctlres.Resource) error
return true, nil
}

_, err = c.identifiedResources.Update(latestResWithHistoryUpdated)
jsonStr, err := json.Marshal(latestResWithHistoryUpdated.Annotations())
data := []byte(fmt.Sprintf("{\"metadata\": {\"annotations\": %s }}", jsonStr))

_, err = c.identifiedResources.Patch(savedRes, types.MergePatchType, data)
if err != nil {
latestResWithHistory = nil // Get again
return false, fmt.Errorf("Saving record of last applied resource: %w", err)
Expand Down

0 comments on commit 3482fd8

Please sign in to comment.