Make RESTClient more generic to API version, simplify version handling

RESTClient is an abstraction on top of arbitrary HTTP endpoints that
follow the Kubernetes API conventions. Refactored RESTClientFor so that
assumptions that are Kube specific happen outside of that method (so
others can reuse the RESTClient). Added more validation to client.New
to ensure clients give good input. Exposed APIVersion on RESTClient
as a method so that wrapper code (code that adds typed / structured
methods over rest endpoints like client.Client) can more easily make
decisions about what APIVersion it is running under.
This commit is contained in:
Clayton Coleman
2015-01-06 12:36:08 -05:00
parent d314862e46
commit b03fbf90f8
13 changed files with 233 additions and 88 deletions

View File

@@ -38,7 +38,7 @@ import (
)
func makeNamespaceURL(namespace, suffix string) string {
if client.NamespaceInPathFor(testapi.Version()) {
if !(testapi.Version() == "v1beta1" || testapi.Version() == "v1beta2") {
return makeURL("/ns/" + namespace + suffix)
}
return makeURL(suffix + "?namespace=" + namespace)