Allow handlers earlier in a request flow to inject a UID for an object

This commit is contained in:
derekwaynecarr
2016-05-07 09:23:15 -04:00
parent 5e16101aab
commit 029acfc8aa
3 changed files with 37 additions and 5 deletions

View File

@@ -29,7 +29,13 @@ import (
// FillObjectMetaSystemFields populates fields that are managed by the system on ObjectMeta.
func FillObjectMetaSystemFields(ctx Context, meta *ObjectMeta) {
meta.CreationTimestamp = unversioned.Now()
meta.UID = util.NewUUID()
// allows admission controllers to assign a UID earlier in the request processing
// to support tracking resources pending creation.
uid, found := UIDFrom(ctx)
if !found {
uid = util.NewUUID()
}
meta.UID = uid
meta.SelfLink = ""
}