MCPcopy
hub / github.com/kubernetes/client-go / IsValidPathSegmentName

Function IsValidPathSegmentName

rest/request.go:1170–1185  ·  view source on GitHub ↗

IsValidPathSegmentName validates the name can be safely encoded as a path segment

(name string)

Source from the content-addressed store, hash-verified

1168
1169// IsValidPathSegmentName validates the name can be safely encoded as a path segment
1170func IsValidPathSegmentName(name string) []string {
1171 for _, illegalName := range NameMayNotBe {
1172 if name == illegalName {
1173 return []string{fmt.Sprintf(`may not be '%s'`, illegalName)}
1174 }
1175 }
1176
1177 var errors []string
1178 for _, illegalContent := range NameMayNotContain {
1179 if strings.Contains(name, illegalContent) {
1180 errors = append(errors, fmt.Sprintf(`may not contain '%s'`, illegalContent))
1181 }
1182 }
1183
1184 return errors
1185}
1186
1187// IsValidPathSegmentPrefix validates the name can be used as a prefix for a name which will be encoded as a path segment
1188// It does not check for exact matches with disallowed names, since an arbitrary suffix might make the name valid

Callers 5

ResourceMethod · 0.85
SubResourceMethod · 0.85
NameMethod · 0.85
NamespaceMethod · 0.85
ValidatePathSegmentNameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected