本文整理匯總了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
}