diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 4af7476a99b..55d499ba0ac 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,7 +1,7 @@ { "ImportPath": "k8s.io/kubernetes", "GoVersion": "go1.6", - "GodepVersion": "v74", + "GodepVersion": "v67", "Packages": [ "github.com/ugorji/go/codec/codecgen", "github.com/onsi/ginkgo/ginkgo", @@ -744,18 +744,18 @@ }, { "ImportPath": "github.com/emicklei/go-restful", - "Comment": "v1.2-54-g7c47e25", - "Rev": "7c47e2558a0bbbaba9ecab06bc6681e73028a28a" + "Comment": "v1.2-66-gc4afa8e", + "Rev": "c4afa8e5421428d584b32d36d7b35f2c9ae5f823" }, { "ImportPath": "github.com/emicklei/go-restful/log", - "Comment": "v1.2-54-g7c47e25", - "Rev": "7c47e2558a0bbbaba9ecab06bc6681e73028a28a" + "Comment": "v1.2-66-gc4afa8e", + "Rev": "c4afa8e5421428d584b32d36d7b35f2c9ae5f823" }, { "ImportPath": "github.com/emicklei/go-restful/swagger", - "Comment": "v1.2-54-g7c47e25", - "Rev": "7c47e2558a0bbbaba9ecab06bc6681e73028a28a" + "Comment": "v1.2-66-gc4afa8e", + "Rev": "c4afa8e5421428d584b32d36d7b35f2c9ae5f823" }, { "ImportPath": "github.com/evanphx/json-patch", diff --git a/vendor/github.com/emicklei/go-restful/README.md b/vendor/github.com/emicklei/go-restful/README.md index 8f954c0163c..e5492e47672 100644 --- a/vendor/github.com/emicklei/go-restful/README.md +++ b/vendor/github.com/emicklei/go-restful/README.md @@ -40,7 +40,7 @@ func (u UserResource) findUser(request *restful.Request, response *restful.Respo - Routes for request → function mapping with path parameter (e.g. {id}) support - Configurable router: - - Routing algorithm after [JSR311](http://jsr311.java.net/nonav/releases/1.1/spec/spec.html) that is implemented using (but doest **not** accept) regular expressions (See RouterJSR311 which is used by default) + - 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 (See RouterJSR311 which is used by default) - Fast routing algorithm that allows static elements, regular expressions and dynamic parameters in the URL path (e.g. /meetings/{id} or /static/{subpath:*}, See CurlyRouter) - 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 @@ -71,4 +71,4 @@ func (u UserResource) findUser(request *restful.Request, response *restful.Respo (c) 2012 - 2015, http://ernestmicklei.com. MIT License -Type ```git shortlog -s``` for a full list of contributors. \ No newline at end of file +Type ```git shortlog -s``` for a full list of contributors. diff --git a/vendor/github.com/emicklei/go-restful/curly.go b/vendor/github.com/emicklei/go-restful/curly.go index ce284f74768..185300dbc73 100644 --- a/vendor/github.com/emicklei/go-restful/curly.go +++ b/vendor/github.com/emicklei/go-restful/curly.go @@ -44,16 +44,16 @@ func (c CurlyRouter) SelectRoute( } // 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) []Route { - candidates := &sortableCurlyRoutes{[]*curlyRoute{}} +func (c CurlyRouter) selectRoutes(ws *WebService, requestTokens []string) sortableCurlyRoutes { + candidates := sortableCurlyRoutes{} 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? + candidates.add(curlyRoute{each, paramCount, staticCount}) // TODO make sure Routes() return pointers? } } sort.Sort(sort.Reverse(candidates)) - return candidates.routes() + return candidates } // matchesRouteByPathTokens computes whether it matches, howmany parameters do match and what the number of static path elements are. @@ -110,9 +110,9 @@ func (c CurlyRouter) regularMatchesPathToken(routeToken string, colon int, reque // 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 []Route, httpRequest *http.Request) (*Route, error) { +func (c CurlyRouter) detectRoute(candidateRoutes sortableCurlyRoutes, httpRequest *http.Request) (*Route, error) { // tracing is done inside detectRoute - return RouterJSR311{}.detectRoute(candidateRoutes, httpRequest) + return RouterJSR311{}.detectRoute(candidateRoutes.routes(), httpRequest) } // detectWebService returns the best matching webService given the list of path tokens. diff --git a/vendor/github.com/emicklei/go-restful/curly_route.go b/vendor/github.com/emicklei/go-restful/curly_route.go index 3edab72fd80..296f94650e6 100644 --- a/vendor/github.com/emicklei/go-restful/curly_route.go +++ b/vendor/github.com/emicklei/go-restful/curly_route.go @@ -11,30 +11,28 @@ type curlyRoute struct { staticCount int } -type sortableCurlyRoutes struct { - candidates []*curlyRoute +type sortableCurlyRoutes []curlyRoute + +func (s *sortableCurlyRoutes) add(route curlyRoute) { + *s = append(*s, route) } -func (s *sortableCurlyRoutes) add(route *curlyRoute) { - s.candidates = append(s.candidates, route) -} - -func (s *sortableCurlyRoutes) routes() (routes []Route) { - for _, each := range s.candidates { +func (s sortableCurlyRoutes) routes() (routes []Route) { + for _, each := range s { routes = append(routes, each.route) // TODO change return type } return routes } -func (s *sortableCurlyRoutes) Len() int { - return len(s.candidates) +func (s sortableCurlyRoutes) Len() int { + return len(s) } -func (s *sortableCurlyRoutes) Swap(i, j int) { - s.candidates[i], s.candidates[j] = s.candidates[j], s.candidates[i] +func (s sortableCurlyRoutes) Swap(i, j int) { + s[i], s[j] = s[j], s[i] } -func (s *sortableCurlyRoutes) Less(i, j int) bool { - ci := s.candidates[i] - cj := s.candidates[j] +func (s sortableCurlyRoutes) Less(i, j int) bool { + ci := s[i] + cj := s[j] // primary key if ci.staticCount < cj.staticCount { diff --git a/vendor/github.com/emicklei/go-restful/jsr311.go b/vendor/github.com/emicklei/go-restful/jsr311.go index b4fa9bbae69..511444ac685 100644 --- a/vendor/github.com/emicklei/go-restful/jsr311.go +++ b/vendor/github.com/emicklei/go-restful/jsr311.go @@ -74,7 +74,7 @@ func (r RouterJSR311) detectRoute(routes []Route, httpRequest *http.Request) (*R // accept outputMediaOk := []Route{} accept := httpRequest.Header.Get(HEADER_Accept) - if accept == "" { + if len(accept) == 0 { accept = "*/*" } for _, each := range inputMediaOk { @@ -88,7 +88,8 @@ func (r RouterJSR311) detectRoute(routes []Route, httpRequest *http.Request) (*R } return nil, NewError(http.StatusNotAcceptable, "406: Not Acceptable") } - return r.bestMatchByMedia(outputMediaOk, contentType, accept), nil + // return r.bestMatchByMedia(outputMediaOk, contentType, accept), nil + return &outputMediaOk[0], nil } // http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2 diff --git a/vendor/github.com/emicklei/go-restful/response.go b/vendor/github.com/emicklei/go-restful/response.go index 696c67eb70c..971cd0b42ce 100644 --- a/vendor/github.com/emicklei/go-restful/response.go +++ b/vendor/github.com/emicklei/go-restful/response.go @@ -130,25 +130,25 @@ func (r *Response) WriteHeaderAndEntity(status int, value interface{}) error { } // 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 valuel ; not using a registered EntityReaderWriter. +// 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 valuel ; not using a registered EntityReaderWriter. +// 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 valuel ; not using a registered EntityReaderWriter. +// 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 valuel ; not using a registered EntityReaderWriter. +// 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) } diff --git a/vendor/github.com/emicklei/go-restful/route_builder.go b/vendor/github.com/emicklei/go-restful/route_builder.go index b49b7c74d35..8bc1ab68462 100644 --- a/vendor/github.com/emicklei/go-restful/route_builder.go +++ b/vendor/github.com/emicklei/go-restful/route_builder.go @@ -128,7 +128,7 @@ func (b *RouteBuilder) Param(parameter *Parameter) *RouteBuilder { return b } -// Operation allows you to document what the acutal method/function call is of the Route. +// 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 diff --git a/vendor/github.com/emicklei/go-restful/swagger/config.go b/vendor/github.com/emicklei/go-restful/swagger/config.go index 944d988eefb..510d6fc133a 100644 --- a/vendor/github.com/emicklei/go-restful/swagger/config.go +++ b/vendor/github.com/emicklei/go-restful/swagger/config.go @@ -9,6 +9,8 @@ import ( // PostBuildDeclarationMapFunc can be used to modify the api declaration map. type PostBuildDeclarationMapFunc func(apiDeclarationMap *ApiDeclarationList) +type MapSchemaFormatFunc func(typeName string) string + type Config struct { // url where the services are available, e.g. http://localhost:8080 // if left empty then the basePath of Swagger is taken from the actual request @@ -31,4 +33,6 @@ type Config struct { PostBuildHandler PostBuildDeclarationMapFunc // Swagger global info struct Info Info + // [optional] If set, model builder should call this handler to get addition typename-to-swagger-format-field convertion. + SchemaFormatHandler MapSchemaFormatFunc } diff --git a/vendor/github.com/emicklei/go-restful/swagger/model_builder.go b/vendor/github.com/emicklei/go-restful/swagger/model_builder.go index fcc2976cb96..696d192e5bc 100644 --- a/vendor/github.com/emicklei/go-restful/swagger/model_builder.go +++ b/vendor/github.com/emicklei/go-restful/swagger/model_builder.go @@ -14,6 +14,7 @@ type ModelBuildable interface { type modelBuilder struct { Models *ModelList + Config *Config } type documentable interface { @@ -231,7 +232,7 @@ func (b modelBuilder) buildStructTypeProperty(field reflect.StructField, jsonNam if field.Name == fieldType.Name() && field.Anonymous && !hasNamedJSONTag(field) { // embedded struct - sub := modelBuilder{new(ModelList)} + sub := modelBuilder{new(ModelList), b.Config} sub.addModel(fieldType, "") subKey := sub.keyFrom(fieldType) // merge properties from sub @@ -410,6 +411,11 @@ func (b modelBuilder) jsonSchemaType(modelName string) string { } func (b modelBuilder) jsonSchemaFormat(modelName string) string { + if b.Config != nil && b.Config.SchemaFormatHandler != nil { + if mapped := b.Config.SchemaFormatHandler(modelName); mapped != "" { + return mapped + } + } schemaMap := map[string]string{ "int": "int32", "int32": "int32", diff --git a/vendor/github.com/emicklei/go-restful/swagger/swagger_webservice.go b/vendor/github.com/emicklei/go-restful/swagger/swagger_webservice.go index 8dc3d5f9ea6..58dd6259022 100644 --- a/vendor/github.com/emicklei/go-restful/swagger/swagger_webservice.go +++ b/vendor/github.com/emicklei/go-restful/swagger/swagger_webservice.go @@ -241,7 +241,7 @@ func (sws SwaggerService) composeDeclaration(ws *restful.WebService, pathPrefix DataTypeFields: DataTypeFields{Type: &voidString}, Parameters: []Parameter{}, Nickname: route.Operation, - ResponseMessages: composeResponseMessages(route, &decl)} + ResponseMessages: composeResponseMessages(route, &decl, &sws.config)} operation.Consumes = route.Consumes operation.Produces = route.Produces @@ -271,7 +271,7 @@ func withoutWildcard(path string) string { } // composeResponseMessages takes the ResponseErrors (if any) and creates ResponseMessages from them. -func composeResponseMessages(route restful.Route, decl *ApiDeclaration) (messages []ResponseMessage) { +func composeResponseMessages(route restful.Route, decl *ApiDeclaration, config *Config) (messages []ResponseMessage) { if route.ResponseErrors == nil { return messages } @@ -294,7 +294,7 @@ func composeResponseMessages(route restful.Route, decl *ApiDeclaration) (message if isCollection { modelName = "array[" + modelName + "]" } - modelBuilder{&decl.Models}.addModel(st, "") + modelBuilder{Models: &decl.Models, Config: config}.addModel(st, "") // reference the model message.ResponseModel = modelName } @@ -332,11 +332,11 @@ func detectCollectionType(st reflect.Type) (bool, reflect.Type) { // addModelFromSample creates and adds (or overwrites) a Model from a sample resource func (sws SwaggerService) addModelFromSampleTo(operation *Operation, isResponse bool, sample interface{}, models *ModelList) { if isResponse { - type_, items := asDataType(sample) + type_, items := asDataType(sample, &sws.config) operation.Type = type_ operation.Items = items } - modelBuilder{models}.addModelFrom(sample) + modelBuilder{Models: models, Config: &sws.config}.addModelFrom(sample) } func asSwaggerParameter(param restful.ParameterData) Parameter { @@ -411,7 +411,7 @@ func asParamType(kind int) string { return "" } -func asDataType(any interface{}) (*string, *Item) { +func asDataType(any interface{}, config *Config) (*string, *Item) { // If it's not a collection, return the suggested model name st := reflect.TypeOf(any) isCollection, st := detectCollectionType(st) @@ -424,7 +424,7 @@ func asDataType(any interface{}) (*string, *Item) { // XXX: This is not very elegant // We create an Item object referring to the given model models := ModelList{} - mb := modelBuilder{&models} + mb := modelBuilder{Models: &models, Config: config} mb.addModelFrom(any) elemTypeName := mb.getElementTypeName(modelName, "", st)