本文整理汇总了Golang中github.com/openshift/origin/pkg/image/api/validation.ValidateImageStreamName函数的典型用法代码示例。如果您正苦于以下问题:Golang ValidateImageStreamName函数的具体用法?Golang ValidateImageStreamName怎么用?Golang ValidateImageStreamName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ValidateImageStreamName函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: validateToImageReference
func validateToImageReference(reference *kapi.ObjectReference, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
kind, name, namespace := reference.Kind, reference.Name, reference.Namespace
switch kind {
case "ImageStreamTag":
if len(name) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("name"), ""))
} else if _, _, ok := imageapi.SplitImageStreamTag(name); !ok {
allErrs = append(allErrs, field.Invalid(fldPath.Child("name"), name, "ImageStreamTag object references must be in the form <name>:<tag>"))
} else if name, _, _ := imageapi.SplitImageStreamTag(name); len(imageapivalidation.ValidateImageStreamName(name, false)) != 0 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("name"), name, "ImageStreamTag name contains invalid syntax"))
}
if len(namespace) != 0 && len(kvalidation.IsDNS1123Subdomain(namespace)) != 0 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("namespace"), namespace, "namespace must be a valid subdomain"))
}
case "DockerImage":
if len(namespace) != 0 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("namespace"), namespace, "namespace is not valid when used with a 'DockerImage'"))
}
if _, err := imageapi.ParseDockerImageReference(name); err != nil {
allErrs = append(allErrs, field.Invalid(fldPath.Child("name"), name, fmt.Sprintf("name is not a valid Docker pull specification: %v", err)))
}
case "":
allErrs = append(allErrs, field.Required(fldPath.Child("kind"), ""))
default:
allErrs = append(allErrs, field.Invalid(fldPath.Child("kind"), kind, "the target of build output must be an 'ImageStreamTag' or 'DockerImage'"))
}
return allErrs
}
示例2: validateImageStreamTagName
func validateImageStreamTagName(istag string) error {
name, _, ok := imageapi.SplitImageStreamTag(istag)
if !ok {
return fmt.Errorf("invalid ImageStreamTag: %s", istag)
}
if reasons := imageval.ValidateImageStreamName(name, false); len(reasons) != 0 {
return errors.New(strings.Join(reasons, ", "))
}
return nil
}
示例3: validateImageStreamTagName
func validateImageStreamTagName(istag string) error {
name, _, ok := imageapi.SplitImageStreamTag(istag)
if !ok {
return fmt.Errorf("must be in the form of <name>:<tag>")
}
if reasons := imageval.ValidateImageStreamName(name, false); len(reasons) != 0 {
return errors.New(strings.Join(reasons, ", "))
}
return nil
}
示例4: validateImageStreamTagName
func validateImageStreamTagName(istag string) error {
name, _, ok := imageapi.SplitImageStreamTag(istag)
if !ok {
return fmt.Errorf("invalid ImageStreamTag: %s", istag)
}
ok, reason := imageval.ValidateImageStreamName(name, false)
if !ok {
return errors.New(reason)
}
return nil
}