Preserve UID/ResourceVersion in the BindingREST endpoint
Change-Id: If4023da10c455963a320fdb9fc2a73c099bea3db Kubernetes-commit: 62889f416cb60f66b3f04810ef2475c425b8394a
This commit is contained in:
parent
0fc1d27cde
commit
62e2e0a1b7
|
|
@ -162,8 +162,13 @@ func createHandler(r rest.NamedCreater, scope *RequestScope, admit admission.Int
|
||||||
userInfo, _ := request.UserFrom(ctx)
|
userInfo, _ := request.UserFrom(ctx)
|
||||||
|
|
||||||
if objectMeta, err := meta.Accessor(obj); err == nil {
|
if objectMeta, err := meta.Accessor(obj); err == nil {
|
||||||
// Wipe fields which cannot take user-provided values
|
preserveObjectMetaSystemFields := false
|
||||||
|
if c, ok := r.(rest.SubresourceObjectMetaPreserver); ok && len(scope.Subresource) > 0 {
|
||||||
|
preserveObjectMetaSystemFields = c.PreserveRequestObjectMetaSystemFieldsOnSubresourceCreate()
|
||||||
|
}
|
||||||
|
if !preserveObjectMetaSystemFields {
|
||||||
rest.WipeObjectMetaSystemFields(objectMeta)
|
rest.WipeObjectMetaSystemFields(objectMeta)
|
||||||
|
}
|
||||||
|
|
||||||
// ensure namespace on the object is correct, or error if a conflicting namespace was set in the object
|
// ensure namespace on the object is correct, or error if a conflicting namespace was set in the object
|
||||||
if err := rest.EnsureObjectNamespaceMatchesRequestNamespace(rest.ExpectedNamespaceForResource(namespace, scope.Resource), objectMeta); err != nil {
|
if err := rest.EnsureObjectNamespaceMatchesRequestNamespace(rest.ExpectedNamespaceForResource(namespace, scope.Resource), objectMeta); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,13 @@ type NamedCreater interface {
|
||||||
Create(ctx context.Context, name string, obj runtime.Object, createValidation ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error)
|
Create(ctx context.Context, name string, obj runtime.Object, createValidation ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SubresourceObjectMetaPreserver adds configuration options to a Creater for subresources.
|
||||||
|
type SubresourceObjectMetaPreserver interface {
|
||||||
|
// PreserveRequestObjectMetaSystemFieldsOnSubresourceCreate indicates that a
|
||||||
|
// handler should preserve fields of ObjectMeta that are managed by the system.
|
||||||
|
PreserveRequestObjectMetaSystemFieldsOnSubresourceCreate() bool
|
||||||
|
}
|
||||||
|
|
||||||
// UpdatedObjectInfo provides information about an updated object to an Updater.
|
// UpdatedObjectInfo provides information about an updated object to an Updater.
|
||||||
// It requires access to the old object in order to return the newly updated object.
|
// It requires access to the old object in order to return the newly updated object.
|
||||||
type UpdatedObjectInfo interface {
|
type UpdatedObjectInfo interface {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue