Skip to content

Commit

Permalink
Do not DeepCopy resources in constructors
Browse files Browse the repository at this point in the history
if the resources are already getting deep copied later on

Signed-off-by: Praveen Rewar <[email protected]>
  • Loading branch information
praveenrewar committed Jan 18, 2024
1 parent 75e9565 commit 77d777d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 14 deletions.
2 changes: 1 addition & 1 deletion pkg/kapp/diff/masked_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewMaskedResource(res ctlres.Resource, rules []ctlconf.DiffMaskRule) Masked
if res == nil {
panic("Expected res be non-nil")
}
return MaskedResource{res.DeepCopy(), rules}
return MaskedResource{res, rules}
}

func (r MaskedResource) Resource() (ctlres.Resource, error) {
Expand Down
7 changes: 0 additions & 7 deletions pkg/kapp/diff/rebased_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ func NewRebasedResource(existingRes, newRes ctlres.Resource, mods []ctlres.Resou
panic("Expected either existingRes or newRes be non-nil")
}

if existingRes != nil {
existingRes = existingRes.DeepCopy()
}
if newRes != nil {
newRes = newRes.DeepCopy()
}

return RebasedResource{existingRes: existingRes, newRes: newRes, mods: mods}
}

Expand Down
3 changes: 0 additions & 3 deletions pkg/kapp/diff/resource_with_removed_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ type ResourceWithRemovedFields struct {
}

func NewResourceWithRemovedFields(res ctlres.Resource, mods []ctlres.FieldRemoveMod) ResourceWithRemovedFields {
if res != nil {
res = res.DeepCopy()
}
return ResourceWithRemovedFields{res: res, mods: mods}
}

Expand Down
3 changes: 0 additions & 3 deletions pkg/kapp/resources/resource_with_managed_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ type ResourceWithManagedFields struct {
}

func NewResourceWithManagedFields(res Resource, managedFields bool) ResourceWithManagedFields {
if res != nil {
res = res.DeepCopy()
}
return ResourceWithManagedFields{res: res, managedFields: managedFields}
}

Expand Down

0 comments on commit 77d777d

Please sign in to comment.