summaryrefslogtreecommitdiff
path: root/vendor/k8s.io/apimachinery/pkg/util/validation
diff options
context:
space:
mode:
authordependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>2020-05-05 08:57:17 +0000
committerDaniel J Walsh <dwalsh@redhat.com>2020-05-05 13:35:55 -0400
commit2f0bc5ff1cde9afb595868b92dd123478af9ef74 (patch)
treed620dce86657a325eb82b251f95e9cd4903ca80f /vendor/k8s.io/apimachinery/pkg/util/validation
parente1be837a4ff149e00ff6af9e71cf9ea625e33e6f (diff)
downloadpodman-2f0bc5ff1cde9afb595868b92dd123478af9ef74.tar.gz
podman-2f0bc5ff1cde9afb595868b92dd123478af9ef74.tar.bz2
podman-2f0bc5ff1cde9afb595868b92dd123478af9ef74.zip
Bump k8s.io/api from 0.17.4 to 0.18.2
Bumps [k8s.io/api](https://github.com/kubernetes/api) from 0.17.4 to 0.18.2. - [Release notes](https://github.com/kubernetes/api/releases) - [Commits](https://github.com/kubernetes/api/compare/v0.17.4...v0.18.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/k8s.io/apimachinery/pkg/util/validation')
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/validation/validation.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/vendor/k8s.io/apimachinery/pkg/util/validation/validation.go b/vendor/k8s.io/apimachinery/pkg/util/validation/validation.go
index 8e1907c2a..915231f2e 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/validation/validation.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/validation/validation.go
@@ -109,6 +109,44 @@ func IsFullyQualifiedDomainName(fldPath *field.Path, name string) field.ErrorLis
return allErrors
}
+// Allowed characters in an HTTP Path as defined by RFC 3986. A HTTP path may
+// contain:
+// * unreserved characters (alphanumeric, '-', '.', '_', '~')
+// * percent-encoded octets
+// * sub-delims ("!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=")
+// * a colon character (":")
+const httpPathFmt string = `[A-Za-z0-9/\-._~%!$&'()*+,;=:]+`
+
+var httpPathRegexp = regexp.MustCompile("^" + httpPathFmt + "$")
+
+// IsDomainPrefixedPath checks if the given string is a domain-prefixed path
+// (e.g. acme.io/foo). All characters before the first "/" must be a valid
+// subdomain as defined by RFC 1123. All characters trailing the first "/" must
+// be valid HTTP Path characters as defined by RFC 3986.
+func IsDomainPrefixedPath(fldPath *field.Path, dpPath string) field.ErrorList {
+ var allErrs field.ErrorList
+ if len(dpPath) == 0 {
+ return append(allErrs, field.Required(fldPath, ""))
+ }
+
+ segments := strings.SplitN(dpPath, "/", 2)
+ if len(segments) != 2 || len(segments[0]) == 0 || len(segments[1]) == 0 {
+ return append(allErrs, field.Invalid(fldPath, dpPath, "must be a domain-prefixed path (such as \"acme.io/foo\")"))
+ }
+
+ host := segments[0]
+ for _, err := range IsDNS1123Subdomain(host) {
+ allErrs = append(allErrs, field.Invalid(fldPath, host, err))
+ }
+
+ path := segments[1]
+ if !httpPathRegexp.MatchString(path) {
+ return append(allErrs, field.Invalid(fldPath, path, RegexError("Invalid path", httpPathFmt)))
+ }
+
+ return allErrs
+}
+
const labelValueFmt string = "(" + qualifiedNameFmt + ")?"
const labelValueErrMsg string = "a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character"