Skip to content

Remove unions logic, keep schema components #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions internal/fixture/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,6 @@ type TestCase struct {
// Managed, if not nil, is the ManagedFields as expected
// after all operations are run.
Managed fieldpath.ManagedFields
// Set to true if the test case needs the union behavior enabled.
RequiresUnions bool
// ReportInputOnNoop if we don't want to compare the output and
// always return it.
ReturnInputOnNoop bool
Expand Down Expand Up @@ -576,7 +574,6 @@ func (tc TestCase) BenchWithConverter(parser Parser, converter merge.Converter)
Converter: converter,
IgnoredFields: tc.IgnoredFields,
ReturnInputOnNoop: tc.ReturnInputOnNoop,
EnableUnions: tc.RequiresUnions,
}
state := State{
Updater: updaterBuilder.BuildUpdater(),
Expand All @@ -599,7 +596,6 @@ func (tc TestCase) TestWithConverter(parser Parser, converter merge.Converter) e
Converter: converter,
IgnoredFields: tc.IgnoredFields,
ReturnInputOnNoop: tc.ReturnInputOnNoop,
EnableUnions: tc.RequiresUnions,
}
state := State{
Updater: updaterBuilder.BuildUpdater(),
Expand Down Expand Up @@ -636,15 +632,5 @@ func (tc TestCase) TestWithConverter(parser Parser, converter merge.Converter) e
}
}

if !tc.RequiresUnions {
// Re-run the test with unions on.
tc2 := tc
tc2.RequiresUnions = true
err := tc2.TestWithConverter(parser, converter)
if err != nil {
return fmt.Errorf("fails if unions are on: %v", err)
}
}

return nil
}
234 changes: 0 additions & 234 deletions merge/union_test.go

This file was deleted.

31 changes: 0 additions & 31 deletions merge/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ type UpdaterBuilder struct {
Converter Converter
IgnoredFields map[fieldpath.APIVersion]*fieldpath.Set

EnableUnions bool

// Stop comparing the new object with old object after applying.
// This was initially used to avoid spurious etcd update, but
// since that's vastly inefficient, we've come-up with a better
Expand All @@ -49,7 +47,6 @@ func (u *UpdaterBuilder) BuildUpdater() *Updater {
return &Updater{
Converter: u.Converter,
IgnoredFields: u.IgnoredFields,
enableUnions: u.EnableUnions,
returnInputOnNoop: u.ReturnInputOnNoop,
}
}
Expand All @@ -63,19 +60,9 @@ type Updater struct {
// Deprecated: This will eventually become private.
IgnoredFields map[fieldpath.APIVersion]*fieldpath.Set

enableUnions bool

returnInputOnNoop bool
}

// EnableUnionFeature turns on union handling. It is disabled by default until the
// feature is complete.
//
// Deprecated: Use the builder instead.
func (s *Updater) EnableUnionFeature() {
s.enableUnions = true
}

func (s *Updater) update(oldObject, newObject *typed.TypedValue, version fieldpath.APIVersion, managers fieldpath.ManagedFields, workflow string, force bool) (fieldpath.ManagedFields, *typed.Comparison, error) {
conflicts := fieldpath.ManagedFields{}
removed := fieldpath.ManagedFields{}
Expand Down Expand Up @@ -160,12 +147,6 @@ func (s *Updater) Update(liveObject, newObject *typed.TypedValue, version fieldp
if err != nil {
return nil, fieldpath.ManagedFields{}, err
}
if s.enableUnions {
newObject, err = liveObject.NormalizeUnions(newObject)
if err != nil {
return nil, fieldpath.ManagedFields{}, err
}
}
managers, compare, err := s.update(liveObject, newObject, version, managers, manager, true)
if err != nil {
return nil, fieldpath.ManagedFields{}, err
Expand Down Expand Up @@ -198,22 +179,10 @@ func (s *Updater) Apply(liveObject, configObject *typed.TypedValue, version fiel
if err != nil {
return nil, fieldpath.ManagedFields{}, err
}
if s.enableUnions {
configObject, err = configObject.NormalizeUnionsApply(configObject)
if err != nil {
return nil, fieldpath.ManagedFields{}, err
}
}
newObject, err := liveObject.Merge(configObject)
if err != nil {
return nil, fieldpath.ManagedFields{}, fmt.Errorf("failed to merge config: %v", err)
}
if s.enableUnions {
newObject, err = configObject.NormalizeUnionsApply(newObject)
if err != nil {
return nil, fieldpath.ManagedFields{}, err
}
}
lastSet := managers[manager]
set, err := configObject.ToFieldSet()
if err != nil {
Expand Down
Loading