mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-25 22:48:22 +00:00
published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub) copied from https://github.com/kubernetes/kubernetes.git, branch master, last commit is 124fb610dcbd445fa710da67508ac6d5b822f61d
This commit is contained in:
@@ -27,8 +27,8 @@ import (
|
||||
"time"
|
||||
|
||||
"k8s.io/client-go/pkg/api"
|
||||
"k8s.io/client-go/pkg/api/unversioned"
|
||||
"k8s.io/client-go/pkg/runtime"
|
||||
"k8s.io/client-go/pkg/runtime/schema"
|
||||
"k8s.io/client-go/pkg/util/flowcontrol"
|
||||
)
|
||||
|
||||
@@ -48,7 +48,7 @@ type Interface interface {
|
||||
Patch(pt api.PatchType) *Request
|
||||
Get() *Request
|
||||
Delete() *Request
|
||||
APIVersion() unversioned.GroupVersion
|
||||
APIVersion() schema.GroupVersion
|
||||
}
|
||||
|
||||
// RESTClient imposes common Kubernetes API conventions on a set of resource paths.
|
||||
@@ -100,7 +100,7 @@ func NewRESTClient(baseURL *url.URL, versionedAPIPath string, config ContentConf
|
||||
base.Fragment = ""
|
||||
|
||||
if config.GroupVersion == nil {
|
||||
config.GroupVersion = &unversioned.GroupVersion{}
|
||||
config.GroupVersion = &schema.GroupVersion{}
|
||||
}
|
||||
if len(config.ContentType) == 0 {
|
||||
config.ContentType = "application/json"
|
||||
@@ -173,7 +173,7 @@ func createSerializers(config ContentConfig) (*Serializers, error) {
|
||||
info = mediaTypes[0]
|
||||
}
|
||||
|
||||
internalGV := unversioned.GroupVersions{
|
||||
internalGV := schema.GroupVersions{
|
||||
{
|
||||
Group: config.GroupVersion.Group,
|
||||
Version: runtime.APIVersionInternal,
|
||||
@@ -253,6 +253,6 @@ func (c *RESTClient) Delete() *Request {
|
||||
}
|
||||
|
||||
// APIVersion returns the APIVersion this RESTClient is expected to use.
|
||||
func (c *RESTClient) APIVersion() unversioned.GroupVersion {
|
||||
func (c *RESTClient) APIVersion() schema.GroupVersion {
|
||||
return *c.contentConfig.GroupVersion
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@ import (
|
||||
"k8s.io/client-go/pkg/api/unversioned"
|
||||
"k8s.io/client-go/pkg/apimachinery/registered"
|
||||
"k8s.io/client-go/pkg/runtime"
|
||||
"k8s.io/client-go/pkg/runtime/schema"
|
||||
"k8s.io/client-go/pkg/util/diff"
|
||||
utiltesting "k8s.io/client-go/pkg/util/testing"
|
||||
)
|
||||
@@ -51,7 +52,7 @@ type TestParam struct {
|
||||
func TestSerializer(t *testing.T) {
|
||||
contentConfig := ContentConfig{
|
||||
ContentType: "application/json",
|
||||
GroupVersion: &unversioned.GroupVersion{Group: "other", Version: runtime.APIVersionInternal},
|
||||
GroupVersion: &schema.GroupVersion{Group: "other", Version: runtime.APIVersionInternal},
|
||||
NegotiatedSerializer: api.Codecs,
|
||||
}
|
||||
|
||||
|
@@ -32,6 +32,7 @@ import (
|
||||
"k8s.io/client-go/pkg/api"
|
||||
"k8s.io/client-go/pkg/api/unversioned"
|
||||
"k8s.io/client-go/pkg/runtime"
|
||||
"k8s.io/client-go/pkg/runtime/schema"
|
||||
certutil "k8s.io/client-go/pkg/util/cert"
|
||||
"k8s.io/client-go/pkg/util/flowcontrol"
|
||||
"k8s.io/client-go/pkg/version"
|
||||
@@ -150,7 +151,7 @@ type ContentConfig struct {
|
||||
// GroupVersion is the API version to talk to. Must be provided when initializing
|
||||
// a RESTClient directly. When initializing a Client, will be set with the default
|
||||
// code version.
|
||||
GroupVersion *unversioned.GroupVersion
|
||||
GroupVersion *schema.GroupVersion
|
||||
// NegotiatedSerializer is used for obtaining encoders and decoders for multiple
|
||||
// supported media types.
|
||||
NegotiatedSerializer runtime.NegotiatedSerializer
|
||||
|
@@ -27,9 +27,9 @@ import (
|
||||
|
||||
"k8s.io/client-go/pkg/api"
|
||||
"k8s.io/client-go/pkg/api/testapi"
|
||||
"k8s.io/client-go/pkg/api/unversioned"
|
||||
"k8s.io/client-go/pkg/apimachinery/registered"
|
||||
"k8s.io/client-go/pkg/runtime"
|
||||
"k8s.io/client-go/pkg/runtime/schema"
|
||||
"k8s.io/client-go/pkg/util/diff"
|
||||
"k8s.io/client-go/pkg/util/flowcontrol"
|
||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||
@@ -133,7 +133,7 @@ func (t *fakeLimiter) Accept() {}
|
||||
|
||||
type fakeCodec struct{}
|
||||
|
||||
func (c *fakeCodec) Decode([]byte, *unversioned.GroupVersionKind, runtime.Object) (runtime.Object, *unversioned.GroupVersionKind, error) {
|
||||
func (c *fakeCodec) Decode([]byte, *schema.GroupVersionKind, runtime.Object) (runtime.Object, *schema.GroupVersionKind, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
|
@@ -24,9 +24,9 @@ import (
|
||||
|
||||
"k8s.io/client-go/pkg/api"
|
||||
"k8s.io/client-go/pkg/api/testapi"
|
||||
"k8s.io/client-go/pkg/api/unversioned"
|
||||
"k8s.io/client-go/pkg/apimachinery/registered"
|
||||
"k8s.io/client-go/pkg/runtime"
|
||||
"k8s.io/client-go/pkg/runtime/schema"
|
||||
"k8s.io/client-go/pkg/util/flowcontrol"
|
||||
"k8s.io/client-go/rest"
|
||||
)
|
||||
@@ -78,7 +78,7 @@ func (c *RESTClient) Verb(verb string) *rest.Request {
|
||||
return c.request(verb)
|
||||
}
|
||||
|
||||
func (c *RESTClient) APIVersion() unversioned.GroupVersion {
|
||||
func (c *RESTClient) APIVersion() schema.GroupVersion {
|
||||
return *(testapi.Default.GroupVersion())
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ func (c *RESTClient) request(verb string) *rest.Request {
|
||||
}
|
||||
ns := c.NegotiatedSerializer
|
||||
info, _ := runtime.SerializerInfoForMediaType(ns.SupportedMediaTypes(), runtime.ContentTypeJSON)
|
||||
internalVersion := unversioned.GroupVersion{
|
||||
internalVersion := schema.GroupVersion{
|
||||
Group: registered.GroupOrDie(groupName).GroupVersion.Group,
|
||||
Version: runtime.APIVersionInternal,
|
||||
}
|
||||
|
@@ -39,6 +39,7 @@ import (
|
||||
"k8s.io/client-go/pkg/fields"
|
||||
"k8s.io/client-go/pkg/labels"
|
||||
"k8s.io/client-go/pkg/runtime"
|
||||
"k8s.io/client-go/pkg/runtime/schema"
|
||||
"k8s.io/client-go/pkg/runtime/serializer/streaming"
|
||||
"k8s.io/client-go/pkg/util/flowcontrol"
|
||||
"k8s.io/client-go/pkg/util/net"
|
||||
@@ -333,10 +334,10 @@ func (r resourceTypeToFieldMapping) filterField(resourceType, field, value strin
|
||||
return fMapping.filterField(field, value)
|
||||
}
|
||||
|
||||
type versionToResourceToFieldMapping map[unversioned.GroupVersion]resourceTypeToFieldMapping
|
||||
type versionToResourceToFieldMapping map[schema.GroupVersion]resourceTypeToFieldMapping
|
||||
|
||||
// filterField transforms the given field/value selector for the given groupVersion and resource
|
||||
func (v versionToResourceToFieldMapping) filterField(groupVersion *unversioned.GroupVersion, resourceType, field, value string) (newField, newValue string, err error) {
|
||||
func (v versionToResourceToFieldMapping) filterField(groupVersion *schema.GroupVersion, resourceType, field, value string) (newField, newValue string, err error) {
|
||||
rMapping, ok := v[*groupVersion]
|
||||
if !ok {
|
||||
// no groupVersion overrides registered, default to identity mapping
|
||||
@@ -1001,7 +1002,7 @@ func (r *Request) newUnstructuredResponseError(body []byte, isTextResponse bool,
|
||||
return errors.NewGenericServerResponse(
|
||||
statusCode,
|
||||
method,
|
||||
unversioned.GroupResource{
|
||||
schema.GroupResource{
|
||||
Group: r.content.GroupVersion.Group,
|
||||
Resource: r.resource,
|
||||
},
|
||||
@@ -1146,7 +1147,7 @@ func (r Result) Error() error {
|
||||
|
||||
// attempt to convert the body into a Status object
|
||||
// to be backwards compatible with old servers that do not return a version, default to "v1"
|
||||
out, _, err := r.decoder.Decode(r.body, &unversioned.GroupVersionKind{Version: "v1"}, nil)
|
||||
out, _, err := r.decoder.Decode(r.body, &schema.GroupVersionKind{Version: "v1"}, nil)
|
||||
if err != nil {
|
||||
glog.V(5).Infof("body was not decodable (unable to check for Status): %v", err)
|
||||
return r.err
|
||||
|
@@ -39,6 +39,7 @@ import (
|
||||
"k8s.io/client-go/pkg/apimachinery/registered"
|
||||
"k8s.io/client-go/pkg/labels"
|
||||
"k8s.io/client-go/pkg/runtime"
|
||||
"k8s.io/client-go/pkg/runtime/schema"
|
||||
"k8s.io/client-go/pkg/runtime/serializer/streaming"
|
||||
"k8s.io/client-go/pkg/util/clock"
|
||||
"k8s.io/client-go/pkg/util/diff"
|
||||
@@ -270,8 +271,8 @@ func TestRequestURI(t *testing.T) {
|
||||
|
||||
type NotAnAPIObject struct{}
|
||||
|
||||
func (obj NotAnAPIObject) GroupVersionKind() *unversioned.GroupVersionKind { return nil }
|
||||
func (obj NotAnAPIObject) SetGroupVersionKind(gvk *unversioned.GroupVersionKind) {}
|
||||
func (obj NotAnAPIObject) GroupVersionKind() *schema.GroupVersionKind { return nil }
|
||||
func (obj NotAnAPIObject) SetGroupVersionKind(gvk *schema.GroupVersionKind) {}
|
||||
|
||||
func defaultContentConfig() ContentConfig {
|
||||
return ContentConfig{
|
||||
@@ -327,7 +328,7 @@ func TestResultIntoWithErrReturnsErr(t *testing.T) {
|
||||
|
||||
func TestURLTemplate(t *testing.T) {
|
||||
uri, _ := url.Parse("http://localhost")
|
||||
r := NewRequest(nil, "POST", uri, "", ContentConfig{GroupVersion: &unversioned.GroupVersion{Group: "test"}}, Serializers{}, nil, nil)
|
||||
r := NewRequest(nil, "POST", uri, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil)
|
||||
r.Prefix("pre1").Resource("r1").Namespace("ns").Name("nm").Param("p0", "v0")
|
||||
full := r.URL()
|
||||
if full.String() != "http://localhost/pre1/namespaces/ns/r1/nm?p0=v0" {
|
||||
@@ -1412,7 +1413,7 @@ func TestAbsPath(t *testing.T) {
|
||||
{"/p1/api/p2", "/api/r1", "/api/", "/p1/api/p2/api/"},
|
||||
} {
|
||||
u, _ := url.Parse("http://localhost:123" + tc.configPrefix)
|
||||
r := NewRequest(nil, "POST", u, "", ContentConfig{GroupVersion: &unversioned.GroupVersion{Group: "test"}}, Serializers{}, nil, nil).Prefix(tc.resourcePrefix).AbsPath(tc.absPath)
|
||||
r := NewRequest(nil, "POST", u, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil).Prefix(tc.resourcePrefix).AbsPath(tc.absPath)
|
||||
if r.pathPrefix != tc.wantsAbsPath {
|
||||
t.Errorf("test case %d failed, unexpected path: %q, expected %q", i, r.pathPrefix, tc.wantsAbsPath)
|
||||
}
|
||||
@@ -1432,7 +1433,7 @@ func TestUintParam(t *testing.T) {
|
||||
|
||||
for _, item := range table {
|
||||
u, _ := url.Parse("http://localhost")
|
||||
r := NewRequest(nil, "GET", u, "", ContentConfig{GroupVersion: &unversioned.GroupVersion{Group: "test"}}, Serializers{}, nil, nil).AbsPath("").UintParam(item.name, item.testVal)
|
||||
r := NewRequest(nil, "GET", u, "", ContentConfig{GroupVersion: &schema.GroupVersion{Group: "test"}}, Serializers{}, nil, nil).AbsPath("").UintParam(item.name, item.testVal)
|
||||
if e, a := item.expectStr, r.URL().String(); e != a {
|
||||
t.Errorf("expected %v, got %v", e, a)
|
||||
}
|
||||
|
@@ -21,13 +21,13 @@ import (
|
||||
"net/url"
|
||||
"path"
|
||||
|
||||
"k8s.io/client-go/pkg/api/unversioned"
|
||||
"k8s.io/client-go/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
// DefaultServerURL converts a host, host:port, or URL string to the default base server API path
|
||||
// to use with a Client at a given API version following the standard conventions for a
|
||||
// Kubernetes API.
|
||||
func DefaultServerURL(host, apiPath string, groupVersion unversioned.GroupVersion, defaultTLS bool) (*url.URL, string, error) {
|
||||
func DefaultServerURL(host, apiPath string, groupVersion schema.GroupVersion, defaultTLS bool) (*url.URL, string, error) {
|
||||
if host == "" {
|
||||
return nil, "", fmt.Errorf("host must be a URL or a host:port pair")
|
||||
}
|
||||
@@ -89,5 +89,5 @@ func defaultServerUrlFor(config *Config) (*url.URL, string, error) {
|
||||
if config.GroupVersion != nil {
|
||||
return DefaultServerURL(host, config.APIPath, *config.GroupVersion, defaultTLS)
|
||||
}
|
||||
return DefaultServerURL(host, config.APIPath, unversioned.GroupVersion{}, defaultTLS)
|
||||
return DefaultServerURL(host, config.APIPath, schema.GroupVersion{}, defaultTLS)
|
||||
}
|
||||
|
Reference in New Issue
Block a user