本文整理汇总了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 = ""
}
}