Skip to content

Commit

Permalink
Merge pull request #863 from carvel-dev/memory-optimisation
Browse files Browse the repository at this point in the history
Memory optimization
  • Loading branch information
praveenrewar authored Jan 19, 2024
2 parents b494b67 + 9f70c5d commit 90412c7
Show file tree
Hide file tree
Showing 23 changed files with 495 additions and 90 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ require (
github.com/cppforlife/cobrautil v0.0.0-20221130162803-acdfead391ef
github.com/cppforlife/color v1.9.1-0.20200716202919-6706ac40b835
github.com/cppforlife/go-cli-ui v0.0.0-20220425131040-94f26b16bc14
github.com/cppforlife/go-patch v0.2.0
github.com/cppforlife/go-patch v0.0.0-20240118020416-2147782e467b
github.com/google/go-cmp v0.6.0
github.com/hashicorp/go-version v1.6.0
github.com/k14s/difflib v0.0.0-20201117154628-0c031775bf57
github.com/k14s/difflib v0.0.0-20240118055029-596a7a5585c3
github.com/k14s/ytt v0.36.0
github.com/mitchellh/go-wordwrap v1.0.1
github.com/spf13/cobra v1.7.0
Expand Down
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ github.com/cppforlife/color v1.9.1-0.20200716202919-6706ac40b835/go.mod h1:dYeVs
github.com/cppforlife/go-cli-ui v0.0.0-20200505234325-512793797f05/go.mod h1:I0qrzCmuPWYI6kAOvkllYjaW2aovclWbJ96+v+YyHb0=
github.com/cppforlife/go-cli-ui v0.0.0-20220425131040-94f26b16bc14 h1:MjRdR01xh0sfkeS3OOBv+MYkYsrbHuTDc4rfBnVdFaI=
github.com/cppforlife/go-cli-ui v0.0.0-20220425131040-94f26b16bc14/go.mod h1:AlgTssDlstr4mf92TR4DPITLfl5+7wEY4cKStCmeeto=
github.com/cppforlife/go-patch v0.2.0 h1:Y14MnCQjDlbw7WXT4k+u6DPAA9XnygN4BfrSpI/19RU=
github.com/cppforlife/go-patch v0.2.0/go.mod h1:67a7aIi94FHDZdoeGSJRRFDp66l9MhaAG1yGxpUoFD8=
github.com/cppforlife/go-patch v0.0.0-20240118020416-2147782e467b h1:+8LQctLhaj+63L/37l8IK/5Q3odN6RzWlglonUwrKok=
github.com/cppforlife/go-patch v0.0.0-20240118020416-2147782e467b/go.mod h1:67a7aIi94FHDZdoeGSJRRFDp66l9MhaAG1yGxpUoFD8=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
Expand Down Expand Up @@ -169,8 +169,9 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/k14s/difflib v0.0.0-20201117154628-0c031775bf57 h1:CwBRArr+BWBopnUJhDjJw86rPL/jGbEjfHWKzTasSqE=
github.com/k14s/difflib v0.0.0-20201117154628-0c031775bf57/go.mod h1:B0xN2MiNBGWOWi9CcfAo9LBI8IU4J1utlbOIJCsmKr4=
github.com/k14s/difflib v0.0.0-20240118055029-596a7a5585c3 h1:q2ikACDbDDbyUcN9JkDcNMGhIx1EBRkctAsPZMr35qM=
github.com/k14s/difflib v0.0.0-20240118055029-596a7a5585c3/go.mod h1:B0xN2MiNBGWOWi9CcfAo9LBI8IU4J1utlbOIJCsmKr4=
github.com/k14s/starlark-go v0.0.0-20200720175618-3a5c849cc368 h1:4bcRTTSx+LKSxMWibIwzHnDNmaN1x52oEpvnjCy+8vk=
github.com/k14s/starlark-go v0.0.0-20200720175618-3a5c849cc368/go.mod h1:lKGj1op99m4GtQISxoD2t+K+WO/q2NzEPKvfXFQfbCA=
github.com/k14s/ytt v0.36.0 h1:ERr7q+r3ziYJv91fvTx2b76d1MIo3SI/EsAS01WU+Zo=
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/app/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (o *DeleteOptions) calculateAndPresentChanges(existingResources []ctlres.Re
)

{ // Figure out changes for X existing resources -> 0 new resources
changeFactory := ctldiff.NewChangeFactory(nil, nil, nil)
changeFactory := ctldiff.NewChangeFactory(nil, nil, nil, ctldiff.ChangeOpts{o.DiffFlags.AnchoredDiff})
changeSetFactory := ctldiff.NewChangeSetFactory(o.DiffFlags.ChangeSetOpts, changeFactory)

changes, err := changeSetFactory.New(existingResources, nil).Calculate()
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/app/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func (o *DeployOptions) calculateAndPresentChanges(existingResources,
var clusterChangeSet ctlcap.ClusterChangeSet

{ // Figure out changes for X existing resources -> X new resources
changeFactory := ctldiff.NewChangeFactory(conf.RebaseMods(), conf.DiffAgainstLastAppliedFieldExclusionMods(), conf.DiffAgainstExistingFieldExclusionMods())
changeFactory := ctldiff.NewChangeFactory(conf.RebaseMods(), conf.DiffAgainstLastAppliedFieldExclusionMods(), conf.DiffAgainstExistingFieldExclusionMods(), ctldiff.ChangeOpts{o.DiffFlags.AnchoredDiff})
changeSetFactory := ctldiff.NewChangeSetFactory(o.DiffFlags.ChangeSetOpts, changeFactory)

err := ctldiff.NewRenewableResources(existingResources, newResources).Prepare()
Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/tools/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (o *DiffOptions) Run() error {
return err
}

changeFactory := ctldiff.NewChangeFactory(nil, nil, nil)
changeFactory := ctldiff.NewChangeFactory(nil, nil, nil, ctldiff.ChangeOpts{o.DiffFlags.AnchoredDiff})

changes, err := ctldiff.NewChangeSet(existingResources, newResources, o.DiffFlags.ChangeSetOpts, changeFactory).Calculate()
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/kapp/cmd/tools/diff_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type DiffFlags struct {
Run bool
ExitStatus bool
UI bool

AnchoredDiff bool
}

func (s *DiffFlags) SetWithPrefix(prefix string, cmd *cobra.Command) {
Expand All @@ -39,4 +41,6 @@ func (s *DiffFlags) SetWithPrefix(prefix string, cmd *cobra.Command) {

cmd.Flags().StringVar(&s.Filter, prefix+"filter", "", `Set changes filter (example: {"and":[{"ops":["update"]},{"existingResource":{"kinds":["Deployment"]}]})`)
cmd.Flags().BoolVar(&s.ChangesYAML, prefix+"changes-yaml", false, "Print YAML to be applied")

cmd.Flags().BoolVar(&s.AnchoredDiff, prefix+"anchored", false, "Allow using anchored diff for large resources")
}
2 changes: 1 addition & 1 deletion pkg/kapp/config/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func TestDefaultTemplateRules(t *testing.T) {
_, defaultConfig, err := config.NewConfFromResourcesWithDefaults([]ctlres.Resource{})
require.NoError(t, err)
changeFactory := ctldiff.NewChangeFactory(defaultConfig.RebaseMods(), defaultConfig.DiffAgainstLastAppliedFieldExclusionMods(), defaultConfig.DiffAgainstExistingFieldExclusionMods())
changeFactory := ctldiff.NewChangeFactory(defaultConfig.RebaseMods(), defaultConfig.DiffAgainstLastAppliedFieldExclusionMods(), defaultConfig.DiffAgainstExistingFieldExclusionMods(), ctldiff.ChangeOpts{false})

testCases := []struct {
description string
Expand Down
40 changes: 6 additions & 34 deletions pkg/kapp/diff/change.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package diff
import (
"github.com/cppforlife/go-patch/patch"
ctlres "github.com/vmware-tanzu/carvel-kapp/pkg/kapp/resources"
"gopkg.in/yaml.v2"
)

type ChangeOp string
Expand Down Expand Up @@ -46,11 +45,13 @@ type ChangeImpl struct {
configurableTextDiff *ConfigurableTextDiff
opsDiff *OpsDiff
changeOpVal ChangeOp

opts ChangeOpts
}

var _ Change = &ChangeImpl{}

func NewChange(existingRes, newRes, appliedRes, clusterOriginalRes ctlres.Resource) *ChangeImpl {
func NewChange(existingRes, newRes, appliedRes, clusterOriginalRes ctlres.Resource, opts ChangeOpts) *ChangeImpl {
if existingRes == nil && newRes == nil {
panic("Expected either existingRes or newRes be non-nil")
}
Expand All @@ -68,7 +69,7 @@ func NewChange(existingRes, newRes, appliedRes, clusterOriginalRes ctlres.Resour
clusterOriginalRes = clusterOriginalRes.DeepCopy()
}

return &ChangeImpl{existingRes: existingRes, newRes: newRes, appliedRes: appliedRes, clusterOriginalRes: clusterOriginalRes}
return &ChangeImpl{existingRes: existingRes, newRes: newRes, appliedRes: appliedRes, clusterOriginalRes: clusterOriginalRes, opts: opts}
}

func (d *ChangeImpl) NewOrExistingResource() ctlres.Resource {
Expand Down Expand Up @@ -130,7 +131,7 @@ func (d *ChangeImpl) isIgnoredTransient() bool {
func (d *ChangeImpl) ConfigurableTextDiff() *ConfigurableTextDiff {
// diff is called very often, so memoize
if d.configurableTextDiff == nil {
d.configurableTextDiff = NewConfigurableTextDiff(d.existingRes, d.newRes, d.IsIgnored())
d.configurableTextDiff = NewConfigurableTextDiff(d.existingRes, d.newRes, d.IsIgnored(), d.opts)
}
return d.configurableTextDiff
}
Expand All @@ -147,36 +148,7 @@ func (d *ChangeImpl) OpsDiff() OpsDiff {
}

func (d *ChangeImpl) calculateOpsDiff() OpsDiff {
var existingObj interface{}
var newObj interface{}

if d.existingRes != nil {
existingBytes, err := d.existingRes.AsYAMLBytes()
if err != nil {
panic("yamling existingRes") // TODO panic
}

err = yaml.Unmarshal(existingBytes, &existingObj)
if err != nil {
panic("unyamling existingRes") // TODO panic
}
}

if d.newRes != nil {
newBytes, err := d.newRes.AsYAMLBytes()
if err != nil {
panic("yamling newRes") // TODO panic
}

err = yaml.Unmarshal(newBytes, &newObj)
if err != nil {
panic("unyamling newRes") // TODO panic
}
} else if d.IsIgnored() {
newObj = existingObj // show as no changes
}

return OpsDiff(patch.Diff{Left: existingObj, Right: newObj}.Calculate())
return OpsDiff(patch.Diff{Left: d.existingRes.UnstructuredObject(), Right: d.newRes.UnstructuredObject()}.Calculate())
}

func (d *ChangeImpl) newResHasExistsAnnotation() bool {
Expand Down
13 changes: 9 additions & 4 deletions pkg/kapp/diff/change_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ type ChangeFactory struct {
rebaseMods []ctlres.ResourceModWithMultiple
diffAgainstLastAppliedFieldExclusionMods []ctlres.FieldRemoveMod
diffAgainstExistingFieldExclusionRules []ctlres.FieldRemoveMod
opts ChangeOpts
}

type ChangeOpts struct {
AllowAnchoredDiff bool
}

func NewChangeFactory(rebaseMods []ctlres.ResourceModWithMultiple,
diffAgainstLastAppliedFieldExclusionMods []ctlres.FieldRemoveMod, diffAgainstExistingFieldExclusionRules []ctlres.FieldRemoveMod) ChangeFactory {
diffAgainstLastAppliedFieldExclusionMods []ctlres.FieldRemoveMod, diffAgainstExistingFieldExclusionRules []ctlres.FieldRemoveMod, opts ChangeOpts) ChangeFactory {

return ChangeFactory{rebaseMods, diffAgainstLastAppliedFieldExclusionMods, diffAgainstExistingFieldExclusionRules}
return ChangeFactory{rebaseMods, diffAgainstLastAppliedFieldExclusionMods, diffAgainstExistingFieldExclusionRules, opts}
}

func (f ChangeFactory) NewChangeAgainstLastApplied(existingRes, newRes ctlres.Resource) (Change, error) {
Expand Down Expand Up @@ -59,7 +64,7 @@ func (f ChangeFactory) NewChangeAgainstLastApplied(existingRes, newRes ctlres.Re
return nil, err
}

return NewChange(existingRes, rebasedNewRes, newRes, existingResForRebasing), nil
return NewChange(existingRes, rebasedNewRes, newRes, existingResForRebasing, f.opts), nil
}

func (f ChangeFactory) NewExactChange(existingRes, newRes ctlres.Resource) (Change, error) {
Expand All @@ -86,7 +91,7 @@ func (f ChangeFactory) NewExactChange(existingRes, newRes ctlres.Resource) (Chan
return nil, err
}

return NewChange(existingRes, rebasedNewRes, newRes, existingRes), nil
return NewChange(existingRes, rebasedNewRes, newRes, existingRes, f.opts), nil
}

func (f ChangeFactory) NewResourceWithHistory(resource ctlres.Resource) ResourceWithHistory {
Expand Down
10 changes: 5 additions & 5 deletions pkg/kapp/diff/change_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ metadata:
},
}

changeFactory := ctldiff.NewChangeFactory(mods, nil, nil)
changeFactory := ctldiff.NewChangeFactory(mods, nil, nil, ctldiff.ChangeOpts{false})
changeSet := ctldiff.NewChangeSet([]ctlres.Resource{existingRes}, []ctlres.Resource{newRes},
ctldiff.ChangeSetOpts{}, changeFactory)

Expand Down Expand Up @@ -106,7 +106,7 @@ metadata:
},
}

changeFactory := ctldiff.NewChangeFactory(mods, nil, nil)
changeFactory := ctldiff.NewChangeFactory(mods, nil, nil, ctldiff.ChangeOpts{false})
changeSet := ctldiff.NewChangeSet([]ctlres.Resource{existingRes}, []ctlres.Resource{newRes},
ctldiff.ChangeSetOpts{}, changeFactory)

Expand Down Expand Up @@ -174,7 +174,7 @@ metadata:
},
}

changeFactory := ctldiff.NewChangeFactory(rebaseMods, ignoreFieldsMods, nil)
changeFactory := ctldiff.NewChangeFactory(rebaseMods, ignoreFieldsMods, nil, ctldiff.ChangeOpts{false})
changeSet := ctldiff.NewChangeSet([]ctlres.Resource{existingRes}, []ctlres.Resource{newRes},
ctldiff.ChangeSetOpts{AgainstLastApplied: true}, changeFactory)

Expand Down Expand Up @@ -246,7 +246,7 @@ metadata:
},
}

changeFactory := ctldiff.NewChangeFactory(rebaseMods, ignoreFieldsMods, nil)
changeFactory := ctldiff.NewChangeFactory(rebaseMods, ignoreFieldsMods, nil, ctldiff.ChangeOpts{false})
changeSet := ctldiff.NewChangeSet([]ctlres.Resource{existingRes}, []ctlres.Resource{newRes},
ctldiff.ChangeSetOpts{AgainstLastApplied: true}, changeFactory)

Expand Down Expand Up @@ -304,7 +304,7 @@ metadata:
},
}

changeFactory := ctldiff.NewChangeFactory(mods, nil, nil)
changeFactory := ctldiff.NewChangeFactory(mods, nil, nil, ctldiff.ChangeOpts{false})
changeSet := ctldiff.NewChangeSet([]ctlres.Resource{existingRes}, []ctlres.Resource{newRes},
ctldiff.ChangeSetOpts{}, changeFactory)

Expand Down
2 changes: 1 addition & 1 deletion pkg/kapp/diff/change_set_with_versioned_rs.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (d ChangeSetWithVersionedRs) noopAndDeleteChanges(
}

func (d ChangeSetWithVersionedRs) newKeepChange(existingRes ctlres.Resource) Change {
return NewChangePrecalculated(existingRes, nil, nil, ChangeOpKeep, NewConfigurableTextDiff(existingRes, nil, true), OpsDiff{})
return NewChangePrecalculated(existingRes, nil, nil, ChangeOpKeep, NewConfigurableTextDiff(existingRes, nil, true, ChangeOpts{false}), OpsDiff{})
}

func (d ChangeSetWithVersionedRs) newNoopChange(existingRes ctlres.Resource) Change {
Expand Down
8 changes: 5 additions & 3 deletions pkg/kapp/diff/configurable_text_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ type ConfigurableTextDiff struct {
ignored bool

memoizedTextDiff *TextDiff

opts ChangeOpts
}

func NewConfigurableTextDiff(existingRes, newRes ctlres.Resource, ignored bool) *ConfigurableTextDiff {
return &ConfigurableTextDiff{existingRes, newRes, ignored, nil}
func NewConfigurableTextDiff(existingRes, newRes ctlres.Resource, ignored bool, opts ChangeOpts) *ConfigurableTextDiff {
return &ConfigurableTextDiff{existingRes, newRes, ignored, nil, opts}
}

func (d ConfigurableTextDiff) Full() TextDiff {
Expand Down Expand Up @@ -73,5 +75,5 @@ func (d ConfigurableTextDiff) calculate(existingRes, newRes ctlres.Resource) Tex
newLines = existingLines // show as no changes
}

return NewTextDiff(existingLines, newLines)
return NewTextDiff(existingLines, newLines, d.opts.AllowAnchoredDiff)
}
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
13 changes: 3 additions & 10 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 All @@ -45,10 +38,10 @@ func (r RebasedResource) Resource() (ctlres.Resource, error) {
if t.IsResourceMatching(result) {
// copy newRes and existingRes as they may be modified in place
resSources := map[ctlres.FieldCopyModSource]ctlres.Resource{
ctlres.FieldCopyModSourceNew: r.newRes.DeepCopy(),
ctlres.FieldCopyModSourceExisting: r.existingRes.DeepCopy(),
ctlres.FieldCopyModSourceNew: r.newRes,
ctlres.FieldCopyModSourceExisting: r.existingRes,
// Might be useful for more advanced rebase rules like ytt-based
ctlres.FieldCopyModSource("_current"): result.DeepCopy(),
ctlres.FieldCopyModSource("_current"): result,
}

err := t.ApplyFromMultiple(result, resSources)
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
6 changes: 5 additions & 1 deletion pkg/kapp/diff/text_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ type TextDiff struct {
recs []difflib.DiffRecord
}

func NewTextDiff(existingLines, newLines []string) TextDiff {
func NewTextDiff(existingLines, newLines []string, allowAnchoredDiff bool) TextDiff {
if allowAnchoredDiff && (len(existingLines) > 500 || len(newLines) > 500) {
// Diff is memory hungry, use AnchoredDiff for large resources
return TextDiff{difflib.AnchoredDiff(existingLines, newLines)}
}
return TextDiff{difflib.Diff(existingLines, newLines)}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/kapp/resources/mod_field_copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (t FieldCopyMod) ApplyFromMultiple(res Resource, srcs map[FieldCopyModSourc
// Make a copy of resource, to avoid modifications
// that may be done even in case when there is nothing to copy
updatedRes := res.DeepCopy()
source = source.DeepCopy()
updated, err := t.apply(updatedRes.unstructured().Object, source.unstructured().Object, t.Path, Path{}, srcs)
if err != nil {
return fmt.Errorf("FieldCopyMod for path '%s' on resource '%s': %s", t.Path.AsString(), res.Description(), err)
Expand Down Expand Up @@ -198,7 +199,7 @@ func (t FieldCopyMod) copyIntoMap(obj map[string]interface{}, fullPath Path, src
continue
}

val, found, err := t.obtainValue(srcRes.unstructured().Object, fullPath)
val, found, err := t.obtainValue(srcRes.DeepCopy().unstructured().Object, fullPath)
if err != nil {
return false, err
} else if !found {
Expand Down
4 changes: 4 additions & 0 deletions pkg/kapp/resources/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type Resource interface {
MarkTransient(bool)
Transient() bool

UnstructuredObject() map[string]interface{}

unstructured() unstructured.Unstructured // private
unstructuredPtr() *unstructured.Unstructured // private
setUnstructured(unstructured.Unstructured) // private
Expand Down Expand Up @@ -280,6 +282,8 @@ func (r *ResourceImpl) Debug(title string) {
func (r *ResourceImpl) SetOrigin(origin string) { r.origin = origin }
func (r *ResourceImpl) Origin() string { return r.origin }

func (r *ResourceImpl) UnstructuredObject() map[string]interface{} { return r.un.Object }

func (r *ResourceImpl) unstructured() unstructured.Unstructured { return r.un }
func (r *ResourceImpl) unstructuredPtr() *unstructured.Unstructured { return &r.un }
func (r *ResourceImpl) setUnstructured(un unstructured.Unstructured) { r.un = un }
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
Loading

0 comments on commit 90412c7

Please sign in to comment.