Skip to content

Commit 26d9e70

Browse files
author
jennybuckley
committed
Dont convert to empty version
1 parent 5bd90b3 commit 26d9e70

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

internal/fixture/state.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,14 @@ func (s *State) CompareLive(obj typed.YAMLObject) (*typed.Comparison, error) {
147147
return s.Live.Compare(tv)
148148
}
149149

150-
// dummyConverter doesn't convert, it just returns the same exact object no matter what.
150+
// dummyConverter doesn't convert, it just returns the same exact object, as long as a version is provided.
151151
type dummyConverter struct{}
152152

153153
// Convert returns the object given in input, not doing any conversion.
154154
func (dummyConverter) Convert(v typed.TypedValue, version fieldpath.APIVersion) (typed.TypedValue, error) {
155+
if len(version) == 0 {
156+
return nil, fmt.Errorf("cannot convert to invalid version: %q", version)
157+
}
155158
return v, nil
156159
}
157160

merge/update.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ func (s *Updater) Apply(liveObject, configObject typed.TypedValue, version field
153153
}
154154

155155
func (s *Updater) removeDisownedItems(merged, applied typed.TypedValue, lastSet *fieldpath.VersionedSet) (typed.TypedValue, error) {
156+
if lastSet.Set.Empty() {
157+
return merged, nil
158+
}
156159
convertedApplied, err := s.Converter.Convert(applied, lastSet.APIVersion)
157160
if err != nil {
158161
return nil, fmt.Errorf("failed to convert applied config to last applied version: %v", err)

0 commit comments

Comments
 (0)