Skip to content

Commit 6e48806

Browse files
authored
Merge pull request #54 from jennybuckley/optimize
skip converting to same version
2 parents d43a45b + 1313454 commit 6e48806

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

merge/update.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type Updater struct {
3232
Converter Converter
3333
}
3434

35-
func (s *Updater) update(oldObject, newObject typed.TypedValue, managers fieldpath.ManagedFields, workflow string, force bool) (fieldpath.ManagedFields, error) {
35+
func (s *Updater) update(oldObject, newObject typed.TypedValue, version fieldpath.APIVersion, managers fieldpath.ManagedFields, workflow string, force bool) (fieldpath.ManagedFields, error) {
3636
if managers == nil {
3737
managers = fieldpath.ManagedFields{}
3838
}
@@ -41,7 +41,12 @@ func (s *Updater) update(oldObject, newObject typed.TypedValue, managers fieldpa
4141
oldObject typed.TypedValue
4242
newObject typed.TypedValue
4343
}
44-
versions := map[fieldpath.APIVersion]Versioned{}
44+
versions := map[fieldpath.APIVersion]Versioned{
45+
version: Versioned{
46+
oldObject: oldObject,
47+
newObject: newObject,
48+
},
49+
}
4550

4651
for manager, managerSet := range managers {
4752
if manager == workflow {
@@ -92,7 +97,7 @@ func (s *Updater) update(oldObject, newObject typed.TypedValue, managers fieldpa
9297
// this is a CREATE call).
9398
func (s *Updater) Update(liveObject, newObject typed.TypedValue, version fieldpath.APIVersion, managers fieldpath.ManagedFields, manager string) (fieldpath.ManagedFields, error) {
9499
var err error
95-
managers, err = s.update(liveObject, newObject, managers, manager, true)
100+
managers, err = s.update(liveObject, newObject, version, managers, manager, true)
96101
if err != nil {
97102
return fieldpath.ManagedFields{}, err
98103
}
@@ -118,7 +123,7 @@ func (s *Updater) Apply(liveObject, configObject typed.TypedValue, version field
118123
if err != nil {
119124
return typed.TypedValue{}, fieldpath.ManagedFields{}, fmt.Errorf("failed to merge config: %v", err)
120125
}
121-
managers, err = s.update(liveObject, newObject, managers, manager, force)
126+
managers, err = s.update(liveObject, newObject, version, managers, manager, force)
122127
if err != nil {
123128
return typed.TypedValue{}, fieldpath.ManagedFields{}, err
124129
}

0 commit comments

Comments
 (0)