mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 18:28:13 +00:00 
			
		
		
		
	Bump go-openapi dependencies to preferred version
Signed-off-by: He Xiaoxi <xxhe@alauda.io>
This commit is contained in:
		
							
								
								
									
										109
									
								
								vendor/github.com/go-openapi/swag/util.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										109
									
								
								vendor/github.com/go-openapi/swag/util.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -15,11 +15,8 @@ | ||||
| package swag | ||||
|  | ||||
| import ( | ||||
| 	"math" | ||||
| 	"reflect" | ||||
| 	"regexp" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| 	"unicode" | ||||
| ) | ||||
|  | ||||
| @@ -29,8 +26,6 @@ var commonInitialisms *indexOfInitialisms | ||||
| // initialisms is a slice of sorted initialisms | ||||
| var initialisms []string | ||||
|  | ||||
| var once sync.Once | ||||
|  | ||||
| var isInitialism func(string) bool | ||||
|  | ||||
| func init() { | ||||
| @@ -49,6 +44,8 @@ func init() { | ||||
| 		"HTTP":  true, | ||||
| 		"ID":    true, | ||||
| 		"IP":    true, | ||||
| 		"IPv4":  true, | ||||
| 		"IPv6":  true, | ||||
| 		"JSON":  true, | ||||
| 		"LHS":   true, | ||||
| 		"OAI":   true, | ||||
| @@ -79,15 +76,12 @@ func init() { | ||||
|  | ||||
| 	// a thread-safe index of initialisms | ||||
| 	commonInitialisms = newIndexOfInitialisms().load(configuredInitialisms) | ||||
| 	initialisms = commonInitialisms.sorted() | ||||
|  | ||||
| 	// a test function | ||||
| 	isInitialism = commonInitialisms.isInitialism | ||||
| } | ||||
|  | ||||
| func ensureSorted() { | ||||
| 	initialisms = commonInitialisms.sorted() | ||||
| } | ||||
|  | ||||
| const ( | ||||
| 	//collectionFormatComma = "csv" | ||||
| 	collectionFormatSpace = "ssv" | ||||
| @@ -153,49 +147,20 @@ func SplitByFormat(data, format string) []string { | ||||
| 	return result | ||||
| } | ||||
|  | ||||
| type byLength []string | ||||
| type byInitialism []string | ||||
|  | ||||
| func (s byLength) Len() int { | ||||
| func (s byInitialism) Len() int { | ||||
| 	return len(s) | ||||
| } | ||||
| func (s byLength) Swap(i, j int) { | ||||
| func (s byInitialism) Swap(i, j int) { | ||||
| 	s[i], s[j] = s[j], s[i] | ||||
| } | ||||
| func (s byLength) Less(i, j int) bool { | ||||
| 	return len(s[i]) < len(s[j]) | ||||
| } | ||||
|  | ||||
| // Prepares strings by splitting by caps, spaces, dashes, and underscore | ||||
| func split(str string) []string { | ||||
| 	repl := strings.NewReplacer( | ||||
| 		"@", "At ", | ||||
| 		"&", "And ", | ||||
| 		"|", "Pipe ", | ||||
| 		"$", "Dollar ", | ||||
| 		"!", "Bang ", | ||||
| 		"-", " ", | ||||
| 		"_", " ", | ||||
| 	) | ||||
|  | ||||
| 	rex1 := regexp.MustCompile(`(\p{Lu})`) | ||||
| 	rex2 := regexp.MustCompile(`(\pL|\pM|\pN|\p{Pc})+`) | ||||
|  | ||||
| 	str = trim(str) | ||||
|  | ||||
| 	// Convert dash and underscore to spaces | ||||
| 	str = repl.Replace(str) | ||||
|  | ||||
| 	// Split when uppercase is found (needed for Snake) | ||||
| 	str = rex1.ReplaceAllString(str, " $1") | ||||
|  | ||||
| 	// 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) | ||||
| func (s byInitialism) Less(i, j int) bool { | ||||
| 	if len(s[i]) != len(s[j]) { | ||||
| 		return len(s[i]) < len(s[j]) | ||||
| 	} | ||||
| 	// Get the final list of words | ||||
| 	//words = rex2.FindAllString(str, -1) | ||||
| 	return rex2.FindAllString(str, -1) | ||||
|  | ||||
| 	return strings.Compare(s[i], s[j]) > 0 | ||||
| } | ||||
|  | ||||
| // Removes leading whitespaces | ||||
| @@ -215,7 +180,7 @@ func lower(str string) string { | ||||
|  | ||||
| // Camelize an uppercased word | ||||
| func Camelize(word string) (camelized string) { | ||||
| 	for pos, ru := range word { | ||||
| 	for pos, ru := range []rune(word) { | ||||
| 		if pos > 0 { | ||||
| 			camelized += string(unicode.ToLower(ru)) | ||||
| 		} else { | ||||
| @@ -250,30 +215,31 @@ func ToCommandName(name string) string { | ||||
|  | ||||
| // ToHumanNameLower represents a code name as a human series of words | ||||
| func ToHumanNameLower(name string) string { | ||||
| 	in := split(name) | ||||
| 	in := newSplitter(withPostSplitInitialismCheck).split(name) | ||||
| 	out := make([]string, 0, len(in)) | ||||
|  | ||||
| 	for _, w := range in { | ||||
| 		if !isInitialism(upper(w)) { | ||||
| 			out = append(out, lower(w)) | ||||
| 		if !w.IsInitialism() { | ||||
| 			out = append(out, lower(w.GetOriginal())) | ||||
| 		} else { | ||||
| 			out = append(out, w) | ||||
| 			out = append(out, w.GetOriginal()) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return strings.Join(out, " ") | ||||
| } | ||||
|  | ||||
| // ToHumanNameTitle represents a code name as a human series of words with the first letters titleized | ||||
| func ToHumanNameTitle(name string) string { | ||||
| 	in := split(name) | ||||
| 	out := make([]string, 0, len(in)) | ||||
| 	in := newSplitter(withPostSplitInitialismCheck).split(name) | ||||
|  | ||||
| 	out := make([]string, 0, len(in)) | ||||
| 	for _, w := range in { | ||||
| 		uw := upper(w) | ||||
| 		if !isInitialism(uw) { | ||||
| 			out = append(out, upper(w[:1])+lower(w[1:])) | ||||
| 		original := w.GetOriginal() | ||||
| 		if !w.IsInitialism() { | ||||
| 			out = append(out, Camelize(original)) | ||||
| 		} else { | ||||
| 			out = append(out, w) | ||||
| 			out = append(out, original) | ||||
| 		} | ||||
| 	} | ||||
| 	return strings.Join(out, " ") | ||||
| @@ -289,7 +255,7 @@ func ToJSONName(name string) string { | ||||
| 			out = append(out, lower(w)) | ||||
| 			continue | ||||
| 		} | ||||
| 		out = append(out, upper(w[:1])+lower(w[1:])) | ||||
| 		out = append(out, Camelize(w)) | ||||
| 	} | ||||
| 	return strings.Join(out, "") | ||||
| } | ||||
| @@ -308,28 +274,25 @@ 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 { | ||||
| 	in := split(name) | ||||
| 	out := make([]string, 0, len(in)) | ||||
| 	lexems := newSplitter(withPostSplitInitialismCheck).split(name) | ||||
|  | ||||
| 	for _, w := range in { | ||||
| 		uw := upper(w) | ||||
| 		mod := int(math.Min(float64(len(uw)), 2)) | ||||
| 		if !isInitialism(uw) && !isInitialism(uw[:len(uw)-mod]) { | ||||
| 			uw = upper(w[:1]) + lower(w[1:]) | ||||
| 	result := "" | ||||
| 	for _, lexem := range lexems { | ||||
| 		goName := lexem.GetUnsafeGoName() | ||||
|  | ||||
| 		// to support old behavior | ||||
| 		if lexem.IsInitialism() { | ||||
| 			goName = upper(goName) | ||||
| 		} | ||||
| 		out = append(out, uw) | ||||
| 		result += goName | ||||
| 	} | ||||
|  | ||||
| 	result := strings.Join(out, "") | ||||
| 	if len(result) > 0 { | ||||
| 		ud := upper(result[:1]) | ||||
| 		ru := []rune(ud) | ||||
| 		if unicode.IsUpper(ru[0]) { | ||||
| 			result = ud + result[1:] | ||||
| 		} else { | ||||
| 			result = "X" + ud + result[1:] | ||||
| 		if !unicode.IsUpper([]rune(result)[0]) { | ||||
| 			result = "X" + result | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return result | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 He Xiaoxi
					He Xiaoxi