本文整理汇总了Golang中k8s/io/kubernetes/pkg/api/validation.ValidatePodName函数的典型用法代码示例。如果您正苦于以下问题:Golang ValidatePodName函数的具体用法?Golang ValidatePodName怎么用?Golang ValidatePodName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ValidatePodName函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getPodsPrefix
func getPodsPrefix(controllerName string) string {
// use the dash (if the name isn't too long) to make the pod name a bit prettier
prefix := fmt.Sprintf("%s-", controllerName)
if len(validation.ValidatePodName(prefix, true)) != 0 {
prefix = controllerName
}
return prefix
}
示例2: getReplicaPrefix
func getReplicaPrefix(controllerName string) string {
// use the dash (if the name isn't too long) to make the pod name a bit prettier
prefix := fmt.Sprintf("%s-", controllerName)
if ok, _ := validation.ValidatePodName(prefix, true); !ok {
prefix = controllerName
}
return prefix
}
示例3: parseDestination
func parseDestination(destination string) (string, string, error) {
parts := strings.SplitN(destination, ":", 2)
if len(parts) < 2 || len(parts[0]) == 0 || len(parts[1]) == 0 {
return "", "", fmt.Errorf("invalid destination %s: must be of the form PODNAME:DESTINATION_DIR", destination)
}
valid, msg := kvalidation.ValidatePodName(parts[0], false)
if !valid {
return "", "", fmt.Errorf("invalid pod name %s: %s", parts[0], msg)
}
return parts[0], parts[1], nil
}
示例4: PodMetricsUrl
func PodMetricsUrl(namespace string, name string) (string, error) {
errs := validation.ValidateNamespaceName(namespace, false)
if len(errs) > 0 {
message := fmt.Sprintf("invalid namespace: %s - %v", namespace, errs)
return "", errors.New(message)
}
if len(name) > 0 {
errs = validation.ValidatePodName(name, false)
if len(errs) > 0 {
message := fmt.Sprintf("invalid pod name: %s - %v", name, errs)
return "", errors.New(message)
}
}
return fmt.Sprintf("%s/namespaces/%s/pods/%s", MetricsRoot, namespace, name), nil
}
示例5: parsePathSpec
// parsePathSpec parses a string argument into a pathSpec object
func parsePathSpec(path string) (*pathSpec, error) {
parts := strings.SplitN(path, ":", 2)
if len(parts) == 1 || (isWindows() && len(parts[0]) == 1) {
return &pathSpec{
Path: path,
}, nil
}
if reasons := kvalidation.ValidatePodName(parts[0], false); len(reasons) != 0 {
return nil, fmt.Errorf("invalid pod name %s: %s", parts[0], strings.Join(reasons, ", "))
}
return &pathSpec{
PodName: parts[0],
Path: parts[1],
}, nil
}
示例6: parsePathSpec
// parsePathSpec parses a string argument into a pathSpec object
func parsePathSpec(path string) (*pathSpec, error) {
parts := strings.SplitN(path, ":", 2)
if len(parts) == 1 || (isWindows() && len(parts[0]) == 1) {
return &pathSpec{
Path: path,
}, nil
}
valid, msg := kvalidation.ValidatePodName(parts[0], false)
if !valid {
return nil, fmt.Errorf("invalid pod name %s: %s", parts[0], msg)
}
return &pathSpec{
PodName: parts[0],
Path: parts[1],
}, nil
}