• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang validation.NameIsDNSSubdomain函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中k8s/io/kubernetes/pkg/api/validation.NameIsDNSSubdomain函数的典型用法代码示例。如果您正苦于以下问题:Golang NameIsDNSSubdomain函数的具体用法?Golang NameIsDNSSubdomain怎么用?Golang NameIsDNSSubdomain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NameIsDNSSubdomain函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: ValidateClientNameField

func ValidateClientNameField(value string, field string) fielderrors.ValidationErrorList {
	if len(value) == 0 {
		return fielderrors.ValidationErrorList{fielderrors.NewFieldRequired(field)}
	} else if ok, msg := validation.NameIsDNSSubdomain(value, false); !ok {
		return fielderrors.ValidationErrorList{fielderrors.NewFieldInvalid(field, value, msg)}
	}
	return fielderrors.ValidationErrorList{}
}
开发者ID:johnmccawley,项目名称:origin,代码行数:8,代码来源:validation.go


示例2: ValidateClientNameField

func ValidateClientNameField(value string, fldPath *field.Path) field.ErrorList {
	if len(value) == 0 {
		return field.ErrorList{field.Required(fldPath, "")}
	} else if ok, msg := validation.NameIsDNSSubdomain(value, false); !ok {
		return field.ErrorList{field.Invalid(fldPath, value, msg)}
	}
	return field.ErrorList{}
}
开发者ID:richm,项目名称:origin,代码行数:8,代码来源:validation.go


示例3: ValidateClientNameField

func ValidateClientNameField(value string, fldPath *field.Path) field.ErrorList {
	if len(value) == 0 {
		return field.ErrorList{field.Required(fldPath, "")}
	} else if _, saName, err := serviceaccount.SplitUsername(value); err == nil {
		if reasons := validation.ValidateServiceAccountName(saName, false); len(reasons) != 0 {
			return field.ErrorList{field.Invalid(fldPath, value, strings.Join(reasons, ", "))}
		}
	} else if reasons := validation.NameIsDNSSubdomain(value, false); len(reasons) != 0 {
		return field.ErrorList{field.Invalid(fldPath, value, strings.Join(reasons, ", "))}
	}
	return field.ErrorList{}
}
开发者ID:xgwang-zte,项目名称:origin,代码行数:12,代码来源:validation.go


示例4: ValidateClientNameField

func ValidateClientNameField(value string, fldPath *field.Path) field.ErrorList {
	if len(value) == 0 {
		return field.ErrorList{field.Required(fldPath, "")}
	} else if _, saName, err := serviceaccount.SplitUsername(value); err == nil {
		if ok, errString := validation.ValidateServiceAccountName(saName, false); !ok {
			return field.ErrorList{field.Invalid(fldPath, value, errString)}
		}
	} else if ok, msg := validation.NameIsDNSSubdomain(value, false); !ok {
		return field.ErrorList{field.Invalid(fldPath, value, msg)}
	}
	return field.ErrorList{}
}
开发者ID:RomainVabre,项目名称:origin,代码行数:12,代码来源:validation.go


示例5: GetValidDNSSubdomainName

// GetValidDNSSubdomainName massages the given name to be a valid dns subdomain name.
// Most resources (such as secrets, clusters) require the names to be valid dns subdomain.
// This is a generic function (not specific to federation). Should be moved to a more generic location if others want to use it.
func GetValidDNSSubdomainName(name string) (string, error) {
	// "_" are not allowed. Replace them by "-".
	name = regexp.MustCompile("_").ReplaceAllLiteralString(name, "-")
	maxLength := validation_util.DNS1123SubdomainMaxLength
	if len(name) > maxLength {
		name = name[0 : maxLength-1]
	}
	// Verify that name now passes the validation.
	if errors := validation.NameIsDNSSubdomain(name, false); len(errors) != 0 {
		return "", fmt.Errorf("errors in converting name to a valid DNS subdomain %s", errors)
	}
	return name, nil
}
开发者ID:CodeJuan,项目名称:kubernetes,代码行数:16,代码来源:federation_util.go


示例6: ValidateThirdPartyResourceName

func ValidateThirdPartyResourceName(name string, prefix bool) []string {
	// Make sure it's a valid DNS subdomain
	if msgs := apivalidation.NameIsDNSSubdomain(name, prefix); len(msgs) != 0 {
		return msgs
	}

	// Make sure it's at least three segments (kind + two-segment group name)
	if !prefix {
		parts := strings.Split(name, ".")
		if len(parts) < 3 {
			return []string{"must be at least three segments long: <kind>.<domain>.<tld>"}
		}
	}

	return nil
}
开发者ID:maisem,项目名称:kubernetes,代码行数:16,代码来源:validation.go


示例7: ValidateThirdPartyResourceName

func ValidateThirdPartyResourceName(name string, prefix bool) (bool, string) {
	// Make sure it's a valid DNS subdomain
	if ok, msg := apivalidation.NameIsDNSSubdomain(name, prefix); !ok {
		return ok, msg
	}

	// Make sure it's at least three segments (kind + two-segment group name)
	if !prefix {
		parts := strings.Split(name, ".")
		if len(parts) < 3 {
			return false, "must be at least three segments long: <kind>.<domain>.<tld>"
		}
	}

	return true, ""
}
开发者ID:vulpecula,项目名称:kubernetes,代码行数:16,代码来源:validation.go


