Revert "Adding converter functions to convert field label selectors to internal version before matching"

This commit is contained in:
Zach Loafman
2015-02-28 11:42:49 -08:00
parent 0fec31a11e
commit 5f35a67002
13 changed files with 56 additions and 224 deletions

View File

@@ -18,6 +18,7 @@ package apiserver
import (
"net/http"
"net/url"
"path"
"regexp"
"strings"
@@ -26,6 +27,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/httplog"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
watchjson "github.com/GoogleCloudPlatform/kubernetes/pkg/watch/json"
@@ -54,6 +56,25 @@ func (h *WatchHandler) setSelfLinkAddName(obj runtime.Object, req *http.Request)
return h.linker.SetSelfLink(obj, newURL.String())
}
func getWatchParams(query url.Values) (label, field labels.Selector, resourceVersion string, err error) {
s, perr := labels.ParseSelector(query.Get("labels"))
if perr != nil {
err = perr
return
}
label = s
s, perr = labels.ParseSelector(query.Get("fields"))
if perr != nil {
err = perr
return
}
field = s
resourceVersion = query.Get("resourceVersion")
return
}
var connectionUpgradeRegex = regexp.MustCompile("(^|.*,\\s*)upgrade($|\\s*,)")
func isWebsocketRequest(req *http.Request) bool {
@@ -96,13 +117,11 @@ func (h *WatchHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
return
}
label, field, err := parseSelectorQueryParams(req.URL.Query(), requestInfo.APIVersion, apiResource)
label, field, resourceVersion, err := getWatchParams(req.URL.Query())
if err != nil {
httpCode = errorJSON(err, h.codec, w)
return
}
resourceVersion := req.URL.Query().Get("resourceVersion")
watching, err := watcher.Watch(ctx, label, field, resourceVersion)
if err != nil {
httpCode = errorJSON(err, h.codec, w)