index
int64
0
0
repo_id
stringlengths
21
232
file_path
stringlengths
34
259
content
stringlengths
1
14.1M
__index_level_0__
int64
0
10k
0
kubeflow_public_repos/fate-operator/vendor/github.com/rs/zerolog/internal
kubeflow_public_repos/fate-operator/vendor/github.com/rs/zerolog/internal/json/base.go
package json type Encoder struct{} // AppendKey appends a new key to the output JSON. func (e Encoder) AppendKey(dst []byte, key string) []byte { if dst[len(dst)-1] != '{' { dst = append(dst, ',') } return append(e.AppendString(dst, key), ':') }
8,800
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/curly.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "net/http" "regexp" "sort" "strings" ) // CurlyRouter expects Routes with paths that contain zero or more parameters in curly brackets. type CurlyRouter struct{} // SelectRoute is part of the Router interface and returns the best match // for the WebService and its Route for the given Request. func (c CurlyRouter) SelectRoute( webServices []*WebService, httpRequest *http.Request) (selectedService *WebService, selected *Route, err error) { requestTokens := tokenizePath(httpRequest.URL.Path) detectedService := c.detectWebService(requestTokens, webServices) if detectedService == nil { if trace { traceLogger.Printf("no WebService was found to match URL path:%s\n", httpRequest.URL.Path) } return nil, nil, NewError(http.StatusNotFound, "404: Page Not Found") } candidateRoutes := c.selectRoutes(detectedService, requestTokens) if len(candidateRoutes) == 0 { if trace { traceLogger.Printf("no Route in WebService with path %s was found to match URL path:%s\n", detectedService.rootPath, httpRequest.URL.Path) } return detectedService, nil, NewError(http.StatusNotFound, "404: Page Not Found") } selectedRoute, err := c.detectRoute(candidateRoutes, httpRequest) if selectedRoute == nil { return detectedService, nil, err } return detectedService, selectedRoute, nil } // selectRoutes return a collection of Route from a WebService that matches the path tokens from the request. func (c CurlyRouter) selectRoutes(ws *WebService, requestTokens []string) sortableCurlyRoutes { candidates := make(sortableCurlyRoutes, 0, 8) for _, each := range ws.routes { matches, paramCount, staticCount := c.matchesRouteByPathTokens(each.pathParts, requestTokens) if matches { candidates.add(curlyRoute{each, paramCount, staticCount}) // TODO make sure Routes() return pointers? } } sort.Sort(candidates) return candidates } // matchesRouteByPathTokens computes whether it matches, howmany parameters do match and what the number of static path elements are. func (c CurlyRouter) matchesRouteByPathTokens(routeTokens, requestTokens []string) (matches bool, paramCount int, staticCount int) { if len(routeTokens) < len(requestTokens) { // proceed in matching only if last routeToken is wildcard count := len(routeTokens) if count == 0 || !strings.HasSuffix(routeTokens[count-1], "*}") { return false, 0, 0 } // proceed } for i, routeToken := range routeTokens { if i == len(requestTokens) { // reached end of request path return false, 0, 0 } requestToken := requestTokens[i] if strings.HasPrefix(routeToken, "{") { paramCount++ if colon := strings.Index(routeToken, ":"); colon != -1 { // match by regex matchesToken, matchesRemainder := c.regularMatchesPathToken(routeToken, colon, requestToken) if !matchesToken { return false, 0, 0 } if matchesRemainder { break } } } else { // no { prefix if requestToken != routeToken { return false, 0, 0 } staticCount++ } } return true, paramCount, staticCount } // regularMatchesPathToken tests whether the regular expression part of routeToken matches the requestToken or all remaining tokens // format routeToken is {someVar:someExpression}, e.g. {zipcode:[\d][\d][\d][\d][A-Z][A-Z]} func (c CurlyRouter) regularMatchesPathToken(routeToken string, colon int, requestToken string) (matchesToken bool, matchesRemainder bool) { regPart := routeToken[colon+1 : len(routeToken)-1] if regPart == "*" { if trace { traceLogger.Printf("wildcard parameter detected in route token %s that matches %s\n", routeToken, requestToken) } return true, true } matched, err := regexp.MatchString(regPart, requestToken) return (matched && err == nil), false } var jsr311Router = RouterJSR311{} // detectRoute selectes from a list of Route the first match by inspecting both the Accept and Content-Type // headers of the Request. See also RouterJSR311 in jsr311.go func (c CurlyRouter) detectRoute(candidateRoutes sortableCurlyRoutes, httpRequest *http.Request) (*Route, error) { // tracing is done inside detectRoute return jsr311Router.detectRoute(candidateRoutes.routes(), httpRequest) } // detectWebService returns the best matching webService given the list of path tokens. // see also computeWebserviceScore func (c CurlyRouter) detectWebService(requestTokens []string, webServices []*WebService) *WebService { var best *WebService score := -1 for _, each := range webServices { matches, eachScore := c.computeWebserviceScore(requestTokens, each.pathExpr.tokens) if matches && (eachScore > score) { best = each score = eachScore } } return best } // computeWebserviceScore returns whether tokens match and // the weighted score of the longest matching consecutive tokens from the beginning. func (c CurlyRouter) computeWebserviceScore(requestTokens []string, tokens []string) (bool, int) { if len(tokens) > len(requestTokens) { return false, 0 } score := 0 for i := 0; i < len(tokens); i++ { each := requestTokens[i] other := tokens[i] if len(each) == 0 && len(other) == 0 { score++ continue } if len(other) > 0 && strings.HasPrefix(other, "{") { // no empty match if len(each) == 0 { return false, score } score += 1 } else { // not a parameter if each != other { return false, score } score += (len(tokens) - i) * 10 //fuzzy } } return true, score }
8,801
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/bench_test.sh
#go test -run=none -file bench_test.go -test.bench . -cpuprofile=bench_test.out go test -c ./go-restful.test -test.run=none -test.cpuprofile=tmp.prof -test.bench=BenchmarkMany ./go-restful.test -test.run=none -test.cpuprofile=curly.prof -test.bench=BenchmarkManyCurly #go tool pprof go-restful.test tmp.prof go tool pprof go-restful.test curly.prof
8,802
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/mime.go
package restful import ( "strconv" "strings" ) type mime struct { media string quality float64 } // insertMime adds a mime to a list and keeps it sorted by quality. func insertMime(l []mime, e mime) []mime { for i, each := range l { // if current mime has lower quality then insert before if e.quality > each.quality { left := append([]mime{}, l[0:i]...) return append(append(left, e), l[i:]...) } } return append(l, e) } const qFactorWeightingKey = "q" // sortedMimes returns a list of mime sorted (desc) by its specified quality. // e.g. text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3 func sortedMimes(accept string) (sorted []mime) { for _, each := range strings.Split(accept, ",") { typeAndQuality := strings.Split(strings.Trim(each, " "), ";") if len(typeAndQuality) == 1 { sorted = insertMime(sorted, mime{typeAndQuality[0], 1.0}) } else { // take factor qAndWeight := strings.Split(typeAndQuality[1], "=") if len(qAndWeight) == 2 && strings.Trim(qAndWeight[0], " ") == qFactorWeightingKey { f, err := strconv.ParseFloat(qAndWeight[1], 64) if err != nil { traceLogger.Printf("unable to parse quality in %s, %v", each, err) } else { sorted = insertMime(sorted, mime{typeAndQuality[0], f}) } } else { sorted = insertMime(sorted, mime{typeAndQuality[0], 1.0}) } } } return }
8,803
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/jsr311.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "errors" "fmt" "net/http" "sort" ) // RouterJSR311 implements the flow for matching Requests to Routes (and consequently Resource Functions) // as specified by the JSR311 http://jsr311.java.net/nonav/releases/1.1/spec/spec.html. // RouterJSR311 implements the Router interface. // Concept of locators is not implemented. type RouterJSR311 struct{} // SelectRoute is part of the Router interface and returns the best match // for the WebService and its Route for the given Request. func (r RouterJSR311) SelectRoute( webServices []*WebService, httpRequest *http.Request) (selectedService *WebService, selectedRoute *Route, err error) { // Identify the root resource class (WebService) dispatcher, finalMatch, err := r.detectDispatcher(httpRequest.URL.Path, webServices) if err != nil { return nil, nil, NewError(http.StatusNotFound, "") } // Obtain the set of candidate methods (Routes) routes := r.selectRoutes(dispatcher, finalMatch) if len(routes) == 0 { return dispatcher, nil, NewError(http.StatusNotFound, "404: Page Not Found") } // Identify the method (Route) that will handle the request route, ok := r.detectRoute(routes, httpRequest) return dispatcher, route, ok } // ExtractParameters is used to obtain the path parameters from the route using the same matching // engine as the JSR 311 router. func (r RouterJSR311) ExtractParameters(route *Route, webService *WebService, urlPath string) map[string]string { webServiceExpr := webService.pathExpr webServiceMatches := webServiceExpr.Matcher.FindStringSubmatch(urlPath) pathParameters := r.extractParams(webServiceExpr, webServiceMatches) routeExpr := route.pathExpr routeMatches := routeExpr.Matcher.FindStringSubmatch(webServiceMatches[len(webServiceMatches)-1]) routeParams := r.extractParams(routeExpr, routeMatches) for key, value := range routeParams { pathParameters[key] = value } return pathParameters } func (RouterJSR311) extractParams(pathExpr *pathExpression, matches []string) map[string]string { params := map[string]string{} for i := 1; i < len(matches); i++ { if len(pathExpr.VarNames) >= i { params[pathExpr.VarNames[i-1]] = matches[i] } } return params } // http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2 func (r RouterJSR311) detectRoute(routes []Route, httpRequest *http.Request) (*Route, error) { candidates := make([]*Route, 0, 8) for i, each := range routes { ok := true for _, fn := range each.If { if !fn(httpRequest) { ok = false break } } if ok { candidates = append(candidates, &routes[i]) } } if len(candidates) == 0 { if trace { traceLogger.Printf("no Route found (from %d) that passes conditional checks", len(routes)) } return nil, NewError(http.StatusNotFound, "404: Not Found") } // http method previous := candidates candidates = candidates[:0] for _, each := range previous { if httpRequest.Method == each.Method { candidates = append(candidates, each) } } if len(candidates) == 0 { if trace { traceLogger.Printf("no Route found (in %d routes) that matches HTTP method %s\n", len(previous), httpRequest.Method) } return nil, NewError(http.StatusMethodNotAllowed, "405: Method Not Allowed") } // content-type contentType := httpRequest.Header.Get(HEADER_ContentType) previous = candidates candidates = candidates[:0] for _, each := range previous { if each.matchesContentType(contentType) { candidates = append(candidates, each) } } if len(candidates) == 0 { if trace { traceLogger.Printf("no Route found (from %d) that matches HTTP Content-Type: %s\n", len(previous), contentType) } if httpRequest.ContentLength > 0 { return nil, NewError(http.StatusUnsupportedMediaType, "415: Unsupported Media Type") } } // accept previous = candidates candidates = candidates[:0] accept := httpRequest.Header.Get(HEADER_Accept) if len(accept) == 0 { accept = "*/*" } for _, each := range previous { if each.matchesAccept(accept) { candidates = append(candidates, each) } } if len(candidates) == 0 { if trace { traceLogger.Printf("no Route found (from %d) that matches HTTP Accept: %s\n", len(previous), accept) } return nil, NewError(http.StatusNotAcceptable, "406: Not Acceptable") } // return r.bestMatchByMedia(outputMediaOk, contentType, accept), nil return candidates[0], nil } // http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2 // n/m > n/* > */* func (r RouterJSR311) bestMatchByMedia(routes []Route, contentType string, accept string) *Route { // TODO return &routes[0] } // http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2 (step 2) func (r RouterJSR311) selectRoutes(dispatcher *WebService, pathRemainder string) []Route { filtered := &sortableRouteCandidates{} for _, each := range dispatcher.Routes() { pathExpr := each.pathExpr matches := pathExpr.Matcher.FindStringSubmatch(pathRemainder) if matches != nil { lastMatch := matches[len(matches)-1] if len(lastMatch) == 0 || lastMatch == "/" { // do not include if value is neither empty nor β€˜/’. filtered.candidates = append(filtered.candidates, routeCandidate{each, len(matches) - 1, pathExpr.LiteralCount, pathExpr.VarCount}) } } } if len(filtered.candidates) == 0 { if trace { traceLogger.Printf("WebService on path %s has no routes that match URL path remainder:%s\n", dispatcher.rootPath, pathRemainder) } return []Route{} } sort.Sort(sort.Reverse(filtered)) // select other routes from candidates whoes expression matches rmatch matchingRoutes := []Route{filtered.candidates[0].route} for c := 1; c < len(filtered.candidates); c++ { each := filtered.candidates[c] if each.route.pathExpr.Matcher.MatchString(pathRemainder) { matchingRoutes = append(matchingRoutes, each.route) } } return matchingRoutes } // http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2 (step 1) func (r RouterJSR311) detectDispatcher(requestPath string, dispatchers []*WebService) (*WebService, string, error) { filtered := &sortableDispatcherCandidates{} for _, each := range dispatchers { matches := each.pathExpr.Matcher.FindStringSubmatch(requestPath) if matches != nil { filtered.candidates = append(filtered.candidates, dispatcherCandidate{each, matches[len(matches)-1], len(matches), each.pathExpr.LiteralCount, each.pathExpr.VarCount}) } } if len(filtered.candidates) == 0 { if trace { traceLogger.Printf("no WebService was found to match URL path:%s\n", requestPath) } return nil, "", errors.New("not found") } sort.Sort(sort.Reverse(filtered)) return filtered.candidates[0].dispatcher, filtered.candidates[0].finalMatch, nil } // Types and functions to support the sorting of Routes type routeCandidate struct { route Route matchesCount int // the number of capturing groups literalCount int // the number of literal characters (means those not resulting from template variable substitution) nonDefaultCount int // the number of capturing groups with non-default regular expressions (i.e. not β€˜([^ /]+?)’) } func (r routeCandidate) expressionToMatch() string { return r.route.pathExpr.Source } func (r routeCandidate) String() string { return fmt.Sprintf("(m=%d,l=%d,n=%d)", r.matchesCount, r.literalCount, r.nonDefaultCount) } type sortableRouteCandidates struct { candidates []routeCandidate } func (rcs *sortableRouteCandidates) Len() int { return len(rcs.candidates) } func (rcs *sortableRouteCandidates) Swap(i, j int) { rcs.candidates[i], rcs.candidates[j] = rcs.candidates[j], rcs.candidates[i] } func (rcs *sortableRouteCandidates) Less(i, j int) bool { ci := rcs.candidates[i] cj := rcs.candidates[j] // primary key if ci.literalCount < cj.literalCount { return true } if ci.literalCount > cj.literalCount { return false } // secundary key if ci.matchesCount < cj.matchesCount { return true } if ci.matchesCount > cj.matchesCount { return false } // tertiary key if ci.nonDefaultCount < cj.nonDefaultCount { return true } if ci.nonDefaultCount > cj.nonDefaultCount { return false } // quaternary key ("source" is interpreted as Path) return ci.route.Path < cj.route.Path } // Types and functions to support the sorting of Dispatchers type dispatcherCandidate struct { dispatcher *WebService finalMatch string matchesCount int // the number of capturing groups literalCount int // the number of literal characters (means those not resulting from template variable substitution) nonDefaultCount int // the number of capturing groups with non-default regular expressions (i.e. not β€˜([^ /]+?)’) } type sortableDispatcherCandidates struct { candidates []dispatcherCandidate } func (dc *sortableDispatcherCandidates) Len() int { return len(dc.candidates) } func (dc *sortableDispatcherCandidates) Swap(i, j int) { dc.candidates[i], dc.candidates[j] = dc.candidates[j], dc.candidates[i] } func (dc *sortableDispatcherCandidates) Less(i, j int) bool { ci := dc.candidates[i] cj := dc.candidates[j] // primary key if ci.matchesCount < cj.matchesCount { return true } if ci.matchesCount > cj.matchesCount { return false } // secundary key if ci.literalCount < cj.literalCount { return true } if ci.literalCount > cj.literalCount { return false } // tertiary key return ci.nonDefaultCount < cj.nonDefaultCount }
8,804
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/entity_accessors.go
package restful // Copyright 2015 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "encoding/xml" "strings" "sync" ) // EntityReaderWriter can read and write values using an encoding such as JSON,XML. type EntityReaderWriter interface { // Read a serialized version of the value from the request. // The Request may have a decompressing reader. Depends on Content-Encoding. Read(req *Request, v interface{}) error // Write a serialized version of the value on the response. // The Response may have a compressing writer. Depends on Accept-Encoding. // status should be a valid Http Status code Write(resp *Response, status int, v interface{}) error } // entityAccessRegistry is a singleton var entityAccessRegistry = &entityReaderWriters{ protection: new(sync.RWMutex), accessors: map[string]EntityReaderWriter{}, } // entityReaderWriters associates MIME to an EntityReaderWriter type entityReaderWriters struct { protection *sync.RWMutex accessors map[string]EntityReaderWriter } func init() { RegisterEntityAccessor(MIME_JSON, NewEntityAccessorJSON(MIME_JSON)) RegisterEntityAccessor(MIME_XML, NewEntityAccessorXML(MIME_XML)) } // RegisterEntityAccessor add/overrides the ReaderWriter for encoding content with this MIME type. func RegisterEntityAccessor(mime string, erw EntityReaderWriter) { entityAccessRegistry.protection.Lock() defer entityAccessRegistry.protection.Unlock() entityAccessRegistry.accessors[mime] = erw } // NewEntityAccessorJSON returns a new EntityReaderWriter for accessing JSON content. // This package is already initialized with such an accessor using the MIME_JSON contentType. func NewEntityAccessorJSON(contentType string) EntityReaderWriter { return entityJSONAccess{ContentType: contentType} } // NewEntityAccessorXML returns a new EntityReaderWriter for accessing XML content. // This package is already initialized with such an accessor using the MIME_XML contentType. func NewEntityAccessorXML(contentType string) EntityReaderWriter { return entityXMLAccess{ContentType: contentType} } // accessorAt returns the registered ReaderWriter for this MIME type. func (r *entityReaderWriters) accessorAt(mime string) (EntityReaderWriter, bool) { r.protection.RLock() defer r.protection.RUnlock() er, ok := r.accessors[mime] if !ok { // retry with reverse lookup // more expensive but we are in an exceptional situation anyway for k, v := range r.accessors { if strings.Contains(mime, k) { return v, true } } } return er, ok } // entityXMLAccess is a EntityReaderWriter for XML encoding type entityXMLAccess struct { // This is used for setting the Content-Type header when writing ContentType string } // Read unmarshalls the value from XML func (e entityXMLAccess) Read(req *Request, v interface{}) error { return xml.NewDecoder(req.Request.Body).Decode(v) } // Write marshalls the value to JSON and set the Content-Type Header. func (e entityXMLAccess) Write(resp *Response, status int, v interface{}) error { return writeXML(resp, status, e.ContentType, v) } // writeXML marshalls the value to JSON and set the Content-Type Header. func writeXML(resp *Response, status int, contentType string, v interface{}) error { if v == nil { resp.WriteHeader(status) // do not write a nil representation return nil } if resp.prettyPrint { // pretty output must be created and written explicitly output, err := xml.MarshalIndent(v, " ", " ") if err != nil { return err } resp.Header().Set(HEADER_ContentType, contentType) resp.WriteHeader(status) _, err = resp.Write([]byte(xml.Header)) if err != nil { return err } _, err = resp.Write(output) return err } // not-so-pretty resp.Header().Set(HEADER_ContentType, contentType) resp.WriteHeader(status) return xml.NewEncoder(resp).Encode(v) } // entityJSONAccess is a EntityReaderWriter for JSON encoding type entityJSONAccess struct { // This is used for setting the Content-Type header when writing ContentType string } // Read unmarshalls the value from JSON func (e entityJSONAccess) Read(req *Request, v interface{}) error { decoder := NewDecoder(req.Request.Body) decoder.UseNumber() return decoder.Decode(v) } // Write marshalls the value to JSON and set the Content-Type Header. func (e entityJSONAccess) Write(resp *Response, status int, v interface{}) error { return writeJSON(resp, status, e.ContentType, v) } // write marshalls the value to JSON and set the Content-Type Header. func writeJSON(resp *Response, status int, contentType string, v interface{}) error { if v == nil { resp.WriteHeader(status) // do not write a nil representation return nil } if resp.prettyPrint { // pretty output must be created and written explicitly output, err := MarshalIndent(v, "", " ") if err != nil { return err } resp.Header().Set(HEADER_ContentType, contentType) resp.WriteHeader(status) _, err = resp.Write(output) return err } // not-so-pretty resp.Header().Set(HEADER_ContentType, contentType) resp.WriteHeader(status) return NewEncoder(resp).Encode(v) }
8,805
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/coverage.sh
go test -coverprofile=coverage.out go tool cover -html=coverage.out
8,806
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/curly_route.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. // curlyRoute exits for sorting Routes by the CurlyRouter based on number of parameters and number of static path elements. type curlyRoute struct { route Route paramCount int staticCount int } // sortableCurlyRoutes orders by most parameters and path elements first. type sortableCurlyRoutes []curlyRoute func (s *sortableCurlyRoutes) add(route curlyRoute) { *s = append(*s, route) } func (s sortableCurlyRoutes) routes() (routes []Route) { routes = make([]Route, 0, len(s)) for _, each := range s { routes = append(routes, each.route) // TODO change return type } return routes } func (s sortableCurlyRoutes) Len() int { return len(s) } func (s sortableCurlyRoutes) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s sortableCurlyRoutes) Less(i, j int) bool { a := s[j] b := s[i] // primary key if a.staticCount < b.staticCount { return true } if a.staticCount > b.staticCount { return false } // secundary key if a.paramCount < b.paramCount { return true } if a.paramCount > b.paramCount { return false } return a.route.Path < b.route.Path }
8,807
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/compress.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "bufio" "compress/gzip" "compress/zlib" "errors" "io" "net" "net/http" "strings" ) // OBSOLETE : use restful.DefaultContainer.EnableContentEncoding(true) to change this setting. var EnableContentEncoding = false // CompressingResponseWriter is a http.ResponseWriter that can perform content encoding (gzip and zlib) type CompressingResponseWriter struct { writer http.ResponseWriter compressor io.WriteCloser encoding string } // Header is part of http.ResponseWriter interface func (c *CompressingResponseWriter) Header() http.Header { return c.writer.Header() } // WriteHeader is part of http.ResponseWriter interface func (c *CompressingResponseWriter) WriteHeader(status int) { c.writer.WriteHeader(status) } // Write is part of http.ResponseWriter interface // It is passed through the compressor func (c *CompressingResponseWriter) Write(bytes []byte) (int, error) { if c.isCompressorClosed() { return -1, errors.New("Compressing error: tried to write data using closed compressor") } return c.compressor.Write(bytes) } // CloseNotify is part of http.CloseNotifier interface func (c *CompressingResponseWriter) CloseNotify() <-chan bool { return c.writer.(http.CloseNotifier).CloseNotify() } // Close the underlying compressor func (c *CompressingResponseWriter) Close() error { if c.isCompressorClosed() { return errors.New("Compressing error: tried to close already closed compressor") } c.compressor.Close() if ENCODING_GZIP == c.encoding { currentCompressorProvider.ReleaseGzipWriter(c.compressor.(*gzip.Writer)) } if ENCODING_DEFLATE == c.encoding { currentCompressorProvider.ReleaseZlibWriter(c.compressor.(*zlib.Writer)) } // gc hint needed? c.compressor = nil return nil } func (c *CompressingResponseWriter) isCompressorClosed() bool { return nil == c.compressor } // Hijack implements the Hijacker interface // This is especially useful when combining Container.EnabledContentEncoding // in combination with websockets (for instance gorilla/websocket) func (c *CompressingResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { hijacker, ok := c.writer.(http.Hijacker) if !ok { return nil, nil, errors.New("ResponseWriter doesn't support Hijacker interface") } return hijacker.Hijack() } // WantsCompressedResponse reads the Accept-Encoding header to see if and which encoding is requested. func wantsCompressedResponse(httpRequest *http.Request) (bool, string) { header := httpRequest.Header.Get(HEADER_AcceptEncoding) gi := strings.Index(header, ENCODING_GZIP) zi := strings.Index(header, ENCODING_DEFLATE) // use in order of appearance if gi == -1 { return zi != -1, ENCODING_DEFLATE } else if zi == -1 { return gi != -1, ENCODING_GZIP } else { if gi < zi { return true, ENCODING_GZIP } return true, ENCODING_DEFLATE } } // NewCompressingResponseWriter create a CompressingResponseWriter for a known encoding = {gzip,deflate} func NewCompressingResponseWriter(httpWriter http.ResponseWriter, encoding string) (*CompressingResponseWriter, error) { httpWriter.Header().Set(HEADER_ContentEncoding, encoding) c := new(CompressingResponseWriter) c.writer = httpWriter var err error if ENCODING_GZIP == encoding { w := currentCompressorProvider.AcquireGzipWriter() w.Reset(httpWriter) c.compressor = w c.encoding = ENCODING_GZIP } else if ENCODING_DEFLATE == encoding { w := currentCompressorProvider.AcquireZlibWriter() w.Reset(httpWriter) c.compressor = w c.encoding = ENCODING_DEFLATE } else { return nil, errors.New("Unknown encoding:" + encoding) } return c, err }
8,808
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/parameter.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. const ( // PathParameterKind = indicator of Request parameter type "path" PathParameterKind = iota // QueryParameterKind = indicator of Request parameter type "query" QueryParameterKind // BodyParameterKind = indicator of Request parameter type "body" BodyParameterKind // HeaderParameterKind = indicator of Request parameter type "header" HeaderParameterKind // FormParameterKind = indicator of Request parameter type "form" FormParameterKind // CollectionFormatCSV comma separated values `foo,bar` CollectionFormatCSV = CollectionFormat("csv") // CollectionFormatSSV space separated values `foo bar` CollectionFormatSSV = CollectionFormat("ssv") // CollectionFormatTSV tab separated values `foo\tbar` CollectionFormatTSV = CollectionFormat("tsv") // CollectionFormatPipes pipe separated values `foo|bar` CollectionFormatPipes = CollectionFormat("pipes") // CollectionFormatMulti corresponds to multiple parameter instances instead of multiple values for a single // instance `foo=bar&foo=baz`. This is valid only for QueryParameters and FormParameters CollectionFormatMulti = CollectionFormat("multi") ) type CollectionFormat string func (cf CollectionFormat) String() string { return string(cf) } // Parameter is for documententing the parameter used in a Http Request // ParameterData kinds are Path,Query and Body type Parameter struct { data *ParameterData } // ParameterData represents the state of a Parameter. // It is made public to make it accessible to e.g. the Swagger package. type ParameterData struct { Name, Description, DataType, DataFormat string Kind int Required bool AllowableValues map[string]string AllowMultiple bool DefaultValue string CollectionFormat string } // Data returns the state of the Parameter func (p *Parameter) Data() ParameterData { return *p.data } // Kind returns the parameter type indicator (see const for valid values) func (p *Parameter) Kind() int { return p.data.Kind } func (p *Parameter) bePath() *Parameter { p.data.Kind = PathParameterKind return p } func (p *Parameter) beQuery() *Parameter { p.data.Kind = QueryParameterKind return p } func (p *Parameter) beBody() *Parameter { p.data.Kind = BodyParameterKind return p } func (p *Parameter) beHeader() *Parameter { p.data.Kind = HeaderParameterKind return p } func (p *Parameter) beForm() *Parameter { p.data.Kind = FormParameterKind return p } // Required sets the required field and returns the receiver func (p *Parameter) Required(required bool) *Parameter { p.data.Required = required return p } // AllowMultiple sets the allowMultiple field and returns the receiver func (p *Parameter) AllowMultiple(multiple bool) *Parameter { p.data.AllowMultiple = multiple return p } // AllowableValues sets the allowableValues field and returns the receiver func (p *Parameter) AllowableValues(values map[string]string) *Parameter { p.data.AllowableValues = values return p } // DataType sets the dataType field and returns the receiver func (p *Parameter) DataType(typeName string) *Parameter { p.data.DataType = typeName return p } // DataFormat sets the dataFormat field for Swagger UI func (p *Parameter) DataFormat(formatName string) *Parameter { p.data.DataFormat = formatName return p } // DefaultValue sets the default value field and returns the receiver func (p *Parameter) DefaultValue(stringRepresentation string) *Parameter { p.data.DefaultValue = stringRepresentation return p } // Description sets the description value field and returns the receiver func (p *Parameter) Description(doc string) *Parameter { p.data.Description = doc return p } // CollectionFormat sets the collection format for an array type func (p *Parameter) CollectionFormat(format CollectionFormat) *Parameter { p.data.CollectionFormat = format.String() return p }
8,809
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/path_processor.go
package restful import ( "bytes" "strings" ) // Copyright 2018 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. // PathProcessor is extra behaviour that a Router can provide to extract path parameters from the path. // If a Router does not implement this interface then the default behaviour will be used. type PathProcessor interface { // ExtractParameters gets the path parameters defined in the route and webService from the urlPath ExtractParameters(route *Route, webService *WebService, urlPath string) map[string]string } type defaultPathProcessor struct{} // Extract the parameters from the request url path func (d defaultPathProcessor) ExtractParameters(r *Route, _ *WebService, urlPath string) map[string]string { urlParts := tokenizePath(urlPath) pathParameters := map[string]string{} for i, key := range r.pathParts { var value string if i >= len(urlParts) { value = "" } else { value = urlParts[i] } if strings.HasPrefix(key, "{") { // path-parameter if colon := strings.Index(key, ":"); colon != -1 { // extract by regex regPart := key[colon+1 : len(key)-1] keyPart := key[1:colon] if regPart == "*" { pathParameters[keyPart] = untokenizePath(i, urlParts) break } else { pathParameters[keyPart] = value } } else { // without enclosing {} pathParameters[key[1:len(key)-1]] = value } } } return pathParameters } // Untokenize back into an URL path using the slash separator func untokenizePath(offset int, parts []string) string { var buffer bytes.Buffer for p := offset; p < len(parts); p++ { buffer.WriteString(parts[p]) // do not end if p < len(parts)-1 { buffer.WriteString("/") } } return buffer.String() }
8,810
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/path_expression.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "bytes" "fmt" "regexp" "strings" ) // PathExpression holds a compiled path expression (RegExp) needed to match against // Http request paths and to extract path parameter values. type pathExpression struct { LiteralCount int // the number of literal characters (means those not resulting from template variable substitution) VarNames []string // the names of parameters (enclosed by {}) in the path VarCount int // the number of named parameters (enclosed by {}) in the path Matcher *regexp.Regexp Source string // Path as defined by the RouteBuilder tokens []string } // NewPathExpression creates a PathExpression from the input URL path. // Returns an error if the path is invalid. func newPathExpression(path string) (*pathExpression, error) { expression, literalCount, varNames, varCount, tokens := templateToRegularExpression(path) compiled, err := regexp.Compile(expression) if err != nil { return nil, err } return &pathExpression{literalCount, varNames, varCount, compiled, expression, tokens}, nil } // http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-370003.7.3 func templateToRegularExpression(template string) (expression string, literalCount int, varNames []string, varCount int, tokens []string) { var buffer bytes.Buffer buffer.WriteString("^") //tokens = strings.Split(template, "/") tokens = tokenizePath(template) for _, each := range tokens { if each == "" { continue } buffer.WriteString("/") if strings.HasPrefix(each, "{") { // check for regular expression in variable colon := strings.Index(each, ":") var varName string if colon != -1 { // extract expression varName = strings.TrimSpace(each[1:colon]) paramExpr := strings.TrimSpace(each[colon+1 : len(each)-1]) if paramExpr == "*" { // special case buffer.WriteString("(.*)") } else { buffer.WriteString(fmt.Sprintf("(%s)", paramExpr)) // between colon and closing moustache } } else { // plain var varName = strings.TrimSpace(each[1 : len(each)-1]) buffer.WriteString("([^/]+?)") } varNames = append(varNames, varName) varCount += 1 } else { literalCount += len(each) encoded := each // TODO URI encode buffer.WriteString(regexp.QuoteMeta(encoded)) } } return strings.TrimRight(buffer.String(), "/") + "(/.*)?$", literalCount, varNames, varCount, tokens }
8,811
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/json.go
// +build !jsoniter package restful import "encoding/json" var ( MarshalIndent = json.MarshalIndent NewDecoder = json.NewDecoder NewEncoder = json.NewEncoder )
8,812
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/route.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "net/http" "strings" ) // RouteFunction declares the signature of a function that can be bound to a Route. type RouteFunction func(*Request, *Response) // RouteSelectionConditionFunction declares the signature of a function that // can be used to add extra conditional logic when selecting whether the route // matches the HTTP request. type RouteSelectionConditionFunction func(httpRequest *http.Request) bool // Route binds a HTTP Method,Path,Consumes combination to a RouteFunction. type Route struct { Method string Produces []string Consumes []string Path string // webservice root path + described path Function RouteFunction Filters []FilterFunction If []RouteSelectionConditionFunction // cached values for dispatching relativePath string pathParts []string pathExpr *pathExpression // cached compilation of relativePath as RegExp // documentation Doc string Notes string Operation string ParameterDocs []*Parameter ResponseErrors map[int]ResponseError DefaultResponse *ResponseError ReadSample, WriteSample interface{} // structs that model an example request or response payload // Extra information used to store custom information about the route. Metadata map[string]interface{} // marks a route as deprecated Deprecated bool //Overrides the container.contentEncodingEnabled contentEncodingEnabled *bool } // Initialize for Route func (r *Route) postBuild() { r.pathParts = tokenizePath(r.Path) } // Create Request and Response from their http versions func (r *Route) wrapRequestResponse(httpWriter http.ResponseWriter, httpRequest *http.Request, pathParams map[string]string) (*Request, *Response) { wrappedRequest := NewRequest(httpRequest) wrappedRequest.pathParameters = pathParams wrappedRequest.selectedRoutePath = r.Path wrappedResponse := NewResponse(httpWriter) wrappedResponse.requestAccept = httpRequest.Header.Get(HEADER_Accept) wrappedResponse.routeProduces = r.Produces return wrappedRequest, wrappedResponse } // dispatchWithFilters call the function after passing through its own filters func (r *Route) dispatchWithFilters(wrappedRequest *Request, wrappedResponse *Response) { if len(r.Filters) > 0 { chain := FilterChain{Filters: r.Filters, Target: r.Function} chain.ProcessFilter(wrappedRequest, wrappedResponse) } else { // unfiltered r.Function(wrappedRequest, wrappedResponse) } } func stringTrimSpaceCutset(r rune) bool { return r == ' ' } // Return whether the mimeType matches to what this Route can produce. func (r Route) matchesAccept(mimeTypesWithQuality string) bool { remaining := mimeTypesWithQuality for { var mimeType string if end := strings.Index(remaining, ","); end == -1 { mimeType, remaining = remaining, "" } else { mimeType, remaining = remaining[:end], remaining[end+1:] } if quality := strings.Index(mimeType, ";"); quality != -1 { mimeType = mimeType[:quality] } mimeType = strings.TrimFunc(mimeType, stringTrimSpaceCutset) if mimeType == "*/*" { return true } for _, producibleType := range r.Produces { if producibleType == "*/*" || producibleType == mimeType { return true } } if len(remaining) == 0 { return false } } } // Return whether this Route can consume content with a type specified by mimeTypes (can be empty). func (r Route) matchesContentType(mimeTypes string) bool { if len(r.Consumes) == 0 { // did not specify what it can consume ; any media type (β€œ*/*”) is assumed return true } if len(mimeTypes) == 0 { // idempotent methods with (most-likely or guaranteed) empty content match missing Content-Type m := r.Method if m == "GET" || m == "HEAD" || m == "OPTIONS" || m == "DELETE" || m == "TRACE" { return true } // proceed with default mimeTypes = MIME_OCTET } remaining := mimeTypes for { var mimeType string if end := strings.Index(remaining, ","); end == -1 { mimeType, remaining = remaining, "" } else { mimeType, remaining = remaining[:end], remaining[end+1:] } if quality := strings.Index(mimeType, ";"); quality != -1 { mimeType = mimeType[:quality] } mimeType = strings.TrimFunc(mimeType, stringTrimSpaceCutset) for _, consumeableType := range r.Consumes { if consumeableType == "*/*" || consumeableType == mimeType { return true } } if len(remaining) == 0 { return false } } } // Tokenize an URL path using the slash separator ; the result does not have empty tokens func tokenizePath(path string) []string { if "/" == path { return nil } return strings.Split(strings.Trim(path, "/"), "/") } // for debugging func (r Route) String() string { return r.Method + " " + r.Path } // EnableContentEncoding (default=false) allows for GZIP or DEFLATE encoding of responses. Overrides the container.contentEncodingEnabled value. func (r Route) EnableContentEncoding(enabled bool) { r.contentEncodingEnabled = &enabled }
8,813
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/jsoniter.go
// +build jsoniter package restful import "github.com/json-iterator/go" var ( json = jsoniter.ConfigCompatibleWithStandardLibrary MarshalIndent = json.MarshalIndent NewDecoder = json.NewDecoder NewEncoder = json.NewEncoder )
8,814
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/README.md
go-restful ========== package for building REST-style Web Services using Google Go [![Build Status](https://travis-ci.org/emicklei/go-restful.png)](https://travis-ci.org/emicklei/go-restful) [![Go Report Card](https://goreportcard.com/badge/github.com/emicklei/go-restful)](https://goreportcard.com/report/github.com/emicklei/go-restful) [![GoDoc](https://godoc.org/github.com/emicklei/go-restful?status.svg)](https://godoc.org/github.com/emicklei/go-restful) - [Code examples](https://github.com/emicklei/go-restful/tree/master/examples) REST asks developers to use HTTP methods explicitly and in a way that's consistent with the protocol definition. This basic REST design principle establishes a one-to-one mapping between create, read, update, and delete (CRUD) operations and HTTP methods. According to this mapping: - GET = Retrieve a representation of a resource - POST = Create if you are sending content to the server to create a subordinate of the specified resource collection, using some server-side algorithm. - PUT = Create if you are sending the full content of the specified resource (URI). - PUT = Update if you are updating the full content of the specified resource. - DELETE = Delete if you are requesting the server to delete the resource - PATCH = Update partial content of a resource - OPTIONS = Get information about the communication options for the request URI ### Example ```Go ws := new(restful.WebService) ws. Path("/users"). Consumes(restful.MIME_XML, restful.MIME_JSON). Produces(restful.MIME_JSON, restful.MIME_XML) ws.Route(ws.GET("/{user-id}").To(u.findUser). Doc("get a user"). Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")). Writes(User{})) ... func (u UserResource) findUser(request *restful.Request, response *restful.Response) { id := request.PathParameter("user-id") ... } ``` [Full API of a UserResource](https://github.com/emicklei/go-restful/tree/master/examples/restful-user-resource.go) ### Features - Routes for request &#8594; function mapping with path parameter (e.g. {id}) support - Configurable router: - (default) Fast routing algorithm that allows static elements, regular expressions and dynamic parameters in the URL path (e.g. /meetings/{id} or /static/{subpath:*} - Routing algorithm after [JSR311](http://jsr311.java.net/nonav/releases/1.1/spec/spec.html) that is implemented using (but does **not** accept) regular expressions - Request API for reading structs from JSON/XML and accesing parameters (path,query,header) - Response API for writing structs to JSON/XML and setting headers - Customizable encoding using EntityReaderWriter registration - Filters for intercepting the request &#8594; response flow on Service or Route level - Request-scoped variables using attributes - Containers for WebServices on different HTTP endpoints - Content encoding (gzip,deflate) of request and response payloads - Automatic responses on OPTIONS (using a filter) - Automatic CORS request handling (using a filter) - API declaration for Swagger UI ([go-restful-openapi](https://github.com/emicklei/go-restful-openapi), see [go-restful-swagger12](https://github.com/emicklei/go-restful-swagger12)) - Panic recovery to produce HTTP 500, customizable using RecoverHandler(...) - Route errors produce HTTP 404/405/406/415 errors, customizable using ServiceErrorHandler(...) - Configurable (trace) logging - Customizable gzip/deflate readers and writers using CompressorProvider registration ## How to customize There are several hooks to customize the behavior of the go-restful package. - Router algorithm - Panic recovery - JSON decoder - Trace logging - Compression - Encoders for other serializers - Use [jsoniter](https://github.com/json-iterator/go) by build this package using a tag, e.g. `go build -tags=jsoniter .` TODO: write examples of these. ## Resources - [Example posted on blog](http://ernestmicklei.com/2012/11/go-restful-first-working-example/) - [Design explained on blog](http://ernestmicklei.com/2012/11/go-restful-api-design/) - [sourcegraph](https://sourcegraph.com/github.com/emicklei/go-restful) - [showcase: Zazkia - tcp proxy for testing resiliency](https://github.com/emicklei/zazkia) - [showcase: Mora - MongoDB REST Api server](https://github.com/emicklei/mora) Type ```git shortlog -s``` for a full list of contributors. Β© 2012 - 2018, http://ernestmicklei.com. MIT License. Contributions are welcome.
8,815
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/logger.go
package restful // Copyright 2014 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "github.com/emicklei/go-restful/log" ) var trace bool = false var traceLogger log.StdLogger func init() { traceLogger = log.Logger // use the package logger by default } // TraceLogger enables detailed logging of Http request matching and filter invocation. Default no logger is set. // You may call EnableTracing() directly to enable trace logging to the package-wide logger. func TraceLogger(logger log.StdLogger) { traceLogger = logger EnableTracing(logger != nil) } // SetLogger exposes the setter for the global logger on the top-level package func SetLogger(customLogger log.StdLogger) { log.SetLogger(customLogger) } // EnableTracing can be used to Trace logging on and off. func EnableTracing(enabled bool) { trace = enabled }
8,816
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/service_error.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import "fmt" // ServiceError is a transport object to pass information about a non-Http error occurred in a WebService while processing a request. type ServiceError struct { Code int Message string } // NewError returns a ServiceError using the code and reason func NewError(code int, message string) ServiceError { return ServiceError{Code: code, Message: message} } // Error returns a text representation of the service error func (s ServiceError) Error() string { return fmt.Sprintf("[ServiceError:%v] %v", s.Code, s.Message) }
8,817
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/router.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import "net/http" // A RouteSelector finds the best matching Route given the input HTTP Request // RouteSelectors can optionally also implement the PathProcessor interface to also calculate the // path parameters after the route has been selected. type RouteSelector interface { // SelectRoute finds a Route given the input HTTP Request and a list of WebServices. // It returns a selected Route and its containing WebService or an error indicating // a problem. SelectRoute( webServices []*WebService, httpRequest *http.Request) (selectedService *WebService, selected *Route, err error) }
8,818
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/request.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "compress/zlib" "net/http" ) var defaultRequestContentType string // Request is a wrapper for a http Request that provides convenience methods type Request struct { Request *http.Request pathParameters map[string]string attributes map[string]interface{} // for storing request-scoped values selectedRoutePath string // root path + route path that matched the request, e.g. /meetings/{id}/attendees } func NewRequest(httpRequest *http.Request) *Request { return &Request{ Request: httpRequest, pathParameters: map[string]string{}, attributes: map[string]interface{}{}, } // empty parameters, attributes } // If ContentType is missing or */* is given then fall back to this type, otherwise // a "Unable to unmarshal content of type:" response is returned. // Valid values are restful.MIME_JSON and restful.MIME_XML // Example: // restful.DefaultRequestContentType(restful.MIME_JSON) func DefaultRequestContentType(mime string) { defaultRequestContentType = mime } // PathParameter accesses the Path parameter value by its name func (r *Request) PathParameter(name string) string { return r.pathParameters[name] } // PathParameters accesses the Path parameter values func (r *Request) PathParameters() map[string]string { return r.pathParameters } // QueryParameter returns the (first) Query parameter value by its name func (r *Request) QueryParameter(name string) string { return r.Request.FormValue(name) } // QueryParameters returns the all the query parameters values by name func (r *Request) QueryParameters(name string) []string { return r.Request.URL.Query()[name] } // BodyParameter parses the body of the request (once for typically a POST or a PUT) and returns the value of the given name or an error. func (r *Request) BodyParameter(name string) (string, error) { err := r.Request.ParseForm() if err != nil { return "", err } return r.Request.PostFormValue(name), nil } // HeaderParameter returns the HTTP Header value of a Header name or empty if missing func (r *Request) HeaderParameter(name string) string { return r.Request.Header.Get(name) } // ReadEntity checks the Accept header and reads the content into the entityPointer. func (r *Request) ReadEntity(entityPointer interface{}) (err error) { contentType := r.Request.Header.Get(HEADER_ContentType) contentEncoding := r.Request.Header.Get(HEADER_ContentEncoding) // check if the request body needs decompression if ENCODING_GZIP == contentEncoding { gzipReader := currentCompressorProvider.AcquireGzipReader() defer currentCompressorProvider.ReleaseGzipReader(gzipReader) gzipReader.Reset(r.Request.Body) r.Request.Body = gzipReader } else if ENCODING_DEFLATE == contentEncoding { zlibReader, err := zlib.NewReader(r.Request.Body) if err != nil { return err } r.Request.Body = zlibReader } // lookup the EntityReader, use defaultRequestContentType if needed and provided entityReader, ok := entityAccessRegistry.accessorAt(contentType) if !ok { if len(defaultRequestContentType) != 0 { entityReader, ok = entityAccessRegistry.accessorAt(defaultRequestContentType) } if !ok { return NewError(http.StatusBadRequest, "Unable to unmarshal content of type:"+contentType) } } return entityReader.Read(r, entityPointer) } // SetAttribute adds or replaces the attribute with the given value. func (r *Request) SetAttribute(name string, value interface{}) { r.attributes[name] = value } // Attribute returns the value associated to the given name. Returns nil if absent. func (r Request) Attribute(name string) interface{} { return r.attributes[name] } // SelectedRoutePath root path + route path that matched the request, e.g. /meetings/{id}/attendees func (r Request) SelectedRoutePath() string { return r.selectedRoutePath }
8,819
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/cors_filter.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "regexp" "strconv" "strings" ) // CrossOriginResourceSharing is used to create a Container Filter that implements CORS. // Cross-origin resource sharing (CORS) is a mechanism that allows JavaScript on a web page // to make XMLHttpRequests to another domain, not the domain the JavaScript originated from. // // http://en.wikipedia.org/wiki/Cross-origin_resource_sharing // http://enable-cors.org/server.html // http://www.html5rocks.com/en/tutorials/cors/#toc-handling-a-not-so-simple-request type CrossOriginResourceSharing struct { ExposeHeaders []string // list of Header names AllowedHeaders []string // list of Header names AllowedDomains []string // list of allowed values for Http Origin. An allowed value can be a regular expression to support subdomain matching. If empty all are allowed. AllowedMethods []string MaxAge int // number of seconds before requiring new Options request CookiesAllowed bool Container *Container allowedOriginPatterns []*regexp.Regexp // internal field for origin regexp check. } // Filter is a filter function that implements the CORS flow as documented on http://enable-cors.org/server.html // and http://www.html5rocks.com/static/images/cors_server_flowchart.png func (c CrossOriginResourceSharing) Filter(req *Request, resp *Response, chain *FilterChain) { origin := req.Request.Header.Get(HEADER_Origin) if len(origin) == 0 { if trace { traceLogger.Print("no Http header Origin set") } chain.ProcessFilter(req, resp) return } if !c.isOriginAllowed(origin) { // check whether this origin is allowed if trace { traceLogger.Printf("HTTP Origin:%s is not part of %v, neither matches any part of %v", origin, c.AllowedDomains, c.allowedOriginPatterns) } chain.ProcessFilter(req, resp) return } if req.Request.Method != "OPTIONS" { c.doActualRequest(req, resp) chain.ProcessFilter(req, resp) return } if acrm := req.Request.Header.Get(HEADER_AccessControlRequestMethod); acrm != "" { c.doPreflightRequest(req, resp) } else { c.doActualRequest(req, resp) chain.ProcessFilter(req, resp) return } } func (c CrossOriginResourceSharing) doActualRequest(req *Request, resp *Response) { c.setOptionsHeaders(req, resp) // continue processing the response } func (c *CrossOriginResourceSharing) doPreflightRequest(req *Request, resp *Response) { if len(c.AllowedMethods) == 0 { if c.Container == nil { c.AllowedMethods = DefaultContainer.computeAllowedMethods(req) } else { c.AllowedMethods = c.Container.computeAllowedMethods(req) } } acrm := req.Request.Header.Get(HEADER_AccessControlRequestMethod) if !c.isValidAccessControlRequestMethod(acrm, c.AllowedMethods) { if trace { traceLogger.Printf("Http header %s:%s is not in %v", HEADER_AccessControlRequestMethod, acrm, c.AllowedMethods) } return } acrhs := req.Request.Header.Get(HEADER_AccessControlRequestHeaders) if len(acrhs) > 0 { for _, each := range strings.Split(acrhs, ",") { if !c.isValidAccessControlRequestHeader(strings.Trim(each, " ")) { if trace { traceLogger.Printf("Http header %s:%s is not in %v", HEADER_AccessControlRequestHeaders, acrhs, c.AllowedHeaders) } return } } } resp.AddHeader(HEADER_AccessControlAllowMethods, strings.Join(c.AllowedMethods, ",")) resp.AddHeader(HEADER_AccessControlAllowHeaders, acrhs) c.setOptionsHeaders(req, resp) // return http 200 response, no body } func (c CrossOriginResourceSharing) setOptionsHeaders(req *Request, resp *Response) { c.checkAndSetExposeHeaders(resp) c.setAllowOriginHeader(req, resp) c.checkAndSetAllowCredentials(resp) if c.MaxAge > 0 { resp.AddHeader(HEADER_AccessControlMaxAge, strconv.Itoa(c.MaxAge)) } } func (c CrossOriginResourceSharing) isOriginAllowed(origin string) bool { if len(origin) == 0 { return false } if len(c.AllowedDomains) == 0 { return true } allowed := false for _, domain := range c.AllowedDomains { if domain == origin { allowed = true break } } if !allowed { if len(c.allowedOriginPatterns) == 0 { // compile allowed domains to allowed origin patterns allowedOriginRegexps, err := compileRegexps(c.AllowedDomains) if err != nil { return false } c.allowedOriginPatterns = allowedOriginRegexps } for _, pattern := range c.allowedOriginPatterns { if allowed = pattern.MatchString(origin); allowed { break } } } return allowed } func (c CrossOriginResourceSharing) setAllowOriginHeader(req *Request, resp *Response) { origin := req.Request.Header.Get(HEADER_Origin) if c.isOriginAllowed(origin) { resp.AddHeader(HEADER_AccessControlAllowOrigin, origin) } } func (c CrossOriginResourceSharing) checkAndSetExposeHeaders(resp *Response) { if len(c.ExposeHeaders) > 0 { resp.AddHeader(HEADER_AccessControlExposeHeaders, strings.Join(c.ExposeHeaders, ",")) } } func (c CrossOriginResourceSharing) checkAndSetAllowCredentials(resp *Response) { if c.CookiesAllowed { resp.AddHeader(HEADER_AccessControlAllowCredentials, "true") } } func (c CrossOriginResourceSharing) isValidAccessControlRequestMethod(method string, allowedMethods []string) bool { for _, each := range allowedMethods { if each == method { return true } } return false } func (c CrossOriginResourceSharing) isValidAccessControlRequestHeader(header string) bool { for _, each := range c.AllowedHeaders { if strings.ToLower(each) == strings.ToLower(header) { return true } } return false } // Take a list of strings and compile them into a list of regular expressions. func compileRegexps(regexpStrings []string) ([]*regexp.Regexp, error) { regexps := []*regexp.Regexp{} for _, regexpStr := range regexpStrings { r, err := regexp.Compile(regexpStr) if err != nil { return regexps, err } regexps = append(regexps, r) } return regexps, nil }
8,820
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/Makefile
all: test test: go test -v . ex: cd examples && ls *.go | xargs go build -o /tmp/ignore
8,821
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/Srcfile
{"SkipDirs": ["examples"]}
8,822
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/web_service_container.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "net/http" ) // DefaultContainer is a restful.Container that uses http.DefaultServeMux var DefaultContainer *Container func init() { DefaultContainer = NewContainer() DefaultContainer.ServeMux = http.DefaultServeMux } // If set the true then panics will not be caught to return HTTP 500. // In that case, Route functions are responsible for handling any error situation. // Default value is false = recover from panics. This has performance implications. // OBSOLETE ; use restful.DefaultContainer.DoNotRecover(true) var DoNotRecover = false // Add registers a new WebService add it to the DefaultContainer. func Add(service *WebService) { DefaultContainer.Add(service) } // Filter appends a container FilterFunction from the DefaultContainer. // These are called before dispatching a http.Request to a WebService. func Filter(filter FilterFunction) { DefaultContainer.Filter(filter) } // RegisteredWebServices returns the collections of WebServices from the DefaultContainer func RegisteredWebServices() []*WebService { return DefaultContainer.RegisteredWebServices() }
8,823
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/LICENSE
Copyright (c) 2012,2013 Ernest Micklei MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8,824
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/options_filter.go
package restful import "strings" // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. // OPTIONSFilter is a filter function that inspects the Http Request for the OPTIONS method // and provides the response with a set of allowed methods for the request URL Path. // As for any filter, you can also install it for a particular WebService within a Container. // Note: this filter is not needed when using CrossOriginResourceSharing (for CORS). func (c *Container) OPTIONSFilter(req *Request, resp *Response, chain *FilterChain) { if "OPTIONS" != req.Request.Method { chain.ProcessFilter(req, resp) return } archs := req.Request.Header.Get(HEADER_AccessControlRequestHeaders) methods := strings.Join(c.computeAllowedMethods(req), ",") origin := req.Request.Header.Get(HEADER_Origin) resp.AddHeader(HEADER_Allow, methods) resp.AddHeader(HEADER_AccessControlAllowOrigin, origin) resp.AddHeader(HEADER_AccessControlAllowHeaders, archs) resp.AddHeader(HEADER_AccessControlAllowMethods, methods) } // OPTIONSFilter is a filter function that inspects the Http Request for the OPTIONS method // and provides the response with a set of allowed methods for the request URL Path. // Note: this filter is not needed when using CrossOriginResourceSharing (for CORS). func OPTIONSFilter() FilterFunction { return DefaultContainer.OPTIONSFilter }
8,825
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/compressor_cache.go
package restful // Copyright 2015 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "compress/gzip" "compress/zlib" ) // BoundedCachedCompressors is a CompressorProvider that uses a cache with a fixed amount // of writers and readers (resources). // If a new resource is acquired and all are in use, it will return a new unmanaged resource. type BoundedCachedCompressors struct { gzipWriters chan *gzip.Writer gzipReaders chan *gzip.Reader zlibWriters chan *zlib.Writer writersCapacity int readersCapacity int } // NewBoundedCachedCompressors returns a new, with filled cache, BoundedCachedCompressors. func NewBoundedCachedCompressors(writersCapacity, readersCapacity int) *BoundedCachedCompressors { b := &BoundedCachedCompressors{ gzipWriters: make(chan *gzip.Writer, writersCapacity), gzipReaders: make(chan *gzip.Reader, readersCapacity), zlibWriters: make(chan *zlib.Writer, writersCapacity), writersCapacity: writersCapacity, readersCapacity: readersCapacity, } for ix := 0; ix < writersCapacity; ix++ { b.gzipWriters <- newGzipWriter() b.zlibWriters <- newZlibWriter() } for ix := 0; ix < readersCapacity; ix++ { b.gzipReaders <- newGzipReader() } return b } // AcquireGzipWriter returns an resettable *gzip.Writer. Needs to be released. func (b *BoundedCachedCompressors) AcquireGzipWriter() *gzip.Writer { var writer *gzip.Writer select { case writer, _ = <-b.gzipWriters: default: // return a new unmanaged one writer = newGzipWriter() } return writer } // ReleaseGzipWriter accepts a writer (does not have to be one that was cached) // only when the cache has room for it. It will ignore it otherwise. func (b *BoundedCachedCompressors) ReleaseGzipWriter(w *gzip.Writer) { // forget the unmanaged ones if len(b.gzipWriters) < b.writersCapacity { b.gzipWriters <- w } } // AcquireGzipReader returns a *gzip.Reader. Needs to be released. func (b *BoundedCachedCompressors) AcquireGzipReader() *gzip.Reader { var reader *gzip.Reader select { case reader, _ = <-b.gzipReaders: default: // return a new unmanaged one reader = newGzipReader() } return reader } // ReleaseGzipReader accepts a reader (does not have to be one that was cached) // only when the cache has room for it. It will ignore it otherwise. func (b *BoundedCachedCompressors) ReleaseGzipReader(r *gzip.Reader) { // forget the unmanaged ones if len(b.gzipReaders) < b.readersCapacity { b.gzipReaders <- r } } // AcquireZlibWriter returns an resettable *zlib.Writer. Needs to be released. func (b *BoundedCachedCompressors) AcquireZlibWriter() *zlib.Writer { var writer *zlib.Writer select { case writer, _ = <-b.zlibWriters: default: // return a new unmanaged one writer = newZlibWriter() } return writer } // ReleaseZlibWriter accepts a writer (does not have to be one that was cached) // only when the cache has room for it. It will ignore it otherwise. func (b *BoundedCachedCompressors) ReleaseZlibWriter(w *zlib.Writer) { // forget the unmanaged ones if len(b.zlibWriters) < b.writersCapacity { b.zlibWriters <- w } }
8,826
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/CHANGES.md
## Change history of go-restful v2.9.5 - fix panic in Response.WriteError if err == nil v2.9.4 - fix issue #400 , parsing mime type quality - Route Builder added option for contentEncodingEnabled (#398) v2.9.3 - Avoid return of 415 Unsupported Media Type when request body is empty (#396) v2.9.2 - Reduce allocations in per-request methods to improve performance (#395) v2.9.1 - Fix issue with default responses and invalid status code 0. (#393) v2.9.0 - add per Route content encoding setting (overrides container setting) v2.8.0 - add Request.QueryParameters() - add json-iterator (via build tag) - disable vgo module (until log is moved) v2.7.1 - add vgo module v2.6.1 - add JSONNewDecoderFunc to allow custom JSON Decoder usage (go 1.10+) v2.6.0 - Make JSR 311 routing and path param processing consistent - Adding description to RouteBuilder.Reads() - Update example for Swagger12 and OpenAPI 2017-09-13 - added route condition functions using `.If(func)` in route building. 2017-02-16 - solved issue #304, make operation names unique 2017-01-30 [IMPORTANT] For swagger users, change your import statement to: swagger "github.com/emicklei/go-restful-swagger12" - moved swagger 1.2 code to go-restful-swagger12 - created TAG 2.0.0 2017-01-27 - remove defer request body close - expose Dispatch for testing filters and Routefunctions - swagger response model cannot be array - created TAG 1.0.0 2016-12-22 - (API change) Remove code related to caching request content. Removes SetCacheReadEntity(doCache bool) 2016-11-26 - Default change! now use CurlyRouter (was RouterJSR311) - Default change! no more caching of request content - Default change! do not recover from panics 2016-09-22 - fix the DefaultRequestContentType feature 2016-02-14 - take the qualify factor of the Accept header mediatype into account when deciding the contentype of the response - add constructors for custom entity accessors for xml and json 2015-09-27 - rename new WriteStatusAnd... to WriteHeaderAnd... for consistency 2015-09-25 - fixed problem with changing Header after WriteHeader (issue 235) 2015-09-14 - changed behavior of WriteHeader (immediate write) and WriteEntity (no status write) - added support for custom EntityReaderWriters. 2015-08-06 - add support for reading entities from compressed request content - use sync.Pool for compressors of http response and request body - add Description to Parameter for documentation in Swagger UI 2015-03-20 - add configurable logging 2015-03-18 - if not specified, the Operation is derived from the Route function 2015-03-17 - expose Parameter creation functions - make trace logger an interface - fix OPTIONSFilter - customize rendering of ServiceError - JSR311 router now handles wildcards - add Notes to Route 2014-11-27 - (api add) PrettyPrint per response. (as proposed in #167) 2014-11-12 - (api add) ApiVersion(.) for documentation in Swagger UI 2014-11-10 - (api change) struct fields tagged with "description" show up in Swagger UI 2014-10-31 - (api change) ReturnsError -> Returns - (api add) RouteBuilder.Do(aBuilder) for DRY use of RouteBuilder - fix swagger nested structs - sort Swagger response messages by code 2014-10-23 - (api add) ReturnsError allows you to document Http codes in swagger - fixed problem with greedy CurlyRouter - (api add) Access-Control-Max-Age in CORS - add tracing functionality (injectable) for debugging purposes - support JSON parse 64bit int - fix empty parameters for swagger - WebServicesUrl is now optional for swagger - fixed duplicate AccessControlAllowOrigin in CORS - (api change) expose ServeMux in container - (api add) added AllowedDomains in CORS - (api add) ParameterNamed for detailed documentation 2014-04-16 - (api add) expose constructor of Request for testing. 2014-06-27 - (api add) ParameterNamed gives access to a Parameter definition and its data (for further specification). - (api add) SetCacheReadEntity allow scontrol over whether or not the request body is being cached (default true for compatibility reasons). 2014-07-03 - (api add) CORS can be configured with a list of allowed domains 2014-03-12 - (api add) Route path parameters can use wildcard or regular expressions. (requires CurlyRouter) 2014-02-26 - (api add) Request now provides information about the matched Route, see method SelectedRoutePath 2014-02-17 - (api change) renamed parameter constants (go-lint checks) 2014-01-10 - (api add) support for CloseNotify, see http://golang.org/pkg/net/http/#CloseNotifier 2014-01-07 - (api change) Write* methods in Response now return the error or nil. - added example of serving HTML from a Go template. - fixed comparing Allowed headers in CORS (is now case-insensitive) 2013-11-13 - (api add) Response knows how many bytes are written to the response body. 2013-10-29 - (api add) RecoverHandler(handler RecoverHandleFunction) to change how panic recovery is handled. Default behavior is to log and return a stacktrace. This may be a security issue as it exposes sourcecode information. 2013-10-04 - (api add) Response knows what HTTP status has been written - (api add) Request can have attributes (map of string->interface, also called request-scoped variables 2013-09-12 - (api change) Router interface simplified - Implemented CurlyRouter, a Router that does not use|allow regular expressions in paths 2013-08-05 - add OPTIONS support - add CORS support 2013-08-27 - fixed some reported issues (see github) - (api change) deprecated use of WriteError; use WriteErrorString instead 2014-04-15 - (fix) v1.0.1 tag: fix Issue 111: WriteErrorString 2013-08-08 - (api add) Added implementation Container: a WebServices collection with its own http.ServeMux allowing multiple endpoints per program. Existing uses of go-restful will register their services to the DefaultContainer. - (api add) the swagger package has be extended to have a UI per container. - if panic is detected then a small stack trace is printed (thanks to runner-mei) - (api add) WriteErrorString to Response Important API changes: - (api remove) package variable DoNotRecover no longer works ; use restful.DefaultContainer.DoNotRecover(true) instead. - (api remove) package variable EnableContentEncoding no longer works ; use restful.DefaultContainer.EnableContentEncoding(true) instead. 2013-07-06 - (api add) Added support for response encoding (gzip and deflate(zlib)). This feature is disabled on default (for backwards compatibility). Use restful.EnableContentEncoding = true in your initialization to enable this feature. 2013-06-19 - (improve) DoNotRecover option, moved request body closer, improved ReadEntity 2013-06-03 - (api change) removed Dispatcher interface, hide PathExpression - changed receiver names of type functions to be more idiomatic Go 2013-06-02 - (optimize) Cache the RegExp compilation of Paths. 2013-05-22 - (api add) Added support for request/response filter functions 2013-05-18 - (api add) Added feature to change the default Http Request Dispatch function (travis cline) - (api change) Moved Swagger Webservice to swagger package (see example restful-user) [2012-11-14 .. 2013-05-18> - See https://github.com/emicklei/go-restful/commits 2012-11-14 - Initial commit
8,827
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/response.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "bufio" "errors" "net" "net/http" ) // DefaultResponseMimeType is DEPRECATED, use DefaultResponseContentType(mime) var DefaultResponseMimeType string //PrettyPrintResponses controls the indentation feature of XML and JSON serialization var PrettyPrintResponses = true // Response is a wrapper on the actual http ResponseWriter // It provides several convenience methods to prepare and write response content. type Response struct { http.ResponseWriter requestAccept string // mime-type what the Http Request says it wants to receive routeProduces []string // mime-types what the Route says it can produce statusCode int // HTTP status code that has been written explicitly (if zero then net/http has written 200) contentLength int // number of bytes written for the response body prettyPrint bool // controls the indentation feature of XML and JSON serialization. It is initialized using var PrettyPrintResponses. err error // err property is kept when WriteError is called hijacker http.Hijacker // if underlying ResponseWriter supports it } // NewResponse creates a new response based on a http ResponseWriter. func NewResponse(httpWriter http.ResponseWriter) *Response { hijacker, _ := httpWriter.(http.Hijacker) return &Response{ResponseWriter: httpWriter, routeProduces: []string{}, statusCode: http.StatusOK, prettyPrint: PrettyPrintResponses, hijacker: hijacker} } // DefaultResponseContentType set a default. // If Accept header matching fails, fall back to this type. // Valid values are restful.MIME_JSON and restful.MIME_XML // Example: // restful.DefaultResponseContentType(restful.MIME_JSON) func DefaultResponseContentType(mime string) { DefaultResponseMimeType = mime } // InternalServerError writes the StatusInternalServerError header. // DEPRECATED, use WriteErrorString(http.StatusInternalServerError,reason) func (r Response) InternalServerError() Response { r.WriteHeader(http.StatusInternalServerError) return r } // Hijack implements the http.Hijacker interface. This expands // the Response to fulfill http.Hijacker if the underlying // http.ResponseWriter supports it. func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error) { if r.hijacker == nil { return nil, nil, errors.New("http.Hijacker not implemented by underlying http.ResponseWriter") } return r.hijacker.Hijack() } // PrettyPrint changes whether this response must produce pretty (line-by-line, indented) JSON or XML output. func (r *Response) PrettyPrint(bePretty bool) { r.prettyPrint = bePretty } // AddHeader is a shortcut for .Header().Add(header,value) func (r Response) AddHeader(header string, value string) Response { r.Header().Add(header, value) return r } // SetRequestAccepts tells the response what Mime-type(s) the HTTP request said it wants to accept. Exposed for testing. func (r *Response) SetRequestAccepts(mime string) { r.requestAccept = mime } // EntityWriter returns the registered EntityWriter that the entity (requested resource) // can write according to what the request wants (Accept) and what the Route can produce or what the restful defaults say. // If called before WriteEntity and WriteHeader then a false return value can be used to write a 406: Not Acceptable. func (r *Response) EntityWriter() (EntityReaderWriter, bool) { sorted := sortedMimes(r.requestAccept) for _, eachAccept := range sorted { for _, eachProduce := range r.routeProduces { if eachProduce == eachAccept.media { if w, ok := entityAccessRegistry.accessorAt(eachAccept.media); ok { return w, true } } } if eachAccept.media == "*/*" { for _, each := range r.routeProduces { if w, ok := entityAccessRegistry.accessorAt(each); ok { return w, true } } } } // if requestAccept is empty writer, ok := entityAccessRegistry.accessorAt(r.requestAccept) if !ok { // if not registered then fallback to the defaults (if set) if DefaultResponseMimeType == MIME_JSON { return entityAccessRegistry.accessorAt(MIME_JSON) } if DefaultResponseMimeType == MIME_XML { return entityAccessRegistry.accessorAt(MIME_XML) } // Fallback to whatever the route says it can produce. // https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for _, each := range r.routeProduces { if w, ok := entityAccessRegistry.accessorAt(each); ok { return w, true } } if trace { traceLogger.Printf("no registered EntityReaderWriter found for %s", r.requestAccept) } } return writer, ok } // WriteEntity calls WriteHeaderAndEntity with Http Status OK (200) func (r *Response) WriteEntity(value interface{}) error { return r.WriteHeaderAndEntity(http.StatusOK, value) } // WriteHeaderAndEntity marshals the value using the representation denoted by the Accept Header and the registered EntityWriters. // If no Accept header is specified (or */*) then respond with the Content-Type as specified by the first in the Route.Produces. // If an Accept header is specified then respond with the Content-Type as specified by the first in the Route.Produces that is matched with the Accept header. // If the value is nil then no response is send except for the Http status. You may want to call WriteHeader(http.StatusNotFound) instead. // If there is no writer available that can represent the value in the requested MIME type then Http Status NotAcceptable is written. // Current implementation ignores any q-parameters in the Accept Header. // Returns an error if the value could not be written on the response. func (r *Response) WriteHeaderAndEntity(status int, value interface{}) error { writer, ok := r.EntityWriter() if !ok { r.WriteHeader(http.StatusNotAcceptable) return nil } return writer.Write(r, status, value) } // WriteAsXml is a convenience method for writing a value in xml (requires Xml tags on the value) // It uses the standard encoding/xml package for marshalling the value ; not using a registered EntityReaderWriter. func (r *Response) WriteAsXml(value interface{}) error { return writeXML(r, http.StatusOK, MIME_XML, value) } // WriteHeaderAndXml is a convenience method for writing a status and value in xml (requires Xml tags on the value) // It uses the standard encoding/xml package for marshalling the value ; not using a registered EntityReaderWriter. func (r *Response) WriteHeaderAndXml(status int, value interface{}) error { return writeXML(r, status, MIME_XML, value) } // WriteAsJson is a convenience method for writing a value in json. // It uses the standard encoding/json package for marshalling the value ; not using a registered EntityReaderWriter. func (r *Response) WriteAsJson(value interface{}) error { return writeJSON(r, http.StatusOK, MIME_JSON, value) } // WriteJson is a convenience method for writing a value in Json with a given Content-Type. // It uses the standard encoding/json package for marshalling the value ; not using a registered EntityReaderWriter. func (r *Response) WriteJson(value interface{}, contentType string) error { return writeJSON(r, http.StatusOK, contentType, value) } // WriteHeaderAndJson is a convenience method for writing the status and a value in Json with a given Content-Type. // It uses the standard encoding/json package for marshalling the value ; not using a registered EntityReaderWriter. func (r *Response) WriteHeaderAndJson(status int, value interface{}, contentType string) error { return writeJSON(r, status, contentType, value) } // WriteError write the http status and the error string on the response. err can be nil. func (r *Response) WriteError(httpStatus int, err error) error { r.err = err if err == nil { r.WriteErrorString(httpStatus, "") } else { r.WriteErrorString(httpStatus, err.Error()) } return err } // WriteServiceError is a convenience method for a responding with a status and a ServiceError func (r *Response) WriteServiceError(httpStatus int, err ServiceError) error { r.err = err return r.WriteHeaderAndEntity(httpStatus, err) } // WriteErrorString is a convenience method for an error status with the actual error func (r *Response) WriteErrorString(httpStatus int, errorReason string) error { if r.err == nil { // if not called from WriteError r.err = errors.New(errorReason) } r.WriteHeader(httpStatus) if _, err := r.Write([]byte(errorReason)); err != nil { return err } return nil } // Flush implements http.Flusher interface, which sends any buffered data to the client. func (r *Response) Flush() { if f, ok := r.ResponseWriter.(http.Flusher); ok { f.Flush() } else if trace { traceLogger.Printf("ResponseWriter %v doesn't support Flush", r) } } // WriteHeader is overridden to remember the Status Code that has been written. // Changes to the Header of the response have no effect after this. func (r *Response) WriteHeader(httpStatus int) { r.statusCode = httpStatus r.ResponseWriter.WriteHeader(httpStatus) } // StatusCode returns the code that has been written using WriteHeader. func (r Response) StatusCode() int { if 0 == r.statusCode { // no status code has been written yet; assume OK return http.StatusOK } return r.statusCode } // Write writes the data to the connection as part of an HTTP reply. // Write is part of http.ResponseWriter interface. func (r *Response) Write(bytes []byte) (int, error) { written, err := r.ResponseWriter.Write(bytes) r.contentLength += written return written, err } // ContentLength returns the number of bytes written for the response content. // Note that this value is only correct if all data is written through the Response using its Write* methods. // Data written directly using the underlying http.ResponseWriter is not accounted for. func (r Response) ContentLength() int { return r.contentLength } // CloseNotify is part of http.CloseNotifier interface func (r Response) CloseNotify() <-chan bool { return r.ResponseWriter.(http.CloseNotifier).CloseNotify() } // Error returns the err created by WriteError func (r Response) Error() error { return r.err }
8,828
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/constants.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. const ( MIME_XML = "application/xml" // Accept or Content-Type used in Consumes() and/or Produces() MIME_JSON = "application/json" // Accept or Content-Type used in Consumes() and/or Produces() MIME_OCTET = "application/octet-stream" // If Content-Type is not present in request, use the default HEADER_Allow = "Allow" HEADER_Accept = "Accept" HEADER_Origin = "Origin" HEADER_ContentType = "Content-Type" HEADER_LastModified = "Last-Modified" HEADER_AcceptEncoding = "Accept-Encoding" HEADER_ContentEncoding = "Content-Encoding" HEADER_AccessControlExposeHeaders = "Access-Control-Expose-Headers" HEADER_AccessControlRequestMethod = "Access-Control-Request-Method" HEADER_AccessControlRequestHeaders = "Access-Control-Request-Headers" HEADER_AccessControlAllowMethods = "Access-Control-Allow-Methods" HEADER_AccessControlAllowOrigin = "Access-Control-Allow-Origin" HEADER_AccessControlAllowCredentials = "Access-Control-Allow-Credentials" HEADER_AccessControlAllowHeaders = "Access-Control-Allow-Headers" HEADER_AccessControlMaxAge = "Access-Control-Max-Age" ENCODING_GZIP = "gzip" ENCODING_DEFLATE = "deflate" )
8,829
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/doc.go
/* Package restful , a lean package for creating REST-style WebServices without magic. WebServices and Routes A WebService has a collection of Route objects that dispatch incoming Http Requests to a function calls. Typically, a WebService has a root path (e.g. /users) and defines common MIME types for its routes. WebServices must be added to a container (see below) in order to handler Http requests from a server. A Route is defined by a HTTP method, an URL path and (optionally) the MIME types it consumes (Content-Type) and produces (Accept). This package has the logic to find the best matching Route and if found, call its Function. ws := new(restful.WebService) ws. Path("/users"). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON, restful.MIME_XML) ws.Route(ws.GET("/{user-id}").To(u.findUser)) // u is a UserResource ... // GET http://localhost:8080/users/1 func (u UserResource) findUser(request *restful.Request, response *restful.Response) { id := request.PathParameter("user-id") ... } The (*Request, *Response) arguments provide functions for reading information from the request and writing information back to the response. See the example https://github.com/emicklei/go-restful/blob/master/examples/restful-user-resource.go with a full implementation. Regular expression matching Routes A Route parameter can be specified using the format "uri/{var[:regexp]}" or the special version "uri/{var:*}" for matching the tail of the path. For example, /persons/{name:[A-Z][A-Z]} can be used to restrict values for the parameter "name" to only contain capital alphabetic characters. Regular expressions must use the standard Go syntax as described in the regexp package. (https://code.google.com/p/re2/wiki/Syntax) This feature requires the use of a CurlyRouter. Containers A Container holds a collection of WebServices, Filters and a http.ServeMux for multiplexing http requests. Using the statements "restful.Add(...) and restful.Filter(...)" will register WebServices and Filters to the Default Container. The Default container of go-restful uses the http.DefaultServeMux. You can create your own Container and create a new http.Server for that particular container. container := restful.NewContainer() server := &http.Server{Addr: ":8081", Handler: container} Filters A filter dynamically intercepts requests and responses to transform or use the information contained in the requests or responses. You can use filters to perform generic logging, measurement, authentication, redirect, set response headers etc. In the restful package there are three hooks into the request,response flow where filters can be added. Each filter must define a FilterFunction: func (req *restful.Request, resp *restful.Response, chain *restful.FilterChain) Use the following statement to pass the request,response pair to the next filter or RouteFunction chain.ProcessFilter(req, resp) Container Filters These are processed before any registered WebService. // install a (global) filter for the default container (processed before any webservice) restful.Filter(globalLogging) WebService Filters These are processed before any Route of a WebService. // install a webservice filter (processed before any route) ws.Filter(webserviceLogging).Filter(measureTime) Route Filters These are processed before calling the function associated with the Route. // install 2 chained route filters (processed before calling findUser) ws.Route(ws.GET("/{user-id}").Filter(routeLogging).Filter(NewCountFilter().routeCounter).To(findUser)) See the example https://github.com/emicklei/go-restful/blob/master/examples/restful-filters.go with full implementations. Response Encoding Two encodings are supported: gzip and deflate. To enable this for all responses: restful.DefaultContainer.EnableContentEncoding(true) If a Http request includes the Accept-Encoding header then the response content will be compressed using the specified encoding. Alternatively, you can create a Filter that performs the encoding and install it per WebService or Route. See the example https://github.com/emicklei/go-restful/blob/master/examples/restful-encoding-filter.go OPTIONS support By installing a pre-defined container filter, your Webservice(s) can respond to the OPTIONS Http request. Filter(OPTIONSFilter()) CORS By installing the filter of a CrossOriginResourceSharing (CORS), your WebService(s) can handle CORS requests. cors := CrossOriginResourceSharing{ExposeHeaders: []string{"X-My-Header"}, CookiesAllowed: false, Container: DefaultContainer} Filter(cors.Filter) Error Handling Unexpected things happen. If a request cannot be processed because of a failure, your service needs to tell via the response what happened and why. For this reason HTTP status codes exist and it is important to use the correct code in every exceptional situation. 400: Bad Request If path or query parameters are not valid (content or type) then use http.StatusBadRequest. 404: Not Found Despite a valid URI, the resource requested may not be available 500: Internal Server Error If the application logic could not process the request (or write the response) then use http.StatusInternalServerError. 405: Method Not Allowed The request has a valid URL but the method (GET,PUT,POST,...) is not allowed. 406: Not Acceptable The request does not have or has an unknown Accept Header set for this operation. 415: Unsupported Media Type The request does not have or has an unknown Content-Type Header set for this operation. ServiceError In addition to setting the correct (error) Http status code, you can choose to write a ServiceError message on the response. Performance options This package has several options that affect the performance of your service. It is important to understand them and how you can change it. restful.DefaultContainer.DoNotRecover(false) DoNotRecover controls whether panics will be caught to return HTTP 500. If set to false, the container will recover from panics. Default value is true restful.SetCompressorProvider(NewBoundedCachedCompressors(20, 20)) If content encoding is enabled then the default strategy for getting new gzip/zlib writers and readers is to use a sync.Pool. Because writers are expensive structures, performance is even more improved when using a preloaded cache. You can also inject your own implementation. Trouble shooting This package has the means to produce detail logging of the complete Http request matching process and filter invocation. Enabling this feature requires you to set an implementation of restful.StdLogger (e.g. log.Logger) instance such as: restful.TraceLogger(log.New(os.Stdout, "[restful] ", log.LstdFlags|log.Lshortfile)) Logging The restful.SetLogger() method allows you to override the logger used by the package. By default restful uses the standard library `log` package and logs to stdout. Different logging packages are supported as long as they conform to `StdLogger` interface defined in the `log` sub-package, writing an adapter for your preferred package is simple. Resources [project]: https://github.com/emicklei/go-restful [examples]: https://github.com/emicklei/go-restful/blob/master/examples [design]: http://ernestmicklei.com/2012/11/11/go-restful-api-design/ [showcases]: https://github.com/emicklei/mora, https://github.com/emicklei/landskape (c) 2012-2015, http://ernestmicklei.com. MIT License */ package restful
8,830
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/container.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "bytes" "errors" "fmt" "net/http" "os" "runtime" "strings" "sync" "github.com/emicklei/go-restful/log" ) // Container holds a collection of WebServices and a http.ServeMux to dispatch http requests. // The requests are further dispatched to routes of WebServices using a RouteSelector type Container struct { webServicesLock sync.RWMutex webServices []*WebService ServeMux *http.ServeMux isRegisteredOnRoot bool containerFilters []FilterFunction doNotRecover bool // default is true recoverHandleFunc RecoverHandleFunction serviceErrorHandleFunc ServiceErrorHandleFunction router RouteSelector // default is a CurlyRouter (RouterJSR311 is a slower alternative) contentEncodingEnabled bool // default is false } // NewContainer creates a new Container using a new ServeMux and default router (CurlyRouter) func NewContainer() *Container { return &Container{ webServices: []*WebService{}, ServeMux: http.NewServeMux(), isRegisteredOnRoot: false, containerFilters: []FilterFunction{}, doNotRecover: true, recoverHandleFunc: logStackOnRecover, serviceErrorHandleFunc: writeServiceError, router: CurlyRouter{}, contentEncodingEnabled: false} } // RecoverHandleFunction declares functions that can be used to handle a panic situation. // The first argument is what recover() returns. The second must be used to communicate an error response. type RecoverHandleFunction func(interface{}, http.ResponseWriter) // RecoverHandler changes the default function (logStackOnRecover) to be called // when a panic is detected. DoNotRecover must be have its default value (=false). func (c *Container) RecoverHandler(handler RecoverHandleFunction) { c.recoverHandleFunc = handler } // ServiceErrorHandleFunction declares functions that can be used to handle a service error situation. // The first argument is the service error, the second is the request that resulted in the error and // the third must be used to communicate an error response. type ServiceErrorHandleFunction func(ServiceError, *Request, *Response) // ServiceErrorHandler changes the default function (writeServiceError) to be called // when a ServiceError is detected. func (c *Container) ServiceErrorHandler(handler ServiceErrorHandleFunction) { c.serviceErrorHandleFunc = handler } // DoNotRecover controls whether panics will be caught to return HTTP 500. // If set to true, Route functions are responsible for handling any error situation. // Default value is true. func (c *Container) DoNotRecover(doNot bool) { c.doNotRecover = doNot } // Router changes the default Router (currently CurlyRouter) func (c *Container) Router(aRouter RouteSelector) { c.router = aRouter } // EnableContentEncoding (default=false) allows for GZIP or DEFLATE encoding of responses. func (c *Container) EnableContentEncoding(enabled bool) { c.contentEncodingEnabled = enabled } // Add a WebService to the Container. It will detect duplicate root paths and exit in that case. func (c *Container) Add(service *WebService) *Container { c.webServicesLock.Lock() defer c.webServicesLock.Unlock() // if rootPath was not set then lazy initialize it if len(service.rootPath) == 0 { service.Path("/") } // cannot have duplicate root paths for _, each := range c.webServices { if each.RootPath() == service.RootPath() { log.Printf("WebService with duplicate root path detected:['%v']", each) os.Exit(1) } } // If not registered on root then add specific mapping if !c.isRegisteredOnRoot { c.isRegisteredOnRoot = c.addHandler(service, c.ServeMux) } c.webServices = append(c.webServices, service) return c } // addHandler may set a new HandleFunc for the serveMux // this function must run inside the critical region protected by the webServicesLock. // returns true if the function was registered on root ("/") func (c *Container) addHandler(service *WebService, serveMux *http.ServeMux) bool { pattern := fixedPrefixPath(service.RootPath()) // check if root path registration is needed if "/" == pattern || "" == pattern { serveMux.HandleFunc("/", c.dispatch) return true } // detect if registration already exists alreadyMapped := false for _, each := range c.webServices { if each.RootPath() == service.RootPath() { alreadyMapped = true break } } if !alreadyMapped { serveMux.HandleFunc(pattern, c.dispatch) if !strings.HasSuffix(pattern, "/") { serveMux.HandleFunc(pattern+"/", c.dispatch) } } return false } func (c *Container) Remove(ws *WebService) error { if c.ServeMux == http.DefaultServeMux { errMsg := fmt.Sprintf("cannot remove a WebService from a Container using the DefaultServeMux: ['%v']", ws) log.Print(errMsg) return errors.New(errMsg) } c.webServicesLock.Lock() defer c.webServicesLock.Unlock() // build a new ServeMux and re-register all WebServices newServeMux := http.NewServeMux() newServices := []*WebService{} newIsRegisteredOnRoot := false for _, each := range c.webServices { if each.rootPath != ws.rootPath { // If not registered on root then add specific mapping if !newIsRegisteredOnRoot { newIsRegisteredOnRoot = c.addHandler(each, newServeMux) } newServices = append(newServices, each) } } c.webServices, c.ServeMux, c.isRegisteredOnRoot = newServices, newServeMux, newIsRegisteredOnRoot return nil } // logStackOnRecover is the default RecoverHandleFunction and is called // when DoNotRecover is false and the recoverHandleFunc is not set for the container. // Default implementation logs the stacktrace and writes the stacktrace on the response. // This may be a security issue as it exposes sourcecode information. func logStackOnRecover(panicReason interface{}, httpWriter http.ResponseWriter) { var buffer bytes.Buffer buffer.WriteString(fmt.Sprintf("recover from panic situation: - %v\r\n", panicReason)) for i := 2; ; i += 1 { _, file, line, ok := runtime.Caller(i) if !ok { break } buffer.WriteString(fmt.Sprintf(" %s:%d\r\n", file, line)) } log.Print(buffer.String()) httpWriter.WriteHeader(http.StatusInternalServerError) httpWriter.Write(buffer.Bytes()) } // writeServiceError is the default ServiceErrorHandleFunction and is called // when a ServiceError is returned during route selection. Default implementation // calls resp.WriteErrorString(err.Code, err.Message) func writeServiceError(err ServiceError, req *Request, resp *Response) { resp.WriteErrorString(err.Code, err.Message) } // Dispatch the incoming Http Request to a matching WebService. func (c *Container) Dispatch(httpWriter http.ResponseWriter, httpRequest *http.Request) { if httpWriter == nil { panic("httpWriter cannot be nil") } if httpRequest == nil { panic("httpRequest cannot be nil") } c.dispatch(httpWriter, httpRequest) } // Dispatch the incoming Http Request to a matching WebService. func (c *Container) dispatch(httpWriter http.ResponseWriter, httpRequest *http.Request) { writer := httpWriter // CompressingResponseWriter should be closed after all operations are done defer func() { if compressWriter, ok := writer.(*CompressingResponseWriter); ok { compressWriter.Close() } }() // Instal panic recovery unless told otherwise if !c.doNotRecover { // catch all for 500 response defer func() { if r := recover(); r != nil { c.recoverHandleFunc(r, writer) return } }() } // Find best match Route ; err is non nil if no match was found var webService *WebService var route *Route var err error func() { c.webServicesLock.RLock() defer c.webServicesLock.RUnlock() webService, route, err = c.router.SelectRoute( c.webServices, httpRequest) }() // Detect if compression is needed // assume without compression, test for override contentEncodingEnabled := c.contentEncodingEnabled if route != nil && route.contentEncodingEnabled != nil { contentEncodingEnabled = *route.contentEncodingEnabled } if contentEncodingEnabled { doCompress, encoding := wantsCompressedResponse(httpRequest) if doCompress { var err error writer, err = NewCompressingResponseWriter(httpWriter, encoding) if err != nil { log.Print("unable to install compressor: ", err) httpWriter.WriteHeader(http.StatusInternalServerError) return } } } if err != nil { // a non-200 response has already been written // run container filters anyway ; they should not touch the response... chain := FilterChain{Filters: c.containerFilters, Target: func(req *Request, resp *Response) { switch err.(type) { case ServiceError: ser := err.(ServiceError) c.serviceErrorHandleFunc(ser, req, resp) } // TODO }} chain.ProcessFilter(NewRequest(httpRequest), NewResponse(writer)) return } pathProcessor, routerProcessesPath := c.router.(PathProcessor) if !routerProcessesPath { pathProcessor = defaultPathProcessor{} } pathParams := pathProcessor.ExtractParameters(route, webService, httpRequest.URL.Path) wrappedRequest, wrappedResponse := route.wrapRequestResponse(writer, httpRequest, pathParams) // pass through filters (if any) if len(c.containerFilters)+len(webService.filters)+len(route.Filters) > 0 { // compose filter chain allFilters := []FilterFunction{} allFilters = append(allFilters, c.containerFilters...) allFilters = append(allFilters, webService.filters...) allFilters = append(allFilters, route.Filters...) chain := FilterChain{Filters: allFilters, Target: func(req *Request, resp *Response) { // handle request by route after passing all filters route.Function(wrappedRequest, wrappedResponse) }} chain.ProcessFilter(wrappedRequest, wrappedResponse) } else { // no filters, handle request by route route.Function(wrappedRequest, wrappedResponse) } } // fixedPrefixPath returns the fixed part of the partspec ; it may include template vars {} func fixedPrefixPath(pathspec string) string { varBegin := strings.Index(pathspec, "{") if -1 == varBegin { return pathspec } return pathspec[:varBegin] } // ServeHTTP implements net/http.Handler therefore a Container can be a Handler in a http.Server func (c *Container) ServeHTTP(httpwriter http.ResponseWriter, httpRequest *http.Request) { c.ServeMux.ServeHTTP(httpwriter, httpRequest) } // Handle registers the handler for the given pattern. If a handler already exists for pattern, Handle panics. func (c *Container) Handle(pattern string, handler http.Handler) { c.ServeMux.Handle(pattern, handler) } // HandleWithFilter registers the handler for the given pattern. // Container's filter chain is applied for handler. // If a handler already exists for pattern, HandleWithFilter panics. func (c *Container) HandleWithFilter(pattern string, handler http.Handler) { f := func(httpResponse http.ResponseWriter, httpRequest *http.Request) { if len(c.containerFilters) == 0 { handler.ServeHTTP(httpResponse, httpRequest) return } chain := FilterChain{Filters: c.containerFilters, Target: func(req *Request, resp *Response) { handler.ServeHTTP(httpResponse, httpRequest) }} chain.ProcessFilter(NewRequest(httpRequest), NewResponse(httpResponse)) } c.Handle(pattern, http.HandlerFunc(f)) } // Filter appends a container FilterFunction. These are called before dispatching // a http.Request to a WebService from the container func (c *Container) Filter(filter FilterFunction) { c.containerFilters = append(c.containerFilters, filter) } // RegisteredWebServices returns the collections of added WebServices func (c *Container) RegisteredWebServices() []*WebService { c.webServicesLock.RLock() defer c.webServicesLock.RUnlock() result := make([]*WebService, len(c.webServices)) for ix := range c.webServices { result[ix] = c.webServices[ix] } return result } // computeAllowedMethods returns a list of HTTP methods that are valid for a Request func (c *Container) computeAllowedMethods(req *Request) []string { // Go through all RegisteredWebServices() and all its Routes to collect the options methods := []string{} requestPath := req.Request.URL.Path for _, ws := range c.RegisteredWebServices() { matches := ws.pathExpr.Matcher.FindStringSubmatch(requestPath) if matches != nil { finalMatch := matches[len(matches)-1] for _, rt := range ws.Routes() { matches := rt.pathExpr.Matcher.FindStringSubmatch(finalMatch) if matches != nil { lastMatch := matches[len(matches)-1] if lastMatch == "" || lastMatch == "/" { // do not include if value is neither empty nor β€˜/’. methods = append(methods, rt.Method) } } } } } // methods = append(methods, "OPTIONS") not sure about this return methods } // newBasicRequestResponse creates a pair of Request,Response from its http versions. // It is basic because no parameter or (produces) content-type information is given. func newBasicRequestResponse(httpWriter http.ResponseWriter, httpRequest *http.Request) (*Request, *Response) { resp := NewResponse(httpWriter) resp.requestAccept = httpRequest.Header.Get(HEADER_Accept) return NewRequest(httpRequest), resp }
8,831
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/web_service.go
package restful import ( "errors" "os" "reflect" "sync" "github.com/emicklei/go-restful/log" ) // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. // WebService holds a collection of Route values that bind a Http Method + URL Path to a function. type WebService struct { rootPath string pathExpr *pathExpression // cached compilation of rootPath as RegExp routes []Route produces []string consumes []string pathParameters []*Parameter filters []FilterFunction documentation string apiVersion string typeNameHandleFunc TypeNameHandleFunction dynamicRoutes bool // protects 'routes' if dynamic routes are enabled routesLock sync.RWMutex } func (w *WebService) SetDynamicRoutes(enable bool) { w.dynamicRoutes = enable } // TypeNameHandleFunction declares functions that can handle translating the name of a sample object // into the restful documentation for the service. type TypeNameHandleFunction func(sample interface{}) string // TypeNameHandler sets the function that will convert types to strings in the parameter // and model definitions. If not set, the web service will invoke // reflect.TypeOf(object).String(). func (w *WebService) TypeNameHandler(handler TypeNameHandleFunction) *WebService { w.typeNameHandleFunc = handler return w } // reflectTypeName is the default TypeNameHandleFunction and for a given object // returns the name that Go identifies it with (e.g. "string" or "v1.Object") via // the reflection API. func reflectTypeName(sample interface{}) string { return reflect.TypeOf(sample).String() } // compilePathExpression ensures that the path is compiled into a RegEx for those routers that need it. func (w *WebService) compilePathExpression() { compiled, err := newPathExpression(w.rootPath) if err != nil { log.Printf("invalid path:%s because:%v", w.rootPath, err) os.Exit(1) } w.pathExpr = compiled } // ApiVersion sets the API version for documentation purposes. func (w *WebService) ApiVersion(apiVersion string) *WebService { w.apiVersion = apiVersion return w } // Version returns the API version for documentation purposes. func (w *WebService) Version() string { return w.apiVersion } // Path specifies the root URL template path of the WebService. // All Routes will be relative to this path. func (w *WebService) Path(root string) *WebService { w.rootPath = root if len(w.rootPath) == 0 { w.rootPath = "/" } w.compilePathExpression() return w } // Param adds a PathParameter to document parameters used in the root path. func (w *WebService) Param(parameter *Parameter) *WebService { if w.pathParameters == nil { w.pathParameters = []*Parameter{} } w.pathParameters = append(w.pathParameters, parameter) return w } // PathParameter creates a new Parameter of kind Path for documentation purposes. // It is initialized as required with string as its DataType. func (w *WebService) PathParameter(name, description string) *Parameter { return PathParameter(name, description) } // PathParameter creates a new Parameter of kind Path for documentation purposes. // It is initialized as required with string as its DataType. func PathParameter(name, description string) *Parameter { p := &Parameter{&ParameterData{Name: name, Description: description, Required: true, DataType: "string"}} p.bePath() return p } // QueryParameter creates a new Parameter of kind Query for documentation purposes. // It is initialized as not required with string as its DataType. func (w *WebService) QueryParameter(name, description string) *Parameter { return QueryParameter(name, description) } // QueryParameter creates a new Parameter of kind Query for documentation purposes. // It is initialized as not required with string as its DataType. func QueryParameter(name, description string) *Parameter { p := &Parameter{&ParameterData{Name: name, Description: description, Required: false, DataType: "string", CollectionFormat: CollectionFormatCSV.String()}} p.beQuery() return p } // BodyParameter creates a new Parameter of kind Body for documentation purposes. // It is initialized as required without a DataType. func (w *WebService) BodyParameter(name, description string) *Parameter { return BodyParameter(name, description) } // BodyParameter creates a new Parameter of kind Body for documentation purposes. // It is initialized as required without a DataType. func BodyParameter(name, description string) *Parameter { p := &Parameter{&ParameterData{Name: name, Description: description, Required: true}} p.beBody() return p } // HeaderParameter creates a new Parameter of kind (Http) Header for documentation purposes. // It is initialized as not required with string as its DataType. func (w *WebService) HeaderParameter(name, description string) *Parameter { return HeaderParameter(name, description) } // HeaderParameter creates a new Parameter of kind (Http) Header for documentation purposes. // It is initialized as not required with string as its DataType. func HeaderParameter(name, description string) *Parameter { p := &Parameter{&ParameterData{Name: name, Description: description, Required: false, DataType: "string"}} p.beHeader() return p } // FormParameter creates a new Parameter of kind Form (using application/x-www-form-urlencoded) for documentation purposes. // It is initialized as required with string as its DataType. func (w *WebService) FormParameter(name, description string) *Parameter { return FormParameter(name, description) } // FormParameter creates a new Parameter of kind Form (using application/x-www-form-urlencoded) for documentation purposes. // It is initialized as required with string as its DataType. func FormParameter(name, description string) *Parameter { p := &Parameter{&ParameterData{Name: name, Description: description, Required: false, DataType: "string"}} p.beForm() return p } // Route creates a new Route using the RouteBuilder and add to the ordered list of Routes. func (w *WebService) Route(builder *RouteBuilder) *WebService { w.routesLock.Lock() defer w.routesLock.Unlock() builder.copyDefaults(w.produces, w.consumes) w.routes = append(w.routes, builder.Build()) return w } // RemoveRoute removes the specified route, looks for something that matches 'path' and 'method' func (w *WebService) RemoveRoute(path, method string) error { if !w.dynamicRoutes { return errors.New("dynamic routes are not enabled.") } w.routesLock.Lock() defer w.routesLock.Unlock() newRoutes := make([]Route, (len(w.routes) - 1)) current := 0 for ix := range w.routes { if w.routes[ix].Method == method && w.routes[ix].Path == path { continue } newRoutes[current] = w.routes[ix] current = current + 1 } w.routes = newRoutes return nil } // Method creates a new RouteBuilder and initialize its http method func (w *WebService) Method(httpMethod string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method(httpMethod) } // Produces specifies that this WebService can produce one or more MIME types. // Http requests must have one of these values set for the Accept header. func (w *WebService) Produces(contentTypes ...string) *WebService { w.produces = contentTypes return w } // Consumes specifies that this WebService can consume one or more MIME types. // Http requests must have one of these values set for the Content-Type header. func (w *WebService) Consumes(accepts ...string) *WebService { w.consumes = accepts return w } // Routes returns the Routes associated with this WebService func (w *WebService) Routes() []Route { if !w.dynamicRoutes { return w.routes } // Make a copy of the array to prevent concurrency problems w.routesLock.RLock() defer w.routesLock.RUnlock() result := make([]Route, len(w.routes)) for ix := range w.routes { result[ix] = w.routes[ix] } return result } // RootPath returns the RootPath associated with this WebService. Default "/" func (w *WebService) RootPath() string { return w.rootPath } // PathParameters return the path parameter names for (shared among its Routes) func (w *WebService) PathParameters() []*Parameter { return w.pathParameters } // Filter adds a filter function to the chain of filters applicable to all its Routes func (w *WebService) Filter(filter FilterFunction) *WebService { w.filters = append(w.filters, filter) return w } // Doc is used to set the documentation of this service. func (w *WebService) Doc(plainText string) *WebService { w.documentation = plainText return w } // Documentation returns it. func (w *WebService) Documentation() string { return w.documentation } /* Convenience methods */ // HEAD is a shortcut for .Method("HEAD").Path(subPath) func (w *WebService) HEAD(subPath string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("HEAD").Path(subPath) } // GET is a shortcut for .Method("GET").Path(subPath) func (w *WebService) GET(subPath string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("GET").Path(subPath) } // POST is a shortcut for .Method("POST").Path(subPath) func (w *WebService) POST(subPath string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("POST").Path(subPath) } // PUT is a shortcut for .Method("PUT").Path(subPath) func (w *WebService) PUT(subPath string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("PUT").Path(subPath) } // PATCH is a shortcut for .Method("PATCH").Path(subPath) func (w *WebService) PATCH(subPath string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("PATCH").Path(subPath) } // DELETE is a shortcut for .Method("DELETE").Path(subPath) func (w *WebService) DELETE(subPath string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("DELETE").Path(subPath) }
8,832
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/route_builder.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "fmt" "os" "reflect" "runtime" "strings" "sync/atomic" "github.com/emicklei/go-restful/log" ) // RouteBuilder is a helper to construct Routes. type RouteBuilder struct { rootPath string currentPath string produces []string consumes []string httpMethod string // required function RouteFunction // required filters []FilterFunction conditions []RouteSelectionConditionFunction typeNameHandleFunc TypeNameHandleFunction // required // documentation doc string notes string operation string readSample, writeSample interface{} parameters []*Parameter errorMap map[int]ResponseError defaultResponse *ResponseError metadata map[string]interface{} deprecated bool contentEncodingEnabled *bool } // Do evaluates each argument with the RouteBuilder itself. // This allows you to follow DRY principles without breaking the fluent programming style. // Example: // ws.Route(ws.DELETE("/{name}").To(t.deletePerson).Do(Returns200, Returns500)) // // func Returns500(b *RouteBuilder) { // b.Returns(500, "Internal Server Error", restful.ServiceError{}) // } func (b *RouteBuilder) Do(oneArgBlocks ...func(*RouteBuilder)) *RouteBuilder { for _, each := range oneArgBlocks { each(b) } return b } // To bind the route to a function. // If this route is matched with the incoming Http Request then call this function with the *Request,*Response pair. Required. func (b *RouteBuilder) To(function RouteFunction) *RouteBuilder { b.function = function return b } // Method specifies what HTTP method to match. Required. func (b *RouteBuilder) Method(method string) *RouteBuilder { b.httpMethod = method return b } // Produces specifies what MIME types can be produced ; the matched one will appear in the Content-Type Http header. func (b *RouteBuilder) Produces(mimeTypes ...string) *RouteBuilder { b.produces = mimeTypes return b } // Consumes specifies what MIME types can be consumes ; the Accept Http header must matched any of these func (b *RouteBuilder) Consumes(mimeTypes ...string) *RouteBuilder { b.consumes = mimeTypes return b } // Path specifies the relative (w.r.t WebService root path) URL path to match. Default is "/". func (b *RouteBuilder) Path(subPath string) *RouteBuilder { b.currentPath = subPath return b } // Doc tells what this route is all about. Optional. func (b *RouteBuilder) Doc(documentation string) *RouteBuilder { b.doc = documentation return b } // Notes is a verbose explanation of the operation behavior. Optional. func (b *RouteBuilder) Notes(notes string) *RouteBuilder { b.notes = notes return b } // Reads tells what resource type will be read from the request payload. Optional. // A parameter of type "body" is added ,required is set to true and the dataType is set to the qualified name of the sample's type. func (b *RouteBuilder) Reads(sample interface{}, optionalDescription ...string) *RouteBuilder { fn := b.typeNameHandleFunc if fn == nil { fn = reflectTypeName } typeAsName := fn(sample) description := "" if len(optionalDescription) > 0 { description = optionalDescription[0] } b.readSample = sample bodyParameter := &Parameter{&ParameterData{Name: "body", Description: description}} bodyParameter.beBody() bodyParameter.Required(true) bodyParameter.DataType(typeAsName) b.Param(bodyParameter) return b } // ParameterNamed returns a Parameter already known to the RouteBuilder. Returns nil if not. // Use this to modify or extend information for the Parameter (through its Data()). func (b RouteBuilder) ParameterNamed(name string) (p *Parameter) { for _, each := range b.parameters { if each.Data().Name == name { return each } } return p } // Writes tells what resource type will be written as the response payload. Optional. func (b *RouteBuilder) Writes(sample interface{}) *RouteBuilder { b.writeSample = sample return b } // Param allows you to document the parameters of the Route. It adds a new Parameter (does not check for duplicates). func (b *RouteBuilder) Param(parameter *Parameter) *RouteBuilder { if b.parameters == nil { b.parameters = []*Parameter{} } b.parameters = append(b.parameters, parameter) return b } // Operation allows you to document what the actual method/function call is of the Route. // Unless called, the operation name is derived from the RouteFunction set using To(..). func (b *RouteBuilder) Operation(name string) *RouteBuilder { b.operation = name return b } // ReturnsError is deprecated, use Returns instead. func (b *RouteBuilder) ReturnsError(code int, message string, model interface{}) *RouteBuilder { log.Print("ReturnsError is deprecated, use Returns instead.") return b.Returns(code, message, model) } // Returns allows you to document what responses (errors or regular) can be expected. // The model parameter is optional ; either pass a struct instance or use nil if not applicable. func (b *RouteBuilder) Returns(code int, message string, model interface{}) *RouteBuilder { err := ResponseError{ Code: code, Message: message, Model: model, IsDefault: false, // this field is deprecated, use default response instead. } // lazy init because there is no NewRouteBuilder (yet) if b.errorMap == nil { b.errorMap = map[int]ResponseError{} } b.errorMap[code] = err return b } // DefaultReturns is a special Returns call that sets the default of the response. func (b *RouteBuilder) DefaultReturns(message string, model interface{}) *RouteBuilder { b.defaultResponse = &ResponseError{ Message: message, Model: model, } return b } // Metadata adds or updates a key=value pair to the metadata map. func (b *RouteBuilder) Metadata(key string, value interface{}) *RouteBuilder { if b.metadata == nil { b.metadata = map[string]interface{}{} } b.metadata[key] = value return b } // Deprecate sets the value of deprecated to true. Deprecated routes have a special UI treatment to warn against use func (b *RouteBuilder) Deprecate() *RouteBuilder { b.deprecated = true return b } // ResponseError represents a response; not necessarily an error. type ResponseError struct { Code int Message string Model interface{} IsDefault bool } func (b *RouteBuilder) servicePath(path string) *RouteBuilder { b.rootPath = path return b } // Filter appends a FilterFunction to the end of filters for this Route to build. func (b *RouteBuilder) Filter(filter FilterFunction) *RouteBuilder { b.filters = append(b.filters, filter) return b } // If sets a condition function that controls matching the Route based on custom logic. // The condition function is provided the HTTP request and should return true if the route // should be considered. // // Efficiency note: the condition function is called before checking the method, produces, and // consumes criteria, so that the correct HTTP status code can be returned. // // Lifecycle note: no filter functions have been called prior to calling the condition function, // so the condition function should not depend on any context that might be set up by container // or route filters. func (b *RouteBuilder) If(condition RouteSelectionConditionFunction) *RouteBuilder { b.conditions = append(b.conditions, condition) return b } // ContentEncodingEnabled allows you to override the Containers value for auto-compressing this route response. func (b *RouteBuilder) ContentEncodingEnabled(enabled bool) *RouteBuilder { b.contentEncodingEnabled = &enabled return b } // If no specific Route path then set to rootPath // If no specific Produces then set to rootProduces // If no specific Consumes then set to rootConsumes func (b *RouteBuilder) copyDefaults(rootProduces, rootConsumes []string) { if len(b.produces) == 0 { b.produces = rootProduces } if len(b.consumes) == 0 { b.consumes = rootConsumes } } // typeNameHandler sets the function that will convert types to strings in the parameter // and model definitions. func (b *RouteBuilder) typeNameHandler(handler TypeNameHandleFunction) *RouteBuilder { b.typeNameHandleFunc = handler return b } // Build creates a new Route using the specification details collected by the RouteBuilder func (b *RouteBuilder) Build() Route { pathExpr, err := newPathExpression(b.currentPath) if err != nil { log.Printf("Invalid path:%s because:%v", b.currentPath, err) os.Exit(1) } if b.function == nil { log.Printf("No function specified for route:" + b.currentPath) os.Exit(1) } operationName := b.operation if len(operationName) == 0 && b.function != nil { // extract from definition operationName = nameOfFunction(b.function) } route := Route{ Method: b.httpMethod, Path: concatPath(b.rootPath, b.currentPath), Produces: b.produces, Consumes: b.consumes, Function: b.function, Filters: b.filters, If: b.conditions, relativePath: b.currentPath, pathExpr: pathExpr, Doc: b.doc, Notes: b.notes, Operation: operationName, ParameterDocs: b.parameters, ResponseErrors: b.errorMap, DefaultResponse: b.defaultResponse, ReadSample: b.readSample, WriteSample: b.writeSample, Metadata: b.metadata, Deprecated: b.deprecated, contentEncodingEnabled: b.contentEncodingEnabled, } route.postBuild() return route } func concatPath(path1, path2 string) string { return strings.TrimRight(path1, "/") + "/" + strings.TrimLeft(path2, "/") } var anonymousFuncCount int32 // nameOfFunction returns the short name of the function f for documentation. // It uses a runtime feature for debugging ; its value may change for later Go versions. func nameOfFunction(f interface{}) string { fun := runtime.FuncForPC(reflect.ValueOf(f).Pointer()) tokenized := strings.Split(fun.Name(), ".") last := tokenized[len(tokenized)-1] last = strings.TrimSuffix(last, ")Β·fm") // < Go 1.5 last = strings.TrimSuffix(last, ")-fm") // Go 1.5 last = strings.TrimSuffix(last, "Β·fm") // < Go 1.5 last = strings.TrimSuffix(last, "-fm") // Go 1.5 if last == "func1" { // this could mean conflicts in API docs val := atomic.AddInt32(&anonymousFuncCount, 1) last = "func" + fmt.Sprintf("%d", val) atomic.StoreInt32(&anonymousFuncCount, val) } return last }
8,833
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/filter.go
package restful // Copyright 2013 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. // FilterChain is a request scoped object to process one or more filters before calling the target RouteFunction. type FilterChain struct { Filters []FilterFunction // ordered list of FilterFunction Index int // index into filters that is currently in progress Target RouteFunction // function to call after passing all filters } // ProcessFilter passes the request,response pair through the next of Filters. // Each filter can decide to proceed to the next Filter or handle the Response itself. func (f *FilterChain) ProcessFilter(request *Request, response *Response) { if f.Index < len(f.Filters) { f.Index++ f.Filters[f.Index-1](request, response, f) } else { f.Target(request, response) } } // FilterFunction definitions must call ProcessFilter on the FilterChain to pass on the control and eventually call the RouteFunction type FilterFunction func(*Request, *Response, *FilterChain) // NoBrowserCacheFilter is a filter function to set HTTP headers that disable browser caching // See examples/restful-no-cache-filter.go for usage func NoBrowserCacheFilter(req *Request, resp *Response, chain *FilterChain) { resp.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") // HTTP 1.1. resp.Header().Set("Pragma", "no-cache") // HTTP 1.0. resp.Header().Set("Expires", "0") // Proxies. chain.ProcessFilter(req, resp) }
8,834
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/compressor_pools.go
package restful // Copyright 2015 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "bytes" "compress/gzip" "compress/zlib" "sync" ) // SyncPoolCompessors is a CompressorProvider that use the standard sync.Pool. type SyncPoolCompessors struct { GzipWriterPool *sync.Pool GzipReaderPool *sync.Pool ZlibWriterPool *sync.Pool } // NewSyncPoolCompessors returns a new ("empty") SyncPoolCompessors. func NewSyncPoolCompessors() *SyncPoolCompessors { return &SyncPoolCompessors{ GzipWriterPool: &sync.Pool{ New: func() interface{} { return newGzipWriter() }, }, GzipReaderPool: &sync.Pool{ New: func() interface{} { return newGzipReader() }, }, ZlibWriterPool: &sync.Pool{ New: func() interface{} { return newZlibWriter() }, }, } } func (s *SyncPoolCompessors) AcquireGzipWriter() *gzip.Writer { return s.GzipWriterPool.Get().(*gzip.Writer) } func (s *SyncPoolCompessors) ReleaseGzipWriter(w *gzip.Writer) { s.GzipWriterPool.Put(w) } func (s *SyncPoolCompessors) AcquireGzipReader() *gzip.Reader { return s.GzipReaderPool.Get().(*gzip.Reader) } func (s *SyncPoolCompessors) ReleaseGzipReader(r *gzip.Reader) { s.GzipReaderPool.Put(r) } func (s *SyncPoolCompessors) AcquireZlibWriter() *zlib.Writer { return s.ZlibWriterPool.Get().(*zlib.Writer) } func (s *SyncPoolCompessors) ReleaseZlibWriter(w *zlib.Writer) { s.ZlibWriterPool.Put(w) } func newGzipWriter() *gzip.Writer { // create with an empty bytes writer; it will be replaced before using the gzipWriter writer, err := gzip.NewWriterLevel(new(bytes.Buffer), gzip.BestSpeed) if err != nil { panic(err.Error()) } return writer } func newGzipReader() *gzip.Reader { // create with an empty reader (but with GZIP header); it will be replaced before using the gzipReader // we can safely use currentCompressProvider because it is set on package initialization. w := currentCompressorProvider.AcquireGzipWriter() defer currentCompressorProvider.ReleaseGzipWriter(w) b := new(bytes.Buffer) w.Reset(b) w.Flush() w.Close() reader, err := gzip.NewReader(bytes.NewReader(b.Bytes())) if err != nil { panic(err.Error()) } return reader } func newZlibWriter() *zlib.Writer { writer, err := zlib.NewWriterLevel(new(bytes.Buffer), gzip.BestSpeed) if err != nil { panic(err.Error()) } return writer }
8,835
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/compressors.go
package restful // Copyright 2015 Ernest Micklei. All rights reserved. // Use of this source code is governed by a license // that can be found in the LICENSE file. import ( "compress/gzip" "compress/zlib" ) // CompressorProvider describes a component that can provider compressors for the std methods. type CompressorProvider interface { // Returns a *gzip.Writer which needs to be released later. // Before using it, call Reset(). AcquireGzipWriter() *gzip.Writer // Releases an acquired *gzip.Writer. ReleaseGzipWriter(w *gzip.Writer) // Returns a *gzip.Reader which needs to be released later. AcquireGzipReader() *gzip.Reader // Releases an acquired *gzip.Reader. ReleaseGzipReader(w *gzip.Reader) // Returns a *zlib.Writer which needs to be released later. // Before using it, call Reset(). AcquireZlibWriter() *zlib.Writer // Releases an acquired *zlib.Writer. ReleaseZlibWriter(w *zlib.Writer) } // DefaultCompressorProvider is the actual provider of compressors (zlib or gzip). var currentCompressorProvider CompressorProvider func init() { currentCompressorProvider = NewSyncPoolCompessors() } // CurrentCompressorProvider returns the current CompressorProvider. // It is initialized using a SyncPoolCompessors. func CurrentCompressorProvider() CompressorProvider { return currentCompressorProvider } // SetCompressorProvider sets the actual provider of compressors (zlib or gzip). func SetCompressorProvider(p CompressorProvider) { if p == nil { panic("cannot set compressor provider to nil") } currentCompressorProvider = p }
8,836
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/.travis.yml
language: go go: - 1.x script: go test -v
8,837
0
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful
kubeflow_public_repos/fate-operator/vendor/github.com/emicklei/go-restful/log/log.go
package log import ( stdlog "log" "os" ) // StdLogger corresponds to a minimal subset of the interface satisfied by stdlib log.Logger type StdLogger interface { Print(v ...interface{}) Printf(format string, v ...interface{}) } var Logger StdLogger func init() { // default Logger SetLogger(stdlog.New(os.Stderr, "[restful] ", stdlog.LstdFlags|stdlog.Lshortfile)) } // SetLogger sets the logger for this package func SetLogger(customLogger StdLogger) { Logger = customLogger } // Print delegates to the Logger func Print(v ...interface{}) { Logger.Print(v...) } // Printf delegates to the Logger func Printf(format string, v ...interface{}) { Logger.Printf(format, v...) }
8,838
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/CODE_OF_CONDUCT.md
# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/
8,839
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/go.mod
module github.com/go-openapi/swag require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/kr/pretty v0.1.0 // indirect github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63 github.com/stretchr/testify v1.3.0 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect gopkg.in/yaml.v2 v2.2.2 ) replace github.com/golang/lint => golang.org/x/lint v0.0.0-20190409202823-959b441ac422 replace sourcegraph.com/sourcegraph/go-diff => github.com/sourcegraph/go-diff v0.5.1
8,840
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/convert_types.go
package swag import "time" // This file was taken from the aws go sdk // String returns a pointer to of the string value passed in. func String(v string) *string { return &v } // StringValue returns the value of the string pointer passed in or // "" if the pointer is nil. func StringValue(v *string) string { if v != nil { return *v } return "" } // StringSlice converts a slice of string values into a slice of // string pointers func StringSlice(src []string) []*string { dst := make([]*string, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // StringValueSlice converts a slice of string pointers into a slice of // string values func StringValueSlice(src []*string) []string { dst := make([]string, len(src)) for i := 0; i < len(src); i++ { if src[i] != nil { dst[i] = *(src[i]) } } return dst } // StringMap converts a string map of string values into a string // map of string pointers func StringMap(src map[string]string) map[string]*string { dst := make(map[string]*string) for k, val := range src { v := val dst[k] = &v } return dst } // StringValueMap converts a string map of string pointers into a string // map of string values func StringValueMap(src map[string]*string) map[string]string { dst := make(map[string]string) for k, val := range src { if val != nil { dst[k] = *val } } return dst } // Bool returns a pointer to of the bool value passed in. func Bool(v bool) *bool { return &v } // BoolValue returns the value of the bool pointer passed in or // false if the pointer is nil. func BoolValue(v *bool) bool { if v != nil { return *v } return false } // BoolSlice converts a slice of bool values into a slice of // bool pointers func BoolSlice(src []bool) []*bool { dst := make([]*bool, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // BoolValueSlice converts a slice of bool pointers into a slice of // bool values func BoolValueSlice(src []*bool) []bool { dst := make([]bool, len(src)) for i := 0; i < len(src); i++ { if src[i] != nil { dst[i] = *(src[i]) } } return dst } // BoolMap converts a string map of bool values into a string // map of bool pointers func BoolMap(src map[string]bool) map[string]*bool { dst := make(map[string]*bool) for k, val := range src { v := val dst[k] = &v } return dst } // BoolValueMap converts a string map of bool pointers into a string // map of bool values func BoolValueMap(src map[string]*bool) map[string]bool { dst := make(map[string]bool) for k, val := range src { if val != nil { dst[k] = *val } } return dst } // Int returns a pointer to of the int value passed in. func Int(v int) *int { return &v } // IntValue returns the value of the int pointer passed in or // 0 if the pointer is nil. func IntValue(v *int) int { if v != nil { return *v } return 0 } // IntSlice converts a slice of int values into a slice of // int pointers func IntSlice(src []int) []*int { dst := make([]*int, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // IntValueSlice converts a slice of int pointers into a slice of // int values func IntValueSlice(src []*int) []int { dst := make([]int, len(src)) for i := 0; i < len(src); i++ { if src[i] != nil { dst[i] = *(src[i]) } } return dst } // IntMap converts a string map of int values into a string // map of int pointers func IntMap(src map[string]int) map[string]*int { dst := make(map[string]*int) for k, val := range src { v := val dst[k] = &v } return dst } // IntValueMap converts a string map of int pointers into a string // map of int values func IntValueMap(src map[string]*int) map[string]int { dst := make(map[string]int) for k, val := range src { if val != nil { dst[k] = *val } } return dst } // Int32 returns a pointer to of the int64 value passed in. func Int32(v int32) *int32 { return &v } // Int32Value returns the value of the int64 pointer passed in or // 0 if the pointer is nil. func Int32Value(v *int32) int32 { if v != nil { return *v } return 0 } // Int32Slice converts a slice of int64 values into a slice of // int32 pointers func Int32Slice(src []int32) []*int32 { dst := make([]*int32, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // Int32ValueSlice converts a slice of int32 pointers into a slice of // int32 values func Int32ValueSlice(src []*int32) []int32 { dst := make([]int32, len(src)) for i := 0; i < len(src); i++ { if src[i] != nil { dst[i] = *(src[i]) } } return dst } // Int32Map converts a string map of int32 values into a string // map of int32 pointers func Int32Map(src map[string]int32) map[string]*int32 { dst := make(map[string]*int32) for k, val := range src { v := val dst[k] = &v } return dst } // Int32ValueMap converts a string map of int32 pointers into a string // map of int32 values func Int32ValueMap(src map[string]*int32) map[string]int32 { dst := make(map[string]int32) for k, val := range src { if val != nil { dst[k] = *val } } return dst } // Int64 returns a pointer to of the int64 value passed in. func Int64(v int64) *int64 { return &v } // Int64Value returns the value of the int64 pointer passed in or // 0 if the pointer is nil. func Int64Value(v *int64) int64 { if v != nil { return *v } return 0 } // Int64Slice converts a slice of int64 values into a slice of // int64 pointers func Int64Slice(src []int64) []*int64 { dst := make([]*int64, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // Int64ValueSlice converts a slice of int64 pointers into a slice of // int64 values func Int64ValueSlice(src []*int64) []int64 { dst := make([]int64, len(src)) for i := 0; i < len(src); i++ { if src[i] != nil { dst[i] = *(src[i]) } } return dst } // Int64Map converts a string map of int64 values into a string // map of int64 pointers func Int64Map(src map[string]int64) map[string]*int64 { dst := make(map[string]*int64) for k, val := range src { v := val dst[k] = &v } return dst } // Int64ValueMap converts a string map of int64 pointers into a string // map of int64 values func Int64ValueMap(src map[string]*int64) map[string]int64 { dst := make(map[string]int64) for k, val := range src { if val != nil { dst[k] = *val } } return dst } // Uint returns a pouinter to of the uint value passed in. func Uint(v uint) *uint { return &v } // UintValue returns the value of the uint pouinter passed in or // 0 if the pouinter is nil. func UintValue(v *uint) uint { if v != nil { return *v } return 0 } // UintSlice converts a slice of uint values uinto a slice of // uint pouinters func UintSlice(src []uint) []*uint { dst := make([]*uint, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // UintValueSlice converts a slice of uint pouinters uinto a slice of // uint values func UintValueSlice(src []*uint) []uint { dst := make([]uint, len(src)) for i := 0; i < len(src); i++ { if src[i] != nil { dst[i] = *(src[i]) } } return dst } // UintMap converts a string map of uint values uinto a string // map of uint pouinters func UintMap(src map[string]uint) map[string]*uint { dst := make(map[string]*uint) for k, val := range src { v := val dst[k] = &v } return dst } // UintValueMap converts a string map of uint pouinters uinto a string // map of uint values func UintValueMap(src map[string]*uint) map[string]uint { dst := make(map[string]uint) for k, val := range src { if val != nil { dst[k] = *val } } return dst } // Uint32 returns a pouinter to of the uint64 value passed in. func Uint32(v uint32) *uint32 { return &v } // Uint32Value returns the value of the uint64 pouinter passed in or // 0 if the pouinter is nil. func Uint32Value(v *uint32) uint32 { if v != nil { return *v } return 0 } // Uint32Slice converts a slice of uint64 values uinto a slice of // uint32 pouinters func Uint32Slice(src []uint32) []*uint32 { dst := make([]*uint32, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // Uint32ValueSlice converts a slice of uint32 pouinters uinto a slice of // uint32 values func Uint32ValueSlice(src []*uint32) []uint32 { dst := make([]uint32, len(src)) for i := 0; i < len(src); i++ { if src[i] != nil { dst[i] = *(src[i]) } } return dst } // Uint32Map converts a string map of uint32 values uinto a string // map of uint32 pouinters func Uint32Map(src map[string]uint32) map[string]*uint32 { dst := make(map[string]*uint32) for k, val := range src { v := val dst[k] = &v } return dst } // Uint32ValueMap converts a string map of uint32 pouinters uinto a string // map of uint32 values func Uint32ValueMap(src map[string]*uint32) map[string]uint32 { dst := make(map[string]uint32) for k, val := range src { if val != nil { dst[k] = *val } } return dst } // Uint64 returns a pouinter to of the uint64 value passed in. func Uint64(v uint64) *uint64 { return &v } // Uint64Value returns the value of the uint64 pouinter passed in or // 0 if the pouinter is nil. func Uint64Value(v *uint64) uint64 { if v != nil { return *v } return 0 } // Uint64Slice converts a slice of uint64 values uinto a slice of // uint64 pouinters func Uint64Slice(src []uint64) []*uint64 { dst := make([]*uint64, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // Uint64ValueSlice converts a slice of uint64 pouinters uinto a slice of // uint64 values func Uint64ValueSlice(src []*uint64) []uint64 { dst := make([]uint64, len(src)) for i := 0; i < len(src); i++ { if src[i] != nil { dst[i] = *(src[i]) } } return dst } // Uint64Map converts a string map of uint64 values uinto a string // map of uint64 pouinters func Uint64Map(src map[string]uint64) map[string]*uint64 { dst := make(map[string]*uint64) for k, val := range src { v := val dst[k] = &v } return dst } // Uint64ValueMap converts a string map of uint64 pouinters uinto a string // map of uint64 values func Uint64ValueMap(src map[string]*uint64) map[string]uint64 { dst := make(map[string]uint64) for k, val := range src { if val != nil { dst[k] = *val } } return dst } // Float64 returns a pointer to of the float64 value passed in. func Float64(v float64) *float64 { return &v } // Float64Value returns the value of the float64 pointer passed in or // 0 if the pointer is nil. func Float64Value(v *float64) float64 { if v != nil { return *v } return 0 } // Float64Slice converts a slice of float64 values into a slice of // float64 pointers func Float64Slice(src []float64) []*float64 { dst := make([]*float64, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // Float64ValueSlice converts a slice of float64 pointers into a slice of // float64 values func Float64ValueSlice(src []*float64) []float64 { dst := make([]float64, len(src)) for i := 0; i < len(src); i++ { if src[i] != nil { dst[i] = *(src[i]) } } return dst } // Float64Map converts a string map of float64 values into a string // map of float64 pointers func Float64Map(src map[string]float64) map[string]*float64 { dst := make(map[string]*float64) for k, val := range src { v := val dst[k] = &v } return dst } // Float64ValueMap converts a string map of float64 pointers into a string // map of float64 values func Float64ValueMap(src map[string]*float64) map[string]float64 { dst := make(map[string]float64) for k, val := range src { if val != nil { dst[k] = *val } } return dst } // Time returns a pointer to of the time.Time value passed in. func Time(v time.Time) *time.Time { return &v } // TimeValue returns the value of the time.Time pointer passed in or // time.Time{} if the pointer is nil. func TimeValue(v *time.Time) time.Time { if v != nil { return *v } return time.Time{} } // TimeSlice converts a slice of time.Time values into a slice of // time.Time pointers func TimeSlice(src []time.Time) []*time.Time { dst := make([]*time.Time, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // TimeValueSlice converts a slice of time.Time pointers into a slice of // time.Time values func TimeValueSlice(src []*time.Time) []time.Time { dst := make([]time.Time, len(src)) for i := 0; i < len(src); i++ { if src[i] != nil { dst[i] = *(src[i]) } } return dst } // TimeMap converts a string map of time.Time values into a string // map of time.Time pointers func TimeMap(src map[string]time.Time) map[string]*time.Time { dst := make(map[string]*time.Time) for k, val := range src { v := val dst[k] = &v } return dst } // TimeValueMap converts a string map of time.Time pointers into a string // map of time.Time values func TimeValueMap(src map[string]*time.Time) map[string]time.Time { dst := make(map[string]time.Time) for k, val := range src { if val != nil { dst[k] = *val } } return dst }
8,841
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/post_go18.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // +build go1.8 package swag import "net/url" func pathUnescape(path string) (string, error) { return url.PathUnescape(path) }
8,842
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/convert.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package swag import ( "math" "strconv" "strings" ) // same as ECMA Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER const ( maxJSONFloat = float64(1<<53 - 1) // 9007199254740991.0 2^53 - 1 minJSONFloat = -float64(1<<53 - 1) //-9007199254740991.0 -2^53 - 1 epsilon float64 = 1e-9 ) // IsFloat64AJSONInteger allow for integers [-2^53, 2^53-1] inclusive func IsFloat64AJSONInteger(f float64) bool { if math.IsNaN(f) || math.IsInf(f, 0) || f < minJSONFloat || f > maxJSONFloat { return false } fa := math.Abs(f) g := float64(uint64(f)) ga := math.Abs(g) diff := math.Abs(f - g) // more info: https://floating-point-gui.de/errors/comparison/#look-out-for-edge-cases switch { case f == g: // best case return true case f == float64(int64(f)) || f == float64(uint64(f)): // optimistic case return true case f == 0 || g == 0 || diff < math.SmallestNonzeroFloat64: // very close to 0 values return diff < (epsilon * math.SmallestNonzeroFloat64) } // check the relative error return diff/math.Min(fa+ga, math.MaxFloat64) < epsilon } var evaluatesAsTrue map[string]struct{} func init() { evaluatesAsTrue = map[string]struct{}{ "true": {}, "1": {}, "yes": {}, "ok": {}, "y": {}, "on": {}, "selected": {}, "checked": {}, "t": {}, "enabled": {}, } } // ConvertBool turn a string into a boolean func ConvertBool(str string) (bool, error) { _, ok := evaluatesAsTrue[strings.ToLower(str)] return ok, nil } // ConvertFloat32 turn a string into a float32 func ConvertFloat32(str string) (float32, error) { f, err := strconv.ParseFloat(str, 32) if err != nil { return 0, err } return float32(f), nil } // ConvertFloat64 turn a string into a float64 func ConvertFloat64(str string) (float64, error) { return strconv.ParseFloat(str, 64) } // ConvertInt8 turn a string into int8 boolean func ConvertInt8(str string) (int8, error) { i, err := strconv.ParseInt(str, 10, 8) if err != nil { return 0, err } return int8(i), nil } // ConvertInt16 turn a string into a int16 func ConvertInt16(str string) (int16, error) { i, err := strconv.ParseInt(str, 10, 16) if err != nil { return 0, err } return int16(i), nil } // ConvertInt32 turn a string into a int32 func ConvertInt32(str string) (int32, error) { i, err := strconv.ParseInt(str, 10, 32) if err != nil { return 0, err } return int32(i), nil } // ConvertInt64 turn a string into a int64 func ConvertInt64(str string) (int64, error) { return strconv.ParseInt(str, 10, 64) } // ConvertUint8 turn a string into a uint8 func ConvertUint8(str string) (uint8, error) { i, err := strconv.ParseUint(str, 10, 8) if err != nil { return 0, err } return uint8(i), nil } // ConvertUint16 turn a string into a uint16 func ConvertUint16(str string) (uint16, error) { i, err := strconv.ParseUint(str, 10, 16) if err != nil { return 0, err } return uint16(i), nil } // ConvertUint32 turn a string into a uint32 func ConvertUint32(str string) (uint32, error) { i, err := strconv.ParseUint(str, 10, 32) if err != nil { return 0, err } return uint32(i), nil } // ConvertUint64 turn a string into a uint64 func ConvertUint64(str string) (uint64, error) { return strconv.ParseUint(str, 10, 64) } // FormatBool turns a boolean into a string func FormatBool(value bool) string { return strconv.FormatBool(value) } // FormatFloat32 turns a float32 into a string func FormatFloat32(value float32) string { return strconv.FormatFloat(float64(value), 'f', -1, 32) } // FormatFloat64 turns a float64 into a string func FormatFloat64(value float64) string { return strconv.FormatFloat(value, 'f', -1, 64) } // FormatInt8 turns an int8 into a string func FormatInt8(value int8) string { return strconv.FormatInt(int64(value), 10) } // FormatInt16 turns an int16 into a string func FormatInt16(value int16) string { return strconv.FormatInt(int64(value), 10) } // FormatInt32 turns an int32 into a string func FormatInt32(value int32) string { return strconv.Itoa(int(value)) } // FormatInt64 turns an int64 into a string func FormatInt64(value int64) string { return strconv.FormatInt(value, 10) } // FormatUint8 turns an uint8 into a string func FormatUint8(value uint8) string { return strconv.FormatUint(uint64(value), 10) } // FormatUint16 turns an uint16 into a string func FormatUint16(value uint16) string { return strconv.FormatUint(uint64(value), 10) } // FormatUint32 turns an uint32 into a string func FormatUint32(value uint32) string { return strconv.FormatUint(uint64(value), 10) } // FormatUint64 turns an uint64 into a string func FormatUint64(value uint64) string { return strconv.FormatUint(value, 10) }
8,843
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/json.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package swag import ( "bytes" "encoding/json" "log" "reflect" "strings" "sync" "github.com/mailru/easyjson/jlexer" "github.com/mailru/easyjson/jwriter" ) // nullJSON represents a JSON object with null type var nullJSON = []byte("null") // DefaultJSONNameProvider the default cache for types var DefaultJSONNameProvider = NewNameProvider() const comma = byte(',') var closers map[byte]byte func init() { closers = map[byte]byte{ '{': '}', '[': ']', } } type ejMarshaler interface { MarshalEasyJSON(w *jwriter.Writer) } type ejUnmarshaler interface { UnmarshalEasyJSON(w *jlexer.Lexer) } // WriteJSON writes json data, prefers finding an appropriate interface to short-circuit the marshaller // so it takes the fastest option available. func WriteJSON(data interface{}) ([]byte, error) { if d, ok := data.(ejMarshaler); ok { jw := new(jwriter.Writer) d.MarshalEasyJSON(jw) return jw.BuildBytes() } if d, ok := data.(json.Marshaler); ok { return d.MarshalJSON() } return json.Marshal(data) } // ReadJSON reads json data, prefers finding an appropriate interface to short-circuit the unmarshaller // so it takes the fastes option available func ReadJSON(data []byte, value interface{}) error { trimmedData := bytes.Trim(data, "\x00") if d, ok := value.(ejUnmarshaler); ok { jl := &jlexer.Lexer{Data: trimmedData} d.UnmarshalEasyJSON(jl) return jl.Error() } if d, ok := value.(json.Unmarshaler); ok { return d.UnmarshalJSON(trimmedData) } return json.Unmarshal(trimmedData, value) } // DynamicJSONToStruct converts an untyped json structure into a struct func DynamicJSONToStruct(data interface{}, target interface{}) error { // TODO: convert straight to a json typed map (mergo + iterate?) b, err := WriteJSON(data) if err != nil { return err } return ReadJSON(b, target) } // ConcatJSON concatenates multiple json objects efficiently func ConcatJSON(blobs ...[]byte) []byte { if len(blobs) == 0 { return nil } last := len(blobs) - 1 for blobs[last] == nil || bytes.Equal(blobs[last], nullJSON) { // strips trailing null objects last-- if last < 0 { // there was nothing but "null"s or nil... return nil } } if last == 0 { return blobs[0] } var opening, closing byte var idx, a int buf := bytes.NewBuffer(nil) for i, b := range blobs[:last+1] { if b == nil || bytes.Equal(b, nullJSON) { // a null object is in the list: skip it continue } if len(b) > 0 && opening == 0 { // is this an array or an object? opening, closing = b[0], closers[b[0]] } if opening != '{' && opening != '[' { continue // don't know how to concatenate non container objects } if len(b) < 3 { // yep empty but also the last one, so closing this thing if i == last && a > 0 { if err := buf.WriteByte(closing); err != nil { log.Println(err) } } continue } idx = 0 if a > 0 { // we need to join with a comma for everything beyond the first non-empty item if err := buf.WriteByte(comma); err != nil { log.Println(err) } idx = 1 // this is not the first or the last so we want to drop the leading bracket } if i != last { // not the last one, strip brackets if _, err := buf.Write(b[idx : len(b)-1]); err != nil { log.Println(err) } } else { // last one, strip only the leading bracket if _, err := buf.Write(b[idx:]); err != nil { log.Println(err) } } a++ } // somehow it ended up being empty, so provide a default value if buf.Len() == 0 { if err := buf.WriteByte(opening); err != nil { log.Println(err) } if err := buf.WriteByte(closing); err != nil { log.Println(err) } } return buf.Bytes() } // ToDynamicJSON turns an object into a properly JSON typed structure func ToDynamicJSON(data interface{}) interface{} { // TODO: convert straight to a json typed map (mergo + iterate?) b, err := json.Marshal(data) if err != nil { log.Println(err) } var res interface{} if err := json.Unmarshal(b, &res); err != nil { log.Println(err) } return res } // FromDynamicJSON turns an object into a properly JSON typed structure func FromDynamicJSON(data, target interface{}) error { b, err := json.Marshal(data) if err != nil { log.Println(err) } return json.Unmarshal(b, target) } // NameProvider represents an object capabale of translating from go property names // to json property names // This type is thread-safe. type NameProvider struct { lock *sync.Mutex index map[reflect.Type]nameIndex } type nameIndex struct { jsonNames map[string]string goNames map[string]string } // NewNameProvider creates a new name provider func NewNameProvider() *NameProvider { return &NameProvider{ lock: &sync.Mutex{}, index: make(map[reflect.Type]nameIndex), } } func buildnameIndex(tpe reflect.Type, idx, reverseIdx map[string]string) { for i := 0; i < tpe.NumField(); i++ { targetDes := tpe.Field(i) if targetDes.PkgPath != "" { // unexported continue } if targetDes.Anonymous { // walk embedded structures tree down first buildnameIndex(targetDes.Type, idx, reverseIdx) continue } if tag := targetDes.Tag.Get("json"); tag != "" { parts := strings.Split(tag, ",") if len(parts) == 0 { continue } nm := parts[0] if nm == "-" { continue } if nm == "" { // empty string means we want to use the Go name nm = targetDes.Name } idx[nm] = targetDes.Name reverseIdx[targetDes.Name] = nm } } } func newNameIndex(tpe reflect.Type) nameIndex { var idx = make(map[string]string, tpe.NumField()) var reverseIdx = make(map[string]string, tpe.NumField()) buildnameIndex(tpe, idx, reverseIdx) return nameIndex{jsonNames: idx, goNames: reverseIdx} } // GetJSONNames gets all the json property names for a type func (n *NameProvider) GetJSONNames(subject interface{}) []string { n.lock.Lock() defer n.lock.Unlock() tpe := reflect.Indirect(reflect.ValueOf(subject)).Type() names, ok := n.index[tpe] if !ok { names = n.makeNameIndex(tpe) } res := make([]string, 0, len(names.jsonNames)) for k := range names.jsonNames { res = append(res, k) } return res } // GetJSONName gets the json name for a go property name func (n *NameProvider) GetJSONName(subject interface{}, name string) (string, bool) { tpe := reflect.Indirect(reflect.ValueOf(subject)).Type() return n.GetJSONNameForType(tpe, name) } // GetJSONNameForType gets the json name for a go property name on a given type func (n *NameProvider) GetJSONNameForType(tpe reflect.Type, name string) (string, bool) { n.lock.Lock() defer n.lock.Unlock() names, ok := n.index[tpe] if !ok { names = n.makeNameIndex(tpe) } nme, ok := names.goNames[name] return nme, ok } func (n *NameProvider) makeNameIndex(tpe reflect.Type) nameIndex { names := newNameIndex(tpe) n.index[tpe] = names return names } // GetGoName gets the go name for a json property name func (n *NameProvider) GetGoName(subject interface{}, name string) (string, bool) { tpe := reflect.Indirect(reflect.ValueOf(subject)).Type() return n.GetGoNameForType(tpe, name) } // GetGoNameForType gets the go name for a given type for a json property name func (n *NameProvider) GetGoNameForType(tpe reflect.Type, name string) (string, bool) { n.lock.Lock() defer n.lock.Unlock() names, ok := n.index[tpe] if !ok { names = n.makeNameIndex(tpe) } nme, ok := names.jsonNames[name] return nme, ok }
8,844
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/README.md
# Swag [![Build Status](https://travis-ci.org/go-openapi/swag.svg?branch=master)](https://travis-ci.org/go-openapi/swag) [![codecov](https://codecov.io/gh/go-openapi/swag/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/swag) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) [![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/swag/master/LICENSE) [![GoDoc](https://godoc.org/github.com/go-openapi/swag?status.svg)](http://godoc.org/github.com/go-openapi/swag) [![GolangCI](https://golangci.com/badges/github.com/go-openapi/swag.svg)](https://golangci.com) [![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/swag)](https://goreportcard.com/report/github.com/go-openapi/swag) Contains a bunch of helper functions for go-openapi and go-swagger projects. You may also use it standalone for your projects. * convert between value and pointers for builtin types * convert from string to builtin types (wraps strconv) * fast json concatenation * search in path * load from file or http * name mangling This repo has only few dependencies outside of the standard library: * YAML utilities depend on gopkg.in/yaml.v2
8,845
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/pre_go18.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // +build !go1.8 package swag import "net/url" func pathUnescape(path string) (string, error) { return url.QueryUnescape(path) }
8,846
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/yaml.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package swag import ( "encoding/json" "fmt" "path/filepath" "strconv" "github.com/mailru/easyjson/jlexer" "github.com/mailru/easyjson/jwriter" yaml "gopkg.in/yaml.v2" ) // YAMLMatcher matches yaml func YAMLMatcher(path string) bool { ext := filepath.Ext(path) return ext == ".yaml" || ext == ".yml" } // YAMLToJSON converts YAML unmarshaled data into json compatible data func YAMLToJSON(data interface{}) (json.RawMessage, error) { jm, err := transformData(data) if err != nil { return nil, err } b, err := WriteJSON(jm) return json.RawMessage(b), err } // BytesToYAMLDoc converts a byte slice into a YAML document func BytesToYAMLDoc(data []byte) (interface{}, error) { var canary map[interface{}]interface{} // validate this is an object and not a different type if err := yaml.Unmarshal(data, &canary); err != nil { return nil, err } var document yaml.MapSlice // preserve order that is present in the document if err := yaml.Unmarshal(data, &document); err != nil { return nil, err } return document, nil } // JSONMapSlice represent a JSON object, with the order of keys maintained type JSONMapSlice []JSONMapItem // MarshalJSON renders a JSONMapSlice as JSON func (s JSONMapSlice) MarshalJSON() ([]byte, error) { w := &jwriter.Writer{Flags: jwriter.NilMapAsEmpty | jwriter.NilSliceAsEmpty} s.MarshalEasyJSON(w) return w.BuildBytes() } // MarshalEasyJSON renders a JSONMapSlice as JSON, using easyJSON func (s JSONMapSlice) MarshalEasyJSON(w *jwriter.Writer) { w.RawByte('{') ln := len(s) last := ln - 1 for i := 0; i < ln; i++ { s[i].MarshalEasyJSON(w) if i != last { // last item w.RawByte(',') } } w.RawByte('}') } // UnmarshalJSON makes a JSONMapSlice from JSON func (s *JSONMapSlice) UnmarshalJSON(data []byte) error { l := jlexer.Lexer{Data: data} s.UnmarshalEasyJSON(&l) return l.Error() } // UnmarshalEasyJSON makes a JSONMapSlice from JSON, using easyJSON func (s *JSONMapSlice) UnmarshalEasyJSON(in *jlexer.Lexer) { if in.IsNull() { in.Skip() return } var result JSONMapSlice in.Delim('{') for !in.IsDelim('}') { var mi JSONMapItem mi.UnmarshalEasyJSON(in) result = append(result, mi) } *s = result } // JSONMapItem represents the value of a key in a JSON object held by JSONMapSlice type JSONMapItem struct { Key string Value interface{} } // MarshalJSON renders a JSONMapItem as JSON func (s JSONMapItem) MarshalJSON() ([]byte, error) { w := &jwriter.Writer{Flags: jwriter.NilMapAsEmpty | jwriter.NilSliceAsEmpty} s.MarshalEasyJSON(w) return w.BuildBytes() } // MarshalEasyJSON renders a JSONMapItem as JSON, using easyJSON func (s JSONMapItem) MarshalEasyJSON(w *jwriter.Writer) { w.String(s.Key) w.RawByte(':') w.Raw(WriteJSON(s.Value)) } // UnmarshalJSON makes a JSONMapItem from JSON func (s *JSONMapItem) UnmarshalJSON(data []byte) error { l := jlexer.Lexer{Data: data} s.UnmarshalEasyJSON(&l) return l.Error() } // UnmarshalEasyJSON makes a JSONMapItem from JSON, using easyJSON func (s *JSONMapItem) UnmarshalEasyJSON(in *jlexer.Lexer) { key := in.UnsafeString() in.WantColon() value := in.Interface() in.WantComma() s.Key = key s.Value = value } func transformData(input interface{}) (out interface{}, err error) { format := func(t interface{}) (string, error) { switch k := t.(type) { case string: return k, nil case uint: return strconv.FormatUint(uint64(k), 10), nil case uint8: return strconv.FormatUint(uint64(k), 10), nil case uint16: return strconv.FormatUint(uint64(k), 10), nil case uint32: return strconv.FormatUint(uint64(k), 10), nil case uint64: return strconv.FormatUint(k, 10), nil case int: return strconv.Itoa(k), nil case int8: return strconv.FormatInt(int64(k), 10), nil case int16: return strconv.FormatInt(int64(k), 10), nil case int32: return strconv.FormatInt(int64(k), 10), nil case int64: return strconv.FormatInt(k, 10), nil default: return "", fmt.Errorf("unexpected map key type, got: %T", k) } } switch in := input.(type) { case yaml.MapSlice: o := make(JSONMapSlice, len(in)) for i, mi := range in { var nmi JSONMapItem if nmi.Key, err = format(mi.Key); err != nil { return nil, err } v, ert := transformData(mi.Value) if ert != nil { return nil, ert } nmi.Value = v o[i] = nmi } return o, nil case map[interface{}]interface{}: o := make(JSONMapSlice, 0, len(in)) for ke, va := range in { var nmi JSONMapItem if nmi.Key, err = format(ke); err != nil { return nil, err } v, ert := transformData(va) if ert != nil { return nil, ert } nmi.Value = v o = append(o, nmi) } return o, nil case []interface{}: len1 := len(in) o := make([]interface{}, len1) for i := 0; i < len1; i++ { o[i], err = transformData(in[i]) if err != nil { return nil, err } } return o, nil } return input, nil } // YAMLDoc loads a yaml document from either http or a file and converts it to json func YAMLDoc(path string) (json.RawMessage, error) { yamlDoc, err := YAMLData(path) if err != nil { return nil, err } data, err := YAMLToJSON(yamlDoc) if err != nil { return nil, err } return data, nil } // YAMLData loads a yaml document from either http or a file func YAMLData(path string) (interface{}, error) { data, err := LoadFromFileOrHTTP(path) if err != nil { return nil, err } return BytesToYAMLDoc(data) }
8,847
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/net.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package swag import ( "net" "strconv" ) // SplitHostPort splits a network address into a host and a port. // The port is -1 when there is no port to be found func SplitHostPort(addr string) (host string, port int, err error) { h, p, err := net.SplitHostPort(addr) if err != nil { return "", -1, err } if p == "" { return "", -1, &net.AddrError{Err: "missing port in address", Addr: addr} } pi, err := strconv.Atoi(p) if err != nil { return "", -1, err } return h, pi, nil }
8,848
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/split.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package swag import ( "unicode" ) var nameReplaceTable = map[rune]string{ '@': "At ", '&': "And ", '|': "Pipe ", '$': "Dollar ", '!': "Bang ", '-': "", '_': "", } type ( splitter struct { postSplitInitialismCheck bool initialisms []string } splitterOption func(*splitter) *splitter ) // split calls the splitter; splitter provides more control and post options func split(str string) []string { lexems := newSplitter().split(str) result := make([]string, 0, len(lexems)) for _, lexem := range lexems { result = append(result, lexem.GetOriginal()) } return result } func (s *splitter) split(str string) []nameLexem { return s.toNameLexems(str) } func newSplitter(options ...splitterOption) *splitter { splitter := &splitter{ postSplitInitialismCheck: false, initialisms: initialisms, } for _, option := range options { splitter = option(splitter) } return splitter } // withPostSplitInitialismCheck allows to catch initialisms after main split process func withPostSplitInitialismCheck(s *splitter) *splitter { s.postSplitInitialismCheck = true return s } type ( initialismMatch struct { start, end int body []rune complete bool } initialismMatches []*initialismMatch ) func (s *splitter) toNameLexems(name string) []nameLexem { nameRunes := []rune(name) matches := s.gatherInitialismMatches(nameRunes) return s.mapMatchesToNameLexems(nameRunes, matches) } func (s *splitter) gatherInitialismMatches(nameRunes []rune) initialismMatches { matches := make(initialismMatches, 0) for currentRunePosition, currentRune := range nameRunes { newMatches := make(initialismMatches, 0, len(matches)) // check current initialism matches for _, match := range matches { if keepCompleteMatch := match.complete; keepCompleteMatch { newMatches = append(newMatches, match) continue } // drop failed match currentMatchRune := match.body[currentRunePosition-match.start] if !s.initialismRuneEqual(currentMatchRune, currentRune) { continue } // try to complete ongoing match if currentRunePosition-match.start == len(match.body)-1 { // we are close; the next step is to check the symbol ahead // if it is a small letter, then it is not the end of match // but beginning of the next word if currentRunePosition < len(nameRunes)-1 { nextRune := nameRunes[currentRunePosition+1] if newWord := unicode.IsLower(nextRune); newWord { // oh ok, it was the start of a new word continue } } match.complete = true match.end = currentRunePosition } newMatches = append(newMatches, match) } // check for new initialism matches for _, initialism := range s.initialisms { initialismRunes := []rune(initialism) if s.initialismRuneEqual(initialismRunes[0], currentRune) { newMatches = append(newMatches, &initialismMatch{ start: currentRunePosition, body: initialismRunes, complete: false, }) } } matches = newMatches } return matches } func (s *splitter) mapMatchesToNameLexems(nameRunes []rune, matches initialismMatches) []nameLexem { nameLexems := make([]nameLexem, 0) var lastAcceptedMatch *initialismMatch for _, match := range matches { if !match.complete { continue } if firstMatch := lastAcceptedMatch == nil; firstMatch { nameLexems = append(nameLexems, s.breakCasualString(nameRunes[:match.start])...) nameLexems = append(nameLexems, s.breakInitialism(string(match.body))) lastAcceptedMatch = match continue } if overlappedMatch := match.start <= lastAcceptedMatch.end; overlappedMatch { continue } middle := nameRunes[lastAcceptedMatch.end+1 : match.start] nameLexems = append(nameLexems, s.breakCasualString(middle)...) nameLexems = append(nameLexems, s.breakInitialism(string(match.body))) lastAcceptedMatch = match } // we have not found any accepted matches if lastAcceptedMatch == nil { return s.breakCasualString(nameRunes) } if lastAcceptedMatch.end+1 != len(nameRunes) { rest := nameRunes[lastAcceptedMatch.end+1:] nameLexems = append(nameLexems, s.breakCasualString(rest)...) } return nameLexems } func (s *splitter) initialismRuneEqual(a, b rune) bool { return a == b } func (s *splitter) breakInitialism(original string) nameLexem { return newInitialismNameLexem(original, original) } func (s *splitter) breakCasualString(str []rune) []nameLexem { segments := make([]nameLexem, 0) currentSegment := "" addCasualNameLexem := func(original string) { segments = append(segments, newCasualNameLexem(original)) } addInitialismNameLexem := func(original, match string) { segments = append(segments, newInitialismNameLexem(original, match)) } addNameLexem := func(original string) { if s.postSplitInitialismCheck { for _, initialism := range s.initialisms { if upper(initialism) == upper(original) { addInitialismNameLexem(original, initialism) return } } } addCasualNameLexem(original) } for _, rn := range string(str) { if replace, found := nameReplaceTable[rn]; found { if currentSegment != "" { addNameLexem(currentSegment) currentSegment = "" } if replace != "" { addNameLexem(replace) } continue } if !unicode.In(rn, unicode.L, unicode.M, unicode.N, unicode.Pc) { if currentSegment != "" { addNameLexem(currentSegment) currentSegment = "" } continue } if unicode.IsUpper(rn) { if currentSegment != "" { addNameLexem(currentSegment) } currentSegment = "" } currentSegment += string(rn) } if currentSegment != "" { addNameLexem(currentSegment) } return segments }
8,849
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/loading.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package swag import ( "fmt" "io/ioutil" "log" "net/http" "path/filepath" "strings" "time" ) // LoadHTTPTimeout the default timeout for load requests var LoadHTTPTimeout = 30 * time.Second // LoadFromFileOrHTTP loads the bytes from a file or a remote http server based on the path passed in func LoadFromFileOrHTTP(path string) ([]byte, error) { return LoadStrategy(path, ioutil.ReadFile, loadHTTPBytes(LoadHTTPTimeout))(path) } // LoadFromFileOrHTTPWithTimeout loads the bytes from a file or a remote http server based on the path passed in // timeout arg allows for per request overriding of the request timeout func LoadFromFileOrHTTPWithTimeout(path string, timeout time.Duration) ([]byte, error) { return LoadStrategy(path, ioutil.ReadFile, loadHTTPBytes(timeout))(path) } // LoadStrategy returns a loader function for a given path or uri func LoadStrategy(path string, local, remote func(string) ([]byte, error)) func(string) ([]byte, error) { if strings.HasPrefix(path, "http") { return remote } return func(pth string) ([]byte, error) { upth, err := pathUnescape(pth) if err != nil { return nil, err } return local(filepath.FromSlash(upth)) } } func loadHTTPBytes(timeout time.Duration) func(path string) ([]byte, error) { return func(path string) ([]byte, error) { client := &http.Client{Timeout: timeout} req, err := http.NewRequest("GET", path, nil) if err != nil { return nil, err } resp, err := client.Do(req) defer func() { if resp != nil { if e := resp.Body.Close(); e != nil { log.Println(e) } } }() if err != nil { return nil, err } if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("could not access document at %q [%s] ", path, resp.Status) } return ioutil.ReadAll(resp.Body) } }
8,850
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/post_go19.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // +build go1.9 package swag import ( "sort" "sync" ) // indexOfInitialisms is a thread-safe implementation of the sorted index of initialisms. // Since go1.9, this may be implemented with sync.Map. type indexOfInitialisms struct { sortMutex *sync.Mutex index *sync.Map } func newIndexOfInitialisms() *indexOfInitialisms { return &indexOfInitialisms{ sortMutex: new(sync.Mutex), index: new(sync.Map), } } func (m *indexOfInitialisms) load(initial map[string]bool) *indexOfInitialisms { m.sortMutex.Lock() defer m.sortMutex.Unlock() for k, v := range initial { m.index.Store(k, v) } return m } func (m *indexOfInitialisms) isInitialism(key string) bool { _, ok := m.index.Load(key) return ok } func (m *indexOfInitialisms) add(key string) *indexOfInitialisms { m.index.Store(key, true) return m } func (m *indexOfInitialisms) sorted() (result []string) { m.sortMutex.Lock() defer m.sortMutex.Unlock() m.index.Range(func(key, value interface{}) bool { k := key.(string) result = append(result, k) return true }) sort.Sort(sort.Reverse(byInitialism(result))) return }
8,851
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/util.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package swag import ( "reflect" "strings" "unicode" ) // 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 isInitialism func(string) bool // GoNamePrefixFunc sets an optional rule to prefix go names // which do not start with a letter. // // e.g. to help converting "123" into "{prefix}123" // // The default is to prefix with "X" var GoNamePrefixFunc func(string) string func init() { // 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, "IPv4": true, "IPv6": 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, } // a thread-safe index of initialisms commonInitialisms = newIndexOfInitialisms().load(configuredInitialisms) initialisms = commonInitialisms.sorted() // a test function isInitialism = commonInitialisms.isInitialism } 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 // csv: comma separated value (default) func JoinByFormat(data []string, format string) []string { if len(data) == 0 { return data } var sep string switch format { case collectionFormatSpace: sep = " " case collectionFormatTab: sep = "\t" case collectionFormatPipe: sep = "|" case collectionFormatMulti: return data default: sep = "," } return []string{strings.Join(data, sep)} } // SplitByFormat splits a string by a known format: // ssv: space separated value // 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 collectionFormatSpace: sep = " " case collectionFormatTab: sep = "\t" case collectionFormatPipe: sep = "|" case collectionFormatMulti: return nil default: sep = "," } var result []string for _, s := range strings.Split(data, sep) { if ts := strings.TrimSpace(s); ts != "" { result = append(result, ts) } } return result } type byInitialism []string func (s byInitialism) Len() int { return len(s) } func (s byInitialism) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s byInitialism) Less(i, j int) bool { if len(s[i]) != len(s[j]) { return len(s[i]) < len(s[j]) } return strings.Compare(s[i], s[j]) > 0 } // Removes leading whitespaces func trim(str string) string { return strings.Trim(str, " ") } // Shortcut to strings.ToUpper() func upper(str string) string { return strings.ToUpper(trim(str)) } // Shortcut to strings.ToLower() func lower(str string) string { return strings.ToLower(trim(str)) } // Camelize an uppercased word func Camelize(word string) (camelized string) { for pos, ru := range []rune(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 { 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 { in := split(name) out := make([]string, 0, len(in)) for _, w := range in { out = append(out, lower(w)) } return strings.Join(out, "-") } // ToHumanNameLower represents a code name as a human series of words func ToHumanNameLower(name string) string { in := newSplitter(withPostSplitInitialismCheck).split(name) out := make([]string, 0, len(in)) for _, w := range in { if !w.IsInitialism() { out = append(out, lower(w.GetOriginal())) } else { 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 := newSplitter(withPostSplitInitialismCheck).split(name) out := make([]string, 0, len(in)) for _, w := range in { original := w.GetOriginal() if !w.IsInitialism() { out = append(out, Camelize(original)) } else { out = append(out, original) } } return strings.Join(out, " ") } // ToJSONName camelcases a name which can be underscored or pascal cased func ToJSONName(name string) string { in := split(name) out := make([]string, 0, len(in)) for i, w := range in { if i == 0 { out = append(out, lower(w)) continue } out = append(out, Camelize(w)) } return strings.Join(out, "") } // ToVarName camelcases a name which can be underscored or pascal cased func ToVarName(name string) string { res := ToGoName(name) if isInitialism(res) { return lower(res) } if len(res) <= 1 { return lower(res) } return lower(res[:1]) + res[1:] } // ToGoName translates a swagger name which can be underscored or camel cased to a name that golint likes func ToGoName(name string) string { lexems := newSplitter(withPostSplitInitialismCheck).split(name) result := "" for _, lexem := range lexems { goName := lexem.GetUnsafeGoName() // to support old behavior if lexem.IsInitialism() { goName = upper(goName) } result += goName } if len(result) > 0 { // Only prefix with X when the first character isn't an ascii letter first := []rune(result)[0] if !unicode.IsLetter(first) || (first > unicode.MaxASCII && !unicode.IsUpper(first)) { if GoNamePrefixFunc == nil { return "X" + result } result = GoNamePrefixFunc(name) + result } first = []rune(result)[0] if unicode.IsLetter(first) && !unicode.IsUpper(first) { result = string(append([]rune{unicode.ToUpper(first)}, []rune(result)[1:]...)) } } 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 { if strings.EqualFold(a, item) { return true } } return false } type zeroable interface { IsZero() bool } // IsZero returns true when the value passed into the function is a zero value. // This allows for safer checking of interface values. func IsZero(data interface{}) bool { // check for things that have an IsZero method instead if vv, ok := data.(zeroable); ok { return vv.IsZero() } // continue with slightly more complex reflection v := reflect.ValueOf(data) switch v.Kind() { case reflect.String: return v.Len() == 0 case reflect.Bool: return !v.Bool() case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return v.Int() == 0 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return v.Uint() == 0 case reflect.Float32, reflect.Float64: return v.Float() == 0 case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: return v.IsNil() case reflect.Struct, reflect.Array: return reflect.DeepEqual(data, reflect.Zero(v.Type()).Interface()) case reflect.Invalid: return true } 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 LongDescription string Options interface{} }
8,852
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/.golangci.yml
linters-settings: govet: check-shadowing: true golint: min-confidence: 0 gocyclo: min-complexity: 25 maligned: suggest-new: true dupl: threshold: 100 goconst: min-len: 3 min-occurrences: 2 linters: enable-all: true disable: - maligned - lll - gochecknoinits - gochecknoglobals
8,853
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/LICENSE
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8,854
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/doc.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /* Package swag contains a bunch of helper functions for go-openapi and go-swagger projects. You may also use it standalone for your projects. * convert between value and pointers for builtin types * convert from string to builtin types (wraps strconv) * fast json concatenation * search in path * load from file or http * name mangling This repo has only few dependencies outside of the standard library: * YAML utilities depend on gopkg.in/yaml.v2 */ package swag
8,855
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/name_lexem.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package swag import "unicode" type ( nameLexem interface { GetUnsafeGoName() string GetOriginal() string IsInitialism() bool } initialismNameLexem struct { original string matchedInitialism string } casualNameLexem struct { original string } ) func newInitialismNameLexem(original, matchedInitialism string) *initialismNameLexem { return &initialismNameLexem{ original: original, matchedInitialism: matchedInitialism, } } func newCasualNameLexem(original string) *casualNameLexem { return &casualNameLexem{ original: original, } } func (l *initialismNameLexem) GetUnsafeGoName() string { return l.matchedInitialism } func (l *casualNameLexem) GetUnsafeGoName() string { var first rune var rest string for i, orig := range l.original { if i == 0 { first = orig continue } if i > 0 { rest = l.original[i:] break } } if len(l.original) > 1 { return string(unicode.ToUpper(first)) + lower(rest) } return l.original } func (l *initialismNameLexem) GetOriginal() string { return l.original } func (l *casualNameLexem) GetOriginal() string { return l.original } func (l *initialismNameLexem) IsInitialism() bool { return true } func (l *casualNameLexem) IsInitialism() bool { return false }
8,856
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/go.sum
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63 h1:nTT4s92Dgz2HlrB2NaMgvlfqHH39OgMhA7z3PK7PGD4= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
8,857
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/.editorconfig
# top-most EditorConfig file root = true # Unix-style newlines with a newline ending every file [*] end_of_line = lf insert_final_newline = true indent_style = space indent_size = 2 trim_trailing_whitespace = true # Set default charset [*.{js,py,go,scala,rb,java,html,css,less,sass,md}] charset = utf-8 # Tab indentation (no size specified) [*.go] indent_style = tab [*.md] trim_trailing_whitespace = false # Matches the exact files either package.json or .travis.yml [{package.json,.travis.yml}] indent_style = space indent_size = 2
8,858
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/.travis.yml
after_success: - bash <(curl -s https://codecov.io/bash) go: - 1.11.x - 1.12.x install: - GO111MODULE=off go get -u gotest.tools/gotestsum env: - GO111MODULE=on language: go notifications: slack: secure: QUWvCkBBK09GF7YtEvHHVt70JOkdlNBG0nIKu/5qc4/nW5HP8I2w0SEf/XR2je0eED1Qe3L/AfMCWwrEj+IUZc3l4v+ju8X8R3Lomhme0Eb0jd1MTMCuPcBT47YCj0M7RON7vXtbFfm1hFJ/jLe5+9FXz0hpXsR24PJc5ZIi/ogNwkaPqG4BmndzecpSh0vc2FJPZUD9LT0I09REY/vXR0oQAalLkW0asGD5taHZTUZq/kBpsNxaAFrLM23i4mUcf33M5fjLpvx5LRICrX/57XpBrDh2TooBU6Qj3CgoY0uPRYUmSNxbVx1czNzl2JtEpb5yjoxfVPQeg0BvQM00G8LJINISR+ohrjhkZmAqchDupAX+yFrxTtORa78CtnIL6z/aTNlgwwVD8kvL/1pFA/JWYmKDmz93mV/+6wubGzNSQCstzjkFA4/iZEKewKUoRIAi/fxyscP6L/rCpmY/4llZZvrnyTqVbt6URWpopUpH4rwYqreXAtJxJsfBJIeSmUIiDIOMGkCTvyTEW3fWGmGoqWtSHLoaWDyAIGb7azb+KvfpWtEcoPFWfSWU+LGee0A/YsUhBl7ADB9A0CJEuR8q4BPpKpfLwPKSiKSAXL7zDkyjExyhtgqbSl2jS+rKIHOZNL8JkCcTP2MKMVd563C5rC5FMKqu3S9m2b6380E= script: - gotestsum -f short-verbose -- -race -coverprofile=coverage.txt -covermode=atomic ./...
8,859
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/pre_go19.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // +build !go1.9 package swag import ( "sort" "sync" ) // indexOfInitialisms is a thread-safe implementation of the sorted index of initialisms. // Before go1.9, this may be implemented with a mutex on the map. type indexOfInitialisms struct { getMutex *sync.Mutex index map[string]bool } func newIndexOfInitialisms() *indexOfInitialisms { return &indexOfInitialisms{ getMutex: new(sync.Mutex), index: make(map[string]bool, 50), } } func (m *indexOfInitialisms) load(initial map[string]bool) *indexOfInitialisms { m.getMutex.Lock() defer m.getMutex.Unlock() for k, v := range initial { m.index[k] = v } return m } func (m *indexOfInitialisms) isInitialism(key string) bool { m.getMutex.Lock() defer m.getMutex.Unlock() _, ok := m.index[key] return ok } func (m *indexOfInitialisms) add(key string) *indexOfInitialisms { m.getMutex.Lock() defer m.getMutex.Unlock() m.index[key] = true return m } func (m *indexOfInitialisms) sorted() (result []string) { m.getMutex.Lock() defer m.getMutex.Unlock() for k := range m.index { result = append(result, k) } sort.Sort(sort.Reverse(byInitialism(result))) return }
8,860
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/swag/path.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package swag import ( "os" "path/filepath" "runtime" "strings" ) const ( // GOPATHKey represents the env key for gopath GOPATHKey = "GOPATH" ) // FindInSearchPath finds a package in a provided lists of paths func FindInSearchPath(searchPath, pkg string) string { pathsList := filepath.SplitList(searchPath) for _, path := range pathsList { if evaluatedPath, err := filepath.EvalSymlinks(filepath.Join(path, "src", pkg)); err == nil { if _, err := os.Stat(evaluatedPath); err == nil { return evaluatedPath } } } return "" } // FindInGoSearchPath finds a package in the $GOPATH:$GOROOT func FindInGoSearchPath(pkg string) string { return FindInSearchPath(FullGoSearchPath(), pkg) } // FullGoSearchPath gets the search paths for finding packages func FullGoSearchPath() string { allPaths := os.Getenv(GOPATHKey) if allPaths == "" { allPaths = filepath.Join(os.Getenv("HOME"), "go") } if allPaths != "" { allPaths = strings.Join([]string{allPaths, runtime.GOROOT()}, ":") } else { allPaths = runtime.GOROOT() } return allPaths }
8,861
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/spec.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import "encoding/json" //go:generate curl -L --progress -o ./schemas/v2/schema.json http://swagger.io/v2/schema.json //go:generate curl -L --progress -o ./schemas/jsonschema-draft-04.json http://json-schema.org/draft-04/schema //go:generate go-bindata -pkg=spec -prefix=./schemas -ignore=.*\.md ./schemas/... //go:generate perl -pi -e s,Json,JSON,g bindata.go const ( // SwaggerSchemaURL the url for the swagger 2.0 schema to validate specs SwaggerSchemaURL = "http://swagger.io/v2/schema.json#" // JSONSchemaURL the url for the json schema schema JSONSchemaURL = "http://json-schema.org/draft-04/schema#" ) var ( jsonSchema *Schema swaggerSchema *Schema ) func init() { jsonSchema = MustLoadJSONSchemaDraft04() swaggerSchema = MustLoadSwagger20Schema() } // MustLoadJSONSchemaDraft04 panics when Swagger20Schema returns an error func MustLoadJSONSchemaDraft04() *Schema { d, e := JSONSchemaDraft04() if e != nil { panic(e) } return d } // JSONSchemaDraft04 loads the json schema document for json shema draft04 func JSONSchemaDraft04() (*Schema, error) { b, err := Asset("jsonschema-draft-04.json") if err != nil { return nil, err } schema := new(Schema) if err := json.Unmarshal(b, schema); err != nil { return nil, err } return schema, nil } // MustLoadSwagger20Schema panics when Swagger20Schema returns an error func MustLoadSwagger20Schema() *Schema { d, e := Swagger20Schema() if e != nil { panic(e) } return d } // Swagger20Schema loads the swagger 2.0 schema from the embedded assets func Swagger20Schema() (*Schema, error) { b, err := Asset("v2/schema.json") if err != nil { return nil, err } schema := new(Schema) if err := json.Unmarshal(b, schema); err != nil { return nil, err } return schema, nil }
8,862
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/swagger.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "bytes" "encoding/gob" "encoding/json" "fmt" "strconv" "github.com/go-openapi/jsonpointer" "github.com/go-openapi/swag" ) // Swagger this is the root document object for the API specification. // It combines what previously was the Resource Listing and API Declaration (version 1.2 and earlier) // together into one document. // // For more information: http://goo.gl/8us55a#swagger-object- type Swagger struct { VendorExtensible SwaggerProps } // JSONLookup look up a value by the json property name func (s Swagger) JSONLookup(token string) (interface{}, error) { if ex, ok := s.Extensions[token]; ok { return &ex, nil } r, _, err := jsonpointer.GetForToken(s.SwaggerProps, token) return r, err } // MarshalJSON marshals this swagger structure to json func (s Swagger) MarshalJSON() ([]byte, error) { b1, err := json.Marshal(s.SwaggerProps) if err != nil { return nil, err } b2, err := json.Marshal(s.VendorExtensible) if err != nil { return nil, err } return swag.ConcatJSON(b1, b2), nil } // UnmarshalJSON unmarshals a swagger spec from json func (s *Swagger) UnmarshalJSON(data []byte) error { var sw Swagger if err := json.Unmarshal(data, &sw.SwaggerProps); err != nil { return err } if err := json.Unmarshal(data, &sw.VendorExtensible); err != nil { return err } *s = sw return nil } // GobEncode provides a safe gob encoder for Swagger, including extensions func (s Swagger) GobEncode() ([]byte, error) { var b bytes.Buffer raw := struct { Props SwaggerProps Ext VendorExtensible }{ Props: s.SwaggerProps, Ext: s.VendorExtensible, } err := gob.NewEncoder(&b).Encode(raw) return b.Bytes(), err } // GobDecode provides a safe gob decoder for Swagger, including extensions func (s *Swagger) GobDecode(b []byte) error { var raw struct { Props SwaggerProps Ext VendorExtensible } buf := bytes.NewBuffer(b) err := gob.NewDecoder(buf).Decode(&raw) if err != nil { return err } s.SwaggerProps = raw.Props s.VendorExtensible = raw.Ext return nil } // SwaggerProps captures the top-level properties of an Api specification // // NOTE: validation rules // - the scheme, when present must be from [http, https, ws, wss] // - BasePath must start with a leading "/" // - Paths is required type SwaggerProps struct { ID string `json:"id,omitempty"` Consumes []string `json:"consumes,omitempty"` Produces []string `json:"produces,omitempty"` Schemes []string `json:"schemes,omitempty"` Swagger string `json:"swagger,omitempty"` Info *Info `json:"info,omitempty"` Host string `json:"host,omitempty"` BasePath string `json:"basePath,omitempty"` Paths *Paths `json:"paths"` Definitions Definitions `json:"definitions,omitempty"` Parameters map[string]Parameter `json:"parameters,omitempty"` Responses map[string]Response `json:"responses,omitempty"` SecurityDefinitions SecurityDefinitions `json:"securityDefinitions,omitempty"` Security []map[string][]string `json:"security,omitempty"` Tags []Tag `json:"tags,omitempty"` ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"` } type swaggerPropsAlias SwaggerProps type gobSwaggerPropsAlias struct { Security []map[string]struct { List []string Pad bool } Alias *swaggerPropsAlias SecurityIsEmpty bool } // GobEncode provides a safe gob encoder for SwaggerProps, including empty security requirements func (o SwaggerProps) GobEncode() ([]byte, error) { raw := gobSwaggerPropsAlias{ Alias: (*swaggerPropsAlias)(&o), } var b bytes.Buffer if o.Security == nil { // nil security requirement err := gob.NewEncoder(&b).Encode(raw) return b.Bytes(), err } if len(o.Security) == 0 { // empty, but non-nil security requirement raw.SecurityIsEmpty = true raw.Alias.Security = nil err := gob.NewEncoder(&b).Encode(raw) return b.Bytes(), err } raw.Security = make([]map[string]struct { List []string Pad bool }, 0, len(o.Security)) for _, req := range o.Security { v := make(map[string]struct { List []string Pad bool }, len(req)) for k, val := range req { v[k] = struct { List []string Pad bool }{ List: val, } } raw.Security = append(raw.Security, v) } err := gob.NewEncoder(&b).Encode(raw) return b.Bytes(), err } // GobDecode provides a safe gob decoder for SwaggerProps, including empty security requirements func (o *SwaggerProps) GobDecode(b []byte) error { var raw gobSwaggerPropsAlias buf := bytes.NewBuffer(b) err := gob.NewDecoder(buf).Decode(&raw) if err != nil { return err } if raw.Alias == nil { return nil } switch { case raw.SecurityIsEmpty: // empty, but non-nil security requirement raw.Alias.Security = []map[string][]string{} case len(raw.Alias.Security) == 0: // nil security requirement raw.Alias.Security = nil default: raw.Alias.Security = make([]map[string][]string, 0, len(raw.Security)) for _, req := range raw.Security { v := make(map[string][]string, len(req)) for k, val := range req { v[k] = make([]string, 0, len(val.List)) v[k] = append(v[k], val.List...) } raw.Alias.Security = append(raw.Alias.Security, v) } } *o = *(*SwaggerProps)(raw.Alias) return nil } // Dependencies represent a dependencies property type Dependencies map[string]SchemaOrStringArray // SchemaOrBool represents a schema or boolean value, is biased towards true for the boolean property type SchemaOrBool struct { Allows bool Schema *Schema } // JSONLookup implements an interface to customize json pointer lookup func (s SchemaOrBool) JSONLookup(token string) (interface{}, error) { if token == "allows" { return s.Allows, nil } r, _, err := jsonpointer.GetForToken(s.Schema, token) return r, err } var jsTrue = []byte("true") var jsFalse = []byte("false") // MarshalJSON convert this object to JSON func (s SchemaOrBool) MarshalJSON() ([]byte, error) { if s.Schema != nil { return json.Marshal(s.Schema) } if s.Schema == nil && !s.Allows { return jsFalse, nil } return jsTrue, nil } // UnmarshalJSON converts this bool or schema object from a JSON structure func (s *SchemaOrBool) UnmarshalJSON(data []byte) error { var nw SchemaOrBool if len(data) >= 4 { if data[0] == '{' { var sch Schema if err := json.Unmarshal(data, &sch); err != nil { return err } nw.Schema = &sch } nw.Allows = !(data[0] == 'f' && data[1] == 'a' && data[2] == 'l' && data[3] == 's' && data[4] == 'e') } *s = nw return nil } // SchemaOrStringArray represents a schema or a string array type SchemaOrStringArray struct { Schema *Schema Property []string } // JSONLookup implements an interface to customize json pointer lookup func (s SchemaOrStringArray) JSONLookup(token string) (interface{}, error) { r, _, err := jsonpointer.GetForToken(s.Schema, token) return r, err } // MarshalJSON converts this schema object or array into JSON structure func (s SchemaOrStringArray) MarshalJSON() ([]byte, error) { if len(s.Property) > 0 { return json.Marshal(s.Property) } if s.Schema != nil { return json.Marshal(s.Schema) } return []byte("null"), nil } // UnmarshalJSON converts this schema object or array from a JSON structure func (s *SchemaOrStringArray) UnmarshalJSON(data []byte) error { var first byte if len(data) > 1 { first = data[0] } var nw SchemaOrStringArray if first == '{' { var sch Schema if err := json.Unmarshal(data, &sch); err != nil { return err } nw.Schema = &sch } if first == '[' { if err := json.Unmarshal(data, &nw.Property); err != nil { return err } } *s = nw return nil } // Definitions contains the models explicitly defined in this spec // An object to hold data types that can be consumed and produced by operations. // These data types can be primitives, arrays or models. // // For more information: http://goo.gl/8us55a#definitionsObject type Definitions map[string]Schema // SecurityDefinitions a declaration of the security schemes available to be used in the specification. // This does not enforce the security schemes on the operations and only serves to provide // the relevant details for each scheme. // // For more information: http://goo.gl/8us55a#securityDefinitionsObject type SecurityDefinitions map[string]*SecurityScheme // StringOrArray represents a value that can either be a string // or an array of strings. Mainly here for serialization purposes type StringOrArray []string // Contains returns true when the value is contained in the slice func (s StringOrArray) Contains(value string) bool { for _, str := range s { if str == value { return true } } return false } // JSONLookup implements an interface to customize json pointer lookup func (s SchemaOrArray) JSONLookup(token string) (interface{}, error) { if _, err := strconv.Atoi(token); err == nil { r, _, err := jsonpointer.GetForToken(s.Schemas, token) return r, err } r, _, err := jsonpointer.GetForToken(s.Schema, token) return r, err } // UnmarshalJSON unmarshals this string or array object from a JSON array or JSON string func (s *StringOrArray) UnmarshalJSON(data []byte) error { var first byte if len(data) > 1 { first = data[0] } if first == '[' { var parsed []string if err := json.Unmarshal(data, &parsed); err != nil { return err } *s = StringOrArray(parsed) return nil } var single interface{} if err := json.Unmarshal(data, &single); err != nil { return err } if single == nil { return nil } switch v := single.(type) { case string: *s = StringOrArray([]string{v}) return nil default: return fmt.Errorf("only string or array is allowed, not %T", single) } } // MarshalJSON converts this string or array to a JSON array or JSON string func (s StringOrArray) MarshalJSON() ([]byte, error) { if len(s) == 1 { return json.Marshal([]string(s)[0]) } return json.Marshal([]string(s)) } // SchemaOrArray represents a value that can either be a Schema // or an array of Schema. Mainly here for serialization purposes type SchemaOrArray struct { Schema *Schema Schemas []Schema } // Len returns the number of schemas in this property func (s SchemaOrArray) Len() int { if s.Schema != nil { return 1 } return len(s.Schemas) } // ContainsType returns true when one of the schemas is of the specified type func (s *SchemaOrArray) ContainsType(name string) bool { if s.Schema != nil { return s.Schema.Type != nil && s.Schema.Type.Contains(name) } return false } // MarshalJSON converts this schema object or array into JSON structure func (s SchemaOrArray) MarshalJSON() ([]byte, error) { if len(s.Schemas) > 0 { return json.Marshal(s.Schemas) } return json.Marshal(s.Schema) } // UnmarshalJSON converts this schema object or array from a JSON structure func (s *SchemaOrArray) UnmarshalJSON(data []byte) error { var nw SchemaOrArray var first byte if len(data) > 1 { first = data[0] } if first == '{' { var sch Schema if err := json.Unmarshal(data, &sch); err != nil { return err } nw.Schema = &sch } if first == '[' { if err := json.Unmarshal(data, &nw.Schemas); err != nil { return err } } *s = nw return nil } // vim:set ft=go noet sts=2 sw=2 ts=2:
8,863
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/contact_info.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec // ContactInfo contact information for the exposed API. // // For more information: http://goo.gl/8us55a#contactObject type ContactInfo struct { Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` Email string `json:"email,omitempty"` }
8,864
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/CODE_OF_CONDUCT.md
# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/
8,865
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/go.mod
module github.com/go-openapi/spec require ( github.com/go-openapi/jsonpointer v0.19.3 github.com/go-openapi/jsonreference v0.19.2 github.com/go-openapi/swag v0.19.5 github.com/kr/pty v1.1.5 // indirect github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/testify v1.3.0 golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 // indirect golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f // indirect golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59 // indirect gopkg.in/yaml.v2 v2.2.2 ) go 1.13
8,866
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/expander.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "encoding/json" "fmt" "strings" ) // ExpandOptions provides options for spec expand type ExpandOptions struct { RelativeBase string SkipSchemas bool ContinueOnError bool AbsoluteCircularRef bool } // ResolveRefWithBase resolves a reference against a context root with preservation of base path func ResolveRefWithBase(root interface{}, ref *Ref, opts *ExpandOptions) (*Schema, error) { resolver, err := defaultSchemaLoader(root, opts, nil, nil) if err != nil { return nil, err } specBasePath := "" if opts != nil && opts.RelativeBase != "" { specBasePath, _ = absPath(opts.RelativeBase) } result := new(Schema) if err := resolver.Resolve(ref, result, specBasePath); err != nil { return nil, err } return result, nil } // ResolveRef resolves a reference against a context root // ref is guaranteed to be in root (no need to go to external files) // ResolveRef is ONLY called from the code generation module func ResolveRef(root interface{}, ref *Ref) (*Schema, error) { res, _, err := ref.GetPointer().Get(root) if err != nil { panic(err) } switch sch := res.(type) { case Schema: return &sch, nil case *Schema: return sch, nil case map[string]interface{}: b, _ := json.Marshal(sch) newSch := new(Schema) _ = json.Unmarshal(b, newSch) return newSch, nil default: return nil, fmt.Errorf("unknown type for the resolved reference") } } // ResolveParameter resolves a parameter reference against a context root func ResolveParameter(root interface{}, ref Ref) (*Parameter, error) { return ResolveParameterWithBase(root, ref, nil) } // ResolveParameterWithBase resolves a parameter reference against a context root and base path func ResolveParameterWithBase(root interface{}, ref Ref, opts *ExpandOptions) (*Parameter, error) { resolver, err := defaultSchemaLoader(root, opts, nil, nil) if err != nil { return nil, err } result := new(Parameter) if err := resolver.Resolve(&ref, result, ""); err != nil { return nil, err } return result, nil } // ResolveResponse resolves response a reference against a context root func ResolveResponse(root interface{}, ref Ref) (*Response, error) { return ResolveResponseWithBase(root, ref, nil) } // ResolveResponseWithBase resolves response a reference against a context root and base path func ResolveResponseWithBase(root interface{}, ref Ref, opts *ExpandOptions) (*Response, error) { resolver, err := defaultSchemaLoader(root, opts, nil, nil) if err != nil { return nil, err } result := new(Response) if err := resolver.Resolve(&ref, result, ""); err != nil { return nil, err } return result, nil } // ResolveItems resolves parameter items reference against a context root and base path. // // NOTE: stricly speaking, this construct is not supported by Swagger 2.0. // Similarly, $ref are forbidden in response headers. func ResolveItems(root interface{}, ref Ref, opts *ExpandOptions) (*Items, error) { resolver, err := defaultSchemaLoader(root, opts, nil, nil) if err != nil { return nil, err } basePath := "" if opts.RelativeBase != "" { basePath = opts.RelativeBase } result := new(Items) if err := resolver.Resolve(&ref, result, basePath); err != nil { return nil, err } return result, nil } // ResolvePathItem resolves response a path item against a context root and base path func ResolvePathItem(root interface{}, ref Ref, opts *ExpandOptions) (*PathItem, error) { resolver, err := defaultSchemaLoader(root, opts, nil, nil) if err != nil { return nil, err } basePath := "" if opts.RelativeBase != "" { basePath = opts.RelativeBase } result := new(PathItem) if err := resolver.Resolve(&ref, result, basePath); err != nil { return nil, err } return result, nil } // ExpandSpec expands the references in a swagger spec func ExpandSpec(spec *Swagger, options *ExpandOptions) error { resolver, err := defaultSchemaLoader(spec, options, nil, nil) // Just in case this ever returns an error. if resolver.shouldStopOnError(err) { return err } // getting the base path of the spec to adjust all subsequent reference resolutions specBasePath := "" if options != nil && options.RelativeBase != "" { specBasePath, _ = absPath(options.RelativeBase) } if options == nil || !options.SkipSchemas { for key, definition := range spec.Definitions { var def *Schema var err error if def, err = expandSchema(definition, []string{fmt.Sprintf("#/definitions/%s", key)}, resolver, specBasePath); resolver.shouldStopOnError(err) { return err } if def != nil { spec.Definitions[key] = *def } } } for key := range spec.Parameters { parameter := spec.Parameters[key] if err := expandParameterOrResponse(&parameter, resolver, specBasePath); resolver.shouldStopOnError(err) { return err } spec.Parameters[key] = parameter } for key := range spec.Responses { response := spec.Responses[key] if err := expandParameterOrResponse(&response, resolver, specBasePath); resolver.shouldStopOnError(err) { return err } spec.Responses[key] = response } if spec.Paths != nil { for key := range spec.Paths.Paths { path := spec.Paths.Paths[key] if err := expandPathItem(&path, resolver, specBasePath); resolver.shouldStopOnError(err) { return err } spec.Paths.Paths[key] = path } } return nil } // baseForRoot loads in the cache the root document and produces a fake "root" base path entry // for further $ref resolution func baseForRoot(root interface{}, cache ResolutionCache) string { // cache the root document to resolve $ref's const rootBase = "root" if root != nil { base, _ := absPath(rootBase) normalizedBase := normalizeAbsPath(base) debugLog("setting root doc in cache at: %s", normalizedBase) if cache == nil { cache = resCache } cache.Set(normalizedBase, root) return rootBase } return "" } // ExpandSchema expands the refs in the schema object with reference to the root object // go-openapi/validate uses this function // notice that it is impossible to reference a json schema in a different file other than root func ExpandSchema(schema *Schema, root interface{}, cache ResolutionCache) error { opts := &ExpandOptions{ // when a root is specified, cache the root as an in-memory document for $ref retrieval RelativeBase: baseForRoot(root, cache), SkipSchemas: false, ContinueOnError: false, // when no base path is specified, remaining $ref (circular) are rendered with an absolute path AbsoluteCircularRef: true, } return ExpandSchemaWithBasePath(schema, cache, opts) } // ExpandSchemaWithBasePath expands the refs in the schema object, base path configured through expand options func ExpandSchemaWithBasePath(schema *Schema, cache ResolutionCache, opts *ExpandOptions) error { if schema == nil { return nil } var basePath string if opts.RelativeBase != "" { basePath, _ = absPath(opts.RelativeBase) } resolver, err := defaultSchemaLoader(nil, opts, cache, nil) if err != nil { return err } refs := []string{""} var s *Schema if s, err = expandSchema(*schema, refs, resolver, basePath); err != nil { return err } *schema = *s return nil } func expandItems(target Schema, parentRefs []string, resolver *schemaLoader, basePath string) (*Schema, error) { if target.Items != nil { if target.Items.Schema != nil { t, err := expandSchema(*target.Items.Schema, parentRefs, resolver, basePath) if err != nil { return nil, err } *target.Items.Schema = *t } for i := range target.Items.Schemas { t, err := expandSchema(target.Items.Schemas[i], parentRefs, resolver, basePath) if err != nil { return nil, err } target.Items.Schemas[i] = *t } } return &target, nil } func expandSchema(target Schema, parentRefs []string, resolver *schemaLoader, basePath string) (*Schema, error) { if target.Ref.String() == "" && target.Ref.IsRoot() { // normalizing is important newRef := normalizeFileRef(&target.Ref, basePath) target.Ref = *newRef return &target, nil } // change the base path of resolution when an ID is encountered // otherwise the basePath should inherit the parent's // important: ID can be relative path if target.ID != "" { debugLog("schema has ID: %s", target.ID) // handling the case when id is a folder // remember that basePath has to be a file refPath := target.ID if strings.HasSuffix(target.ID, "/") { // path.Clean here would not work correctly if basepath is http refPath = fmt.Sprintf("%s%s", refPath, "placeholder.json") } basePath = normalizePaths(refPath, basePath) } var t *Schema // if Ref is found, everything else doesn't matter // Ref also changes the resolution scope of children expandSchema if target.Ref.String() != "" { // here the resolution scope is changed because a $ref was encountered normalizedRef := normalizeFileRef(&target.Ref, basePath) normalizedBasePath := normalizedRef.RemoteURI() if resolver.isCircular(normalizedRef, basePath, parentRefs...) { // this means there is a cycle in the recursion tree: return the Ref // - circular refs cannot be expanded. We leave them as ref. // - denormalization means that a new local file ref is set relative to the original basePath debugLog("shortcut circular ref: basePath: %s, normalizedPath: %s, normalized ref: %s", basePath, normalizedBasePath, normalizedRef.String()) if !resolver.options.AbsoluteCircularRef { target.Ref = *denormalizeFileRef(normalizedRef, normalizedBasePath, resolver.context.basePath) } else { target.Ref = *normalizedRef } return &target, nil } debugLog("basePath: %s: calling Resolve with target: %#v", basePath, target) if err := resolver.Resolve(&target.Ref, &t, basePath); resolver.shouldStopOnError(err) { return nil, err } if t != nil { parentRefs = append(parentRefs, normalizedRef.String()) var err error transitiveResolver, err := resolver.transitiveResolver(basePath, target.Ref) if transitiveResolver.shouldStopOnError(err) { return nil, err } basePath = resolver.updateBasePath(transitiveResolver, normalizedBasePath) return expandSchema(*t, parentRefs, transitiveResolver, basePath) } } t, err := expandItems(target, parentRefs, resolver, basePath) if resolver.shouldStopOnError(err) { return &target, err } if t != nil { target = *t } for i := range target.AllOf { t, err := expandSchema(target.AllOf[i], parentRefs, resolver, basePath) if resolver.shouldStopOnError(err) { return &target, err } target.AllOf[i] = *t } for i := range target.AnyOf { t, err := expandSchema(target.AnyOf[i], parentRefs, resolver, basePath) if resolver.shouldStopOnError(err) { return &target, err } target.AnyOf[i] = *t } for i := range target.OneOf { t, err := expandSchema(target.OneOf[i], parentRefs, resolver, basePath) if resolver.shouldStopOnError(err) { return &target, err } if t != nil { target.OneOf[i] = *t } } if target.Not != nil { t, err := expandSchema(*target.Not, parentRefs, resolver, basePath) if resolver.shouldStopOnError(err) { return &target, err } if t != nil { *target.Not = *t } } for k := range target.Properties { t, err := expandSchema(target.Properties[k], parentRefs, resolver, basePath) if resolver.shouldStopOnError(err) { return &target, err } if t != nil { target.Properties[k] = *t } } if target.AdditionalProperties != nil && target.AdditionalProperties.Schema != nil { t, err := expandSchema(*target.AdditionalProperties.Schema, parentRefs, resolver, basePath) if resolver.shouldStopOnError(err) { return &target, err } if t != nil { *target.AdditionalProperties.Schema = *t } } for k := range target.PatternProperties { t, err := expandSchema(target.PatternProperties[k], parentRefs, resolver, basePath) if resolver.shouldStopOnError(err) { return &target, err } if t != nil { target.PatternProperties[k] = *t } } for k := range target.Dependencies { if target.Dependencies[k].Schema != nil { t, err := expandSchema(*target.Dependencies[k].Schema, parentRefs, resolver, basePath) if resolver.shouldStopOnError(err) { return &target, err } if t != nil { *target.Dependencies[k].Schema = *t } } } if target.AdditionalItems != nil && target.AdditionalItems.Schema != nil { t, err := expandSchema(*target.AdditionalItems.Schema, parentRefs, resolver, basePath) if resolver.shouldStopOnError(err) { return &target, err } if t != nil { *target.AdditionalItems.Schema = *t } } for k := range target.Definitions { t, err := expandSchema(target.Definitions[k], parentRefs, resolver, basePath) if resolver.shouldStopOnError(err) { return &target, err } if t != nil { target.Definitions[k] = *t } } return &target, nil } func expandPathItem(pathItem *PathItem, resolver *schemaLoader, basePath string) error { if pathItem == nil { return nil } parentRefs := []string{} if err := resolver.deref(pathItem, parentRefs, basePath); resolver.shouldStopOnError(err) { return err } if pathItem.Ref.String() != "" { var err error resolver, err = resolver.transitiveResolver(basePath, pathItem.Ref) if resolver.shouldStopOnError(err) { return err } } pathItem.Ref = Ref{} for idx := range pathItem.Parameters { if err := expandParameterOrResponse(&(pathItem.Parameters[idx]), resolver, basePath); resolver.shouldStopOnError(err) { return err } } ops := []*Operation{ pathItem.Get, pathItem.Head, pathItem.Options, pathItem.Put, pathItem.Post, pathItem.Patch, pathItem.Delete, } for _, op := range ops { if err := expandOperation(op, resolver, basePath); resolver.shouldStopOnError(err) { return err } } return nil } func expandOperation(op *Operation, resolver *schemaLoader, basePath string) error { if op == nil { return nil } for i := range op.Parameters { param := op.Parameters[i] if err := expandParameterOrResponse(&param, resolver, basePath); resolver.shouldStopOnError(err) { return err } op.Parameters[i] = param } if op.Responses != nil { responses := op.Responses if err := expandParameterOrResponse(responses.Default, resolver, basePath); resolver.shouldStopOnError(err) { return err } for code := range responses.StatusCodeResponses { response := responses.StatusCodeResponses[code] if err := expandParameterOrResponse(&response, resolver, basePath); resolver.shouldStopOnError(err) { return err } responses.StatusCodeResponses[code] = response } } return nil } // ExpandResponseWithRoot expands a response based on a root document, not a fetchable document func ExpandResponseWithRoot(response *Response, root interface{}, cache ResolutionCache) error { opts := &ExpandOptions{ RelativeBase: baseForRoot(root, cache), SkipSchemas: false, ContinueOnError: false, // when no base path is specified, remaining $ref (circular) are rendered with an absolute path AbsoluteCircularRef: true, } resolver, err := defaultSchemaLoader(root, opts, nil, nil) if err != nil { return err } return expandParameterOrResponse(response, resolver, opts.RelativeBase) } // ExpandResponse expands a response based on a basepath // This is the exported version of expandResponse // all refs inside response will be resolved relative to basePath func ExpandResponse(response *Response, basePath string) error { var specBasePath string if basePath != "" { specBasePath, _ = absPath(basePath) } opts := &ExpandOptions{ RelativeBase: specBasePath, } resolver, err := defaultSchemaLoader(nil, opts, nil, nil) if err != nil { return err } return expandParameterOrResponse(response, resolver, opts.RelativeBase) } // ExpandParameterWithRoot expands a parameter based on a root document, not a fetchable document func ExpandParameterWithRoot(parameter *Parameter, root interface{}, cache ResolutionCache) error { opts := &ExpandOptions{ RelativeBase: baseForRoot(root, cache), SkipSchemas: false, ContinueOnError: false, // when no base path is specified, remaining $ref (circular) are rendered with an absolute path AbsoluteCircularRef: true, } resolver, err := defaultSchemaLoader(root, opts, nil, nil) if err != nil { return err } return expandParameterOrResponse(parameter, resolver, opts.RelativeBase) } // ExpandParameter expands a parameter based on a basepath. // This is the exported version of expandParameter // all refs inside parameter will be resolved relative to basePath func ExpandParameter(parameter *Parameter, basePath string) error { var specBasePath string if basePath != "" { specBasePath, _ = absPath(basePath) } opts := &ExpandOptions{ RelativeBase: specBasePath, } resolver, err := defaultSchemaLoader(nil, opts, nil, nil) if err != nil { return err } return expandParameterOrResponse(parameter, resolver, opts.RelativeBase) } func getRefAndSchema(input interface{}) (*Ref, *Schema, error) { var ref *Ref var sch *Schema switch refable := input.(type) { case *Parameter: if refable == nil { return nil, nil, nil } ref = &refable.Ref sch = refable.Schema case *Response: if refable == nil { return nil, nil, nil } ref = &refable.Ref sch = refable.Schema default: return nil, nil, fmt.Errorf("expand: unsupported type %T. Input should be of type *Parameter or *Response", input) } return ref, sch, nil } func expandParameterOrResponse(input interface{}, resolver *schemaLoader, basePath string) error { ref, _, err := getRefAndSchema(input) if err != nil { return err } if ref == nil { return nil } parentRefs := []string{} if err := resolver.deref(input, parentRefs, basePath); resolver.shouldStopOnError(err) { return err } ref, sch, _ := getRefAndSchema(input) if ref.String() != "" { transitiveResolver, err := resolver.transitiveResolver(basePath, *ref) if transitiveResolver.shouldStopOnError(err) { return err } basePath = resolver.updateBasePath(transitiveResolver, basePath) resolver = transitiveResolver } if sch != nil && sch.Ref.String() != "" { // schema expanded to a $ref in another root var ern error sch.Ref, ern = NewRef(normalizePaths(sch.Ref.String(), ref.RemoteURI())) if ern != nil { return ern } } if ref != nil { *ref = Ref{} } if !resolver.options.SkipSchemas && sch != nil { s, err := expandSchema(*sch, parentRefs, resolver, basePath) if resolver.shouldStopOnError(err) { return err } *sch = *s } return nil }
8,867
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/parameter.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "encoding/json" "strings" "github.com/go-openapi/jsonpointer" "github.com/go-openapi/swag" ) // QueryParam creates a query parameter func QueryParam(name string) *Parameter { return &Parameter{ParamProps: ParamProps{Name: name, In: "query"}} } // HeaderParam creates a header parameter, this is always required by default func HeaderParam(name string) *Parameter { return &Parameter{ParamProps: ParamProps{Name: name, In: "header", Required: true}} } // PathParam creates a path parameter, this is always required func PathParam(name string) *Parameter { return &Parameter{ParamProps: ParamProps{Name: name, In: "path", Required: true}} } // BodyParam creates a body parameter func BodyParam(name string, schema *Schema) *Parameter { return &Parameter{ParamProps: ParamProps{Name: name, In: "body", Schema: schema}, SimpleSchema: SimpleSchema{Type: "object"}} } // FormDataParam creates a body parameter func FormDataParam(name string) *Parameter { return &Parameter{ParamProps: ParamProps{Name: name, In: "formData"}} } // FileParam creates a body parameter func FileParam(name string) *Parameter { return &Parameter{ParamProps: ParamProps{Name: name, In: "formData"}, SimpleSchema: SimpleSchema{Type: "file"}} } // SimpleArrayParam creates a param for a simple array (string, int, date etc) func SimpleArrayParam(name, tpe, fmt string) *Parameter { return &Parameter{ParamProps: ParamProps{Name: name}, SimpleSchema: SimpleSchema{Type: jsonArray, CollectionFormat: "csv", Items: &Items{SimpleSchema: SimpleSchema{Type: "string", Format: fmt}}}} } // ParamRef creates a parameter that's a json reference func ParamRef(uri string) *Parameter { p := new(Parameter) p.Ref = MustCreateRef(uri) return p } // ParamProps describes the specific attributes of an operation parameter // // NOTE: // - Schema is defined when "in" == "body": see validate // - AllowEmptyValue is allowed where "in" == "query" || "formData" type ParamProps struct { Description string `json:"description,omitempty"` Name string `json:"name,omitempty"` In string `json:"in,omitempty"` Required bool `json:"required,omitempty"` Schema *Schema `json:"schema,omitempty"` AllowEmptyValue bool `json:"allowEmptyValue,omitempty"` } // Parameter a unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn). // // There are five possible parameter types. // * Path - Used together with [Path Templating](#pathTemplating), where the parameter value is actually part // of the operation's URL. This does not include the host or base path of the API. For example, in `/items/{itemId}`, // the path parameter is `itemId`. // * Query - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`. // * Header - Custom headers that are expected as part of the request. // * Body - The payload that's appended to the HTTP request. Since there can only be one payload, there can only be // _one_ body parameter. The name of the body parameter has no effect on the parameter itself and is used for // documentation purposes only. Since Form parameters are also in the payload, body and form parameters cannot exist // together for the same operation. // * Form - Used to describe the payload of an HTTP request when either `application/x-www-form-urlencoded` or // `multipart/form-data` are used as the content type of the request (in Swagger's definition, // the [`consumes`](#operationConsumes) property of an operation). This is the only parameter type that can be used // to send files, thus supporting the `file` type. Since form parameters are sent in the payload, they cannot be // declared together with a body parameter for the same operation. Form parameters have a different format based on // the content-type used (for further details, consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4). // * `application/x-www-form-urlencoded` - Similar to the format of Query parameters but as a payload. // For example, `foo=1&bar=swagger` - both `foo` and `bar` are form parameters. This is normally used for simple // parameters that are being transferred. // * `multipart/form-data` - each parameter takes a section in the payload with an internal header. // For example, for the header `Content-Disposition: form-data; name="submit-name"` the name of the parameter is // `submit-name`. This type of form parameters is more commonly used for file transfers. // // For more information: http://goo.gl/8us55a#parameterObject type Parameter struct { Refable CommonValidations SimpleSchema VendorExtensible ParamProps } // JSONLookup look up a value by the json property name func (p Parameter) JSONLookup(token string) (interface{}, error) { if ex, ok := p.Extensions[token]; ok { return &ex, nil } if token == jsonRef { return &p.Ref, nil } r, _, err := jsonpointer.GetForToken(p.CommonValidations, token) if err != nil && !strings.HasPrefix(err.Error(), "object has no field") { return nil, err } if r != nil { return r, nil } r, _, err = jsonpointer.GetForToken(p.SimpleSchema, token) if err != nil && !strings.HasPrefix(err.Error(), "object has no field") { return nil, err } if r != nil { return r, nil } r, _, err = jsonpointer.GetForToken(p.ParamProps, token) return r, err } // WithDescription a fluent builder method for the description of the parameter func (p *Parameter) WithDescription(description string) *Parameter { p.Description = description return p } // Named a fluent builder method to override the name of the parameter func (p *Parameter) Named(name string) *Parameter { p.Name = name return p } // WithLocation a fluent builder method to override the location of the parameter func (p *Parameter) WithLocation(in string) *Parameter { p.In = in return p } // Typed a fluent builder method for the type of the parameter value func (p *Parameter) Typed(tpe, format string) *Parameter { p.Type = tpe p.Format = format return p } // CollectionOf a fluent builder method for an array parameter func (p *Parameter) CollectionOf(items *Items, format string) *Parameter { p.Type = jsonArray p.Items = items p.CollectionFormat = format return p } // WithDefault sets the default value on this parameter func (p *Parameter) WithDefault(defaultValue interface{}) *Parameter { p.AsOptional() // with default implies optional p.Default = defaultValue return p } // AllowsEmptyValues flags this parameter as being ok with empty values func (p *Parameter) AllowsEmptyValues() *Parameter { p.AllowEmptyValue = true return p } // NoEmptyValues flags this parameter as not liking empty values func (p *Parameter) NoEmptyValues() *Parameter { p.AllowEmptyValue = false return p } // AsOptional flags this parameter as optional func (p *Parameter) AsOptional() *Parameter { p.Required = false return p } // AsRequired flags this parameter as required func (p *Parameter) AsRequired() *Parameter { if p.Default != nil { // with a default required makes no sense return p } p.Required = true return p } // WithMaxLength sets a max length value func (p *Parameter) WithMaxLength(max int64) *Parameter { p.MaxLength = &max return p } // WithMinLength sets a min length value func (p *Parameter) WithMinLength(min int64) *Parameter { p.MinLength = &min return p } // WithPattern sets a pattern value func (p *Parameter) WithPattern(pattern string) *Parameter { p.Pattern = pattern return p } // WithMultipleOf sets a multiple of value func (p *Parameter) WithMultipleOf(number float64) *Parameter { p.MultipleOf = &number return p } // WithMaximum sets a maximum number value func (p *Parameter) WithMaximum(max float64, exclusive bool) *Parameter { p.Maximum = &max p.ExclusiveMaximum = exclusive return p } // WithMinimum sets a minimum number value func (p *Parameter) WithMinimum(min float64, exclusive bool) *Parameter { p.Minimum = &min p.ExclusiveMinimum = exclusive return p } // WithEnum sets a the enum values (replace) func (p *Parameter) WithEnum(values ...interface{}) *Parameter { p.Enum = append([]interface{}{}, values...) return p } // WithMaxItems sets the max items func (p *Parameter) WithMaxItems(size int64) *Parameter { p.MaxItems = &size return p } // WithMinItems sets the min items func (p *Parameter) WithMinItems(size int64) *Parameter { p.MinItems = &size return p } // UniqueValues dictates that this array can only have unique items func (p *Parameter) UniqueValues() *Parameter { p.UniqueItems = true return p } // AllowDuplicates this array can have duplicates func (p *Parameter) AllowDuplicates() *Parameter { p.UniqueItems = false return p } // UnmarshalJSON hydrates this items instance with the data from JSON func (p *Parameter) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &p.CommonValidations); err != nil { return err } if err := json.Unmarshal(data, &p.Refable); err != nil { return err } if err := json.Unmarshal(data, &p.SimpleSchema); err != nil { return err } if err := json.Unmarshal(data, &p.VendorExtensible); err != nil { return err } return json.Unmarshal(data, &p.ParamProps) } // MarshalJSON converts this items object to JSON func (p Parameter) MarshalJSON() ([]byte, error) { b1, err := json.Marshal(p.CommonValidations) if err != nil { return nil, err } b2, err := json.Marshal(p.SimpleSchema) if err != nil { return nil, err } b3, err := json.Marshal(p.Refable) if err != nil { return nil, err } b4, err := json.Marshal(p.VendorExtensible) if err != nil { return nil, err } b5, err := json.Marshal(p.ParamProps) if err != nil { return nil, err } return swag.ConcatJSON(b3, b1, b2, b4, b5), nil }
8,868
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/README.md
# OAI object model [![Build Status](https://travis-ci.org/go-openapi/spec.svg?branch=master)](https://travis-ci.org/go-openapi/spec) [![codecov](https://codecov.io/gh/go-openapi/spec/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/spec) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) [![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/spec/master/LICENSE) [![GoDoc](https://godoc.org/github.com/go-openapi/spec?status.svg)](http://godoc.org/github.com/go-openapi/spec) [![GolangCI](https://golangci.com/badges/github.com/go-openapi/spec.svg)](https://golangci.com) [![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/spec)](https://goreportcard.com/report/github.com/go-openapi/spec) The object model for OpenAPI specification documents. Currently supports Swagger 2.0.
8,869
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/paths.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "encoding/json" "fmt" "strings" "github.com/go-openapi/swag" ) // Paths holds the relative paths to the individual endpoints. // The path is appended to the [`basePath`](http://goo.gl/8us55a#swaggerBasePath) in order // to construct the full URL. // The Paths may be empty, due to [ACL constraints](http://goo.gl/8us55a#securityFiltering). // // For more information: http://goo.gl/8us55a#pathsObject type Paths struct { VendorExtensible Paths map[string]PathItem `json:"-"` // custom serializer to flatten this, each entry must start with "/" } // JSONLookup look up a value by the json property name func (p Paths) JSONLookup(token string) (interface{}, error) { if pi, ok := p.Paths[token]; ok { return &pi, nil } if ex, ok := p.Extensions[token]; ok { return &ex, nil } return nil, fmt.Errorf("object has no field %q", token) } // UnmarshalJSON hydrates this items instance with the data from JSON func (p *Paths) UnmarshalJSON(data []byte) error { var res map[string]json.RawMessage if err := json.Unmarshal(data, &res); err != nil { return err } for k, v := range res { if strings.HasPrefix(strings.ToLower(k), "x-") { if p.Extensions == nil { p.Extensions = make(map[string]interface{}) } var d interface{} if err := json.Unmarshal(v, &d); err != nil { return err } p.Extensions[k] = d } if strings.HasPrefix(k, "/") { if p.Paths == nil { p.Paths = make(map[string]PathItem) } var pi PathItem if err := json.Unmarshal(v, &pi); err != nil { return err } p.Paths[k] = pi } } return nil } // MarshalJSON converts this items object to JSON func (p Paths) MarshalJSON() ([]byte, error) { b1, err := json.Marshal(p.VendorExtensible) if err != nil { return nil, err } pths := make(map[string]PathItem) for k, v := range p.Paths { if strings.HasPrefix(k, "/") { pths[k] = v } } b2, err := json.Marshal(pths) if err != nil { return nil, err } concated := swag.ConcatJSON(b1, b2) return concated, nil }
8,870
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/.golangci.yml
linters-settings: govet: check-shadowing: true golint: min-confidence: 0 gocyclo: min-complexity: 45 maligned: suggest-new: true dupl: threshold: 200 goconst: min-len: 2 min-occurrences: 2 linters: enable-all: true disable: - maligned - unparam - lll - gochecknoinits - gochecknoglobals
8,871
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/xml_object.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec // XMLObject a metadata object that allows for more fine-tuned XML model definitions. // // For more information: http://goo.gl/8us55a#xmlObject type XMLObject struct { Name string `json:"name,omitempty"` Namespace string `json:"namespace,omitempty"` Prefix string `json:"prefix,omitempty"` Attribute bool `json:"attribute,omitempty"` Wrapped bool `json:"wrapped,omitempty"` } // WithName sets the xml name for the object func (x *XMLObject) WithName(name string) *XMLObject { x.Name = name return x } // WithNamespace sets the xml namespace for the object func (x *XMLObject) WithNamespace(namespace string) *XMLObject { x.Namespace = namespace return x } // WithPrefix sets the xml prefix for the object func (x *XMLObject) WithPrefix(prefix string) *XMLObject { x.Prefix = prefix return x } // AsAttribute flags this object as xml attribute func (x *XMLObject) AsAttribute() *XMLObject { x.Attribute = true return x } // AsElement flags this object as an xml node func (x *XMLObject) AsElement() *XMLObject { x.Attribute = false return x } // AsWrapped flags this object as wrapped, this is mostly useful for array types func (x *XMLObject) AsWrapped() *XMLObject { x.Wrapped = true return x } // AsUnwrapped flags this object as an xml node func (x *XMLObject) AsUnwrapped() *XMLObject { x.Wrapped = false return x }
8,872
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/bindata.go
// Code generated by go-bindata. DO NOT EDIT. // sources: // schemas/jsonschema-draft-04.json (4.357kB) // schemas/v2/schema.json (40.249kB) package spec import ( "bytes" "compress/gzip" "crypto/sha256" "fmt" "io" "io/ioutil" "os" "path/filepath" "strings" "time" ) func bindataRead(data []byte, name string) ([]byte, error) { gz, err := gzip.NewReader(bytes.NewBuffer(data)) if err != nil { return nil, fmt.Errorf("read %q: %v", name, err) } var buf bytes.Buffer _, err = io.Copy(&buf, gz) clErr := gz.Close() if err != nil { return nil, fmt.Errorf("read %q: %v", name, err) } if clErr != nil { return nil, err } return buf.Bytes(), nil } type asset struct { bytes []byte info os.FileInfo digest [sha256.Size]byte } type bindataFileInfo struct { name string size int64 mode os.FileMode modTime time.Time } func (fi bindataFileInfo) Name() string { return fi.name } func (fi bindataFileInfo) Size() int64 { return fi.size } func (fi bindataFileInfo) Mode() os.FileMode { return fi.mode } func (fi bindataFileInfo) ModTime() time.Time { return fi.modTime } func (fi bindataFileInfo) IsDir() bool { return false } func (fi bindataFileInfo) Sys() interface{} { return nil } var _jsonschemaDraft04JSON = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x57\x3d\x6f\xdb\x3c\x10\xde\xf3\x2b\x08\x26\x63\xf2\x2a\x2f\xd0\xc9\x5b\xd1\x2e\x01\x5a\x34\x43\x37\x23\x03\x6d\x9d\x6c\x06\x14\xa9\x50\x54\x60\xc3\xd0\x7f\x2f\x28\x4a\x14\x29\x91\x92\x2d\xa7\x8d\x97\x28\xbc\xaf\xe7\x8e\xf7\xc5\xd3\x0d\x42\x08\x61\x9a\xe2\x15\xc2\x7b\xa5\x8a\x55\x92\xbc\x96\x82\x3f\x94\xdb\x3d\xe4\xe4\x3f\x21\x77\x49\x2a\x49\xa6\x1e\x1e\xbf\x24\xe6\xec\x16\xdf\x1b\xa1\x3b\xf3\xff\x02\xc9\x14\xca\xad\xa4\x85\xa2\x82\x6b\xe9\x6f\x42\x02\x32\x2c\x28\x07\x45\x5a\x15\x3d\x77\x46\x39\xd5\xcc\x25\x5e\x21\x83\xb8\x21\x18\xb6\xaf\x52\x92\xa3\x47\x68\x88\xea\x58\x80\x56\x4e\x1a\xf2\xbd\x4f\xcc\x29\x7f\x52\x90\x6b\x7d\xff\x0f\x48\xb4\x3d\x3f\x21\x7c\x27\x21\xd3\x2a\x6e\x31\xaa\x2d\x53\xdd\xf3\xe3\x42\x94\x54\xd1\x77\x78\xe2\x0a\x76\x20\xe3\x20\x68\xcb\x30\x86\x41\xf3\x2a\xc7\x2b\xf4\x78\x8e\xfe\xef\x90\x91\x8a\xa9\xc7\xb1\x1d\xc2\xd8\x2f\x0d\x75\xed\xc1\x4e\x9c\xc8\x25\x43\xac\xa8\xbe\xd7\xcc\xa9\xd1\xa9\x21\xa0\x1a\xbd\x04\x61\x94\x34\x2f\x18\xfc\x3e\x16\x50\x8e\x4d\x03\x6f\x1c\x58\xdb\x48\x23\xbc\x11\x82\x01\xe1\xfa\xd3\x3a\x8e\x30\xaf\x18\x33\x7f\xf3\x8d\x39\x11\x9b\x57\xd8\x2a\xfd\x55\x2a\x49\xf9\x0e\xc7\xec\x37\xd4\x25\xf7\xec\x5c\x66\xc7\xd7\x99\xaa\xcf\x4f\x89\x8a\xd3\xb7\x0a\x3a\xaa\x92\x15\xf4\x30\x6f\x1c\xb0\xd6\x46\xe7\x98\x39\x2d\xa4\x28\x40\x2a\x3a\x88\x9e\x29\xba\x88\x37\x2d\xca\x60\x38\xfa\xba\x5b\x20\xac\xa8\x62\xb0\x4c\xd4\xaf\xda\x45\x0a\xba\x5c\x3b\xb9\xc7\x79\xc5\x14\x2d\x18\x34\x19\x1c\x51\xdb\x25\x4d\xb4\x7e\x06\x14\x38\x6c\x59\x55\xd2\x77\xf8\x69\x59\xfc\x7b\x73\xed\x93\x43\xcb\x32\x6d\x3c\x28\xdc\x1b\x9a\xd3\x62\xab\xc2\x27\xf7\x41\xc9\x08\x2b\x23\x08\xad\x13\x57\x21\x9c\xd3\x72\x0d\x42\x72\xf8\x01\x7c\xa7\xf6\x83\xce\x39\xd7\x82\x3c\x1f\x2f\xd6\x60\x1b\xa2\xdf\x35\x89\x52\x20\xe7\x73\x74\xe0\x66\x26\x64\x4e\xb4\x97\x58\xc2\x0e\x0e\xe1\x60\x92\x34\x6d\xa0\x10\xd6\xb5\x83\x61\x27\xe6\x47\xd3\x89\xbd\x63\xfd\x3b\x8d\x03\x3d\x6c\x42\x2d\x5b\x70\xee\xe8\xdf\x4b\xf4\x66\x4e\xe1\x01\x45\x17\x80\x74\xad\x4f\xc3\xf3\xae\xc6\x1d\xc6\xd7\xc2\xce\xc9\xe1\x29\x30\x86\x2f\x4a\xa6\x4b\x15\x84\x73\xc9\x6f\xfd\x7f\xa5\x6e\x9e\xbd\xf1\xb0\xd4\xdd\x45\x5a\xc2\x3e\x4b\x78\xab\xa8\x84\x74\x4a\x91\x3b\x92\x23\x05\xf2\x1c\x1e\x7b\xf3\x09\xf8\xcf\xab\x24\xb6\x60\xa2\xe8\x4c\x9f\x75\x77\xaa\x8c\xe6\x01\x45\x36\x86\xcf\xc3\x63\x3a\xea\xd4\x8d\x7e\x06\xac\x14\x0a\xe0\x29\xf0\xed\x07\x22\x1a\x65\xda\x44\xae\xa2\x73\x1a\xe6\x90\x69\xa2\x8c\x46\xb2\x2f\xde\x49\x38\x08\xed\xfe\xfd\x41\xaf\x9f\xa9\x55\xd7\xdd\x22\x8d\xfa\x45\x63\xc5\x0f\x80\xf3\xb4\x08\xd6\x79\x30\x9e\x93\xee\x59\xa6\xd0\x4b\xee\x22\xe3\x33\xc1\x3a\x27\x68\x36\x78\x7e\x87\x0a\x06\xd5\x2e\x20\xd3\xaf\x15\xfb\xd8\x3b\x73\x14\xbb\x92\xed\x05\x5d\x2e\x29\x38\x2c\x94\xe4\x42\x45\x5e\xd3\xb5\x7d\xdf\x47\xca\x38\xb4\x5c\xaf\xfb\x7d\xdd\x6d\xf4\xa1\x2d\x77\xdd\x2f\xce\x6d\xc4\x7b\x8b\x4e\x67\xa9\x6f\xfe\x04\x00\x00\xff\xff\xb1\xd1\x27\x78\x05\x11\x00\x00") func jsonschemaDraft04JSONBytes() ([]byte, error) { return bindataRead( _jsonschemaDraft04JSON, "jsonschema-draft-04.json", ) } func jsonschemaDraft04JSON() (*asset, error) { bytes, err := jsonschemaDraft04JSONBytes() if err != nil { return nil, err } info := bindataFileInfo{name: "jsonschema-draft-04.json", size: 4357, mode: os.FileMode(0644), modTime: time.Unix(1567900649, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe1, 0x48, 0x9d, 0xb, 0x47, 0x55, 0xf0, 0x27, 0x93, 0x30, 0x25, 0x91, 0xd3, 0xfc, 0xb8, 0xf0, 0x7b, 0x68, 0x93, 0xa8, 0x2a, 0x94, 0xf2, 0x48, 0x95, 0xf8, 0xe4, 0xed, 0xf1, 0x1b, 0x82, 0xe2}} return a, nil } var _v2SchemaJSON = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x5d\x4f\x93\xdb\x36\xb2\xbf\xfb\x53\xa0\x14\x57\xd9\xae\xd8\x92\xe3\xf7\x2e\xcf\x97\xd4\xbc\xd8\x49\x66\x37\x5e\x4f\x79\x26\xbb\x87\x78\x5c\x05\x91\x2d\x09\x09\x09\x30\x00\x38\x33\x5a\xef\x7c\xf7\x2d\xf0\x9f\x08\x02\x20\x41\x8a\xd2\xc8\x0e\x0f\xa9\x78\x28\xa0\xd1\xdd\x68\x34\x7e\xdd\xf8\xf7\xf9\x11\x42\x33\x49\x64\x04\xb3\xd7\x68\x76\x86\xfe\x76\xf9\xfe\x1f\xe8\x32\xd8\x40\x8c\xd1\x8a\x71\x74\x79\x8b\xd7\x6b\xe0\xe8\xd5\xfc\x25\x3a\xbb\x38\x9f\xcf\x9e\xab\x0a\x24\x54\xa5\x37\x52\x26\xaf\x17\x0b\x91\x17\x99\x13\xb6\xb8\x79\xb5\x10\x59\xdd\xf9\xef\x82\xd1\x6f\xf2\xc2\x8f\xf3\x4f\xb5\x1a\xea\xc7\x17\x45\x41\xc6\xd7\x8b\x90\xe3\x95\x7c\xf1\xf2\x7f\x8b\xca\x45\x3d\xb9\x4d\x32\xa6\xd8\xf2\x77\x08\x64\xfe\x8d\xc3\x9f\x29\xe1\xa0\x9a\xff\xed\x11\x42\x08\xcd\x8a\xd6\xb3\x9f\x15\x67\x74\xc5\xca\x7f\x27\x58\x6e\xc4\xec\x11\x42\xd7\x59\x5d\x1c\x86\x44\x12\x46\x71\x74\xc1\x59\x02\x5c\x12\x10\xb3\xd7\x68\x85\x23\x01\x59\x81\x04\x4b\x09\x9c\x6a\xbf\x7e\xce\x49\x7d\xba\x7b\x51\xfd\xa1\x44\xe2\xb0\x52\xac\x7d\xb3\x08\x61\x45\x68\x46\x56\x2c\x6e\x80\x86\x8c\xbf\xbd\x93\x40\x05\x61\x74\x96\x95\xbe\x7f\x84\xd0\x7d\x4e\xde\x42\xb7\xe4\xbe\x46\xbb\x14\x5b\x48\x4e\xe8\xba\x90\x05\xa1\x19\xd0\x34\xae\xc4\xce\xbe\xbc\x9a\xbf\x9c\x15\x7f\x5d\x57\xc5\x42\x10\x01\x27\x89\xe2\x48\x51\xb9\xda\x40\xd5\x87\x37\xc0\x15\x5f\x88\xad\x90\xdc\x10\x81\x42\x16\xa4\x31\x50\x39\x2f\x38\xad\xab\xb0\x53\xd8\xac\x94\x56\x6f\xc3\x84\xf4\x11\xa4\x50\xb3\xfa\xe9\xd3\x6f\x9f\x3e\xdf\x2f\xd0\xeb\x8f\x1f\x3f\x7e\xbc\xfe\xf6\xe9\xf7\xaf\x5f\x7f\xfc\x18\x7e\xfb\xec\xfb\xc7\xb3\x36\x79\x54\x43\xe8\x29\xc5\x31\x20\xc6\x11\x49\x9e\xe5\x12\x41\x66\xa0\xe8\xed\x1d\x8e\x93\x08\x5e\xa3\x27\x3b\xc3\x7c\xa2\x73\xba\xc4\x02\x2e\xb0\xdc\xf4\xe5\x76\xd1\xca\x96\xa2\x8a\x94\xcd\x21\xc9\x6c\xec\x2c\x70\x42\x9e\x34\x74\x9d\x19\x7c\xcd\x20\x9c\xea\x2e\x0a\xfe\x42\x84\xd4\x29\x04\x8c\x8a\xb4\x41\xa2\xc1\xdc\x19\x8a\x88\x90\x4a\x49\xef\xce\xdf\xbd\x45\x4a\x52\x81\x70\x10\x40\x22\x21\x44\xcb\x6d\xc5\xec\x4e\x3c\x1c\x45\xef\x57\x9a\xb5\x7d\xae\xfe\xe5\xe4\x31\x86\x90\xe0\xab\x6d\x02\x3b\x2e\xcb\x11\x90\xd9\xa8\xc6\x77\xc2\x59\x98\x06\xfd\xf9\x2e\x78\x45\x01\xa6\xa8\xa0\x71\x5c\xbe\x33\xa7\xd2\xd9\x5f\x95\xef\xd9\xd5\xac\xfd\xdc\x5d\xbf\x5e\xb8\xd1\x3e\xc7\x31\x48\xe0\x5e\x4c\x14\x65\xdf\xb8\xa8\x71\x10\x09\xa3\xc2\xc7\x02\xcb\xa2\x4e\x5a\x02\x82\x94\x13\xb9\xf5\x30\xe6\xb2\xa4\xb5\xfe\x9b\x3e\x7a\xb2\x55\xd2\xa8\x4a\xbc\x16\xb6\x71\x8e\x39\xc7\xdb\x9d\xe1\x10\x09\x71\xbd\x9c\xb3\x41\x89\xd7\xa5\x89\xdc\x57\xb5\x53\x4a\xfe\x4c\xe1\xbc\xa0\x21\x79\x0a\x1a\x0f\x70\xa7\x5c\x08\x8e\xde\xb0\xc0\x43\x24\xad\x74\x63\x0e\xb1\xd9\x90\xe1\xb0\x2d\x13\xa7\x6d\x78\xfd\x04\x14\x38\x8e\x90\xaa\xce\x63\xac\x3e\x23\xbc\x64\xa9\xb4\xf8\x03\x63\xde\xcd\xbe\x16\x13\x4a\x55\xac\x82\x12\xc6\xac\xd4\x35\xf7\x22\xd4\x3a\xff\x22\x73\x0e\x6e\x51\xa0\x75\x1e\xae\x8f\xe8\x5d\xc7\x59\xe6\xe4\x9a\x18\x8d\xd6\x1c\x53\x84\x4d\xb7\x67\x28\x37\x09\x84\x69\x88\x12\x0e\x01\x11\x80\x32\xa2\xf5\xb9\xaa\xc6\xd9\x73\x53\xab\xfb\xb4\x2e\x20\xc6\x54\x92\xa0\x9a\xf3\x69\x1a\x2f\x81\x77\x37\xae\x53\x1a\xce\x40\xc4\xa8\x82\x1c\xb5\xef\xda\x24\x7d\xb9\x61\x69\x14\xa2\x25\xa0\x90\xac\x56\xc0\x81\x4a\xb4\xe2\x2c\xce\x4a\x64\x7a\x9a\x23\xf4\x13\x91\x3f\xa7\x4b\xf4\x63\x84\x6f\x18\x87\x10\xbd\xc3\xfc\x8f\x90\xdd\x52\x44\x04\xc2\x51\xc4\x6e\x21\x74\x48\x21\x81\xc7\xe2\xfd\xea\x12\xf8\x0d\x09\xf6\xe9\x47\x35\xaf\x67\xc4\x14\xf7\x22\x27\x97\xe1\xe2\x76\x2d\x06\x8c\x4a\x1c\x48\x3f\x73\x2d\x0b\x5b\x29\x45\x24\x00\x2a\x0c\x11\xec\x94\xca\xc2\xa6\xc1\x37\x21\x43\x83\x3b\x5f\x97\xf1\x43\x5e\x53\x73\x19\xa5\x36\xd8\x2d\x05\x2e\x34\x0b\xeb\x39\xfc\x1d\x63\x51\x01\xbd\x3d\xbb\x90\x84\x40\x25\x59\x6d\x09\x5d\xa3\x1c\x37\xe6\x5c\x16\x9a\x40\x09\x70\xc1\xe8\x82\xf1\x35\xa6\xe4\xdf\x99\x5c\x8e\x9e\x4d\x79\xb4\x27\x2f\xbf\x7e\xf8\x05\x25\x8c\x50\xa9\x98\x29\x90\x62\x60\xea\x75\xae\x13\xca\xbf\x2b\x1a\x29\x27\x76\xd6\x20\xc6\x64\x5f\xe6\x32\x1a\x08\x87\x21\x07\x21\xbc\xb4\xe4\xe0\x32\x67\xa6\xcd\xf3\x1e\xcd\xd9\x6b\xb6\x6f\x8e\x27\xa7\xed\xdb\xe7\xbc\xcc\x1a\x07\xce\x6f\x87\x33\xf0\xba\x51\x17\x22\x66\x78\x79\x8e\xce\xe5\x13\x81\x80\x06\x2c\xe5\x78\x0d\xa1\xb2\xb8\x54\xa8\x79\x09\xbd\xbf\x3c\x47\x01\x8b\x13\x2c\xc9\x32\xaa\xaa\x1d\xd5\xee\xab\x36\xbd\x6c\xfd\x54\x6c\xc8\x08\x01\x3c\xbd\xe7\x07\x88\xb0\x24\x37\x79\x90\x28\x4a\x1d\x10\x1a\x92\x1b\x12\xa6\x38\x42\x40\xc3\x4c\x43\x62\x8e\xae\x36\xb0\x45\x71\x2a\xa4\x9a\x23\x79\x59\xb1\xa8\xf2\xa4\x0c\x60\x9f\xcc\x8d\x40\xf5\x80\xca\xa8\x99\xc3\xa7\x85\x1f\x31\x25\xa9\x82\xc5\x6d\xbd\xd8\x36\x76\x7c\x02\x28\x97\xf6\x1d\x74\x3b\x11\x7e\x91\xae\x32\xf8\x6c\xf4\xe6\x7b\x9a\xa5\x1f\x62\xc6\x21\xcf\x9a\xe5\xed\x8b\x02\xf3\x2c\x33\x33\xdf\x00\xca\xc9\x09\xb4\x04\xf5\xa5\x08\xd7\xc3\x02\x18\x66\xf1\xab\x1e\x83\x37\x4c\xcd\x12\xc1\x1d\x50\xf6\xaa\xbd\xfe\xe2\x73\x48\x38\x08\xa0\x32\x9b\x18\x44\x86\x0b\x6a\xc1\xaa\x26\x96\x2d\x96\x3c\xa0\x54\x65\x73\x87\x15\xca\x15\xe5\xf5\x94\x46\x9f\x33\x1a\x0c\x9a\xb1\x5a\xd9\x6a\x95\xcd\xcb\x7e\xec\x9a\xc5\x94\x3b\x37\x26\x31\xd7\xfc\xe4\x1f\x13\x8c\x31\x75\x9c\xba\xf7\x87\x3c\xa1\xb7\x4f\x17\x1b\x09\x82\x98\xc4\x70\x95\xd3\xe8\x4c\x48\x5a\xa6\xd6\x2a\x3d\x56\x42\x80\x9f\xaf\xae\x2e\x50\x0c\x42\xe0\x35\x34\x3c\x8a\x62\x03\x37\xba\xb2\x27\x04\xda\x25\x8d\x06\xe2\xa0\x13\x8a\xf3\xf5\xec\x10\x72\x67\x88\x90\x3d\x4b\x64\xeb\xaa\xda\x8f\xf7\x5a\x75\x47\x9a\xa8\x51\x70\x26\xd2\x38\xc6\x7c\xbb\x57\xfc\xbd\xe4\x04\x56\xa8\xa0\x54\x9a\x45\xd5\xf7\x0f\x16\xfc\x57\x1c\x3c\xdf\x23\xba\x77\x38\xda\x16\x4b\x31\x53\x6a\x4d\x9a\x15\x63\xe7\xe1\x18\x69\x9f\x22\xe0\x24\xbb\x94\x4b\x97\xee\x2d\xf9\x70\x87\x72\x7b\xe6\xc4\x33\x2a\x66\x5e\x1c\x35\x72\xe3\x2d\xda\x73\xe4\xc7\x51\x6d\xa4\xa1\x2a\x4f\xde\x94\xcb\xb2\x3e\x31\x48\xae\x82\xce\xc9\xc8\x65\xcd\xc3\xb7\x34\xb6\x2b\xdf\x58\x65\x78\x6e\x73\xac\x5e\x24\x0d\x3f\xdc\x70\x23\xc6\xda\x52\x0b\x2d\x63\x7d\xa9\x49\x2d\x54\x48\x28\xc0\x12\x9c\xe3\x63\xc9\x58\x04\x98\x36\x07\xc8\x0a\xa7\x91\xd4\xf0\xbc\xc1\xa8\xb9\x70\xd0\xc6\xa9\xb6\x78\x80\x5a\xa3\xb4\x2c\xf4\x18\x0b\x8a\x9d\xd0\xb4\x55\x10\xee\x0d\xc5\xd6\xe0\x99\x93\xdc\xa1\x04\xbb\xf1\xa7\x23\xd1\xd1\x97\x8c\x87\x13\x0a\x21\x02\xe9\x99\x25\xed\x20\xc5\x92\x66\x3c\x32\x9c\xd6\x06\xb0\x31\x5c\x86\x29\x0a\xcb\x60\x33\x12\xa5\x91\xfc\x96\x75\xd0\x59\xd7\x13\xbd\xd3\x23\x79\xdd\x2a\x90\xa6\x38\x06\x91\x39\x7f\x20\x72\x03\x1c\x2d\x01\x61\xba\x45\x37\x38\x22\x61\x8e\x71\x85\xc4\x32\x15\x28\x60\x61\x16\xb8\x3d\x29\xdc\x4d\x3d\x2f\x12\x13\x7d\xc8\x7e\x37\xee\xa8\x7f\xfa\xdb\xcb\x17\xff\x77\xfd\xf9\x7f\xee\x9f\x3d\xfe\xcf\xa7\xa7\x45\xfb\xcf\x1e\xf7\xf3\xe0\xff\xc4\x51\x0a\x8e\x4c\xcb\x01\xdc\x0a\x65\xb2\x01\x83\xed\x3d\xe4\xa9\xa3\x4e\x2d\x59\xc5\xe8\x2f\x48\x7d\x5a\x6e\x37\xbf\x5c\x9f\x35\x13\x64\x14\xfa\xef\x0b\x68\xa6\x0d\xb4\x8e\xf1\xa8\xff\xbb\x60\xf4\x03\x64\xab\x5b\x81\x65\x51\xe6\xda\xca\xfa\xf0\xb0\xac\x3e\x9c\xca\x26\x0e\x1d\xdb\x57\x5b\xbb\xb4\x9a\xa6\xb6\x9b\x1a\x6b\xd1\x9a\x9e\x7e\x33\x9a\xec\x41\x69\x45\x22\xb8\xb4\x51\xeb\x04\x77\xca\x6f\x7b\x7b\xc8\xb2\xb0\x95\x92\x25\x5b\xd0\x42\xaa\x2a\xdd\x32\x78\x4f\x0c\xab\x68\x46\x6c\xea\x6d\xf4\x5c\x5e\xde\xc4\xac\xa5\xf9\xd1\x00\x9f\x7d\x98\x65\x24\xbd\xc7\x97\xd4\xb3\x3a\xa8\x2b\xa0\x34\x76\xf9\x65\x5f\x2d\x25\x95\x1b\xcf\xd6\xf4\x9b\x5f\x09\x95\xb0\x36\x3f\xdb\xd0\x39\x2a\x93\x1c\x9d\x03\xa2\x4a\xca\xf5\xf6\x10\xb6\x94\x89\x0b\x6a\x70\x12\x13\x49\x6e\x40\xe4\x29\x12\x2b\xbd\x80\x45\x11\x04\xaa\xc2\x8f\x56\x9e\x5c\x6b\xec\x8d\x5a\x0e\x14\x59\x06\x2b\x1e\x24\xcb\xc2\x56\x4a\x31\xbe\x23\x71\x1a\xfb\x51\x2a\x0b\x3b\x1c\x48\x10\xa5\x82\xdc\xc0\xbb\x3e\x24\x8d\x5a\x76\x2e\x09\xed\xc1\x65\x51\xb8\x83\xcb\x3e\x24\x8d\x5a\x2e\x5d\xfe\x02\x74\x2d\x3d\xf1\xef\xae\xb8\x4b\xe6\x5e\xd4\xaa\xe2\x2e\x5c\x5e\xec\x0e\xf5\x5b\x0c\xcb\x0a\xbb\xa4\x3c\xf7\x1f\x2a\x55\x69\x97\x8c\x7d\x68\x95\xa5\xad\xb4\xf4\x9c\xa5\x07\xb9\x7a\x05\xbb\xad\x50\x6f\xfb\xa0\x4e\x9b\x48\x23\x49\x92\x28\x87\x19\x3e\x32\xee\xca\x3b\x46\x7e\x7f\x18\x64\xcc\xcc\x0f\x34\xe9\x36\x8b\xb7\x6c\xa8\xa5\x5b\x54\x4c\x54\x5b\x15\x3a\xf1\x6c\x2d\xfe\x96\xc8\x0d\xba\x7b\x81\x88\xc8\x23\xab\xee\x7d\x3b\x92\xa7\x60\x29\xe3\xdc\xff\xb8\x64\xe1\xf6\xa2\x5a\x59\xdc\x6f\xeb\x45\x7d\x6a\xd1\x76\x1e\xea\xb8\xf1\xfa\x14\xd3\x36\x63\xe5\xd7\xf3\xe4\xbe\x25\xbd\x5e\x05\xeb\x73\x74\xb5\x21\x2a\x2e\x4e\xa3\x30\xdf\xbf\x43\x28\x2a\xd1\xa5\x2a\x9d\x8a\xfd\x76\xd8\x8d\xbc\x67\x65\xc7\xb8\x03\x45\xec\xa3\xb0\x37\x8a\x70\x4c\x68\x91\x51\x8e\x58\x80\xed\x4a\xf3\x81\x62\xca\x96\xbb\xf1\x52\xcd\x80\xfb\xe4\x4a\x5d\x6c\xdf\x6e\x20\x4b\x80\x30\x8e\x28\x93\xf9\xe9\x8d\x8a\x6d\xd5\x59\x65\x7b\xaa\x44\x9e\xc0\xc2\xd1\x7c\x40\x26\xd6\x1a\xce\xf9\xc5\x69\x7b\x6c\xec\xc8\x71\x7b\xe5\x21\x2e\xd3\xe5\x65\x93\x91\x53\x0b\x7b\x3a\xc7\xfa\x17\x6a\x01\xa7\x33\xd0\xf4\x40\x0f\x39\x87\xda\xe4\x54\x87\x3a\xd5\xe3\xc7\xa6\x8e\x20\xd4\x11\xb2\x4e\xb1\xe9\x14\x9b\x4e\xb1\xe9\x14\x9b\xfe\x15\x63\xd3\x47\xf5\xff\x97\x38\xe9\xcf\x14\xf8\x76\x82\x49\x13\x4c\xaa\x7d\xcd\x6c\x62\x42\x49\x87\x43\x49\x19\x33\x6f\xe3\x44\x6e\x9b\xab\x8a\x3e\x86\xaa\x99\x52\x1b\x5b\x59\x33\x02\x09\xa0\x21\xa1\x6b\x84\x6b\x66\xbb\xdc\x16\x0c\xd3\x68\xab\xec\x36\x4b\xd8\x60\x8a\x40\x31\x85\x6e\x14\x57\x13\xc2\xfb\x92\x10\xde\xbf\x88\xdc\xbc\x53\x5e\x7f\x82\x7a\x13\xd4\x9b\xa0\xde\x04\xf5\x90\x01\xf5\x94\xcb\x7b\x83\x25\x9e\xd0\xde\x84\xf6\x6a\x5f\x4b\xb3\x98\x00\xdf\x04\xf8\x6c\xbc\x7f\x19\x80\xaf\xf1\x71\x45\x22\x98\x40\xe0\x04\x02\x27\x10\xd8\x29\xf5\x04\x02\xff\x4a\x20\x30\xc1\x72\xf3\x65\x02\x40\xd7\xc1\xd1\xe2\x6b\xf1\xa9\x7b\xfb\xe4\x20\xc0\x68\x9d\xd4\xb4\xd3\x96\xb5\xa6\xd1\x41\x20\xe6\x89\xc3\x48\x65\x58\x13\x84\x9c\x56\x56\x3b\x0c\xe0\x6b\x83\x5c\x13\xd2\x9a\x90\xd6\x84\xb4\x26\xa4\x85\x0c\xa4\x45\x19\xfd\xff\x63\x6c\x52\xb5\x1f\x1e\x19\x74\x3a\xcd\xb9\x69\xce\xa6\x3a\x0f\x7a\x2d\x19\xc7\x81\x14\x5d\xcb\xd5\x03\xc9\x39\xd0\xb0\xd1\xb3\xcd\xfb\x7a\x2d\x5d\x3a\x48\xe1\xfa\x2e\xe6\x81\x42\x18\x86\xd6\xc1\xbe\xb1\x23\xd3\xf7\x34\xed\x19\x0a\x0b\xc4\x48\x44\xfd\x22\x50\xb6\x42\x58\xbb\xe5\x3d\xa7\x73\xd4\x8b\xc4\x8c\x70\x61\xec\x73\xee\xc3\x81\x8b\xf5\xe2\xd7\x52\x3e\xcf\xeb\xeb\x17\x3b\x71\x16\xda\x7d\xb8\xde\xf0\x7a\x8f\x06\x2d\xa7\x40\x7b\xc1\x9d\x41\x4d\xb6\x61\xa2\x4e\x9f\x3d\xa0\xc5\xae\xe3\x1c\x1d\x40\x6c\x48\x8b\x63\xa0\xb5\x01\xed\x8e\x02\xe9\x86\xc8\x3b\x06\xee\xdb\x4b\xde\xbd\xc0\xa1\x6f\xcb\xda\xfc\xc2\x44\x16\x87\x9c\x17\x31\xd3\x30\x20\x39\x42\xcb\x6f\xf2\xf1\xf4\x72\x10\xf8\x1c\xa0\xf3\xbd\x10\xea\x21\x35\x7d\xe8\x86\xdb\x15\xed\x81\x81\x07\x28\xbb\x13\x28\xc7\xf8\xce\x7d\x8d\xc2\x31\xb4\x7e\x94\xd6\xdb\x55\xef\x4a\xfb\xed\xc3\x40\x3e\xeb\x9f\xe9\x99\x0f\xdf\x08\x65\x88\x27\x73\x86\x31\x9d\x47\xdf\x55\x19\xba\x3d\xee\x15\x0a\xcd\x8c\xaa\x5e\xb9\xf6\x57\x33\x73\x5a\xa1\x89\x7b\x3b\xa0\xb2\xa4\xc2\xf6\xc1\x53\xb5\x00\xca\x23\xe5\xf4\x60\x6a\xb4\x2d\x74\xea\x4e\xed\x3b\xe3\x47\xfb\xed\x82\x3d\x19\xd4\x3b\x6b\xaf\xae\x2b\x2f\x57\xb3\x82\x68\xcb\xed\x88\x2e\xe1\x5c\xd7\x26\xfa\x0a\x65\xe7\xce\x11\x33\xb4\xdd\x66\xe3\x37\xf6\xfa\x70\xd6\x4f\xa1\x21\x51\xd8\x3c\x26\x14\x4b\xc6\x87\x44\x27\x1c\x70\xf8\x9e\x46\xce\xab\x21\x07\x5f\xc1\x76\x17\x1b\x77\xb4\xda\x75\xa0\x0a\x3a\x30\xe1\xf8\x97\x32\x16\x2b\x00\x75\x85\xee\x62\x46\xef\xd3\x85\xb5\x6b\x60\xbe\xf2\x30\x7a\x8c\x0b\x4b\xa6\xd0\xf9\x64\x42\xe7\x07\x41\x41\xe3\x2c\x5d\xf9\x6d\xe9\x39\x98\x3b\x3b\x5d\x67\xd4\x5c\xed\xf2\xf0\x48\x7b\xbd\x2d\x31\xdd\x3f\x34\xad\x44\x76\x51\x9a\x56\x22\xa7\x95\xc8\x69\x25\xf2\xe1\x56\x22\x1f\x00\x32\x6a\x73\x92\xed\xe1\xc6\x7d\x9f\x49\x2c\x69\x7e\xc8\x31\x4c\x0c\xb4\xf2\x54\x3b\x79\x3b\x9e\x4d\xb4\xd1\x18\x3e\x5f\x9a\x93\xa2\x11\xc3\xda\x27\x0b\xaf\x37\x2e\x5c\x37\xfb\xeb\x9a\xd6\xc3\xac\xc3\xcc\xf8\x1e\x5b\x9d\xac\x22\x64\xb7\xed\x26\xb8\xf3\xb9\x3c\xbb\x1f\xe2\xb0\x22\x77\x43\x6a\x62\x29\x39\x59\xa6\xe6\xe5\xcd\x7b\x83\xc0\x5b\x8e\x93\x64\xac\xeb\xca\x4f\x65\xac\x4a\xbc\x1e\xcd\x82\xfa\x3c\x70\x36\xb6\xb5\xed\x79\xef\xec\x68\x00\xff\x54\xfa\xb5\xe3\xf1\xdb\xe1\xbe\xce\x76\x17\xaf\x57\xb6\x6b\x89\x05\x09\xce\x52\xb9\x01\x2a\x49\xbe\xd9\xf4\xd2\xb8\x7a\xbf\x91\x02\xf3\x22\x8c\x13\xf2\x77\xd8\x8e\x43\x8b\xe1\x54\x6e\x5e\x9d\xc7\x49\x44\x02\x22\xc7\xa4\x79\x81\x85\xb8\x65\x3c\x1c\x93\xe6\x59\xa2\xf8\x1c\x51\x95\x05\xd9\x20\x00\x21\x7e\x60\x21\x58\xa9\x56\xff\xbe\xb6\x5a\x5e\x5b\x3f\x1f\xd6\xd3\x3c\xc4\x4d\xba\x99\xb4\x63\x6e\x7d\x3e\x3d\x57\xd2\x18\x5f\x47\xe8\xc3\x06\x8a\x68\x6c\x7f\x3b\x72\x0f\xe7\xe2\x77\x77\xf1\xd0\x99\xab\xdf\x2e\xfe\xd6\xbb\xcd\x1a\xb9\x90\xd1\xaf\xf2\x38\x3d\xdb\x74\xf8\xeb\xe3\xda\xe8\x2a\x62\xb7\xda\x1b\x07\xa9\xdc\x30\x5e\xbc\x68\xfb\x6b\x9f\x97\xf1\xc6\xb1\xd8\x5c\x29\x1e\x49\x30\xc5\xf7\xde\xad\x91\x42\xf9\xdd\xed\x89\x80\x25\xbe\x37\xd7\xe7\x32\x5c\xe6\x35\xac\xd4\x0c\x2d\xf7\x90\xc4\xe3\xf5\xe3\x2f\x7f\x54\x18\x88\xe3\x61\x47\x85\x64\x7f\xc0\xd7\x3f\x1a\x92\x42\xe9\xc7\x1e\x0d\x95\x76\xa7\x51\xa0\x8f\x02\x1b\x46\x9e\x06\x42\xd1\xf2\x01\x07\x02\xde\xe9\x7d\x1a\x0b\xa7\x32\x16\xcc\xc0\xee\xc4\x90\xd2\x5f\x6f\x98\x54\x5d\xf2\x95\xe1\xa7\x69\x10\x3a\x06\xe1\x65\xb3\x17\x47\x58\x78\xd0\x45\xd6\x5b\xd5\x5f\x25\x1d\x71\x49\xa6\x7a\x64\xda\xd0\x6f\xc7\x3a\x4c\xe3\x09\xc0\x6e\x96\x2c\xa7\xa7\x77\x34\x10\x05\x08\x21\x44\x92\x65\x77\xdf\x20\x5c\xbc\xe7\x97\x3f\xf4\x1a\x45\xd6\xe7\x27\x4a\xde\x74\x27\x66\x11\x7d\x70\xba\xd3\x78\xf9\x1e\x0d\xca\xc8\x39\xde\x7c\xb3\xa6\xe1\xbc\xd7\xc1\x6a\x6f\xb3\x0e\x52\xbe\xe4\x98\x8a\x15\x70\x94\x70\x26\x59\xc0\xa2\xf2\x1c\xfb\xd9\xc5\xf9\xbc\xd5\x92\x9c\xa3\xdf\xe6\x1e\xb3\x0d\x49\xba\x87\x50\x5f\x84\xfe\xe9\xd6\xf8\xbb\xe6\xf0\x7a\xeb\xa6\x65\x3b\x86\x8b\x79\x93\xf5\x59\x20\x6e\xb4\xa7\x44\xf4\x3f\xa5\xfe\x67\x42\x12\xdb\xd3\xe7\xbb\xa5\xa3\x8c\x5c\x2b\x97\xbb\xbb\x7f\x8e\xc5\x6e\xed\x43\x5c\xbf\x74\xc8\x8f\xff\xe6\xd6\xbe\x91\xb6\xf5\x95\xe4\xed\x93\xc4\xa8\x5b\xf9\x76\x4d\x35\xb7\xd8\x8c\xb6\x7d\xaf\x72\xe0\xb6\xbd\x01\x63\x9e\x76\xab\x1a\x32\x76\xe4\x8c\x76\xc2\xad\x6c\xa2\x65\xf7\xcf\xf8\xa7\xda\x2a\xb9\x8c\x3d\x3c\xa3\x9d\x64\x33\xe5\x1a\xb5\x2d\xfb\x86\xa2\x5a\x7f\x19\x5b\x7f\xc6\x3f\xd1\x53\xd3\xe2\x41\x5b\xd3\x4f\xf0\xec\xb0\x42\x73\x43\xd2\x68\x27\xd3\x6a\x6a\x34\xf6\x4e\x1e\x52\x8b\x87\x6c\xcc\xae\x44\xfb\x9e\xa7\x51\x4f\x9d\x55\x03\x81\x8e\x67\xfc\xb4\x69\xf0\x3a\x18\xf2\x40\xd0\xf6\xa8\x34\xe3\xc9\x98\xaf\xf6\xda\x24\xd3\xeb\x60\xb9\x0e\xd3\x1f\xa9\xff\xee\x1f\xfd\x37\x00\x00\xff\xff\x69\x5d\x0a\x6a\x39\x9d\x00\x00") func v2SchemaJSONBytes() ([]byte, error) { return bindataRead( _v2SchemaJSON, "v2/schema.json", ) } func v2SchemaJSON() (*asset, error) { bytes, err := v2SchemaJSONBytes() if err != nil { return nil, err } info := bindataFileInfo{name: "v2/schema.json", size: 40249, mode: os.FileMode(0644), modTime: time.Unix(1567900649, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xcb, 0x25, 0x27, 0xe8, 0x46, 0xae, 0x22, 0xc4, 0xf4, 0x8b, 0x1, 0x32, 0x4d, 0x1f, 0xf8, 0xdf, 0x75, 0x15, 0xc8, 0x2d, 0xc7, 0xed, 0xe, 0x7e, 0x0, 0x75, 0xc0, 0xf9, 0xd2, 0x1f, 0x75, 0x57}} return a, nil } // Asset loads and returns the asset for the given name. // It returns an error if the asset could not be found or // could not be loaded. func Asset(name string) ([]byte, error) { canonicalName := strings.Replace(name, "\\", "/", -1) if f, ok := _bindata[canonicalName]; ok { a, err := f() if err != nil { return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) } return a.bytes, nil } return nil, fmt.Errorf("Asset %s not found", name) } // AssetString returns the asset contents as a string (instead of a []byte). func AssetString(name string) (string, error) { data, err := Asset(name) return string(data), err } // MustAsset is like Asset but panics when Asset would return an error. // It simplifies safe initialization of global variables. func MustAsset(name string) []byte { a, err := Asset(name) if err != nil { panic("asset: Asset(" + name + "): " + err.Error()) } return a } // MustAssetString is like AssetString but panics when Asset would return an // error. It simplifies safe initialization of global variables. func MustAssetString(name string) string { return string(MustAsset(name)) } // AssetInfo loads and returns the asset info for the given name. // It returns an error if the asset could not be found or // could not be loaded. func AssetInfo(name string) (os.FileInfo, error) { canonicalName := strings.Replace(name, "\\", "/", -1) if f, ok := _bindata[canonicalName]; ok { a, err := f() if err != nil { return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) } return a.info, nil } return nil, fmt.Errorf("AssetInfo %s not found", name) } // AssetDigest returns the digest of the file with the given name. It returns an // error if the asset could not be found or the digest could not be loaded. func AssetDigest(name string) ([sha256.Size]byte, error) { canonicalName := strings.Replace(name, "\\", "/", -1) if f, ok := _bindata[canonicalName]; ok { a, err := f() if err != nil { return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s can't read by error: %v", name, err) } return a.digest, nil } return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s not found", name) } // Digests returns a map of all known files and their checksums. func Digests() (map[string][sha256.Size]byte, error) { mp := make(map[string][sha256.Size]byte, len(_bindata)) for name := range _bindata { a, err := _bindata[name]() if err != nil { return nil, err } mp[name] = a.digest } return mp, nil } // AssetNames returns the names of the assets. func AssetNames() []string { names := make([]string, 0, len(_bindata)) for name := range _bindata { names = append(names, name) } return names } // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ "jsonschema-draft-04.json": jsonschemaDraft04JSON, "v2/schema.json": v2SchemaJSON, } // AssetDir returns the file names below a certain // directory embedded in the file by go-bindata. // For example if you run go-bindata on data/... and data contains the // following hierarchy: // data/ // foo.txt // img/ // a.png // b.png // then AssetDir("data") would return []string{"foo.txt", "img"}, // AssetDir("data/img") would return []string{"a.png", "b.png"}, // AssetDir("foo.txt") and AssetDir("notexist") would return an error, and // AssetDir("") will return []string{"data"}. func AssetDir(name string) ([]string, error) { node := _bintree if len(name) != 0 { canonicalName := strings.Replace(name, "\\", "/", -1) pathList := strings.Split(canonicalName, "/") for _, p := range pathList { node = node.Children[p] if node == nil { return nil, fmt.Errorf("Asset %s not found", name) } } } if node.Func != nil { return nil, fmt.Errorf("Asset %s not found", name) } rv := make([]string, 0, len(node.Children)) for childName := range node.Children { rv = append(rv, childName) } return rv, nil } type bintree struct { Func func() (*asset, error) Children map[string]*bintree } var _bintree = &bintree{nil, map[string]*bintree{ "jsonschema-draft-04.json": &bintree{jsonschemaDraft04JSON, map[string]*bintree{}}, "v2": &bintree{nil, map[string]*bintree{ "schema.json": &bintree{v2SchemaJSON, map[string]*bintree{}}, }}, }} // RestoreAsset restores an asset under the given directory. func RestoreAsset(dir, name string) error { data, err := Asset(name) if err != nil { return err } info, err := AssetInfo(name) if err != nil { return err } err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) if err != nil { return err } err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) if err != nil { return err } return os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) } // RestoreAssets restores an asset under the given directory recursively. func RestoreAssets(dir, name string) error { children, err := AssetDir(name) // File if err != nil { return RestoreAsset(dir, name) } // Dir for _, child := range children { err = RestoreAssets(dir, filepath.Join(name, child)) if err != nil { return err } } return nil } func _filePath(dir, name string) string { canonicalName := strings.Replace(name, "\\", "/", -1) return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...) }
8,873
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/LICENSE
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8,874
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/external_docs.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec // ExternalDocumentation allows referencing an external resource for // extended documentation. // // For more information: http://goo.gl/8us55a#externalDocumentationObject type ExternalDocumentation struct { Description string `json:"description,omitempty"` URL string `json:"url,omitempty"` }
8,875
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/ref.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "bytes" "encoding/gob" "encoding/json" "net/http" "os" "path/filepath" "github.com/go-openapi/jsonreference" ) // Refable is a struct for things that accept a $ref property type Refable struct { Ref Ref } // MarshalJSON marshals the ref to json func (r Refable) MarshalJSON() ([]byte, error) { return r.Ref.MarshalJSON() } // UnmarshalJSON unmarshalss the ref from json func (r *Refable) UnmarshalJSON(d []byte) error { return json.Unmarshal(d, &r.Ref) } // Ref represents a json reference that is potentially resolved type Ref struct { jsonreference.Ref } // RemoteURI gets the remote uri part of the ref func (r *Ref) RemoteURI() string { if r.String() == "" { return r.String() } u := *r.GetURL() u.Fragment = "" return u.String() } // IsValidURI returns true when the url the ref points to can be found func (r *Ref) IsValidURI(basepaths ...string) bool { if r.String() == "" { return true } v := r.RemoteURI() if v == "" { return true } if r.HasFullURL { rr, err := http.Get(v) if err != nil { return false } return rr.StatusCode/100 == 2 } if !(r.HasFileScheme || r.HasFullFilePath || r.HasURLPathOnly) { return false } // check for local file pth := v if r.HasURLPathOnly { base := "." if len(basepaths) > 0 { base = filepath.Dir(filepath.Join(basepaths...)) } p, e := filepath.Abs(filepath.ToSlash(filepath.Join(base, pth))) if e != nil { return false } pth = p } fi, err := os.Stat(filepath.ToSlash(pth)) if err != nil { return false } return !fi.IsDir() } // Inherits creates a new reference from a parent and a child // If the child cannot inherit from the parent, an error is returned func (r *Ref) Inherits(child Ref) (*Ref, error) { ref, err := r.Ref.Inherits(child.Ref) if err != nil { return nil, err } return &Ref{Ref: *ref}, nil } // NewRef creates a new instance of a ref object // returns an error when the reference uri is an invalid uri func NewRef(refURI string) (Ref, error) { ref, err := jsonreference.New(refURI) if err != nil { return Ref{}, err } return Ref{Ref: ref}, nil } // MustCreateRef creates a ref object but panics when refURI is invalid. // Use the NewRef method for a version that returns an error. func MustCreateRef(refURI string) Ref { return Ref{Ref: jsonreference.MustCreateRef(refURI)} } // MarshalJSON marshals this ref into a JSON object func (r Ref) MarshalJSON() ([]byte, error) { str := r.String() if str == "" { if r.IsRoot() { return []byte(`{"$ref":""}`), nil } return []byte("{}"), nil } v := map[string]interface{}{"$ref": str} return json.Marshal(v) } // UnmarshalJSON unmarshals this ref from a JSON object func (r *Ref) UnmarshalJSON(d []byte) error { var v map[string]interface{} if err := json.Unmarshal(d, &v); err != nil { return err } return r.fromMap(v) } // GobEncode provides a safe gob encoder for Ref func (r Ref) GobEncode() ([]byte, error) { var b bytes.Buffer raw, err := r.MarshalJSON() if err != nil { return nil, err } err = gob.NewEncoder(&b).Encode(raw) return b.Bytes(), err } // GobDecode provides a safe gob decoder for Ref func (r *Ref) GobDecode(b []byte) error { var raw []byte buf := bytes.NewBuffer(b) err := gob.NewDecoder(buf).Decode(&raw) if err != nil { return err } return json.Unmarshal(raw, r) } func (r *Ref) fromMap(v map[string]interface{}) error { if v == nil { return nil } if vv, ok := v["$ref"]; ok { if str, ok := vv.(string); ok { ref, err := jsonreference.New(str) if err != nil { return err } *r = Ref{Ref: ref} } } return nil }
8,876
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/path_item.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "encoding/json" "github.com/go-openapi/jsonpointer" "github.com/go-openapi/swag" ) // PathItemProps the path item specific properties type PathItemProps struct { Get *Operation `json:"get,omitempty"` Put *Operation `json:"put,omitempty"` Post *Operation `json:"post,omitempty"` Delete *Operation `json:"delete,omitempty"` Options *Operation `json:"options,omitempty"` Head *Operation `json:"head,omitempty"` Patch *Operation `json:"patch,omitempty"` Parameters []Parameter `json:"parameters,omitempty"` } // PathItem describes the operations available on a single path. // A Path Item may be empty, due to [ACL constraints](http://goo.gl/8us55a#securityFiltering). // The path itself is still exposed to the documentation viewer but they will // not know which operations and parameters are available. // // For more information: http://goo.gl/8us55a#pathItemObject type PathItem struct { Refable VendorExtensible PathItemProps } // JSONLookup look up a value by the json property name func (p PathItem) JSONLookup(token string) (interface{}, error) { if ex, ok := p.Extensions[token]; ok { return &ex, nil } if token == jsonRef { return &p.Ref, nil } r, _, err := jsonpointer.GetForToken(p.PathItemProps, token) return r, err } // UnmarshalJSON hydrates this items instance with the data from JSON func (p *PathItem) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &p.Refable); err != nil { return err } if err := json.Unmarshal(data, &p.VendorExtensible); err != nil { return err } return json.Unmarshal(data, &p.PathItemProps) } // MarshalJSON converts this items object to JSON func (p PathItem) MarshalJSON() ([]byte, error) { b3, err := json.Marshal(p.Refable) if err != nil { return nil, err } b4, err := json.Marshal(p.VendorExtensible) if err != nil { return nil, err } b5, err := json.Marshal(p.PathItemProps) if err != nil { return nil, err } concated := swag.ConcatJSON(b3, b4, b5) return concated, nil }
8,877
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/schema_loader.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "encoding/json" "fmt" "log" "net/url" "reflect" "strings" "github.com/go-openapi/swag" ) // PathLoader function to use when loading remote refs var PathLoader func(string) (json.RawMessage, error) func init() { PathLoader = func(path string) (json.RawMessage, error) { data, err := swag.LoadFromFileOrHTTP(path) if err != nil { return nil, err } return json.RawMessage(data), nil } } // resolverContext allows to share a context during spec processing. // At the moment, it just holds the index of circular references found. type resolverContext struct { // circulars holds all visited circular references, which allows shortcuts. // NOTE: this is not just a performance improvement: it is required to figure out // circular references which participate several cycles. // This structure is privately instantiated and needs not be locked against // concurrent access, unless we chose to implement a parallel spec walking. circulars map[string]bool basePath string } func newResolverContext(originalBasePath string) *resolverContext { return &resolverContext{ circulars: make(map[string]bool), basePath: originalBasePath, // keep the root base path in context } } type schemaLoader struct { root interface{} options *ExpandOptions cache ResolutionCache context *resolverContext loadDoc func(string) (json.RawMessage, error) } func (r *schemaLoader) transitiveResolver(basePath string, ref Ref) (*schemaLoader, error) { if ref.IsRoot() || ref.HasFragmentOnly { return r, nil } baseRef, _ := NewRef(basePath) currentRef := normalizeFileRef(&ref, basePath) if strings.HasPrefix(currentRef.String(), baseRef.String()) { return r, nil } // Set a new root to resolve against rootURL := currentRef.GetURL() rootURL.Fragment = "" root, _ := r.cache.Get(rootURL.String()) // shallow copy of resolver options to set a new RelativeBase when // traversing multiple documents newOptions := r.options newOptions.RelativeBase = rootURL.String() debugLog("setting new root: %s", newOptions.RelativeBase) resolver, err := defaultSchemaLoader(root, newOptions, r.cache, r.context) if err != nil { return nil, err } return resolver, nil } func (r *schemaLoader) updateBasePath(transitive *schemaLoader, basePath string) string { if transitive != r { debugLog("got a new resolver") if transitive.options != nil && transitive.options.RelativeBase != "" { basePath, _ = absPath(transitive.options.RelativeBase) debugLog("new basePath = %s", basePath) } } return basePath } func (r *schemaLoader) resolveRef(ref *Ref, target interface{}, basePath string) error { tgt := reflect.ValueOf(target) if tgt.Kind() != reflect.Ptr { return fmt.Errorf("resolve ref: target needs to be a pointer") } refURL := ref.GetURL() if refURL == nil { return nil } var res interface{} var data interface{} var err error // Resolve against the root if it isn't nil, and if ref is pointing at the root, or has a fragment only which means // it is pointing somewhere in the root. root := r.root if (ref.IsRoot() || ref.HasFragmentOnly) && root == nil && basePath != "" { if baseRef, erb := NewRef(basePath); erb == nil { root, _, _, _ = r.load(baseRef.GetURL()) } } if (ref.IsRoot() || ref.HasFragmentOnly) && root != nil { data = root } else { baseRef := normalizeFileRef(ref, basePath) debugLog("current ref is: %s", ref.String()) debugLog("current ref normalized file: %s", baseRef.String()) data, _, _, err = r.load(baseRef.GetURL()) if err != nil { return err } } res = data if ref.String() != "" { res, _, err = ref.GetPointer().Get(data) if err != nil { return err } } return swag.DynamicJSONToStruct(res, target) } func (r *schemaLoader) load(refURL *url.URL) (interface{}, url.URL, bool, error) { debugLog("loading schema from url: %s", refURL) toFetch := *refURL toFetch.Fragment = "" normalized := normalizeAbsPath(toFetch.String()) data, fromCache := r.cache.Get(normalized) if !fromCache { b, err := r.loadDoc(normalized) if err != nil { debugLog("unable to load the document: %v", err) return nil, url.URL{}, false, err } if err := json.Unmarshal(b, &data); err != nil { return nil, url.URL{}, false, err } r.cache.Set(normalized, data) } return data, toFetch, fromCache, nil } // isCircular detects cycles in sequences of $ref. // It relies on a private context (which needs not be locked). func (r *schemaLoader) isCircular(ref *Ref, basePath string, parentRefs ...string) (foundCycle bool) { normalizedRef := normalizePaths(ref.String(), basePath) if _, ok := r.context.circulars[normalizedRef]; ok { // circular $ref has been already detected in another explored cycle foundCycle = true return } foundCycle = swag.ContainsStringsCI(parentRefs, normalizedRef) if foundCycle { r.context.circulars[normalizedRef] = true } return } // Resolve resolves a reference against basePath and stores the result in target // Resolve is not in charge of following references, it only resolves ref by following its URL // if the schema that ref is referring to has more refs in it. Resolve doesn't resolve them // if basePath is an empty string, ref is resolved against the root schema stored in the schemaLoader struct func (r *schemaLoader) Resolve(ref *Ref, target interface{}, basePath string) error { return r.resolveRef(ref, target, basePath) } func (r *schemaLoader) deref(input interface{}, parentRefs []string, basePath string) error { var ref *Ref switch refable := input.(type) { case *Schema: ref = &refable.Ref case *Parameter: ref = &refable.Ref case *Response: ref = &refable.Ref case *PathItem: ref = &refable.Ref default: return fmt.Errorf("deref: unsupported type %T", input) } curRef := ref.String() if curRef != "" { normalizedRef := normalizeFileRef(ref, basePath) normalizedBasePath := normalizedRef.RemoteURI() if r.isCircular(normalizedRef, basePath, parentRefs...) { return nil } if err := r.resolveRef(ref, input, basePath); r.shouldStopOnError(err) { return err } // NOTE(fredbi): removed basePath check => needs more testing if ref.String() != "" && ref.String() != curRef { parentRefs = append(parentRefs, normalizedRef.String()) return r.deref(input, parentRefs, normalizedBasePath) } } return nil } func (r *schemaLoader) shouldStopOnError(err error) bool { if err != nil && !r.options.ContinueOnError { return true } if err != nil { log.Println(err) } return false } func defaultSchemaLoader( root interface{}, expandOptions *ExpandOptions, cache ResolutionCache, context *resolverContext) (*schemaLoader, error) { if cache == nil { cache = resCache } if expandOptions == nil { expandOptions = &ExpandOptions{} } absBase, _ := absPath(expandOptions.RelativeBase) if context == nil { context = newResolverContext(absBase) } return &schemaLoader{ root: root, options: expandOptions, cache: cache, context: context, loadDoc: func(path string) (json.RawMessage, error) { debugLog("fetching document at %q", path) return PathLoader(path) }, }, nil }
8,878
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/operation.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "bytes" "encoding/gob" "encoding/json" "sort" "github.com/go-openapi/jsonpointer" "github.com/go-openapi/swag" ) func init() { //gob.Register(map[string][]interface{}{}) gob.Register(map[string]interface{}{}) gob.Register([]interface{}{}) } // OperationProps describes an operation // // NOTES: // - schemes, when present must be from [http, https, ws, wss]: see validate // - Security is handled as a special case: see MarshalJSON function type OperationProps struct { Description string `json:"description,omitempty"` Consumes []string `json:"consumes,omitempty"` Produces []string `json:"produces,omitempty"` Schemes []string `json:"schemes,omitempty"` Tags []string `json:"tags,omitempty"` Summary string `json:"summary,omitempty"` ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"` ID string `json:"operationId,omitempty"` Deprecated bool `json:"deprecated,omitempty"` Security []map[string][]string `json:"security,omitempty"` Parameters []Parameter `json:"parameters,omitempty"` Responses *Responses `json:"responses,omitempty"` } // MarshalJSON takes care of serializing operation properties to JSON // // We use a custom marhaller here to handle a special cases related to // the Security field. We need to preserve zero length slice // while omitting the field when the value is nil/unset. func (op OperationProps) MarshalJSON() ([]byte, error) { type Alias OperationProps if op.Security == nil { return json.Marshal(&struct { Security []map[string][]string `json:"security,omitempty"` *Alias }{ Security: op.Security, Alias: (*Alias)(&op), }) } return json.Marshal(&struct { Security []map[string][]string `json:"security"` *Alias }{ Security: op.Security, Alias: (*Alias)(&op), }) } // Operation describes a single API operation on a path. // // For more information: http://goo.gl/8us55a#operationObject type Operation struct { VendorExtensible OperationProps } // SuccessResponse gets a success response model func (o *Operation) SuccessResponse() (*Response, int, bool) { if o.Responses == nil { return nil, 0, false } responseCodes := make([]int, 0, len(o.Responses.StatusCodeResponses)) for k := range o.Responses.StatusCodeResponses { if k >= 200 && k < 300 { responseCodes = append(responseCodes, k) } } if len(responseCodes) > 0 { sort.Ints(responseCodes) v := o.Responses.StatusCodeResponses[responseCodes[0]] return &v, responseCodes[0], true } return o.Responses.Default, 0, false } // JSONLookup look up a value by the json property name func (o Operation) JSONLookup(token string) (interface{}, error) { if ex, ok := o.Extensions[token]; ok { return &ex, nil } r, _, err := jsonpointer.GetForToken(o.OperationProps, token) return r, err } // UnmarshalJSON hydrates this items instance with the data from JSON func (o *Operation) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &o.OperationProps); err != nil { return err } return json.Unmarshal(data, &o.VendorExtensible) } // MarshalJSON converts this items object to JSON func (o Operation) MarshalJSON() ([]byte, error) { b1, err := json.Marshal(o.OperationProps) if err != nil { return nil, err } b2, err := json.Marshal(o.VendorExtensible) if err != nil { return nil, err } concated := swag.ConcatJSON(b1, b2) return concated, nil } // NewOperation creates a new operation instance. // It expects an ID as parameter but not passing an ID is also valid. func NewOperation(id string) *Operation { op := new(Operation) op.ID = id return op } // WithID sets the ID property on this operation, allows for chaining. func (o *Operation) WithID(id string) *Operation { o.ID = id return o } // WithDescription sets the description on this operation, allows for chaining func (o *Operation) WithDescription(description string) *Operation { o.Description = description return o } // WithSummary sets the summary on this operation, allows for chaining func (o *Operation) WithSummary(summary string) *Operation { o.Summary = summary return o } // WithExternalDocs sets/removes the external docs for/from this operation. // When you pass empty strings as params the external documents will be removed. // When you pass non-empty string as one value then those values will be used on the external docs object. // So when you pass a non-empty description, you should also pass the url and vice versa. func (o *Operation) WithExternalDocs(description, url string) *Operation { if description == "" && url == "" { o.ExternalDocs = nil return o } if o.ExternalDocs == nil { o.ExternalDocs = &ExternalDocumentation{} } o.ExternalDocs.Description = description o.ExternalDocs.URL = url return o } // Deprecate marks the operation as deprecated func (o *Operation) Deprecate() *Operation { o.Deprecated = true return o } // Undeprecate marks the operation as not deprected func (o *Operation) Undeprecate() *Operation { o.Deprecated = false return o } // WithConsumes adds media types for incoming body values func (o *Operation) WithConsumes(mediaTypes ...string) *Operation { o.Consumes = append(o.Consumes, mediaTypes...) return o } // WithProduces adds media types for outgoing body values func (o *Operation) WithProduces(mediaTypes ...string) *Operation { o.Produces = append(o.Produces, mediaTypes...) return o } // WithTags adds tags for this operation func (o *Operation) WithTags(tags ...string) *Operation { o.Tags = append(o.Tags, tags...) return o } // AddParam adds a parameter to this operation, when a parameter for that location // and with that name already exists it will be replaced func (o *Operation) AddParam(param *Parameter) *Operation { if param == nil { return o } for i, p := range o.Parameters { if p.Name == param.Name && p.In == param.In { params := append(o.Parameters[:i], *param) params = append(params, o.Parameters[i+1:]...) o.Parameters = params return o } } o.Parameters = append(o.Parameters, *param) return o } // RemoveParam removes a parameter from the operation func (o *Operation) RemoveParam(name, in string) *Operation { for i, p := range o.Parameters { if p.Name == name && p.In == in { o.Parameters = append(o.Parameters[:i], o.Parameters[i+1:]...) return o } } return o } // SecuredWith adds a security scope to this operation. func (o *Operation) SecuredWith(name string, scopes ...string) *Operation { o.Security = append(o.Security, map[string][]string{name: scopes}) return o } // WithDefaultResponse adds a default response to the operation. // Passing a nil value will remove the response func (o *Operation) WithDefaultResponse(response *Response) *Operation { return o.RespondsWith(0, response) } // RespondsWith adds a status code response to the operation. // When the code is 0 the value of the response will be used as default response value. // When the value of the response is nil it will be removed from the operation func (o *Operation) RespondsWith(code int, response *Response) *Operation { if o.Responses == nil { o.Responses = new(Responses) } if code == 0 { o.Responses.Default = response return o } if response == nil { delete(o.Responses.StatusCodeResponses, code) return o } if o.Responses.StatusCodeResponses == nil { o.Responses.StatusCodeResponses = make(map[int]Response) } o.Responses.StatusCodeResponses[code] = *response return o } type opsAlias OperationProps type gobAlias struct { Security []map[string]struct { List []string Pad bool } Alias *opsAlias SecurityIsEmpty bool } // GobEncode provides a safe gob encoder for Operation, including empty security requirements func (o Operation) GobEncode() ([]byte, error) { raw := struct { Ext VendorExtensible Props OperationProps }{ Ext: o.VendorExtensible, Props: o.OperationProps, } var b bytes.Buffer err := gob.NewEncoder(&b).Encode(raw) return b.Bytes(), err } // GobDecode provides a safe gob decoder for Operation, including empty security requirements func (o *Operation) GobDecode(b []byte) error { var raw struct { Ext VendorExtensible Props OperationProps } buf := bytes.NewBuffer(b) err := gob.NewDecoder(buf).Decode(&raw) if err != nil { return err } o.VendorExtensible = raw.Ext o.OperationProps = raw.Props return nil } // GobEncode provides a safe gob encoder for Operation, including empty security requirements func (op OperationProps) GobEncode() ([]byte, error) { raw := gobAlias{ Alias: (*opsAlias)(&op), } var b bytes.Buffer if op.Security == nil { // nil security requirement err := gob.NewEncoder(&b).Encode(raw) return b.Bytes(), err } if len(op.Security) == 0 { // empty, but non-nil security requirement raw.SecurityIsEmpty = true raw.Alias.Security = nil err := gob.NewEncoder(&b).Encode(raw) return b.Bytes(), err } raw.Security = make([]map[string]struct { List []string Pad bool }, 0, len(op.Security)) for _, req := range op.Security { v := make(map[string]struct { List []string Pad bool }, len(req)) for k, val := range req { v[k] = struct { List []string Pad bool }{ List: val, } } raw.Security = append(raw.Security, v) } err := gob.NewEncoder(&b).Encode(raw) return b.Bytes(), err } // GobDecode provides a safe gob decoder for Operation, including empty security requirements func (op *OperationProps) GobDecode(b []byte) error { var raw gobAlias buf := bytes.NewBuffer(b) err := gob.NewDecoder(buf).Decode(&raw) if err != nil { return err } if raw.Alias == nil { return nil } switch { case raw.SecurityIsEmpty: // empty, but non-nil security requirement raw.Alias.Security = []map[string][]string{} case len(raw.Alias.Security) == 0: // nil security requirement raw.Alias.Security = nil default: raw.Alias.Security = make([]map[string][]string, 0, len(raw.Security)) for _, req := range raw.Security { v := make(map[string][]string, len(req)) for k, val := range req { v[k] = make([]string, 0, len(val.List)) v[k] = append(v[k], val.List...) } raw.Alias.Security = append(raw.Alias.Security, v) } } *op = *(*OperationProps)(raw.Alias) return nil }
8,879
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/tag.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "encoding/json" "github.com/go-openapi/jsonpointer" "github.com/go-openapi/swag" ) // TagProps describe a tag entry in the top level tags section of a swagger spec type TagProps struct { Description string `json:"description,omitempty"` Name string `json:"name,omitempty"` ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"` } // NewTag creates a new tag func NewTag(name, description string, externalDocs *ExternalDocumentation) Tag { return Tag{TagProps: TagProps{Description: description, Name: name, ExternalDocs: externalDocs}} } // Tag allows adding meta data to a single tag that is used by the // [Operation Object](http://goo.gl/8us55a#operationObject). // It is not mandatory to have a Tag Object per tag used there. // // For more information: http://goo.gl/8us55a#tagObject type Tag struct { VendorExtensible TagProps } // JSONLookup implements an interface to customize json pointer lookup func (t Tag) JSONLookup(token string) (interface{}, error) { if ex, ok := t.Extensions[token]; ok { return &ex, nil } r, _, err := jsonpointer.GetForToken(t.TagProps, token) return r, err } // MarshalJSON marshal this to JSON func (t Tag) MarshalJSON() ([]byte, error) { b1, err := json.Marshal(t.TagProps) if err != nil { return nil, err } b2, err := json.Marshal(t.VendorExtensible) if err != nil { return nil, err } return swag.ConcatJSON(b1, b2), nil } // UnmarshalJSON marshal this from JSON func (t *Tag) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &t.TagProps); err != nil { return err } return json.Unmarshal(data, &t.VendorExtensible) }
8,880
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/response.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "encoding/json" "github.com/go-openapi/jsonpointer" "github.com/go-openapi/swag" ) // ResponseProps properties specific to a response type ResponseProps struct { Description string `json:"description,omitempty"` Schema *Schema `json:"schema,omitempty"` Headers map[string]Header `json:"headers,omitempty"` Examples map[string]interface{} `json:"examples,omitempty"` } // Response describes a single response from an API Operation. // // For more information: http://goo.gl/8us55a#responseObject type Response struct { Refable ResponseProps VendorExtensible } // JSONLookup look up a value by the json property name func (r Response) JSONLookup(token string) (interface{}, error) { if ex, ok := r.Extensions[token]; ok { return &ex, nil } if token == "$ref" { return &r.Ref, nil } ptr, _, err := jsonpointer.GetForToken(r.ResponseProps, token) return ptr, err } // UnmarshalJSON hydrates this items instance with the data from JSON func (r *Response) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &r.ResponseProps); err != nil { return err } if err := json.Unmarshal(data, &r.Refable); err != nil { return err } return json.Unmarshal(data, &r.VendorExtensible) } // MarshalJSON converts this items object to JSON func (r Response) MarshalJSON() ([]byte, error) { b1, err := json.Marshal(r.ResponseProps) if err != nil { return nil, err } b2, err := json.Marshal(r.Refable) if err != nil { return nil, err } b3, err := json.Marshal(r.VendorExtensible) if err != nil { return nil, err } return swag.ConcatJSON(b1, b2, b3), nil } // NewResponse creates a new response instance func NewResponse() *Response { return new(Response) } // ResponseRef creates a response as a json reference func ResponseRef(url string) *Response { resp := NewResponse() resp.Ref = MustCreateRef(url) return resp } // WithDescription sets the description on this response, allows for chaining func (r *Response) WithDescription(description string) *Response { r.Description = description return r } // WithSchema sets the schema on this response, allows for chaining. // Passing a nil argument removes the schema from this response func (r *Response) WithSchema(schema *Schema) *Response { r.Schema = schema return r } // AddHeader adds a header to this response func (r *Response) AddHeader(name string, header *Header) *Response { if header == nil { return r.RemoveHeader(name) } if r.Headers == nil { r.Headers = make(map[string]Header) } r.Headers[name] = *header return r } // RemoveHeader removes a header from this response func (r *Response) RemoveHeader(name string) *Response { delete(r.Headers, name) return r } // AddExample adds an example to this response func (r *Response) AddExample(mediaType string, example interface{}) *Response { if r.Examples == nil { r.Examples = make(map[string]interface{}) } r.Examples[mediaType] = example return r }
8,881
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/normalizer.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "fmt" "net/url" "os" "path" "path/filepath" "strings" ) // normalize absolute path for cache. // on Windows, drive letters should be converted to lower as scheme in net/url.URL func normalizeAbsPath(path string) string { u, err := url.Parse(path) if err != nil { debugLog("normalize absolute path failed: %s", err) return path } return u.String() } // base or refPath could be a file path or a URL // given a base absolute path and a ref path, return the absolute path of refPath // 1) if refPath is absolute, return it // 2) if refPath is relative, join it with basePath keeping the scheme, hosts, and ports if exists // base could be a directory or a full file path func normalizePaths(refPath, base string) string { refURL, _ := url.Parse(refPath) if path.IsAbs(refURL.Path) || filepath.IsAbs(refPath) { // refPath is actually absolute if refURL.Host != "" { return refPath } parts := strings.Split(refPath, "#") result := filepath.FromSlash(parts[0]) if len(parts) == 2 { result += "#" + parts[1] } return result } // relative refPath baseURL, _ := url.Parse(base) if !strings.HasPrefix(refPath, "#") { // combining paths if baseURL.Host != "" { baseURL.Path = path.Join(path.Dir(baseURL.Path), refURL.Path) } else { // base is a file newBase := fmt.Sprintf("%s#%s", filepath.Join(filepath.Dir(base), filepath.FromSlash(refURL.Path)), refURL.Fragment) return newBase } } // copying fragment from ref to base baseURL.Fragment = refURL.Fragment return baseURL.String() } // denormalizePaths returns to simplest notation on file $ref, // i.e. strips the absolute path and sets a path relative to the base path. // // This is currently used when we rewrite ref after a circular ref has been detected func denormalizeFileRef(ref *Ref, relativeBase, originalRelativeBase string) *Ref { debugLog("denormalizeFileRef for: %s", ref.String()) if ref.String() == "" || ref.IsRoot() || ref.HasFragmentOnly { return ref } // strip relativeBase from URI relativeBaseURL, _ := url.Parse(relativeBase) relativeBaseURL.Fragment = "" if relativeBaseURL.IsAbs() && strings.HasPrefix(ref.String(), relativeBase) { // this should work for absolute URI (e.g. http://...): we have an exact match, just trim prefix r, _ := NewRef(strings.TrimPrefix(ref.String(), relativeBase)) return &r } if relativeBaseURL.IsAbs() { // other absolute URL get unchanged (i.e. with a non-empty scheme) return ref } // for relative file URIs: originalRelativeBaseURL, _ := url.Parse(originalRelativeBase) originalRelativeBaseURL.Fragment = "" if strings.HasPrefix(ref.String(), originalRelativeBaseURL.String()) { // the resulting ref is in the expanded spec: return a local ref r, _ := NewRef(strings.TrimPrefix(ref.String(), originalRelativeBaseURL.String())) return &r } // check if we may set a relative path, considering the original base path for this spec. // Example: // spec is located at /mypath/spec.json // my normalized ref points to: /mypath/item.json#/target // expected result: item.json#/target parts := strings.Split(ref.String(), "#") relativePath, err := filepath.Rel(path.Dir(originalRelativeBaseURL.String()), parts[0]) if err != nil { // there is no common ancestor (e.g. different drives on windows) // leaves the ref unchanged return ref } if len(parts) == 2 { relativePath += "#" + parts[1] } r, _ := NewRef(relativePath) return &r } // relativeBase could be an ABSOLUTE file path or an ABSOLUTE URL func normalizeFileRef(ref *Ref, relativeBase string) *Ref { // This is important for when the reference is pointing to the root schema if ref.String() == "" { r, _ := NewRef(relativeBase) return &r } debugLog("normalizing %s against %s", ref.String(), relativeBase) s := normalizePaths(ref.String(), relativeBase) r, _ := NewRef(s) return &r } // absPath returns the absolute path of a file func absPath(fname string) (string, error) { if strings.HasPrefix(fname, "http") { return fname, nil } if filepath.IsAbs(fname) { return fname, nil } wd, err := os.Getwd() return filepath.Join(wd, fname), err }
8,882
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/info.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "encoding/json" "strings" "github.com/go-openapi/jsonpointer" "github.com/go-openapi/swag" ) // Extensions vendor specific extensions type Extensions map[string]interface{} // Add adds a value to these extensions func (e Extensions) Add(key string, value interface{}) { realKey := strings.ToLower(key) e[realKey] = value } // GetString gets a string value from the extensions func (e Extensions) GetString(key string) (string, bool) { if v, ok := e[strings.ToLower(key)]; ok { str, ok := v.(string) return str, ok } return "", false } // GetBool gets a string value from the extensions func (e Extensions) GetBool(key string) (bool, bool) { if v, ok := e[strings.ToLower(key)]; ok { str, ok := v.(bool) return str, ok } return false, false } // GetStringSlice gets a string value from the extensions func (e Extensions) GetStringSlice(key string) ([]string, bool) { if v, ok := e[strings.ToLower(key)]; ok { arr, isSlice := v.([]interface{}) if !isSlice { return nil, false } var strs []string for _, iface := range arr { str, isString := iface.(string) if !isString { return nil, false } strs = append(strs, str) } return strs, ok } return nil, false } // VendorExtensible composition block. type VendorExtensible struct { Extensions Extensions } // AddExtension adds an extension to this extensible object func (v *VendorExtensible) AddExtension(key string, value interface{}) { if value == nil { return } if v.Extensions == nil { v.Extensions = make(map[string]interface{}) } v.Extensions.Add(key, value) } // MarshalJSON marshals the extensions to json func (v VendorExtensible) MarshalJSON() ([]byte, error) { toser := make(map[string]interface{}) for k, v := range v.Extensions { lk := strings.ToLower(k) if strings.HasPrefix(lk, "x-") { toser[k] = v } } return json.Marshal(toser) } // UnmarshalJSON for this extensible object func (v *VendorExtensible) UnmarshalJSON(data []byte) error { var d map[string]interface{} if err := json.Unmarshal(data, &d); err != nil { return err } for k, vv := range d { lk := strings.ToLower(k) if strings.HasPrefix(lk, "x-") { if v.Extensions == nil { v.Extensions = map[string]interface{}{} } v.Extensions[k] = vv } } return nil } // InfoProps the properties for an info definition type InfoProps struct { Description string `json:"description,omitempty"` Title string `json:"title,omitempty"` TermsOfService string `json:"termsOfService,omitempty"` Contact *ContactInfo `json:"contact,omitempty"` License *License `json:"license,omitempty"` Version string `json:"version,omitempty"` } // Info object provides metadata about the API. // The metadata can be used by the clients if needed, and can be presented in the Swagger-UI for convenience. // // For more information: http://goo.gl/8us55a#infoObject type Info struct { VendorExtensible InfoProps } // JSONLookup look up a value by the json property name func (i Info) JSONLookup(token string) (interface{}, error) { if ex, ok := i.Extensions[token]; ok { return &ex, nil } r, _, err := jsonpointer.GetForToken(i.InfoProps, token) return r, err } // MarshalJSON marshal this to JSON func (i Info) MarshalJSON() ([]byte, error) { b1, err := json.Marshal(i.InfoProps) if err != nil { return nil, err } b2, err := json.Marshal(i.VendorExtensible) if err != nil { return nil, err } return swag.ConcatJSON(b1, b2), nil } // UnmarshalJSON marshal this from JSON func (i *Info) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &i.InfoProps); err != nil { return err } return json.Unmarshal(data, &i.VendorExtensible) }
8,883
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/security_scheme.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "encoding/json" "github.com/go-openapi/jsonpointer" "github.com/go-openapi/swag" ) const ( basic = "basic" apiKey = "apiKey" oauth2 = "oauth2" implicit = "implicit" password = "password" application = "application" accessCode = "accessCode" ) // BasicAuth creates a basic auth security scheme func BasicAuth() *SecurityScheme { return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{Type: basic}} } // APIKeyAuth creates an api key auth security scheme func APIKeyAuth(fieldName, valueSource string) *SecurityScheme { return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{Type: apiKey, Name: fieldName, In: valueSource}} } // OAuth2Implicit creates an implicit flow oauth2 security scheme func OAuth2Implicit(authorizationURL string) *SecurityScheme { return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{ Type: oauth2, Flow: implicit, AuthorizationURL: authorizationURL, }} } // OAuth2Password creates a password flow oauth2 security scheme func OAuth2Password(tokenURL string) *SecurityScheme { return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{ Type: oauth2, Flow: password, TokenURL: tokenURL, }} } // OAuth2Application creates an application flow oauth2 security scheme func OAuth2Application(tokenURL string) *SecurityScheme { return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{ Type: oauth2, Flow: application, TokenURL: tokenURL, }} } // OAuth2AccessToken creates an access token flow oauth2 security scheme func OAuth2AccessToken(authorizationURL, tokenURL string) *SecurityScheme { return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{ Type: oauth2, Flow: accessCode, AuthorizationURL: authorizationURL, TokenURL: tokenURL, }} } // SecuritySchemeProps describes a swagger security scheme in the securityDefinitions section type SecuritySchemeProps struct { Description string `json:"description,omitempty"` Type string `json:"type"` Name string `json:"name,omitempty"` // api key In string `json:"in,omitempty"` // api key Flow string `json:"flow,omitempty"` // oauth2 AuthorizationURL string `json:"authorizationUrl,omitempty"` // oauth2 TokenURL string `json:"tokenUrl,omitempty"` // oauth2 Scopes map[string]string `json:"scopes,omitempty"` // oauth2 } // AddScope adds a scope to this security scheme func (s *SecuritySchemeProps) AddScope(scope, description string) { if s.Scopes == nil { s.Scopes = make(map[string]string) } s.Scopes[scope] = description } // SecurityScheme allows the definition of a security scheme that can be used by the operations. // Supported schemes are basic authentication, an API key (either as a header or as a query parameter) // and OAuth2's common flows (implicit, password, application and access code). // // For more information: http://goo.gl/8us55a#securitySchemeObject type SecurityScheme struct { VendorExtensible SecuritySchemeProps } // JSONLookup implements an interface to customize json pointer lookup func (s SecurityScheme) JSONLookup(token string) (interface{}, error) { if ex, ok := s.Extensions[token]; ok { return &ex, nil } r, _, err := jsonpointer.GetForToken(s.SecuritySchemeProps, token) return r, err } // MarshalJSON marshal this to JSON func (s SecurityScheme) MarshalJSON() ([]byte, error) { b1, err := json.Marshal(s.SecuritySchemeProps) if err != nil { return nil, err } b2, err := json.Marshal(s.VendorExtensible) if err != nil { return nil, err } return swag.ConcatJSON(b1, b2), nil } // UnmarshalJSON marshal this from JSON func (s *SecurityScheme) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &s.SecuritySchemeProps); err != nil { return err } return json.Unmarshal(data, &s.VendorExtensible) }
8,884
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/cache.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import "sync" // ResolutionCache a cache for resolving urls type ResolutionCache interface { Get(string) (interface{}, bool) Set(string, interface{}) } type simpleCache struct { lock sync.RWMutex store map[string]interface{} } // Get retrieves a cached URI func (s *simpleCache) Get(uri string) (interface{}, bool) { debugLog("getting %q from resolution cache", uri) s.lock.RLock() v, ok := s.store[uri] debugLog("got %q from resolution cache: %t", uri, ok) s.lock.RUnlock() return v, ok } // Set caches a URI func (s *simpleCache) Set(uri string, data interface{}) { s.lock.Lock() s.store[uri] = data s.lock.Unlock() } var resCache ResolutionCache func init() { resCache = initResolutionCache() } // initResolutionCache initializes the URI resolution cache func initResolutionCache() ResolutionCache { return &simpleCache{store: map[string]interface{}{ "http://swagger.io/v2/schema.json": MustLoadSwagger20Schema(), "http://json-schema.org/draft-04/schema": MustLoadJSONSchemaDraft04(), }} }
8,885
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/debug.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "fmt" "log" "os" "path/filepath" "runtime" ) var ( // Debug is true when the SWAGGER_DEBUG env var is not empty. // It enables a more verbose logging of this package. Debug = os.Getenv("SWAGGER_DEBUG") != "" // specLogger is a debug logger for this package specLogger *log.Logger ) func init() { debugOptions() } func debugOptions() { specLogger = log.New(os.Stdout, "spec:", log.LstdFlags) } func debugLog(msg string, args ...interface{}) { // A private, trivial trace logger, based on go-openapi/spec/expander.go:debugLog() if Debug { _, file1, pos1, _ := runtime.Caller(1) specLogger.Printf("%s:%d: %s", filepath.Base(file1), pos1, fmt.Sprintf(msg, args...)) } }
8,886
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/items.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "encoding/json" "strings" "github.com/go-openapi/jsonpointer" "github.com/go-openapi/swag" ) const ( jsonRef = "$ref" ) // SimpleSchema describe swagger simple schemas for parameters and headers type SimpleSchema struct { Type string `json:"type,omitempty"` Nullable bool `json:"nullable,omitempty"` Format string `json:"format,omitempty"` Items *Items `json:"items,omitempty"` CollectionFormat string `json:"collectionFormat,omitempty"` Default interface{} `json:"default,omitempty"` Example interface{} `json:"example,omitempty"` } // TypeName return the type (or format) of a simple schema func (s *SimpleSchema) TypeName() string { if s.Format != "" { return s.Format } return s.Type } // ItemsTypeName yields the type of items in a simple schema array func (s *SimpleSchema) ItemsTypeName() string { if s.Items == nil { return "" } return s.Items.TypeName() } // CommonValidations describe common JSON-schema validations type CommonValidations struct { Maximum *float64 `json:"maximum,omitempty"` ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"` Minimum *float64 `json:"minimum,omitempty"` ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"` MaxLength *int64 `json:"maxLength,omitempty"` MinLength *int64 `json:"minLength,omitempty"` Pattern string `json:"pattern,omitempty"` MaxItems *int64 `json:"maxItems,omitempty"` MinItems *int64 `json:"minItems,omitempty"` UniqueItems bool `json:"uniqueItems,omitempty"` MultipleOf *float64 `json:"multipleOf,omitempty"` Enum []interface{} `json:"enum,omitempty"` } // Items a limited subset of JSON-Schema's items object. // It is used by parameter definitions that are not located in "body". // // For more information: http://goo.gl/8us55a#items-object type Items struct { Refable CommonValidations SimpleSchema VendorExtensible } // NewItems creates a new instance of items func NewItems() *Items { return &Items{} } // Typed a fluent builder method for the type of item func (i *Items) Typed(tpe, format string) *Items { i.Type = tpe i.Format = format return i } // AsNullable flags this schema as nullable. func (i *Items) AsNullable() *Items { i.Nullable = true return i } // CollectionOf a fluent builder method for an array item func (i *Items) CollectionOf(items *Items, format string) *Items { i.Type = jsonArray i.Items = items i.CollectionFormat = format return i } // WithDefault sets the default value on this item func (i *Items) WithDefault(defaultValue interface{}) *Items { i.Default = defaultValue return i } // WithMaxLength sets a max length value func (i *Items) WithMaxLength(max int64) *Items { i.MaxLength = &max return i } // WithMinLength sets a min length value func (i *Items) WithMinLength(min int64) *Items { i.MinLength = &min return i } // WithPattern sets a pattern value func (i *Items) WithPattern(pattern string) *Items { i.Pattern = pattern return i } // WithMultipleOf sets a multiple of value func (i *Items) WithMultipleOf(number float64) *Items { i.MultipleOf = &number return i } // WithMaximum sets a maximum number value func (i *Items) WithMaximum(max float64, exclusive bool) *Items { i.Maximum = &max i.ExclusiveMaximum = exclusive return i } // WithMinimum sets a minimum number value func (i *Items) WithMinimum(min float64, exclusive bool) *Items { i.Minimum = &min i.ExclusiveMinimum = exclusive return i } // WithEnum sets a the enum values (replace) func (i *Items) WithEnum(values ...interface{}) *Items { i.Enum = append([]interface{}{}, values...) return i } // WithMaxItems sets the max items func (i *Items) WithMaxItems(size int64) *Items { i.MaxItems = &size return i } // WithMinItems sets the min items func (i *Items) WithMinItems(size int64) *Items { i.MinItems = &size return i } // UniqueValues dictates that this array can only have unique items func (i *Items) UniqueValues() *Items { i.UniqueItems = true return i } // AllowDuplicates this array can have duplicates func (i *Items) AllowDuplicates() *Items { i.UniqueItems = false return i } // UnmarshalJSON hydrates this items instance with the data from JSON func (i *Items) UnmarshalJSON(data []byte) error { var validations CommonValidations if err := json.Unmarshal(data, &validations); err != nil { return err } var ref Refable if err := json.Unmarshal(data, &ref); err != nil { return err } var simpleSchema SimpleSchema if err := json.Unmarshal(data, &simpleSchema); err != nil { return err } var vendorExtensible VendorExtensible if err := json.Unmarshal(data, &vendorExtensible); err != nil { return err } i.Refable = ref i.CommonValidations = validations i.SimpleSchema = simpleSchema i.VendorExtensible = vendorExtensible return nil } // MarshalJSON converts this items object to JSON func (i Items) MarshalJSON() ([]byte, error) { b1, err := json.Marshal(i.CommonValidations) if err != nil { return nil, err } b2, err := json.Marshal(i.SimpleSchema) if err != nil { return nil, err } b3, err := json.Marshal(i.Refable) if err != nil { return nil, err } b4, err := json.Marshal(i.VendorExtensible) if err != nil { return nil, err } return swag.ConcatJSON(b4, b3, b1, b2), nil } // JSONLookup look up a value by the json property name func (i Items) JSONLookup(token string) (interface{}, error) { if token == jsonRef { return &i.Ref, nil } r, _, err := jsonpointer.GetForToken(i.CommonValidations, token) if err != nil && !strings.HasPrefix(err.Error(), "object has no field") { return nil, err } if r != nil { return r, nil } r, _, err = jsonpointer.GetForToken(i.SimpleSchema, token) return r, err }
8,887
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/responses.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "encoding/json" "fmt" "reflect" "strconv" "github.com/go-openapi/swag" ) // Responses is a container for the expected responses of an operation. // The container maps a HTTP response code to the expected response. // It is not expected from the documentation to necessarily cover all possible HTTP response codes, // since they may not be known in advance. However, it is expected from the documentation to cover // a successful operation response and any known errors. // // The `default` can be used a default response object for all HTTP codes that are not covered // individually by the specification. // // The `Responses Object` MUST contain at least one response code, and it SHOULD be the response // for a successful operation call. // // For more information: http://goo.gl/8us55a#responsesObject type Responses struct { VendorExtensible ResponsesProps } // JSONLookup implements an interface to customize json pointer lookup func (r Responses) JSONLookup(token string) (interface{}, error) { if token == "default" { return r.Default, nil } if ex, ok := r.Extensions[token]; ok { return &ex, nil } if i, err := strconv.Atoi(token); err == nil { if scr, ok := r.StatusCodeResponses[i]; ok { return scr, nil } } return nil, fmt.Errorf("object has no field %q", token) } // UnmarshalJSON hydrates this items instance with the data from JSON func (r *Responses) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &r.ResponsesProps); err != nil { return err } if err := json.Unmarshal(data, &r.VendorExtensible); err != nil { return err } if reflect.DeepEqual(ResponsesProps{}, r.ResponsesProps) { r.ResponsesProps = ResponsesProps{} } return nil } // MarshalJSON converts this items object to JSON func (r Responses) MarshalJSON() ([]byte, error) { b1, err := json.Marshal(r.ResponsesProps) if err != nil { return nil, err } b2, err := json.Marshal(r.VendorExtensible) if err != nil { return nil, err } concated := swag.ConcatJSON(b1, b2) return concated, nil } // ResponsesProps describes all responses for an operation. // It tells what is the default response and maps all responses with a // HTTP status code. type ResponsesProps struct { Default *Response StatusCodeResponses map[int]Response } // MarshalJSON marshals responses as JSON func (r ResponsesProps) MarshalJSON() ([]byte, error) { toser := map[string]Response{} if r.Default != nil { toser["default"] = *r.Default } for k, v := range r.StatusCodeResponses { toser[strconv.Itoa(k)] = v } return json.Marshal(toser) } // UnmarshalJSON unmarshals responses from JSON func (r *ResponsesProps) UnmarshalJSON(data []byte) error { var res map[string]Response if err := json.Unmarshal(data, &res); err != nil { return nil } if v, ok := res["default"]; ok { r.Default = &v delete(res, "default") } for k, v := range res { if nk, err := strconv.Atoi(k); err == nil { if r.StatusCodeResponses == nil { r.StatusCodeResponses = map[int]Response{} } r.StatusCodeResponses[nk] = v } } return nil }
8,888
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/go.sum
github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-openapi/jsonpointer v0.17.0 h1:nH6xp8XdXHx8dqveo0ZuJBluCO2qGrPbDNZ0dwoRHP0= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.0 h1:FTUMcX77w5rQkClIzDtTxvn6Bsa894CcrzNj2MMfeg8= github.com/go-openapi/jsonpointer v0.19.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.2 h1:A9+F4Dc/MCNB5jibxf6rRvOvR/iFgQdyNx9eIhnGqq0= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonreference v0.19.0 h1:BqWKpV1dFd+AuiKlgtddwVIFQsuMpxfBDBHGfM2yNpk= github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.19.2 h1:o20suLFB4Ri0tuzpWtyHlh7E7HnkqTNLq6aR6WVNS1w= github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= github.com/go-openapi/swag v0.17.0 h1:iqrgMg7Q7SvtbWLlltPrkMs0UBJI6oTSs79JFRUi880= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.19.2 h1:jvO6bCMBEilGwMfHhrd61zIID4oIFdwb76V17SM88dE= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63 h1:nTT4s92Dgz2HlrB2NaMgvlfqHH39OgMhA7z3PK7PGD4= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/net v0.0.0-20181005035420-146acd28ed58 h1:otZG8yDCO4LVps5+9bxOeNiCvgmOyt96J3roHTYs7oE= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 h1:dfGZHvZk057jK2MCeWus/TowKpJ8y4AmooUzdBSR9GU= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
8,889
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/.editorconfig
# top-most EditorConfig file root = true # Unix-style newlines with a newline ending every file [*] end_of_line = lf insert_final_newline = true indent_style = space indent_size = 2 trim_trailing_whitespace = true # Set default charset [*.{js,py,go,scala,rb,java,html,css,less,sass,md}] charset = utf-8 # Tab indentation (no size specified) [*.go] indent_style = tab [*.md] trim_trailing_whitespace = false # Matches the exact files either package.json or .travis.yml [{package.json,.travis.yml}] indent_style = space indent_size = 2
8,890
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/unused.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec /* import ( "net/url" "os" "path" "path/filepath" "github.com/go-openapi/jsonpointer" ) // Some currently unused functions and definitions that // used to be part of the expander. // Moved here for the record and possible future reuse var ( idPtr, _ = jsonpointer.New("/id") refPtr, _ = jsonpointer.New("/$ref") ) func idFromNode(node interface{}) (*Ref, error) { if idValue, _, err := idPtr.Get(node); err == nil { if refStr, ok := idValue.(string); ok && refStr != "" { idRef, err := NewRef(refStr) if err != nil { return nil, err } return &idRef, nil } } return nil, nil } func nextRef(startingNode interface{}, startingRef *Ref, ptr *jsonpointer.Pointer) *Ref { if startingRef == nil { return nil } if ptr == nil { return startingRef } ret := startingRef var idRef *Ref node := startingNode for _, tok := range ptr.DecodedTokens() { node, _, _ = jsonpointer.GetForToken(node, tok) if node == nil { break } idRef, _ = idFromNode(node) if idRef != nil { nw, err := ret.Inherits(*idRef) if err != nil { break } ret = nw } refRef, _, _ := refPtr.Get(node) if refRef != nil { var rf Ref switch value := refRef.(type) { case string: rf, _ = NewRef(value) } nw, err := ret.Inherits(rf) if err != nil { break } nwURL := nw.GetURL() if nwURL.Scheme == "file" || (nwURL.Scheme == "" && nwURL.Host == "") { nwpt := filepath.ToSlash(nwURL.Path) if filepath.IsAbs(nwpt) { _, err := os.Stat(nwpt) if err != nil { nwURL.Path = filepath.Join(".", nwpt) } } } ret = nw } } return ret } // basePathFromSchemaID returns a new basePath based on an existing basePath and a schema ID func basePathFromSchemaID(oldBasePath, id string) string { u, err := url.Parse(oldBasePath) if err != nil { panic(err) } uid, err := url.Parse(id) if err != nil { panic(err) } if path.IsAbs(uid.Path) { return id } u.Path = path.Join(path.Dir(u.Path), uid.Path) return u.String() } */ // type ExtraSchemaProps map[string]interface{} // // JSONSchema represents a structure that is a json schema draft 04 // type JSONSchema struct { // SchemaProps // ExtraSchemaProps // } // // MarshalJSON marshal this to JSON // func (s JSONSchema) MarshalJSON() ([]byte, error) { // b1, err := json.Marshal(s.SchemaProps) // if err != nil { // return nil, err // } // b2, err := s.Ref.MarshalJSON() // if err != nil { // return nil, err // } // b3, err := s.Schema.MarshalJSON() // if err != nil { // return nil, err // } // b4, err := json.Marshal(s.ExtraSchemaProps) // if err != nil { // return nil, err // } // return swag.ConcatJSON(b1, b2, b3, b4), nil // } // // UnmarshalJSON marshal this from JSON // func (s *JSONSchema) UnmarshalJSON(data []byte) error { // var sch JSONSchema // if err := json.Unmarshal(data, &sch.SchemaProps); err != nil { // return err // } // if err := json.Unmarshal(data, &sch.Ref); err != nil { // return err // } // if err := json.Unmarshal(data, &sch.Schema); err != nil { // return err // } // if err := json.Unmarshal(data, &sch.ExtraSchemaProps); err != nil { // return err // } // *s = sch // return nil // }
8,891
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/license.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec // License information for the exposed API. // // For more information: http://goo.gl/8us55a#licenseObject type License struct { Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` }
8,892
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/.travis.yml
after_success: - bash <(curl -s https://codecov.io/bash) go: - 1.11.x - 1.12.x install: - GO111MODULE=off go get -u gotest.tools/gotestsum env: - GO111MODULE=on language: go notifications: slack: secure: QUWvCkBBK09GF7YtEvHHVt70JOkdlNBG0nIKu/5qc4/nW5HP8I2w0SEf/XR2je0eED1Qe3L/AfMCWwrEj+IUZc3l4v+ju8X8R3Lomhme0Eb0jd1MTMCuPcBT47YCj0M7RON7vXtbFfm1hFJ/jLe5+9FXz0hpXsR24PJc5ZIi/ogNwkaPqG4BmndzecpSh0vc2FJPZUD9LT0I09REY/vXR0oQAalLkW0asGD5taHZTUZq/kBpsNxaAFrLM23i4mUcf33M5fjLpvx5LRICrX/57XpBrDh2TooBU6Qj3CgoY0uPRYUmSNxbVx1czNzl2JtEpb5yjoxfVPQeg0BvQM00G8LJINISR+ohrjhkZmAqchDupAX+yFrxTtORa78CtnIL6z/aTNlgwwVD8kvL/1pFA/JWYmKDmz93mV/+6wubGzNSQCstzjkFA4/iZEKewKUoRIAi/fxyscP6L/rCpmY/4llZZvrnyTqVbt6URWpopUpH4rwYqreXAtJxJsfBJIeSmUIiDIOMGkCTvyTEW3fWGmGoqWtSHLoaWDyAIGb7azb+KvfpWtEcoPFWfSWU+LGee0A/YsUhBl7ADB9A0CJEuR8q4BPpKpfLwPKSiKSAXL7zDkyjExyhtgqbSl2jS+rKIHOZNL8JkCcTP2MKMVd563C5rC5FMKqu3S9m2b6380E= script: - gotestsum -f short-verbose -- -race -coverprofile=coverage.txt -covermode=atomic ./...
8,893
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/schema.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "encoding/json" "fmt" "net/url" "strings" "github.com/go-openapi/jsonpointer" "github.com/go-openapi/swag" ) // BooleanProperty creates a boolean property func BooleanProperty() *Schema { return &Schema{SchemaProps: SchemaProps{Type: []string{"boolean"}}} } // BoolProperty creates a boolean property func BoolProperty() *Schema { return BooleanProperty() } // StringProperty creates a string property func StringProperty() *Schema { return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}}} } // CharProperty creates a string property func CharProperty() *Schema { return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}}} } // Float64Property creates a float64/double property func Float64Property() *Schema { return &Schema{SchemaProps: SchemaProps{Type: []string{"number"}, Format: "double"}} } // Float32Property creates a float32/float property func Float32Property() *Schema { return &Schema{SchemaProps: SchemaProps{Type: []string{"number"}, Format: "float"}} } // Int8Property creates an int8 property func Int8Property() *Schema { return &Schema{SchemaProps: SchemaProps{Type: []string{"integer"}, Format: "int8"}} } // Int16Property creates an int16 property func Int16Property() *Schema { return &Schema{SchemaProps: SchemaProps{Type: []string{"integer"}, Format: "int16"}} } // Int32Property creates an int32 property func Int32Property() *Schema { return &Schema{SchemaProps: SchemaProps{Type: []string{"integer"}, Format: "int32"}} } // Int64Property creates an int64 property func Int64Property() *Schema { return &Schema{SchemaProps: SchemaProps{Type: []string{"integer"}, Format: "int64"}} } // StrFmtProperty creates a property for the named string format func StrFmtProperty(format string) *Schema { return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}, Format: format}} } // DateProperty creates a date property func DateProperty() *Schema { return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}, Format: "date"}} } // DateTimeProperty creates a date time property func DateTimeProperty() *Schema { return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}, Format: "date-time"}} } // MapProperty creates a map property func MapProperty(property *Schema) *Schema { return &Schema{SchemaProps: SchemaProps{Type: []string{"object"}, AdditionalProperties: &SchemaOrBool{Allows: true, Schema: property}}} } // RefProperty creates a ref property func RefProperty(name string) *Schema { return &Schema{SchemaProps: SchemaProps{Ref: MustCreateRef(name)}} } // RefSchema creates a ref property func RefSchema(name string) *Schema { return &Schema{SchemaProps: SchemaProps{Ref: MustCreateRef(name)}} } // ArrayProperty creates an array property func ArrayProperty(items *Schema) *Schema { if items == nil { return &Schema{SchemaProps: SchemaProps{Type: []string{"array"}}} } return &Schema{SchemaProps: SchemaProps{Items: &SchemaOrArray{Schema: items}, Type: []string{"array"}}} } // ComposedSchema creates a schema with allOf func ComposedSchema(schemas ...Schema) *Schema { s := new(Schema) s.AllOf = schemas return s } // SchemaURL represents a schema url type SchemaURL string // MarshalJSON marshal this to JSON func (r SchemaURL) MarshalJSON() ([]byte, error) { if r == "" { return []byte("{}"), nil } v := map[string]interface{}{"$schema": string(r)} return json.Marshal(v) } // UnmarshalJSON unmarshal this from JSON func (r *SchemaURL) UnmarshalJSON(data []byte) error { var v map[string]interface{} if err := json.Unmarshal(data, &v); err != nil { return err } return r.fromMap(v) } func (r *SchemaURL) fromMap(v map[string]interface{}) error { if v == nil { return nil } if vv, ok := v["$schema"]; ok { if str, ok := vv.(string); ok { u, err := url.Parse(str) if err != nil { return err } *r = SchemaURL(u.String()) } } return nil } // SchemaProps describes a JSON schema (draft 4) type SchemaProps struct { ID string `json:"id,omitempty"` Ref Ref `json:"-"` Schema SchemaURL `json:"-"` Description string `json:"description,omitempty"` Type StringOrArray `json:"type,omitempty"` Nullable bool `json:"nullable,omitempty"` Format string `json:"format,omitempty"` Title string `json:"title,omitempty"` Default interface{} `json:"default,omitempty"` Maximum *float64 `json:"maximum,omitempty"` ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"` Minimum *float64 `json:"minimum,omitempty"` ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"` MaxLength *int64 `json:"maxLength,omitempty"` MinLength *int64 `json:"minLength,omitempty"` Pattern string `json:"pattern,omitempty"` MaxItems *int64 `json:"maxItems,omitempty"` MinItems *int64 `json:"minItems,omitempty"` UniqueItems bool `json:"uniqueItems,omitempty"` MultipleOf *float64 `json:"multipleOf,omitempty"` Enum []interface{} `json:"enum,omitempty"` MaxProperties *int64 `json:"maxProperties,omitempty"` MinProperties *int64 `json:"minProperties,omitempty"` Required []string `json:"required,omitempty"` Items *SchemaOrArray `json:"items,omitempty"` AllOf []Schema `json:"allOf,omitempty"` OneOf []Schema `json:"oneOf,omitempty"` AnyOf []Schema `json:"anyOf,omitempty"` Not *Schema `json:"not,omitempty"` Properties map[string]Schema `json:"properties,omitempty"` AdditionalProperties *SchemaOrBool `json:"additionalProperties,omitempty"` PatternProperties map[string]Schema `json:"patternProperties,omitempty"` Dependencies Dependencies `json:"dependencies,omitempty"` AdditionalItems *SchemaOrBool `json:"additionalItems,omitempty"` Definitions Definitions `json:"definitions,omitempty"` } // SwaggerSchemaProps are additional properties supported by swagger schemas, but not JSON-schema (draft 4) type SwaggerSchemaProps struct { Discriminator string `json:"discriminator,omitempty"` ReadOnly bool `json:"readOnly,omitempty"` XML *XMLObject `json:"xml,omitempty"` ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"` Example interface{} `json:"example,omitempty"` } // Schema the schema object allows the definition of input and output data types. // These types can be objects, but also primitives and arrays. // This object is based on the [JSON Schema Specification Draft 4](http://json-schema.org/) // and uses a predefined subset of it. // On top of this subset, there are extensions provided by this specification to allow for more complete documentation. // // For more information: http://goo.gl/8us55a#schemaObject type Schema struct { VendorExtensible SchemaProps SwaggerSchemaProps ExtraProps map[string]interface{} `json:"-"` } // JSONLookup implements an interface to customize json pointer lookup func (s Schema) JSONLookup(token string) (interface{}, error) { if ex, ok := s.Extensions[token]; ok { return &ex, nil } if ex, ok := s.ExtraProps[token]; ok { return &ex, nil } r, _, err := jsonpointer.GetForToken(s.SchemaProps, token) if r != nil || (err != nil && !strings.HasPrefix(err.Error(), "object has no field")) { return r, err } r, _, err = jsonpointer.GetForToken(s.SwaggerSchemaProps, token) return r, err } // WithID sets the id for this schema, allows for chaining func (s *Schema) WithID(id string) *Schema { s.ID = id return s } // WithTitle sets the title for this schema, allows for chaining func (s *Schema) WithTitle(title string) *Schema { s.Title = title return s } // WithDescription sets the description for this schema, allows for chaining func (s *Schema) WithDescription(description string) *Schema { s.Description = description return s } // WithProperties sets the properties for this schema func (s *Schema) WithProperties(schemas map[string]Schema) *Schema { s.Properties = schemas return s } // SetProperty sets a property on this schema func (s *Schema) SetProperty(name string, schema Schema) *Schema { if s.Properties == nil { s.Properties = make(map[string]Schema) } s.Properties[name] = schema return s } // WithAllOf sets the all of property func (s *Schema) WithAllOf(schemas ...Schema) *Schema { s.AllOf = schemas return s } // WithMaxProperties sets the max number of properties an object can have func (s *Schema) WithMaxProperties(max int64) *Schema { s.MaxProperties = &max return s } // WithMinProperties sets the min number of properties an object must have func (s *Schema) WithMinProperties(min int64) *Schema { s.MinProperties = &min return s } // Typed sets the type of this schema for a single value item func (s *Schema) Typed(tpe, format string) *Schema { s.Type = []string{tpe} s.Format = format return s } // AddType adds a type with potential format to the types for this schema func (s *Schema) AddType(tpe, format string) *Schema { s.Type = append(s.Type, tpe) if format != "" { s.Format = format } return s } // AsNullable flags this schema as nullable. func (s *Schema) AsNullable() *Schema { s.Nullable = true return s } // CollectionOf a fluent builder method for an array parameter func (s *Schema) CollectionOf(items Schema) *Schema { s.Type = []string{jsonArray} s.Items = &SchemaOrArray{Schema: &items} return s } // WithDefault sets the default value on this parameter func (s *Schema) WithDefault(defaultValue interface{}) *Schema { s.Default = defaultValue return s } // WithRequired flags this parameter as required func (s *Schema) WithRequired(items ...string) *Schema { s.Required = items return s } // AddRequired adds field names to the required properties array func (s *Schema) AddRequired(items ...string) *Schema { s.Required = append(s.Required, items...) return s } // WithMaxLength sets a max length value func (s *Schema) WithMaxLength(max int64) *Schema { s.MaxLength = &max return s } // WithMinLength sets a min length value func (s *Schema) WithMinLength(min int64) *Schema { s.MinLength = &min return s } // WithPattern sets a pattern value func (s *Schema) WithPattern(pattern string) *Schema { s.Pattern = pattern return s } // WithMultipleOf sets a multiple of value func (s *Schema) WithMultipleOf(number float64) *Schema { s.MultipleOf = &number return s } // WithMaximum sets a maximum number value func (s *Schema) WithMaximum(max float64, exclusive bool) *Schema { s.Maximum = &max s.ExclusiveMaximum = exclusive return s } // WithMinimum sets a minimum number value func (s *Schema) WithMinimum(min float64, exclusive bool) *Schema { s.Minimum = &min s.ExclusiveMinimum = exclusive return s } // WithEnum sets a the enum values (replace) func (s *Schema) WithEnum(values ...interface{}) *Schema { s.Enum = append([]interface{}{}, values...) return s } // WithMaxItems sets the max items func (s *Schema) WithMaxItems(size int64) *Schema { s.MaxItems = &size return s } // WithMinItems sets the min items func (s *Schema) WithMinItems(size int64) *Schema { s.MinItems = &size return s } // UniqueValues dictates that this array can only have unique items func (s *Schema) UniqueValues() *Schema { s.UniqueItems = true return s } // AllowDuplicates this array can have duplicates func (s *Schema) AllowDuplicates() *Schema { s.UniqueItems = false return s } // AddToAllOf adds a schema to the allOf property func (s *Schema) AddToAllOf(schemas ...Schema) *Schema { s.AllOf = append(s.AllOf, schemas...) return s } // WithDiscriminator sets the name of the discriminator field func (s *Schema) WithDiscriminator(discriminator string) *Schema { s.Discriminator = discriminator return s } // AsReadOnly flags this schema as readonly func (s *Schema) AsReadOnly() *Schema { s.ReadOnly = true return s } // AsWritable flags this schema as writeable (not read-only) func (s *Schema) AsWritable() *Schema { s.ReadOnly = false return s } // WithExample sets the example for this schema func (s *Schema) WithExample(example interface{}) *Schema { s.Example = example return s } // WithExternalDocs sets/removes the external docs for/from this schema. // When you pass empty strings as params the external documents will be removed. // When you pass non-empty string as one value then those values will be used on the external docs object. // So when you pass a non-empty description, you should also pass the url and vice versa. func (s *Schema) WithExternalDocs(description, url string) *Schema { if description == "" && url == "" { s.ExternalDocs = nil return s } if s.ExternalDocs == nil { s.ExternalDocs = &ExternalDocumentation{} } s.ExternalDocs.Description = description s.ExternalDocs.URL = url return s } // WithXMLName sets the xml name for the object func (s *Schema) WithXMLName(name string) *Schema { if s.XML == nil { s.XML = new(XMLObject) } s.XML.Name = name return s } // WithXMLNamespace sets the xml namespace for the object func (s *Schema) WithXMLNamespace(namespace string) *Schema { if s.XML == nil { s.XML = new(XMLObject) } s.XML.Namespace = namespace return s } // WithXMLPrefix sets the xml prefix for the object func (s *Schema) WithXMLPrefix(prefix string) *Schema { if s.XML == nil { s.XML = new(XMLObject) } s.XML.Prefix = prefix return s } // AsXMLAttribute flags this object as xml attribute func (s *Schema) AsXMLAttribute() *Schema { if s.XML == nil { s.XML = new(XMLObject) } s.XML.Attribute = true return s } // AsXMLElement flags this object as an xml node func (s *Schema) AsXMLElement() *Schema { if s.XML == nil { s.XML = new(XMLObject) } s.XML.Attribute = false return s } // AsWrappedXML flags this object as wrapped, this is mostly useful for array types func (s *Schema) AsWrappedXML() *Schema { if s.XML == nil { s.XML = new(XMLObject) } s.XML.Wrapped = true return s } // AsUnwrappedXML flags this object as an xml node func (s *Schema) AsUnwrappedXML() *Schema { if s.XML == nil { s.XML = new(XMLObject) } s.XML.Wrapped = false return s } // MarshalJSON marshal this to JSON func (s Schema) MarshalJSON() ([]byte, error) { b1, err := json.Marshal(s.SchemaProps) if err != nil { return nil, fmt.Errorf("schema props %v", err) } b2, err := json.Marshal(s.VendorExtensible) if err != nil { return nil, fmt.Errorf("vendor props %v", err) } b3, err := s.Ref.MarshalJSON() if err != nil { return nil, fmt.Errorf("ref prop %v", err) } b4, err := s.Schema.MarshalJSON() if err != nil { return nil, fmt.Errorf("schema prop %v", err) } b5, err := json.Marshal(s.SwaggerSchemaProps) if err != nil { return nil, fmt.Errorf("common validations %v", err) } var b6 []byte if s.ExtraProps != nil { jj, err := json.Marshal(s.ExtraProps) if err != nil { return nil, fmt.Errorf("extra props %v", err) } b6 = jj } return swag.ConcatJSON(b1, b2, b3, b4, b5, b6), nil } // UnmarshalJSON marshal this from JSON func (s *Schema) UnmarshalJSON(data []byte) error { props := struct { SchemaProps SwaggerSchemaProps }{} if err := json.Unmarshal(data, &props); err != nil { return err } sch := Schema{ SchemaProps: props.SchemaProps, SwaggerSchemaProps: props.SwaggerSchemaProps, } var d map[string]interface{} if err := json.Unmarshal(data, &d); err != nil { return err } _ = sch.Ref.fromMap(d) _ = sch.Schema.fromMap(d) delete(d, "$ref") delete(d, "$schema") for _, pn := range swag.DefaultJSONNameProvider.GetJSONNames(s) { delete(d, pn) } for k, vv := range d { lk := strings.ToLower(k) if strings.HasPrefix(lk, "x-") { if sch.Extensions == nil { sch.Extensions = map[string]interface{}{} } sch.Extensions[k] = vv continue } if sch.ExtraProps == nil { sch.ExtraProps = map[string]interface{}{} } sch.ExtraProps[k] = vv } *s = sch return nil }
8,894
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/spec/header.go
// Copyright 2015 go-swagger maintainers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package spec import ( "encoding/json" "strings" "github.com/go-openapi/jsonpointer" "github.com/go-openapi/swag" ) const ( jsonArray = "array" ) // HeaderProps describes a response header type HeaderProps struct { Description string `json:"description,omitempty"` } // Header describes a header for a response of the API // // For more information: http://goo.gl/8us55a#headerObject type Header struct { CommonValidations SimpleSchema VendorExtensible HeaderProps } // ResponseHeader creates a new header instance for use in a response func ResponseHeader() *Header { return new(Header) } // WithDescription sets the description on this response, allows for chaining func (h *Header) WithDescription(description string) *Header { h.Description = description return h } // Typed a fluent builder method for the type of parameter func (h *Header) Typed(tpe, format string) *Header { h.Type = tpe h.Format = format return h } // CollectionOf a fluent builder method for an array item func (h *Header) CollectionOf(items *Items, format string) *Header { h.Type = jsonArray h.Items = items h.CollectionFormat = format return h } // WithDefault sets the default value on this item func (h *Header) WithDefault(defaultValue interface{}) *Header { h.Default = defaultValue return h } // WithMaxLength sets a max length value func (h *Header) WithMaxLength(max int64) *Header { h.MaxLength = &max return h } // WithMinLength sets a min length value func (h *Header) WithMinLength(min int64) *Header { h.MinLength = &min return h } // WithPattern sets a pattern value func (h *Header) WithPattern(pattern string) *Header { h.Pattern = pattern return h } // WithMultipleOf sets a multiple of value func (h *Header) WithMultipleOf(number float64) *Header { h.MultipleOf = &number return h } // WithMaximum sets a maximum number value func (h *Header) WithMaximum(max float64, exclusive bool) *Header { h.Maximum = &max h.ExclusiveMaximum = exclusive return h } // WithMinimum sets a minimum number value func (h *Header) WithMinimum(min float64, exclusive bool) *Header { h.Minimum = &min h.ExclusiveMinimum = exclusive return h } // WithEnum sets a the enum values (replace) func (h *Header) WithEnum(values ...interface{}) *Header { h.Enum = append([]interface{}{}, values...) return h } // WithMaxItems sets the max items func (h *Header) WithMaxItems(size int64) *Header { h.MaxItems = &size return h } // WithMinItems sets the min items func (h *Header) WithMinItems(size int64) *Header { h.MinItems = &size return h } // UniqueValues dictates that this array can only have unique items func (h *Header) UniqueValues() *Header { h.UniqueItems = true return h } // AllowDuplicates this array can have duplicates func (h *Header) AllowDuplicates() *Header { h.UniqueItems = false return h } // MarshalJSON marshal this to JSON func (h Header) MarshalJSON() ([]byte, error) { b1, err := json.Marshal(h.CommonValidations) if err != nil { return nil, err } b2, err := json.Marshal(h.SimpleSchema) if err != nil { return nil, err } b3, err := json.Marshal(h.HeaderProps) if err != nil { return nil, err } return swag.ConcatJSON(b1, b2, b3), nil } // UnmarshalJSON unmarshals this header from JSON func (h *Header) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &h.CommonValidations); err != nil { return err } if err := json.Unmarshal(data, &h.SimpleSchema); err != nil { return err } if err := json.Unmarshal(data, &h.VendorExtensible); err != nil { return err } return json.Unmarshal(data, &h.HeaderProps) } // JSONLookup look up a value by the json property name func (h Header) JSONLookup(token string) (interface{}, error) { if ex, ok := h.Extensions[token]; ok { return &ex, nil } r, _, err := jsonpointer.GetForToken(h.CommonValidations, token) if err != nil && !strings.HasPrefix(err.Error(), "object has no field") { return nil, err } if r != nil { return r, nil } r, _, err = jsonpointer.GetForToken(h.SimpleSchema, token) if err != nil && !strings.HasPrefix(err.Error(), "object has no field") { return nil, err } if r != nil { return r, nil } r, _, err = jsonpointer.GetForToken(h.HeaderProps, token) return r, err }
8,895
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/jsonreference/CODE_OF_CONDUCT.md
# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/
8,896
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/jsonreference/go.mod
module github.com/go-openapi/jsonreference require ( github.com/PuerkitoBio/purell v1.1.1 github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/go-openapi/jsonpointer v0.19.3 github.com/stretchr/testify v1.3.0 golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect golang.org/x/text v0.3.2 // indirect ) go 1.13
8,897
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/jsonreference/README.md
# gojsonreference [![Build Status](https://travis-ci.org/go-openapi/jsonreference.svg?branch=master)](https://travis-ci.org/go-openapi/jsonreference) [![codecov](https://codecov.io/gh/go-openapi/jsonreference/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/jsonreference) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io) [![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/jsonreference/master/LICENSE) [![GoDoc](https://godoc.org/github.com/go-openapi/jsonreference?status.svg)](http://godoc.org/github.com/go-openapi/jsonreference) An implementation of JSON Reference - Go language ## Status Work in progress ( 90% done ) ## Dependencies https://github.com/go-openapi/jsonpointer ## References http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07 http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03
8,898
0
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi
kubeflow_public_repos/fate-operator/vendor/github.com/go-openapi/jsonreference/LICENSE
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8,899