let objects without metadata pass through the managedFields admission controller

Not all objects provide metadata. There might be extention servers that allow for creating objects without the metadata field.

This PR changes the managedFileds admission to deal with objects without the metadata field.
Object without that field will be passed directly to the wrapped admission controller for further validation.
This commit is contained in:
Lukasz Szaszkiewicz 2021-04-29 14:08:36 +02:00
parent 6e29545168
commit 3dbaf305ae

View File

@ -60,7 +60,10 @@ func (admit *managedFieldsValidatingAdmissionController) Admit(ctx context.Conte
}
objectMeta, err := meta.Accessor(a.GetObject())
if err != nil {
return err
// the object we are dealing with doesn't have object metadata defined
// in that case we don't have to keep track of the managedField
// just call the wrapped admission
return mutationInterface.Admit(ctx, a, o)
}
managedFieldsBeforeAdmission := objectMeta.GetManagedFields()
if err := mutationInterface.Admit(ctx, a, o); err != nil {