instancetype: Only replace matcher when defaults are found
Previously the mutation webhook would always overwrite the
{Instancetype,Preference}Matcher of the spec with whatever was returned
by InferDefault{Instancetype,Preference}, including nil.
@@ -188,7 +188,9 @@ func (mutator *VMsMutator) inferDefaultInstancetype(vm *v1.VirtualMachine) error
if err != nil {
return err
}
+ if instancetypeMatcher != nil {
vm.Spec.Instancetype = instancetypeMatcher
+ }
return nil
}
@@ -197,7 +199,9 @@ func (mutator *VMsMutator) inferDefaultPreference(vm *v1.VirtualMachine) error {
if err != nil {
return err
}
+ if preferenceMatcher != nil {
vm.Spec.Preference = preferenceMatcher
+ }
return nil
}
