client/restclient/fake move to client-go
This commit is contained in:
@@ -70,8 +70,6 @@ function save() {
|
||||
|
||||
# save everything for which the staging directory is the source of truth
|
||||
save "rest"
|
||||
# remove the rest/fake until we're authoritative for it (need to update for registry)
|
||||
rm -rf ${CLIENT_REPO_TEMP}/rest/fake
|
||||
save "tools/auth"
|
||||
save "tools/cache"
|
||||
save "tools/clientcmd"
|
||||
@@ -92,7 +90,6 @@ function mkcp() {
|
||||
echo "copying client packages"
|
||||
mkcp "pkg/client/clientset_generated/${CLIENTSET}" "pkg/client/clientset_generated"
|
||||
mkcp "/pkg/client/record" "/pkg/client"
|
||||
mkcp "/pkg/client/restclient/fake" "/pkg/client/restclient"
|
||||
mkcp "/pkg/client/testing" "/pkg/client"
|
||||
# remove this test because it imports the internal clientset
|
||||
rm "${CLIENT_REPO_TEMP}"/pkg/client/testing/core/fake_test.go
|
||||
@@ -188,7 +185,6 @@ mvfolder "pkg/client/clientset_generated/${CLIENTSET}" kubernetes
|
||||
mvfolder pkg/client/typed/discovery discovery
|
||||
mvfolder pkg/client/typed/dynamic dynamic
|
||||
mvfolder pkg/client/record tools/record
|
||||
mvfolder pkg/client/restclient/fake rest/fake
|
||||
mvfolder pkg/client/unversioned/portforward tools/portforward
|
||||
mvfolder pkg/client/testing/core testing
|
||||
mvfolder pkg/client/testing/cache tools/cache/testing
|
||||
|
||||
@@ -125,6 +125,7 @@ func TestNegotiateVersion(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
fakeClient := &fake.RESTClient{
|
||||
APIRegistry: api.Registry,
|
||||
NegotiatedSerializer: testapi.Default.NegotiatedSerializer(),
|
||||
Resp: &http.Response{
|
||||
StatusCode: test.statusCode,
|
||||
|
||||
@@ -22,11 +22,10 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"k8s.io/apimachinery/pkg/apimachinery/registered"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/client-go/pkg/api"
|
||||
"k8s.io/client-go/pkg/api/testapi"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/util/flowcontrol"
|
||||
)
|
||||
@@ -48,6 +47,7 @@ type RESTClient struct {
|
||||
Client *http.Client
|
||||
NegotiatedSerializer runtime.NegotiatedSerializer
|
||||
GroupName string
|
||||
APIRegistry *registered.APIRegistrationManager
|
||||
|
||||
Req *http.Request
|
||||
Resp *http.Response
|
||||
@@ -79,7 +79,7 @@ func (c *RESTClient) Verb(verb string) *restclient.Request {
|
||||
}
|
||||
|
||||
func (c *RESTClient) APIVersion() schema.GroupVersion {
|
||||
return *(testapi.Default.GroupVersion())
|
||||
return c.APIRegistry.GroupOrDie("").GroupVersion
|
||||
}
|
||||
|
||||
func (c *RESTClient) GetRateLimiter() flowcontrol.RateLimiter {
|
||||
@@ -88,24 +88,22 @@ func (c *RESTClient) GetRateLimiter() flowcontrol.RateLimiter {
|
||||
|
||||
func (c *RESTClient) request(verb string) *restclient.Request {
|
||||
config := restclient.ContentConfig{
|
||||
ContentType: runtime.ContentTypeJSON,
|
||||
GroupVersion: &api.Registry.GroupOrDie(api.GroupName).GroupVersion,
|
||||
ContentType: runtime.ContentTypeJSON,
|
||||
// TODO this was hardcoded before, but it doesn't look right
|
||||
GroupVersion: &c.APIRegistry.GroupOrDie("").GroupVersion,
|
||||
NegotiatedSerializer: c.NegotiatedSerializer,
|
||||
}
|
||||
|
||||
groupName := api.GroupName
|
||||
if c.GroupName != "" {
|
||||
groupName = c.GroupName
|
||||
}
|
||||
ns := c.NegotiatedSerializer
|
||||
info, _ := runtime.SerializerInfoForMediaType(ns.SupportedMediaTypes(), runtime.ContentTypeJSON)
|
||||
internalVersion := schema.GroupVersion{
|
||||
Group: api.Registry.GroupOrDie(groupName).GroupVersion.Group,
|
||||
Group: c.APIRegistry.GroupOrDie(c.GroupName).GroupVersion.Group,
|
||||
Version: runtime.APIVersionInternal,
|
||||
}
|
||||
internalVersion.Version = runtime.APIVersionInternal
|
||||
serializers := restclient.Serializers{
|
||||
Encoder: ns.EncoderForVersion(info.Serializer, api.Registry.GroupOrDie(api.GroupName).GroupVersion),
|
||||
// TODO this was hardcoded before, but it doesn't look right
|
||||
Encoder: ns.EncoderForVersion(info.Serializer, c.APIRegistry.GroupOrDie("").GroupVersion),
|
||||
Decoder: ns.DecoderToVersion(info.Serializer, internalVersion),
|
||||
}
|
||||
if info.StreamSerializer != nil {
|
||||
|
||||
Reference in New Issue
Block a user