本文整理匯總了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/api.ObjectMeta類的典型用法代碼示例。如果您正苦於以下問題:Golang ObjectMeta類的具體用法?Golang ObjectMeta怎麽用?Golang ObjectMeta使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ObjectMeta類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ValidateObjectMetaUpdate
// ValidateObjectMetaUpdate validates an object's metadata when updated
func ValidateObjectMetaUpdate(old, meta *api.ObjectMeta) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
// in the event it is left empty, set it, to allow clients more flexibility
if len(meta.UID) == 0 {
meta.UID = old.UID
}
if meta.CreationTimestamp.IsZero() {
meta.CreationTimestamp = old.CreationTimestamp
}
if old.Name != meta.Name {
allErrs = append(allErrs, errs.NewFieldInvalid("name", meta.Name, "field is immutable"))
}
if old.Namespace != meta.Namespace {
allErrs = append(allErrs, errs.NewFieldInvalid("namespace", meta.Namespace, "field is immutable"))
}
if old.UID != meta.UID {
allErrs = append(allErrs, errs.NewFieldInvalid("uid", meta.UID, "field is immutable"))
}
if old.CreationTimestamp != meta.CreationTimestamp {
allErrs = append(allErrs, errs.NewFieldInvalid("creationTimestamp", meta.CreationTimestamp, "field is immutable"))
}
allErrs = append(allErrs, ValidateLabels(meta.Labels, "labels")...)
allErrs = append(allErrs, ValidateAnnotations(meta.Annotations, "annotations")...)
return allErrs
}
示例2: exportObjectMeta
func exportObjectMeta(objMeta *kapi.ObjectMeta, exact bool) {
objMeta.UID = ""
if !exact {
objMeta.Namespace = ""
}
objMeta.CreationTimestamp = util.Time{}
objMeta.DeletionTimestamp = nil
objMeta.ResourceVersion = ""
objMeta.SelfLink = ""
if len(objMeta.GenerateName) > 0 && !exact {
objMeta.Name = ""
}
}