示例8: validateIngressRules

func validateIngressRules(IngressRules []extensions.IngressRule, fldPath *field.Path) field.ErrorList {
	allErrs := field.ErrorList{}
	if len(IngressRules) == 0 {
		return append(allErrs, field.Required(fldPath, ""))
	}
	for i, ih := range IngressRules {
		if len(ih.Host) > 0 {
			// TODO: Ports and ips are allowed in the host part of a url
			// according to RFC 3986, consider allowing them.
			if valid, errMsg := apivalidation.NameIsDNSSubdomain(ih.Host, false); !valid {
				allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("host"), ih.Host, errMsg))
			}
			if isIP := (net.ParseIP(ih.Host) != nil); isIP {
				allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("host"), ih.Host, "must be a DNS name, not an IP address"))
			}
		}
		allErrs = append(allErrs, validateIngressRuleValue(&ih.IngressRuleValue, fldPath.Index(0))...)
	}
	return allErrs
}
开发者ID:MisaKondo,项目名称:kubernetes,代码行数:20,代码来源:validation.go


示例9: validateIngressRules

func validateIngressRules(IngressRules []extensions.IngressRule) errs.ValidationErrorList {
	allErrs := errs.ValidationErrorList{}
	if len(IngressRules) == 0 {
		return append(allErrs, errs.NewFieldRequired("IngressRules"))
	}
	for _, ih := range IngressRules {
		if len(ih.Host) > 0 {
			// TODO: Ports and ips are allowed in the host part of a url
			// according to RFC 3986, consider allowing them.
			if valid, errMsg := apivalidation.NameIsDNSSubdomain(ih.Host, false); !valid {
				allErrs = append(allErrs, errs.NewFieldInvalid("host", ih.Host, errMsg))
			}
			if isIP := (net.ParseIP(ih.Host) != nil); isIP {
				allErrs = append(allErrs, errs.NewFieldInvalid("host", ih.Host, "Host must be a DNS name, not ip address"))
			}
		}
		allErrs = append(allErrs, validateIngressRuleValue(&ih.IngressRuleValue).Prefix("ingressRule")...)
	}
	return allErrs
}
开发者ID:hloganathan,项目名称:origin,代码行数:20,代码来源:validation.go


示例10: ValidateConfigMapName

// ValidateConfigMapName can be used to check whether the given ConfigMap name is valid.
// Prefix indicates this name will be used as part of generation, in which case
// trailing dashes are allowed.
func ValidateConfigMapName(name string, prefix bool) (bool, string) {
	return apivalidation.NameIsDNSSubdomain(name, prefix)
}
开发者ID:MisaKondo,项目名称:kubernetes,代码行数:6,代码来源:validation.go


示例11: ValidateDeploymentName

// Validates that the given name can be used as a deployment name.
func ValidateDeploymentName(name string, prefix bool) (bool, string) {
	return apivalidation.NameIsDNSSubdomain(name, prefix)
}
开发者ID:MisaKondo,项目名称:kubernetes,代码行数:4,代码来源:validation.go


示例12: ValidateThirdPartyResourceName

func ValidateThirdPartyResourceName(name string, prefix bool) (bool, string) {
	return apivalidation.NameIsDNSSubdomain(name, prefix)
}
开发者ID:MisaKondo,项目名称:kubernetes,代码行数:3,代码来源:validation.go


示例13: ValidatePodSecurityPolicyName

// ValidatePodSecurityPolicyName can be used to check whether the given
// pod security policy name is valid.
// Prefix indicates this name will be used as part of generation, in which case
// trailing dashes are allowed.
func ValidatePodSecurityPolicyName(name string, prefix bool) (bool, string) {
	return apivalidation.NameIsDNSSubdomain(name, prefix)
}
开发者ID:richm,项目名称:origin,代码行数:7,代码来源:validation.go


示例14: ValidateNetworkPolicyName

// ValidateNetworkPolicyName can be used to check whether the given networkpolicy
// name is valid.
func ValidateNetworkPolicyName(name string, prefix bool) []string {
	return apivalidation.NameIsDNSSubdomain(name, prefix)
}
开发者ID:maisem,项目名称:kubernetes,代码行数:5,代码来源:validation.go


示例15: ValidateStatefulSetName

// ValidateStatefulSetName can be used to check whether the given StatefulSet name is valid.
// Prefix indicates this name will be used as part of generation, in which case
// trailing dashes are allowed.
func ValidateStatefulSetName(name string, prefix bool) []string {
	// TODO: Validate that there's name for the suffix inserted by the pods.
	// Currently this is just "-index". In the future we may allow a user
	// specified list of suffixes and we need  to validate the longest one.
	return apivalidation.NameIsDNSSubdomain(name, prefix)
}
开发者ID:eljefedelrodeodeljefe,项目名称:kubernetes,代码行数:9,代码来源:validation.go


示例16: ValidateClusterName

func ValidateClusterName(name string, prefix bool) (bool, string) {
	return validation.NameIsDNSSubdomain(name, prefix)
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:3,代码来源:validation.go



注:本文中的k8s/io/kubernetes/pkg/api/validation.NameIsDNSSubdomain函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap