Ejemplo n.º 1
0
func (c *RESTClient) request(verb string) *restclient.Request {
	config := restclient.ContentConfig{
		ContentType:          runtime.ContentTypeJSON,
		GroupVersion:         &registered.GroupOrDie(api.GroupName).GroupVersion,
		NegotiatedSerializer: c.NegotiatedSerializer,
	}

	groupName := api.GroupName
	if c.GroupName != "" {
		groupName = c.GroupName
	}
	ns := c.NegotiatedSerializer
	info, _ := runtime.SerializerInfoForMediaType(ns.SupportedMediaTypes(), runtime.ContentTypeJSON)
	internalVersion := unversioned.GroupVersion{
		Group:   registered.GroupOrDie(groupName).GroupVersion.Group,
		Version: runtime.APIVersionInternal,
	}
	internalVersion.Version = runtime.APIVersionInternal
	serializers := restclient.Serializers{
		Encoder: ns.EncoderForVersion(info.Serializer, registered.GroupOrDie(api.GroupName).GroupVersion),
		Decoder: ns.DecoderToVersion(info.Serializer, internalVersion),
	}
	if info.StreamSerializer != nil {
		serializers.StreamingSerializer = info.StreamSerializer.Serializer
		serializers.Framer = info.StreamSerializer.Framer
	}
	return restclient.NewRequest(c, verb, &url.URL{Host: "localhost"}, "", config, serializers, nil, nil)
}
Ejemplo n.º 2
0
func (c *FakeRESTClient) Delete() *restclient.Request {
	codec := testapi.Default.Codec()
	return restclient.NewRequest(clientFunc(func(req *http.Request) (*http.Response, error) {
		return c.response, c.err
	}), "DELETE", nil, "/api/v1", restclient.ContentConfig{}, restclient.Serializers{
		Encoder: codec,
	}, nil, nil)
}
Ejemplo n.º 3
0
func (c *RESTClient) request(verb string) *restclient.Request {
	config := restclient.ContentConfig{
		GroupVersion: testapi.Default.GroupVersion(),
		Codec:        c.Codec,
	}
	serializers := restclient.Serializers{
		Encoder:             c.Codec,
		Decoder:             c.Codec,
		StreamingSerializer: c.Codec,
		Framer:              runtime.DefaultFramer,
	}
	return restclient.NewRequest(c, verb, &url.URL{Host: "localhost"}, "", config, serializers, nil, nil)
}
Ejemplo n.º 4
0
func (c *RESTClient) request(verb string) *restclient.Request {
	config := restclient.ContentConfig{
		ContentType:          runtime.ContentTypeJSON,
		GroupVersion:         testapi.Default.GroupVersion(),
		NegotiatedSerializer: c.NegotiatedSerializer,
	}
	ns := c.NegotiatedSerializer
	serializer, _ := ns.SerializerForMediaType(runtime.ContentTypeJSON, nil)
	streamingSerializer, _ := ns.StreamingSerializerForMediaType(runtime.ContentTypeJSON, nil)
	internalVersion := unversioned.GroupVersion{
		Group:   testapi.Default.GroupVersion().Group,
		Version: runtime.APIVersionInternal,
	}
	internalVersion.Version = runtime.APIVersionInternal
	serializers := restclient.Serializers{
		Encoder:             ns.EncoderForVersion(serializer, *testapi.Default.GroupVersion()),
		Decoder:             ns.DecoderToVersion(serializer, internalVersion),
		StreamingSerializer: streamingSerializer,
		Framer:              streamingSerializer.Framer,
	}
	return restclient.NewRequest(c, verb, &url.URL{Host: "localhost"}, "", config, serializers, nil, nil)
}
Ejemplo n.º 5
0
func (c *RESTClient) request(verb string) *restclient.Request {
	return restclient.NewRequest(c, verb, &url.URL{Host: "localhost"}, "", restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion(), Codec: c.Codec}, nil, nil)
}
Ejemplo n.º 6
0
func (c *FakeRESTClient) Get() *restclient.Request {
	return restclient.NewRequest(clientFunc(func(req *http.Request) (*http.Response, error) {
		return c.response, c.err
	}), "GET", nil, "/api/v1", restclient.ContentConfig{}, restclient.Serializers{}, nil, nil)
}
Ejemplo n.º 7
0
func (c FakeHeapsterClient) Get(path string) client.RequestInterface {
	return restclient.NewRequest(clientFunc(func(req *http.Request) (*http.Response, error) {
		return nil, fmt.Errorf("fake error")
	}), "GET", nil, "/api/v1", restclient.ContentConfig{}, restclient.Serializers{}, nil, nil)
}