mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 10:18:13 +00:00 
			
		
		
		
	Update a few dependencies
github.com/go-openapi/* github.com/asaskevich/govalidator
This commit is contained in:
		
							
								
								
									
										219
									
								
								vendor/github.com/go-openapi/swag/util.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										219
									
								
								vendor/github.com/go-openapi/swag/util.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -18,62 +18,85 @@ import ( | ||||
| 	"math" | ||||
| 	"reflect" | ||||
| 	"regexp" | ||||
| 	"sort" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| 	"unicode" | ||||
| ) | ||||
|  | ||||
| // Taken from https://github.com/golang/lint/blob/3390df4df2787994aea98de825b964ac7944b817/lint.go#L732-L769 | ||||
| var commonInitialisms = map[string]bool{ | ||||
| 	"ACL":   true, | ||||
| 	"API":   true, | ||||
| 	"ASCII": true, | ||||
| 	"CPU":   true, | ||||
| 	"CSS":   true, | ||||
| 	"DNS":   true, | ||||
| 	"EOF":   true, | ||||
| 	"GUID":  true, | ||||
| 	"HTML":  true, | ||||
| 	"HTTPS": true, | ||||
| 	"HTTP":  true, | ||||
| 	"ID":    true, | ||||
| 	"IP":    true, | ||||
| 	"JSON":  true, | ||||
| 	"LHS":   true, | ||||
| 	"QPS":   true, | ||||
| 	"RAM":   true, | ||||
| 	"RHS":   true, | ||||
| 	"RPC":   true, | ||||
| 	"SLA":   true, | ||||
| 	"SMTP":  true, | ||||
| 	"SQL":   true, | ||||
| 	"SSH":   true, | ||||
| 	"TCP":   true, | ||||
| 	"TLS":   true, | ||||
| 	"TTL":   true, | ||||
| 	"UDP":   true, | ||||
| 	"UI":    true, | ||||
| 	"UID":   true, | ||||
| 	"UUID":  true, | ||||
| 	"URI":   true, | ||||
| 	"URL":   true, | ||||
| 	"UTF8":  true, | ||||
| 	"VM":    true, | ||||
| 	"XML":   true, | ||||
| 	"XMPP":  true, | ||||
| 	"XSRF":  true, | ||||
| 	"XSS":   true, | ||||
| } | ||||
| // commonInitialisms are common acronyms that are kept as whole uppercased words. | ||||
| var commonInitialisms *indexOfInitialisms | ||||
|  | ||||
| // initialisms is a slice of sorted initialisms | ||||
| var initialisms []string | ||||
|  | ||||
| var once sync.Once | ||||
|  | ||||
| var isInitialism func(string) bool | ||||
|  | ||||
| func init() { | ||||
| 	for k := range commonInitialisms { | ||||
| 		initialisms = append(initialisms, k) | ||||
| 	// Taken from https://github.com/golang/lint/blob/3390df4df2787994aea98de825b964ac7944b817/lint.go#L732-L769 | ||||
| 	var configuredInitialisms = map[string]bool{ | ||||
| 		"ACL":   true, | ||||
| 		"API":   true, | ||||
| 		"ASCII": true, | ||||
| 		"CPU":   true, | ||||
| 		"CSS":   true, | ||||
| 		"DNS":   true, | ||||
| 		"EOF":   true, | ||||
| 		"GUID":  true, | ||||
| 		"HTML":  true, | ||||
| 		"HTTPS": true, | ||||
| 		"HTTP":  true, | ||||
| 		"ID":    true, | ||||
| 		"IP":    true, | ||||
| 		"JSON":  true, | ||||
| 		"LHS":   true, | ||||
| 		"OAI":   true, | ||||
| 		"QPS":   true, | ||||
| 		"RAM":   true, | ||||
| 		"RHS":   true, | ||||
| 		"RPC":   true, | ||||
| 		"SLA":   true, | ||||
| 		"SMTP":  true, | ||||
| 		"SQL":   true, | ||||
| 		"SSH":   true, | ||||
| 		"TCP":   true, | ||||
| 		"TLS":   true, | ||||
| 		"TTL":   true, | ||||
| 		"UDP":   true, | ||||
| 		"UI":    true, | ||||
| 		"UID":   true, | ||||
| 		"UUID":  true, | ||||
| 		"URI":   true, | ||||
| 		"URL":   true, | ||||
| 		"UTF8":  true, | ||||
| 		"VM":    true, | ||||
| 		"XML":   true, | ||||
| 		"XMPP":  true, | ||||
| 		"XSRF":  true, | ||||
| 		"XSS":   true, | ||||
| 	} | ||||
| 	sort.Sort(sort.Reverse(byLength(initialisms))) | ||||
|  | ||||
| 	// a thread-safe index of initialisms | ||||
| 	commonInitialisms = newIndexOfInitialisms().load(configuredInitialisms) | ||||
|  | ||||
| 	// a test function | ||||
| 	isInitialism = commonInitialisms.isInitialism | ||||
| } | ||||
|  | ||||
| // JoinByFormat joins a string array by a known format: | ||||
| func ensureSorted() { | ||||
| 	initialisms = commonInitialisms.sorted() | ||||
| } | ||||
|  | ||||
| const ( | ||||
| 	//collectionFormatComma = "csv" | ||||
| 	collectionFormatSpace = "ssv" | ||||
| 	collectionFormatTab   = "tsv" | ||||
| 	collectionFormatPipe  = "pipes" | ||||
| 	collectionFormatMulti = "multi" | ||||
| ) | ||||
|  | ||||
| // JoinByFormat joins a string array by a known format (e.g. swagger's collectionFormat attribute): | ||||
| //		ssv: space separated value | ||||
| //		tsv: tab separated value | ||||
| //		pipes: pipe (|) separated value | ||||
| @@ -84,13 +107,13 @@ func JoinByFormat(data []string, format string) []string { | ||||
| 	} | ||||
| 	var sep string | ||||
| 	switch format { | ||||
| 	case "ssv": | ||||
| 	case collectionFormatSpace: | ||||
| 		sep = " " | ||||
| 	case "tsv": | ||||
| 	case collectionFormatTab: | ||||
| 		sep = "\t" | ||||
| 	case "pipes": | ||||
| 	case collectionFormatPipe: | ||||
| 		sep = "|" | ||||
| 	case "multi": | ||||
| 	case collectionFormatMulti: | ||||
| 		return data | ||||
| 	default: | ||||
| 		sep = "," | ||||
| @@ -103,19 +126,20 @@ func JoinByFormat(data []string, format string) []string { | ||||
| //		tsv: tab separated value | ||||
| //		pipes: pipe (|) separated value | ||||
| //		csv: comma separated value (default) | ||||
| // | ||||
| func SplitByFormat(data, format string) []string { | ||||
| 	if data == "" { | ||||
| 		return nil | ||||
| 	} | ||||
| 	var sep string | ||||
| 	switch format { | ||||
| 	case "ssv": | ||||
| 	case collectionFormatSpace: | ||||
| 		sep = " " | ||||
| 	case "tsv": | ||||
| 	case collectionFormatTab: | ||||
| 		sep = "\t" | ||||
| 	case "pipes": | ||||
| 	case collectionFormatPipe: | ||||
| 		sep = "|" | ||||
| 	case "multi": | ||||
| 	case collectionFormatMulti: | ||||
| 		return nil | ||||
| 	default: | ||||
| 		sep = "," | ||||
| @@ -142,7 +166,7 @@ func (s byLength) Less(i, j int) bool { | ||||
| } | ||||
|  | ||||
| // Prepares strings by splitting by caps, spaces, dashes, and underscore | ||||
| func split(str string) (words []string) { | ||||
| func split(str string) []string { | ||||
| 	repl := strings.NewReplacer( | ||||
| 		"@", "At ", | ||||
| 		"&", "And ", | ||||
| @@ -163,15 +187,15 @@ func split(str string) (words []string) { | ||||
|  | ||||
| 	// Split when uppercase is found (needed for Snake) | ||||
| 	str = rex1.ReplaceAllString(str, " $1") | ||||
| 	// check if consecutive single char things make up an initialism | ||||
|  | ||||
| 	// check if consecutive single char things make up an initialism | ||||
| 	once.Do(ensureSorted) | ||||
| 	for _, k := range initialisms { | ||||
| 		str = strings.Replace(str, rex1.ReplaceAllString(k, " $1"), " "+k, -1) | ||||
| 	} | ||||
| 	// Get the final list of words | ||||
| 	words = rex2.FindAllString(str, -1) | ||||
|  | ||||
| 	return | ||||
| 	//words = rex2.FindAllString(str, -1) | ||||
| 	return rex2.FindAllString(str, -1) | ||||
| } | ||||
|  | ||||
| // Removes leading whitespaces | ||||
| @@ -189,19 +213,36 @@ func lower(str string) string { | ||||
| 	return strings.ToLower(trim(str)) | ||||
| } | ||||
|  | ||||
| // Camelize an uppercased word | ||||
| func Camelize(word string) (camelized string) { | ||||
| 	for pos, ru := range word { | ||||
| 		if pos > 0 { | ||||
| 			camelized += string(unicode.ToLower(ru)) | ||||
| 		} else { | ||||
| 			camelized += string(unicode.ToUpper(ru)) | ||||
| 		} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // ToFileName lowercases and underscores a go type name | ||||
| func ToFileName(name string) string { | ||||
| 	var out []string | ||||
| 	for _, w := range split(name) { | ||||
| 	in := split(name) | ||||
| 	out := make([]string, 0, len(in)) | ||||
|  | ||||
| 	for _, w := range in { | ||||
| 		out = append(out, lower(w)) | ||||
| 	} | ||||
|  | ||||
| 	return strings.Join(out, "_") | ||||
| } | ||||
|  | ||||
| // ToCommandName lowercases and underscores a go type name | ||||
| func ToCommandName(name string) string { | ||||
| 	var out []string | ||||
| 	for _, w := range split(name) { | ||||
| 	in := split(name) | ||||
| 	out := make([]string, 0, len(in)) | ||||
|  | ||||
| 	for _, w := range in { | ||||
| 		out = append(out, lower(w)) | ||||
| 	} | ||||
| 	return strings.Join(out, "-") | ||||
| @@ -209,9 +250,11 @@ func ToCommandName(name string) string { | ||||
|  | ||||
| // ToHumanNameLower represents a code name as a human series of words | ||||
| func ToHumanNameLower(name string) string { | ||||
| 	var out []string | ||||
| 	for _, w := range split(name) { | ||||
| 		if !commonInitialisms[upper(w)] { | ||||
| 	in := split(name) | ||||
| 	out := make([]string, 0, len(in)) | ||||
|  | ||||
| 	for _, w := range in { | ||||
| 		if !isInitialism(upper(w)) { | ||||
| 			out = append(out, lower(w)) | ||||
| 		} else { | ||||
| 			out = append(out, w) | ||||
| @@ -222,10 +265,12 @@ func ToHumanNameLower(name string) string { | ||||
|  | ||||
| // ToHumanNameTitle represents a code name as a human series of words with the first letters titleized | ||||
| func ToHumanNameTitle(name string) string { | ||||
| 	var out []string | ||||
| 	for _, w := range split(name) { | ||||
| 	in := split(name) | ||||
| 	out := make([]string, 0, len(in)) | ||||
|  | ||||
| 	for _, w := range in { | ||||
| 		uw := upper(w) | ||||
| 		if !commonInitialisms[uw] { | ||||
| 		if !isInitialism(uw) { | ||||
| 			out = append(out, upper(w[:1])+lower(w[1:])) | ||||
| 		} else { | ||||
| 			out = append(out, w) | ||||
| @@ -236,8 +281,10 @@ func ToHumanNameTitle(name string) string { | ||||
|  | ||||
| // ToJSONName camelcases a name which can be underscored or pascal cased | ||||
| func ToJSONName(name string) string { | ||||
| 	var out []string | ||||
| 	for i, w := range split(name) { | ||||
| 	in := split(name) | ||||
| 	out := make([]string, 0, len(in)) | ||||
|  | ||||
| 	for i, w := range in { | ||||
| 		if i == 0 { | ||||
| 			out = append(out, lower(w)) | ||||
| 			continue | ||||
| @@ -250,7 +297,7 @@ func ToJSONName(name string) string { | ||||
| // ToVarName camelcases a name which can be underscored or pascal cased | ||||
| func ToVarName(name string) string { | ||||
| 	res := ToGoName(name) | ||||
| 	if _, ok := commonInitialisms[res]; ok { | ||||
| 	if isInitialism(res) { | ||||
| 		return lower(res) | ||||
| 	} | ||||
| 	if len(res) <= 1 { | ||||
| @@ -261,11 +308,13 @@ func ToVarName(name string) string { | ||||
|  | ||||
| // ToGoName translates a swagger name which can be underscored or camel cased to a name that golint likes | ||||
| func ToGoName(name string) string { | ||||
| 	var out []string | ||||
| 	for _, w := range split(name) { | ||||
| 	in := split(name) | ||||
| 	out := make([]string, 0, len(in)) | ||||
|  | ||||
| 	for _, w := range in { | ||||
| 		uw := upper(w) | ||||
| 		mod := int(math.Min(float64(len(uw)), 2)) | ||||
| 		if !commonInitialisms[uw] && !commonInitialisms[uw[:len(uw)-mod]] { | ||||
| 		if !isInitialism(uw) && !isInitialism(uw[:len(uw)-mod]) { | ||||
| 			uw = upper(w[:1]) + lower(w[1:]) | ||||
| 		} | ||||
| 		out = append(out, uw) | ||||
| @@ -284,6 +333,16 @@ func ToGoName(name string) string { | ||||
| 	return result | ||||
| } | ||||
|  | ||||
| // ContainsStrings searches a slice of strings for a case-sensitive match | ||||
| func ContainsStrings(coll []string, item string) bool { | ||||
| 	for _, a := range coll { | ||||
| 		if a == item { | ||||
| 			return true | ||||
| 		} | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| // ContainsStringsCI searches a slice of strings for a case-insensitive match | ||||
| func ContainsStringsCI(coll []string, item string) bool { | ||||
| 	for _, a := range coll { | ||||
| @@ -328,6 +387,16 @@ func IsZero(data interface{}) bool { | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| // AddInitialisms add additional initialisms | ||||
| func AddInitialisms(words ...string) { | ||||
| 	for _, word := range words { | ||||
| 		//commonInitialisms[upper(word)] = true | ||||
| 		commonInitialisms.add(upper(word)) | ||||
| 	} | ||||
| 	// sort again | ||||
| 	initialisms = commonInitialisms.sorted() | ||||
| } | ||||
|  | ||||
| // CommandLineOptionsGroup represents a group of user-defined command line options | ||||
| type CommandLineOptionsGroup struct { | ||||
| 	ShortDescription string | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Mikhail Mazurskiy
					Mikhail Mazurskiy