mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-01 02:38:12 +00:00 
			
		
		
		
	Prepare for content-type negotiation
Combine the fields that will be used for content transformation (content-type, codec, and group version) into a single struct in client, and then pass that struct into the rest client and request. Set the content-type when sending requests to the server, and accept the content type as primary. Will form the foundation for content-negotiation via the client.
This commit is contained in:
		| @@ -482,7 +482,7 @@ func newKubeClient() (*kclient.Client, error) { | ||||
| 		// Only --kube-master-url was provided. | ||||
| 		config = &kclient.Config{ | ||||
| 			Host:          masterURL, | ||||
| 			GroupVersion: &unversioned.GroupVersion{Version: "v1"}, | ||||
| 			ContentConfig: kclient.ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: "v1"}}, | ||||
| 		} | ||||
| 	} else { | ||||
| 		// We either have: | ||||
|   | ||||
| @@ -133,11 +133,11 @@ func startComponents(firstManifestURL, secondManifestURL string) (string, string | ||||
| 		glog.Fatalf("Failed to connect to etcd") | ||||
| 	} | ||||
|  | ||||
| 	cl := client.NewOrDie(&client.Config{Host: apiServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	cl := client.NewOrDie(&client.Config{Host: apiServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
|  | ||||
| 	// TODO: caesarxuchao: hacky way to specify version of Experimental client. | ||||
| 	// We will fix this by supporting multiple group versions in Config | ||||
| 	cl.ExtensionsClient = client.NewExtensionsOrDie(&client.Config{Host: apiServer.URL, GroupVersion: testapi.Extensions.GroupVersion()}) | ||||
| 	cl.ExtensionsClient = client.NewExtensionsOrDie(&client.Config{Host: apiServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Extensions.GroupVersion()}}) | ||||
|  | ||||
| 	// Master | ||||
| 	host, port, err := net.SplitHostPort(strings.TrimLeft(apiServer.URL, "http://")) | ||||
| @@ -984,10 +984,10 @@ func main() { | ||||
| 	// Wait for the synchronization threads to come up. | ||||
| 	time.Sleep(time.Second * 10) | ||||
|  | ||||
| 	kubeClient := client.NewOrDie(&client.Config{Host: apiServerURL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	kubeClient := client.NewOrDie(&client.Config{Host: apiServerURL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	// TODO: caesarxuchao: hacky way to specify version of Experimental client. | ||||
| 	// We will fix this by supporting multiple group versions in Config | ||||
| 	kubeClient.ExtensionsClient = client.NewExtensionsOrDie(&client.Config{Host: apiServerURL, GroupVersion: testapi.Extensions.GroupVersion()}) | ||||
| 	kubeClient.ExtensionsClient = client.NewExtensionsOrDie(&client.Config{Host: apiServerURL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Extensions.GroupVersion()}}) | ||||
|  | ||||
| 	// Run tests in parallel | ||||
| 	testFuncs := []testFunc{ | ||||
|   | ||||
| @@ -490,7 +490,7 @@ func newLifecycleTest(t *testing.T) lifecycleTest { | ||||
| 	// create framework | ||||
| 	client := client.NewOrDie(&client.Config{ | ||||
| 		Host:          apiServer.server.URL, | ||||
| 		GroupVersion: testapi.Default.GroupVersion(), | ||||
| 		ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}, | ||||
| 	}) | ||||
| 	c := *schedcfg.CreateDefaultConfig() | ||||
| 	fw := framework.New(framework.Config{ | ||||
|   | ||||
| @@ -79,6 +79,10 @@ func init() { | ||||
| 	Extensions = Groups[extensions.GroupName] | ||||
| } | ||||
|  | ||||
| func (g TestGroup) ContentConfig() (string, *unversioned.GroupVersion, runtime.Codec) { | ||||
| 	return "application/json", g.GroupVersion(), g.Codec() | ||||
| } | ||||
|  | ||||
| func (g TestGroup) GroupVersion() *unversioned.GroupVersion { | ||||
| 	copyOfGroupVersion := g.externalGroupVersion | ||||
| 	return ©OfGroupVersion | ||||
|   | ||||
							
								
								
									
										4
									
								
								pkg/client/cache/listwatch_test.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								pkg/client/cache/listwatch_test.go
									
									
									
									
										vendored
									
									
								
							| @@ -97,7 +97,7 @@ func TestListWatchesCanList(t *testing.T) { | ||||
| 		server := httptest.NewServer(&handler) | ||||
| 		// TODO: Uncomment when fix #19254 | ||||
| 		// defer server.Close() | ||||
| 		client := client.NewOrDie(&client.Config{Host: server.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 		client := client.NewOrDie(&client.Config{Host: server.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 		lw := NewListWatchFromClient(client, item.resource, item.namespace, item.fieldSelector) | ||||
| 		// This test merely tests that the correct request is made. | ||||
| 		lw.List(api.ListOptions{}) | ||||
| @@ -164,7 +164,7 @@ func TestListWatchesCanWatch(t *testing.T) { | ||||
| 		server := httptest.NewServer(&handler) | ||||
| 		// TODO: Uncomment when fix #19254 | ||||
| 		// defer server.Close() | ||||
| 		client := client.NewOrDie(&client.Config{Host: server.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 		client := client.NewOrDie(&client.Config{Host: server.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 		lw := NewListWatchFromClient(client, item.resource, item.namespace, item.fieldSelector) | ||||
| 		// This test merely tests that the correct request is made. | ||||
| 		lw.Watch(api.ListOptions{ResourceVersion: item.rv}) | ||||
|   | ||||
| @@ -70,7 +70,7 @@ func (c *RESTClient) Delete() *unversioned.Request { | ||||
| } | ||||
|  | ||||
| func (c *RESTClient) request(verb string) *unversioned.Request { | ||||
| 	return unversioned.NewRequest(c, verb, &url.URL{Host: "localhost"}, "", *testapi.Default.GroupVersion(), c.Codec, nil) | ||||
| 	return unversioned.NewRequest(c, verb, &url.URL{Host: "localhost"}, "", unversioned.ContentConfig{GroupVersion: testapi.Default.GroupVersion(), Codec: c.Codec}, nil) | ||||
| } | ||||
|  | ||||
| func (c *RESTClient) Do(req *http.Request) (*http.Response, error) { | ||||
|   | ||||
| @@ -55,14 +55,13 @@ type Config struct { | ||||
| 	Host string | ||||
| 	// APIPath is a sub-path that points to an API root. | ||||
| 	APIPath string | ||||
| 	// 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 | ||||
| 	// Codec specifies the encoding and decoding behavior for runtime.Objects passed | ||||
| 	// to a RESTClient or Client. Required when initializing a RESTClient, optional | ||||
| 	// when initializing a Client. | ||||
| 	Codec runtime.Codec | ||||
| 	// Prefix is the sub path of the server. If not specified, the client will set | ||||
| 	// a default value.  Use "/" to indicate the server root should be used | ||||
| 	Prefix string | ||||
|  | ||||
| 	// ContentConfig contains settings that affect how objects are transformed when | ||||
| 	// sent to the server. | ||||
| 	ContentConfig | ||||
|  | ||||
| 	// Server requires Basic authentication | ||||
| 	Username string | ||||
| @@ -120,6 +119,22 @@ type TLSClientConfig struct { | ||||
| 	CAData []byte | ||||
| } | ||||
|  | ||||
| type ContentConfig struct { | ||||
| 	// ContentType specifies the wire format used to communicate with the server. | ||||
| 	// This value will be set as the Accept header on requests made to the server, and | ||||
| 	// as the default content type on any object sent to the server. If not set, | ||||
| 	// "application/json" is used. | ||||
| 	ContentType string | ||||
| 	// 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 | ||||
| 	// Codec specifies the encoding and decoding behavior for runtime.Objects passed | ||||
| 	// to a RESTClient or Client. Required when initializing a RESTClient, optional | ||||
| 	// when initializing a Client. | ||||
| 	Codec runtime.Codec | ||||
| } | ||||
|  | ||||
| // New creates a Kubernetes client for the given config. This client works with pods, | ||||
| // replication controllers, daemons, and services. It allows operations such as list, get, update | ||||
| // and delete on these objects. An error is returned if the provided configuration | ||||
| @@ -407,16 +422,18 @@ func RESTClientFor(config *Config) (*RESTClient, error) { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	client := NewRESTClient(baseURL, versionedAPIPath, *config.GroupVersion, config.Codec, config.QPS, config.Burst) | ||||
|  | ||||
| 	transport, err := TransportFor(config) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	var httpClient *http.Client | ||||
| 	if transport != http.DefaultTransport { | ||||
| 		client.Client = &http.Client{Transport: transport} | ||||
| 		httpClient = &http.Client{Transport: transport} | ||||
| 	} | ||||
|  | ||||
| 	client := NewRESTClient(baseURL, versionedAPIPath, config.ContentConfig, config.QPS, config.Burst, httpClient) | ||||
|  | ||||
| 	return client, nil | ||||
| } | ||||
|  | ||||
| @@ -432,16 +449,23 @@ func UnversionedRESTClientFor(config *Config) (*RESTClient, error) { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	client := NewRESTClient(baseURL, versionedAPIPath, unversioned.SchemeGroupVersion, config.Codec, config.QPS, config.Burst) | ||||
|  | ||||
| 	transport, err := TransportFor(config) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	var httpClient *http.Client | ||||
| 	if transport != http.DefaultTransport { | ||||
| 		client.Client = &http.Client{Transport: transport} | ||||
| 		httpClient = &http.Client{Transport: transport} | ||||
| 	} | ||||
|  | ||||
| 	versionConfig := config.ContentConfig | ||||
| 	if versionConfig.GroupVersion == nil { | ||||
| 		v := unversioned.SchemeGroupVersion | ||||
| 		versionConfig.GroupVersion = &v | ||||
| 	} | ||||
|  | ||||
| 	client := NewRESTClient(baseURL, versionedAPIPath, versionConfig, config.QPS, config.Burst, httpClient) | ||||
| 	return client, nil | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -70,21 +70,21 @@ func TestNegotiateVersion(t *testing.T) { | ||||
| 		}, | ||||
| 		{ | ||||
| 			name:            "explicit version supported", | ||||
| 			config:          &unversioned.Config{GroupVersion: testapi.Default.GroupVersion()}, | ||||
| 			config:          &unversioned.Config{ContentConfig: unversioned.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}, | ||||
| 			serverVersions:  []string{"/version1", testapi.Default.GroupVersion().String()}, | ||||
| 			clientVersions:  []uapi.GroupVersion{{Version: "version1"}, *testapi.Default.GroupVersion()}, | ||||
| 			expectedVersion: testapi.Default.GroupVersion(), | ||||
| 		}, | ||||
| 		{ | ||||
| 			name:           "explicit version not supported", | ||||
| 			config:         &unversioned.Config{GroupVersion: testapi.Default.GroupVersion()}, | ||||
| 			config:         &unversioned.Config{ContentConfig: unversioned.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}, | ||||
| 			serverVersions: []string{"version1"}, | ||||
| 			clientVersions: []uapi.GroupVersion{{Version: "version1"}, *testapi.Default.GroupVersion()}, | ||||
| 			expectErr:      func(err error) bool { return strings.Contains(err.Error(), `server does not support API version "v1"`) }, | ||||
| 		}, | ||||
| 		{ | ||||
| 			name:           "connection refused error", | ||||
| 			config:         &unversioned.Config{GroupVersion: testapi.Default.GroupVersion()}, | ||||
| 			config:         &unversioned.Config{ContentConfig: unversioned.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}, | ||||
| 			serverVersions: []string{"version1"}, | ||||
| 			clientVersions: []uapi.GroupVersion{{Version: "version1"}, *testapi.Default.GroupVersion()}, | ||||
| 			sendErr:        errors.New("connection refused"), | ||||
|   | ||||
| @@ -93,8 +93,10 @@ func TestSetKubernetesDefaults(t *testing.T) { | ||||
| 			Config{}, | ||||
| 			Config{ | ||||
| 				APIPath: "/api", | ||||
| 				ContentConfig: ContentConfig{ | ||||
| 					GroupVersion: testapi.Default.GroupVersion(), | ||||
| 					Codec:        testapi.Default.Codec(), | ||||
| 				}, | ||||
| 				QPS:   5, | ||||
| 				Burst: 10, | ||||
| 			}, | ||||
| @@ -188,7 +190,7 @@ func TestHelperGetServerAPIVersions(t *testing.T) { | ||||
| 	})) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer server.Close() | ||||
| 	got, err := ServerAPIVersions(&Config{Host: server.URL, GroupVersion: &unversioned.GroupVersion{Group: "invalid version", Version: "one"}, Codec: testapi.Default.Codec()}) | ||||
| 	got, err := ServerAPIVersions(&Config{Host: server.URL, ContentConfig: ContentConfig{GroupVersion: &unversioned.GroupVersion{Group: "invalid version", Version: "one"}, Codec: testapi.Default.Codec()}}) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("unexpected encoding error: %v", err) | ||||
| 	} | ||||
| @@ -208,7 +210,7 @@ func TestSetsCodec(t *testing.T) { | ||||
| 		// "invalidVersion":                       {true, "", nil}, | ||||
| 	} | ||||
| 	for version, expected := range testCases { | ||||
| 		client, err := New(&Config{Host: "127.0.0.1", GroupVersion: &unversioned.GroupVersion{Version: version}}) | ||||
| 		client, err := New(&Config{Host: "127.0.0.1", ContentConfig: ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: version}}}) | ||||
| 		switch { | ||||
| 		case err == nil && expected.Err: | ||||
| 			t.Errorf("expected error but was nil") | ||||
| @@ -222,20 +224,20 @@ func TestSetsCodec(t *testing.T) { | ||||
| 		if e, a := expected.Prefix, client.RESTClient.versionedAPIPath; e != a { | ||||
| 			t.Errorf("expected %#v, got %#v", e, a) | ||||
| 		} | ||||
| 		if e, a := expected.Codec, client.RESTClient.Codec; !reflect.DeepEqual(e, a) { | ||||
| 		if e, a := expected.Codec, client.RESTClient.contentConfig.Codec; !reflect.DeepEqual(e, a) { | ||||
| 			t.Errorf("expected %#v, got %#v", e, a) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestRESTClientRequires(t *testing.T) { | ||||
| 	if _, err := RESTClientFor(&Config{Host: "127.0.0.1", Codec: testapi.Default.Codec()}); err == nil { | ||||
| 	if _, err := RESTClientFor(&Config{Host: "127.0.0.1", ContentConfig: ContentConfig{Codec: testapi.Default.Codec()}}); err == nil { | ||||
| 		t.Errorf("unexpected non-error") | ||||
| 	} | ||||
| 	if _, err := RESTClientFor(&Config{Host: "127.0.0.1", GroupVersion: testapi.Default.GroupVersion()}); err == nil { | ||||
| 	if _, err := RESTClientFor(&Config{Host: "127.0.0.1", ContentConfig: ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}); err == nil { | ||||
| 		t.Errorf("unexpected non-error") | ||||
| 	} | ||||
| 	if _, err := RESTClientFor(&Config{Host: "127.0.0.1", GroupVersion: testapi.Default.GroupVersion(), Codec: testapi.Default.Codec()}); err != nil { | ||||
| 	if _, err := RESTClientFor(&Config{Host: "127.0.0.1", ContentConfig: ContentConfig{GroupVersion: testapi.Default.GroupVersion(), Codec: testapi.Default.Codec()}}); err != nil { | ||||
| 		t.Errorf("unexpected error: %v", err) | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -190,7 +190,7 @@ func TestRequestExecuteRemoteCommand(t *testing.T) { | ||||
| 		server := httptest.NewServer(fakeExecServer(t, i, testCase.Stdin, testCase.Stdout, testCase.Stderr, testCase.Error, testCase.Tty, testCase.MessageCount)) | ||||
|  | ||||
| 		url, _ := url.ParseRequestURI(server.URL) | ||||
| 		c := client.NewRESTClient(url, "", unversioned.GroupVersion{Group: "x"}, nil, -1, -1) | ||||
| 		c := client.NewRESTClient(url, "", client.ContentConfig{GroupVersion: &unversioned.GroupVersion{Group: "x"}}, -1, -1, nil) | ||||
| 		req := c.Post().Resource("testing") | ||||
| 		req.SetHeader(httpstream.HeaderProtocolVersion, StreamProtocolV2Name) | ||||
| 		req.Param("command", "ls") | ||||
| @@ -275,7 +275,7 @@ func TestRequestAttachRemoteCommand(t *testing.T) { | ||||
| 		server := httptest.NewServer(fakeExecServer(t, i, testCase.Stdin, testCase.Stdout, testCase.Stderr, testCase.Error, testCase.Tty, 1)) | ||||
|  | ||||
| 		url, _ := url.ParseRequestURI(server.URL) | ||||
| 		c := client.NewRESTClient(url, "", unversioned.GroupVersion{Group: "x"}, nil, -1, -1) | ||||
| 		c := client.NewRESTClient(url, "", client.ContentConfig{GroupVersion: &unversioned.GroupVersion{Group: "x"}}, -1, -1, nil) | ||||
| 		req := c.Post().Resource("testing") | ||||
|  | ||||
| 		conf := &client.Config{ | ||||
|   | ||||
| @@ -83,8 +83,9 @@ type Request struct { | ||||
| 	// required | ||||
| 	client HTTPClient | ||||
| 	verb   string | ||||
|  | ||||
| 	baseURL *url.URL | ||||
| 	codec   runtime.Codec | ||||
| 	content ContentConfig | ||||
|  | ||||
| 	// generic components accessible via method setters | ||||
| 	pathPrefix string | ||||
| @@ -101,8 +102,6 @@ type Request struct { | ||||
| 	selector     labels.Selector | ||||
| 	timeout      time.Duration | ||||
|  | ||||
| 	groupVersion unversioned.GroupVersion | ||||
|  | ||||
| 	// output | ||||
| 	err  error | ||||
| 	body io.Reader | ||||
| @@ -115,26 +114,28 @@ type Request struct { | ||||
| } | ||||
|  | ||||
| // NewRequest creates a new request helper object for accessing runtime.Objects on a server. | ||||
| func NewRequest(client HTTPClient, verb string, baseURL *url.URL, versionedAPIPath string, groupVersion unversioned.GroupVersion, codec runtime.Codec, backoff BackoffManager) *Request { | ||||
| func NewRequest(client HTTPClient, verb string, baseURL *url.URL, versionedAPIPath string, content ContentConfig, backoff BackoffManager) *Request { | ||||
| 	if backoff == nil { | ||||
| 		glog.V(2).Infof("Not implementing request backoff strategy.") | ||||
| 		backoff = &NoBackoff{} | ||||
| 	} | ||||
| 	metrics.Register() | ||||
|  | ||||
| 	pathPrefix := "/" | ||||
| 	if baseURL != nil { | ||||
| 		pathPrefix = path.Join(pathPrefix, baseURL.Path) | ||||
| 	} | ||||
| 	return &Request{ | ||||
| 	r := &Request{ | ||||
| 		client:     client, | ||||
| 		verb:       verb, | ||||
| 		baseURL:    baseURL, | ||||
| 		pathPrefix: path.Join(pathPrefix, versionedAPIPath), | ||||
| 		groupVersion: groupVersion, | ||||
| 		codec:        codec, | ||||
| 		content:    content, | ||||
| 		backoffMgr: backoff, | ||||
| 	} | ||||
| 	if len(content.ContentType) > 0 { | ||||
| 		r.SetHeader("Accept", content.ContentType+", */*") | ||||
| 	} | ||||
| 	return r | ||||
| } | ||||
|  | ||||
| // Prefix adds segments to the relative beginning to the request path. These | ||||
| @@ -323,8 +324,8 @@ func (r resourceTypeToFieldMapping) filterField(resourceType, field, value strin | ||||
|  | ||||
| type versionToResourceToFieldMapping map[unversioned.GroupVersion]resourceTypeToFieldMapping | ||||
|  | ||||
| func (v versionToResourceToFieldMapping) filterField(groupVersion unversioned.GroupVersion, resourceType, field, value string) (newField, newValue string, err error) { | ||||
| 	rMapping, ok := v[groupVersion] | ||||
| func (v versionToResourceToFieldMapping) filterField(groupVersion *unversioned.GroupVersion, resourceType, field, value string) (newField, newValue string, err error) { | ||||
| 	rMapping, ok := v[*groupVersion] | ||||
| 	if !ok { | ||||
| 		glog.Warningf("Field selector: %v - %v - %v - %v: need to check if this is versioned correctly.", groupVersion, resourceType, field, value) | ||||
| 		return field, value, nil | ||||
| @@ -384,13 +385,13 @@ func (r *Request) FieldsSelectorParam(s fields.Selector) *Request { | ||||
| 		return r | ||||
| 	} | ||||
| 	s2, err := s.Transform(func(field, value string) (newField, newValue string, err error) { | ||||
| 		return fieldMappings.filterField(r.groupVersion, r.resource, field, value) | ||||
| 		return fieldMappings.filterField(r.content.GroupVersion, r.resource, field, value) | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		r.err = err | ||||
| 		return r | ||||
| 	} | ||||
| 	return r.setParam(unversioned.FieldSelectorQueryParam(r.groupVersion.String()), s2.String()) | ||||
| 	return r.setParam(unversioned.FieldSelectorQueryParam(r.content.GroupVersion.String()), s2.String()) | ||||
| } | ||||
|  | ||||
| // LabelsSelectorParam adds the given selector as a query parameter | ||||
| @@ -404,7 +405,7 @@ func (r *Request) LabelsSelectorParam(s labels.Selector) *Request { | ||||
| 	if s.Empty() { | ||||
| 		return r | ||||
| 	} | ||||
| 	return r.setParam(unversioned.LabelSelectorQueryParam(r.groupVersion.String()), s.String()) | ||||
| 	return r.setParam(unversioned.LabelSelectorQueryParam(r.content.GroupVersion.String()), s.String()) | ||||
| } | ||||
|  | ||||
| // UintParam creates a query parameter with the given value. | ||||
| @@ -430,7 +431,7 @@ func (r *Request) VersionedParams(obj runtime.Object, convertor runtime.ObjectCo | ||||
| 	if r.err != nil { | ||||
| 		return r | ||||
| 	} | ||||
| 	versioned, err := convertor.ConvertToVersion(obj, r.groupVersion.String()) | ||||
| 	versioned, err := convertor.ConvertToVersion(obj, r.content.GroupVersion.String()) | ||||
| 	if err != nil { | ||||
| 		r.err = err | ||||
| 		return r | ||||
| @@ -444,14 +445,14 @@ func (r *Request) VersionedParams(obj runtime.Object, convertor runtime.ObjectCo | ||||
| 		for _, value := range v { | ||||
| 			// TODO: Move it to setParam method, once we get rid of | ||||
| 			// FieldSelectorParam & LabelSelectorParam methods. | ||||
| 			if k == unversioned.LabelSelectorQueryParam(r.groupVersion.String()) && value == "" { | ||||
| 			if k == unversioned.LabelSelectorQueryParam(r.content.GroupVersion.String()) && value == "" { | ||||
| 				// Don't set an empty selector for backward compatibility. | ||||
| 				// Since there is no way to get the difference between empty | ||||
| 				// and unspecified string, we don't set it to avoid having | ||||
| 				// labelSelector= param in every request. | ||||
| 				continue | ||||
| 			} | ||||
| 			if k == unversioned.FieldSelectorQueryParam(r.groupVersion.String()) { | ||||
| 			if k == unversioned.FieldSelectorQueryParam(r.content.GroupVersion.String()) { | ||||
| 				if len(value) == 0 { | ||||
| 					// Don't set an empty selector for backward compatibility. | ||||
| 					// Since there is no way to get the difference between empty | ||||
| @@ -467,7 +468,7 @@ func (r *Request) VersionedParams(obj runtime.Object, convertor runtime.ObjectCo | ||||
| 				} | ||||
| 				filteredSelector, err := selector.Transform( | ||||
| 					func(field, value string) (newField, newValue string, err error) { | ||||
| 						return fieldMappings.filterField(r.groupVersion, r.resource, field, value) | ||||
| 						return fieldMappings.filterField(r.content.GroupVersion, r.resource, field, value) | ||||
| 					}) | ||||
| 				if err != nil { | ||||
| 					r.err = fmt.Errorf("untransformable field selector: %v", err) | ||||
| @@ -542,14 +543,14 @@ func (r *Request) Body(obj interface{}) *Request { | ||||
| 		if reflect.ValueOf(t).IsNil() { | ||||
| 			return r | ||||
| 		} | ||||
| 		data, err := runtime.Encode(r.codec, t) | ||||
| 		data, err := runtime.Encode(r.content.Codec, t) | ||||
| 		if err != nil { | ||||
| 			r.err = err | ||||
| 			return r | ||||
| 		} | ||||
| 		glog.V(8).Infof("Request Body: %s", string(data)) | ||||
| 		r.body = bytes.NewBuffer(data) | ||||
| 		r.SetHeader("Content-Type", "application/json") | ||||
| 		r.SetHeader("Content-Type", r.content.ContentType) | ||||
| 	default: | ||||
| 		r.err = fmt.Errorf("unknown type used for body: %+v", obj) | ||||
| 	} | ||||
| @@ -652,7 +653,7 @@ func (r *Request) Watch() (watch.Interface, error) { | ||||
| 		} | ||||
| 		return nil, fmt.Errorf("for request '%+v', got status: %v", url, resp.StatusCode) | ||||
| 	} | ||||
| 	return watch.NewStreamWatcher(watchjson.NewDecoder(resp.Body, r.codec)), nil | ||||
| 	return watch.NewStreamWatcher(watchjson.NewDecoder(resp.Body, r.content.Codec)), nil | ||||
| } | ||||
|  | ||||
| // updateURLMetrics is a convenience function for pushing metrics. | ||||
| @@ -717,7 +718,7 @@ func (r *Request) Stream() (io.ReadCloser, error) { | ||||
| 			return nil, fmt.Errorf("%v while accessing %v", resp.Status, url) | ||||
| 		} | ||||
|  | ||||
| 		if runtimeObject, err := runtime.Decode(r.codec, bodyBytes); err == nil { | ||||
| 		if runtimeObject, err := runtime.Decode(r.content.Codec, bodyBytes); err == nil { | ||||
| 			statusError := errors.FromObject(runtimeObject) | ||||
|  | ||||
| 			if _, ok := statusError.(errors.APIStatus); ok { | ||||
| @@ -847,7 +848,7 @@ func (r *Request) transformResponse(resp *http.Response, req *http.Request) Resu | ||||
| 	// Did the server give us a status response? | ||||
| 	isStatusResponse := false | ||||
| 	var status *unversioned.Status | ||||
| 	result, err := runtime.Decode(r.codec, body) | ||||
| 	result, err := runtime.Decode(r.content.Codec, body) | ||||
| 	if out, ok := result.(*unversioned.Status); err == nil && ok && len(out.Status) > 0 { | ||||
| 		status = out | ||||
| 		isStatusResponse = true | ||||
| @@ -872,8 +873,9 @@ func (r *Request) transformResponse(resp *http.Response, req *http.Request) Resu | ||||
|  | ||||
| 	return Result{ | ||||
| 		body:        body, | ||||
| 		contentType: resp.Header.Get("Content-Type"), | ||||
| 		statusCode:  resp.StatusCode, | ||||
| 		codec:      r.codec, | ||||
| 		decoder:     r.content.Codec, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -908,7 +910,18 @@ func (r *Request) transformUnstructuredResponseError(resp *http.Response, req *h | ||||
| 		message = strings.TrimSpace(string(body)) | ||||
| 	} | ||||
| 	retryAfter, _ := retryAfterSeconds(resp) | ||||
| 	return errors.NewGenericServerResponse(resp.StatusCode, req.Method, unversioned.GroupResource{Group: r.groupVersion.Group, Resource: r.resource}, r.resourceName, message, retryAfter, true) | ||||
| 	return errors.NewGenericServerResponse( | ||||
| 		resp.StatusCode, | ||||
| 		req.Method, | ||||
| 		unversioned.GroupResource{ | ||||
| 			Group:    r.content.GroupVersion.Group, | ||||
| 			Resource: r.resource, | ||||
| 		}, | ||||
| 		r.resourceName, | ||||
| 		message, | ||||
| 		retryAfter, | ||||
| 		true, | ||||
| 	) | ||||
| } | ||||
|  | ||||
| // isTextResponse returns true if the response appears to be a textual media type. | ||||
| @@ -951,10 +964,11 @@ func retryAfterSeconds(resp *http.Response) (int, bool) { | ||||
| // Result contains the result of calling Request.Do(). | ||||
| type Result struct { | ||||
| 	body        []byte | ||||
| 	contentType string | ||||
| 	err         error | ||||
| 	statusCode  int | ||||
|  | ||||
| 	codec runtime.Codec | ||||
| 	decoder runtime.Decoder | ||||
| } | ||||
|  | ||||
| // Raw returns the raw result. | ||||
| @@ -967,8 +981,7 @@ func (r Result) Get() (runtime.Object, error) { | ||||
| 	if r.err != nil { | ||||
| 		return nil, r.err | ||||
| 	} | ||||
| 	obj, err := runtime.Decode(r.codec, r.body) | ||||
| 	return obj, err | ||||
| 	return runtime.Decode(r.decoder, r.body) | ||||
| } | ||||
|  | ||||
| // StatusCode returns the HTTP status code of the request. (Only valid if no | ||||
| @@ -983,7 +996,7 @@ func (r Result) Into(obj runtime.Object) error { | ||||
| 	if r.err != nil { | ||||
| 		return r.err | ||||
| 	} | ||||
| 	return runtime.DecodeInto(r.codec, r.body, obj) | ||||
| 	return runtime.DecodeInto(r.decoder, r.body, obj) | ||||
| } | ||||
|  | ||||
| // WasCreated updates the provided bool pointer to whether the server returned | ||||
|   | ||||
| @@ -45,10 +45,21 @@ import ( | ||||
| 	watchjson "k8s.io/kubernetes/pkg/watch/json" | ||||
| ) | ||||
|  | ||||
| func TestNewRequestSetsAccept(t *testing.T) { | ||||
| 	r := NewRequest(nil, "get", &url.URL{Path: "/path/"}, "", ContentConfig{}, nil) | ||||
| 	if r.headers.Get("Accept") != "" { | ||||
| 		t.Errorf("unexpected headers: %#v", r.headers) | ||||
| 	} | ||||
| 	r = NewRequest(nil, "get", &url.URL{Path: "/path/"}, "", ContentConfig{ContentType: "application/other"}, nil) | ||||
| 	if r.headers.Get("Accept") != "application/other, */*" { | ||||
| 		t.Errorf("unexpected headers: %#v", r.headers) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestRequestWithErrorWontChange(t *testing.T) { | ||||
| 	original := Request{ | ||||
| 		err:     errors.New("test"), | ||||
| 		groupVersion: *testapi.Default.GroupVersion(), | ||||
| 		content: ContentConfig{GroupVersion: testapi.Default.GroupVersion()}, | ||||
| 	} | ||||
| 	r := original | ||||
| 	changed := r.Param("foo", "bar"). | ||||
| @@ -179,7 +190,7 @@ func TestRequestParam(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestRequestVersionedParams(t *testing.T) { | ||||
| 	r := (&Request{groupVersion: v1.SchemeGroupVersion}).Param("foo", "a") | ||||
| 	r := (&Request{content: ContentConfig{GroupVersion: &v1.SchemeGroupVersion}}).Param("foo", "a") | ||||
| 	if !reflect.DeepEqual(r.params, url.Values{"foo": []string{"a"}}) { | ||||
| 		t.Errorf("should have set a param: %#v", r) | ||||
| 	} | ||||
| @@ -195,7 +206,7 @@ func TestRequestVersionedParams(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestRequestVersionedParamsFromListOptions(t *testing.T) { | ||||
| 	r := &Request{groupVersion: v1.SchemeGroupVersion} | ||||
| 	r := &Request{content: ContentConfig{GroupVersion: &v1.SchemeGroupVersion}} | ||||
| 	r.VersionedParams(&api.ListOptions{ResourceVersion: "1"}, api.Scheme) | ||||
| 	if !reflect.DeepEqual(r.params, url.Values{ | ||||
| 		"resourceVersion": []string{"1"}, | ||||
| @@ -250,7 +261,7 @@ func TestRequestBody(t *testing.T) { | ||||
| 	} | ||||
|  | ||||
| 	// test unencodable api object | ||||
| 	r = (&Request{codec: testapi.Default.Codec()}).Body(&NotAnAPIObject{}) | ||||
| 	r = (&Request{content: ContentConfig{Codec: testapi.Default.Codec()}}).Body(&NotAnAPIObject{}) | ||||
| 	if r.err == nil || r.body != nil { | ||||
| 		t.Errorf("should have set err and left body nil: %#v", r) | ||||
| 	} | ||||
| @@ -265,7 +276,7 @@ func TestResultIntoWithErrReturnsErr(t *testing.T) { | ||||
|  | ||||
| func TestURLTemplate(t *testing.T) { | ||||
| 	uri, _ := url.Parse("http://localhost") | ||||
| 	r := NewRequest(nil, "POST", uri, "", unversioned.GroupVersion{Group: "test"}, nil, nil) | ||||
| 	r := NewRequest(nil, "POST", uri, "", ContentConfig{GroupVersion: &unversioned.GroupVersion{Group: "test"}}, 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" { | ||||
| @@ -326,7 +337,7 @@ func TestTransformResponse(t *testing.T) { | ||||
| 		{Response: &http.Response{StatusCode: 200, Body: ioutil.NopCloser(bytes.NewReader(invalid))}, Data: invalid}, | ||||
| 	} | ||||
| 	for i, test := range testCases { | ||||
| 		r := NewRequest(nil, "", uri, "", *testapi.Default.GroupVersion(), testapi.Default.Codec(), nil) | ||||
| 		r := NewRequest(nil, "", uri, "", ContentConfig{GroupVersion: testapi.Default.GroupVersion(), Codec: testapi.Default.Codec()}, nil) | ||||
| 		if test.Response.Body == nil { | ||||
| 			test.Response.Body = ioutil.NopCloser(bytes.NewReader([]byte{})) | ||||
| 		} | ||||
| @@ -413,7 +424,7 @@ func TestTransformUnstructuredError(t *testing.T) { | ||||
|  | ||||
| 	for _, testCase := range testCases { | ||||
| 		r := &Request{ | ||||
| 			codec:        testapi.Default.Codec(), | ||||
| 			content:      ContentConfig{GroupVersion: testapi.Default.GroupVersion(), Codec: testapi.Default.Codec()}, | ||||
| 			resourceName: testCase.Name, | ||||
| 			resource:     testCase.Resource, | ||||
| 		} | ||||
| @@ -464,7 +475,7 @@ func TestRequestWatch(t *testing.T) { | ||||
| 		}, | ||||
| 		{ | ||||
| 			Request: &Request{ | ||||
| 				codec: testapi.Default.Codec(), | ||||
| 				content: ContentConfig{GroupVersion: testapi.Default.GroupVersion(), Codec: testapi.Default.Codec()}, | ||||
| 				client: clientFunc(func(req *http.Request) (*http.Response, error) { | ||||
| 					return &http.Response{StatusCode: http.StatusForbidden}, nil | ||||
| 				}), | ||||
| @@ -477,7 +488,7 @@ func TestRequestWatch(t *testing.T) { | ||||
| 		}, | ||||
| 		{ | ||||
| 			Request: &Request{ | ||||
| 				codec: testapi.Default.Codec(), | ||||
| 				content: ContentConfig{GroupVersion: testapi.Default.GroupVersion(), Codec: testapi.Default.Codec()}, | ||||
| 				client: clientFunc(func(req *http.Request) (*http.Response, error) { | ||||
| 					return &http.Response{StatusCode: http.StatusUnauthorized}, nil | ||||
| 				}), | ||||
| @@ -490,7 +501,7 @@ func TestRequestWatch(t *testing.T) { | ||||
| 		}, | ||||
| 		{ | ||||
| 			Request: &Request{ | ||||
| 				codec: testapi.Default.Codec(), | ||||
| 				content: ContentConfig{GroupVersion: testapi.Default.GroupVersion(), Codec: testapi.Default.Codec()}, | ||||
| 				client: clientFunc(func(req *http.Request) (*http.Response, error) { | ||||
| 					return &http.Response{ | ||||
| 						StatusCode: http.StatusUnauthorized, | ||||
| @@ -602,7 +613,7 @@ func TestRequestStream(t *testing.T) { | ||||
| 						})))), | ||||
| 					}, nil | ||||
| 				}), | ||||
| 				codec:   testapi.Default.Codec(), | ||||
| 				content: ContentConfig{Codec: testapi.Default.Codec()}, | ||||
| 				baseURL: &url.URL{}, | ||||
| 			}, | ||||
| 			Err: true, | ||||
| @@ -1109,7 +1120,7 @@ func TestUintParam(t *testing.T) { | ||||
|  | ||||
| 	for _, item := range table { | ||||
| 		u, _ := url.Parse("http://localhost") | ||||
| 		r := NewRequest(nil, "GET", u, "", unversioned.GroupVersion{Group: "test"}, nil, nil).AbsPath("").UintParam(item.name, item.testVal) | ||||
| 		r := NewRequest(nil, "GET", u, "", ContentConfig{GroupVersion: &unversioned.GroupVersion{Group: "test"}}, 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) | ||||
| 		} | ||||
| @@ -1149,6 +1160,8 @@ func TestBody(t *testing.T) { | ||||
| 	} | ||||
| 	f.Close() | ||||
|  | ||||
| 	var nilObject *api.DeleteOptions | ||||
| 	typedObject := interface{}(nilObject) | ||||
| 	c := testRESTClient(t, nil) | ||||
| 	tests := []struct { | ||||
| 		input    interface{} | ||||
| @@ -1159,6 +1172,7 @@ func TestBody(t *testing.T) { | ||||
| 		{f.Name(), data, nil}, | ||||
| 		{strings.NewReader(data), data, nil}, | ||||
| 		{obj, string(bodyExpected), map[string]string{"Content-Type": "application/json"}}, | ||||
| 		{typedObject, "", nil}, | ||||
| 	} | ||||
| 	for i, tt := range tests { | ||||
| 		r := c.Post().Body(tt.input) | ||||
| @@ -1166,6 +1180,20 @@ func TestBody(t *testing.T) { | ||||
| 			t.Errorf("%d: r.Body(%#v) error: %v", i, tt, r.err) | ||||
| 			continue | ||||
| 		} | ||||
| 		if tt.headers != nil { | ||||
| 			for k, v := range tt.headers { | ||||
| 				if r.headers.Get(k) != v { | ||||
| 					t.Errorf("%d: r.headers[%q] = %q; want %q", i, k, v, v) | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if r.body == nil { | ||||
| 			if len(tt.expected) != 0 { | ||||
| 				t.Errorf("%d: r.body = %q; want %q", i, r.body, tt.expected) | ||||
| 			} | ||||
| 			continue | ||||
| 		} | ||||
| 		buf := make([]byte, len(tt.expected)) | ||||
| 		if _, err := r.body.Read(buf); err != nil { | ||||
| 			t.Errorf("%d: r.body.Read error: %v", i, err) | ||||
| @@ -1175,13 +1203,6 @@ func TestBody(t *testing.T) { | ||||
| 		if body != tt.expected { | ||||
| 			t.Errorf("%d: r.body = %q; want %q", i, body, tt.expected) | ||||
| 		} | ||||
| 		if tt.headers != nil { | ||||
| 			for k, v := range tt.headers { | ||||
| 				if r.headers.Get(k) != v { | ||||
| 					t.Errorf("%d: r.headers[%q] = %q; want %q", i, k, v, v) | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -1282,5 +1303,5 @@ func testRESTClient(t testing.TB, srv *httptest.Server) *RESTClient { | ||||
| 		} | ||||
| 	} | ||||
| 	versionedAPIPath := testapi.Default.ResourcePath("", "", "") | ||||
| 	return NewRESTClient(baseURL, versionedAPIPath, *testapi.Default.GroupVersion(), testapi.Default.Codec(), 0, 0) | ||||
| 	return NewRESTClient(baseURL, versionedAPIPath, ContentConfig{GroupVersion: testapi.Default.GroupVersion(), Codec: testapi.Default.Codec()}, 0, 0, nil) | ||||
| } | ||||
|   | ||||
| @@ -26,7 +26,6 @@ import ( | ||||
|  | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	"k8s.io/kubernetes/pkg/api/unversioned" | ||||
| 	"k8s.io/kubernetes/pkg/runtime" | ||||
| 	"k8s.io/kubernetes/pkg/util" | ||||
| ) | ||||
|  | ||||
| @@ -45,27 +44,25 @@ const ( | ||||
| // | ||||
| // Most consumers should use client.New() to get a Kubernetes API client. | ||||
| type RESTClient struct { | ||||
| 	baseURL          *url.URL | ||||
| 	// base is the root URL for all invocations of the client | ||||
| 	base *url.URL | ||||
| 	// versionedAPIPath is a path segment connecting the base URL to the resource root | ||||
| 	versionedAPIPath string | ||||
| 	// A string identifying the version of the API this client is expected to use. | ||||
| 	groupVersion unversioned.GroupVersion | ||||
|  | ||||
| 	// Codec is the encoding and decoding scheme that applies to a particular set of | ||||
| 	// REST resources. | ||||
| 	Codec runtime.Codec | ||||
|  | ||||
| 	// Set specific behavior of the client.  If not set http.DefaultClient will be | ||||
| 	// used. | ||||
| 	Client *http.Client | ||||
| 	// contentConfig is the information used to communicate with the server. | ||||
| 	contentConfig ContentConfig | ||||
|  | ||||
| 	// TODO extract this into a wrapper interface via the RESTClient interface in kubectl. | ||||
| 	Throttle util.RateLimiter | ||||
|  | ||||
| 	// Set specific behavior of the client.  If not set http.DefaultClient will be used. | ||||
| 	Client *http.Client | ||||
| } | ||||
|  | ||||
| // NewRESTClient creates a new RESTClient. This client performs generic REST functions | ||||
| // such as Get, Put, Post, and Delete on specified paths.  Codec controls encoding and | ||||
| // decoding of responses from the server. | ||||
| func NewRESTClient(baseURL *url.URL, versionedAPIPath string, groupVersion unversioned.GroupVersion, c runtime.Codec, maxQPS float32, maxBurst int) *RESTClient { | ||||
| func NewRESTClient(baseURL *url.URL, versionedAPIPath string, config ContentConfig, maxQPS float32, maxBurst int, client *http.Client) *RESTClient { | ||||
| 	base := *baseURL | ||||
| 	if !strings.HasSuffix(base.Path, "/") { | ||||
| 		base.Path += "/" | ||||
| @@ -73,16 +70,23 @@ func NewRESTClient(baseURL *url.URL, versionedAPIPath string, groupVersion unver | ||||
| 	base.RawQuery = "" | ||||
| 	base.Fragment = "" | ||||
|  | ||||
| 	if config.GroupVersion == nil { | ||||
| 		config.GroupVersion = &unversioned.GroupVersion{} | ||||
| 	} | ||||
| 	if len(config.ContentType) == 0 { | ||||
| 		config.ContentType = "application/json" | ||||
| 	} | ||||
|  | ||||
| 	var throttle util.RateLimiter | ||||
| 	if maxQPS > 0 { | ||||
| 		throttle = util.NewTokenBucketRateLimiter(maxQPS, maxBurst) | ||||
| 	} | ||||
| 	return &RESTClient{ | ||||
| 		baseURL:          &base, | ||||
| 		base:             &base, | ||||
| 		versionedAPIPath: versionedAPIPath, | ||||
| 		groupVersion:     groupVersion, | ||||
| 		Codec:            c, | ||||
| 		contentConfig:    config, | ||||
| 		Throttle:         throttle, | ||||
| 		Client:           client, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -97,12 +101,11 @@ func readExpBackoffConfig() BackoffManager { | ||||
| 	backoffDurationInt, errDuration := strconv.ParseInt(backoffDuration, 10, 64) | ||||
| 	if errBase != nil || errDuration != nil { | ||||
| 		return &NoBackoff{} | ||||
| 	} else { | ||||
| 	} | ||||
| 	return &URLBackoff{ | ||||
| 		Backoff: util.NewBackOff( | ||||
| 			time.Duration(backoffBaseInt)*time.Second, | ||||
| 			time.Duration(backoffDurationInt)*time.Second)} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Verb begins a request with a verb (GET, POST, PUT, DELETE). | ||||
| @@ -125,9 +128,9 @@ func (c *RESTClient) Verb(verb string) *Request { | ||||
| 	backoff := readExpBackoffConfig() | ||||
|  | ||||
| 	if c.Client == nil { | ||||
| 		return NewRequest(nil, verb, c.baseURL, c.versionedAPIPath, c.groupVersion, c.Codec, backoff) | ||||
| 		return NewRequest(nil, verb, c.base, c.versionedAPIPath, c.contentConfig, backoff) | ||||
| 	} | ||||
| 	return NewRequest(c.Client, verb, c.baseURL, c.versionedAPIPath, c.groupVersion, c.Codec, backoff) | ||||
| 	return NewRequest(c.Client, verb, c.base, c.versionedAPIPath, c.contentConfig, backoff) | ||||
| } | ||||
|  | ||||
| // Post begins a POST request. Short for c.Verb("POST"). | ||||
| @@ -157,5 +160,5 @@ func (c *RESTClient) Delete() *Request { | ||||
|  | ||||
| // APIVersion returns the APIVersion this RESTClient is expected to use. | ||||
| func (c *RESTClient) APIVersion() unversioned.GroupVersion { | ||||
| 	return c.groupVersion | ||||
| 	return *c.contentConfig.GroupVersion | ||||
| } | ||||
|   | ||||
| @@ -46,8 +46,10 @@ func TestDoRequestSuccess(t *testing.T) { | ||||
| 	// defer testServer.Close() | ||||
| 	c, err := RESTClientFor(&Config{ | ||||
| 		Host: testServer.URL, | ||||
| 		ContentConfig: ContentConfig{ | ||||
| 			GroupVersion: testapi.Default.GroupVersion(), | ||||
| 			Codec:        testapi.Default.Codec(), | ||||
| 		}, | ||||
| 		Username: "user", | ||||
| 		Password: "pass", | ||||
| 	}) | ||||
| @@ -90,8 +92,10 @@ func TestDoRequestFailed(t *testing.T) { | ||||
| 	// defer testServer.Close() | ||||
| 	c, err := RESTClientFor(&Config{ | ||||
| 		Host: testServer.URL, | ||||
| 		ContentConfig: ContentConfig{ | ||||
| 			GroupVersion: testapi.Default.GroupVersion(), | ||||
| 			Codec:        testapi.Default.Codec(), | ||||
| 		}, | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("unexpected error: %v", err) | ||||
| @@ -123,8 +127,10 @@ func TestDoRequestCreated(t *testing.T) { | ||||
| 	// defer testServer.Close() | ||||
| 	c, err := RESTClientFor(&Config{ | ||||
| 		Host: testServer.URL, | ||||
| 		ContentConfig: ContentConfig{ | ||||
| 			GroupVersion: testapi.Default.GroupVersion(), | ||||
| 			Codec:        testapi.Default.Codec(), | ||||
| 		}, | ||||
| 		Username: "user", | ||||
| 		Password: "pass", | ||||
| 	}) | ||||
|   | ||||
| @@ -77,14 +77,14 @@ func (c *Client) Setup(t *testing.T) *Client { | ||||
| 	if c.Client == nil { | ||||
| 		c.Client = client.NewOrDie(&client.Config{ | ||||
| 			Host:          c.server.URL, | ||||
| 			GroupVersion: testapi.Default.GroupVersion(), | ||||
| 			ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}, | ||||
| 		}) | ||||
|  | ||||
| 		// TODO: caesarxuchao: hacky way to specify version of Experimental client. | ||||
| 		// We will fix this by supporting multiple group versions in Config | ||||
| 		c.ExtensionsClient = client.NewExtensionsOrDie(&client.Config{ | ||||
| 			Host:          c.server.URL, | ||||
| 			GroupVersion: testapi.Extensions.GroupVersion(), | ||||
| 			ContentConfig: client.ContentConfig{GroupVersion: testapi.Extensions.GroupVersion()}, | ||||
| 		}) | ||||
| 	} | ||||
| 	c.QueryValidator = map[string]func(string, string) bool{} | ||||
|   | ||||
| @@ -192,7 +192,7 @@ func TestCreatePods(t *testing.T) { | ||||
| 	testServer := httptest.NewServer(&fakeHandler) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
|  | ||||
| 	podControl := RealPodControl{ | ||||
| 		KubeClient: client, | ||||
| @@ -212,7 +212,7 @@ func TestCreatePods(t *testing.T) { | ||||
| 		Spec: controllerSpec.Spec.Template.Spec, | ||||
| 	} | ||||
| 	fakeHandler.ValidateRequest(t, testapi.Default.ResourcePath("pods", api.NamespaceDefault, ""), "POST", nil) | ||||
| 	actualPod, err := runtime.Decode(client.Codec, []byte(fakeHandler.RequestBody)) | ||||
| 	actualPod, err := runtime.Decode(testapi.Default.Codec(), []byte(fakeHandler.RequestBody)) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("Unexpected error: %#v", err) | ||||
| 	} | ||||
|   | ||||
| @@ -133,7 +133,7 @@ func addPods(podStore cache.Store, nodeName string, label map[string]string, num | ||||
| } | ||||
|  | ||||
| func newTestController() (*DaemonSetsController, *controller.FakePodControl) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewDaemonSetsController(client, controller.NoResyncPeriodFunc) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
| 	podControl := &controller.FakePodControl{} | ||||
| @@ -369,7 +369,7 @@ func TestDSManagerInit(t *testing.T) { | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
|  | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewDaemonSetsController(client, controller.NoResyncPeriodFunc) | ||||
| 	manager.dsStore.Add(ds) | ||||
| 	manager.nodeStore.Add(newNode(nodeName, nil)) | ||||
|   | ||||
| @@ -104,7 +104,7 @@ func TestSyncEndpointsItemsPreserveNoSelector(t *testing.T) { | ||||
| 		}}) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	endpoints := NewEndpointController(client, controller.NoResyncPeriodFunc) | ||||
| 	endpoints.serviceStore.Store.Add(&api.Service{ | ||||
| 		ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: ns}, | ||||
| @@ -137,7 +137,7 @@ func TestCheckLeftoverEndpoints(t *testing.T) { | ||||
| 		}}) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	endpoints := NewEndpointController(client, controller.NoResyncPeriodFunc) | ||||
| 	endpoints.checkLeftoverEndpoints() | ||||
|  | ||||
| @@ -166,7 +166,7 @@ func TestSyncEndpointsProtocolTCP(t *testing.T) { | ||||
| 		}}) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	endpoints := NewEndpointController(client, controller.NoResyncPeriodFunc) | ||||
| 	addPods(endpoints.podStore.Store, ns, 1, 1, 0) | ||||
| 	endpoints.serviceStore.Store.Add(&api.Service{ | ||||
| @@ -208,7 +208,7 @@ func TestSyncEndpointsProtocolUDP(t *testing.T) { | ||||
| 		}}) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	endpoints := NewEndpointController(client, controller.NoResyncPeriodFunc) | ||||
| 	addPods(endpoints.podStore.Store, ns, 1, 1, 0) | ||||
| 	endpoints.serviceStore.Store.Add(&api.Service{ | ||||
| @@ -247,7 +247,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAll(t *testing.T) { | ||||
| 		}}) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	endpoints := NewEndpointController(client, controller.NoResyncPeriodFunc) | ||||
| 	addPods(endpoints.podStore.Store, ns, 1, 1, 0) | ||||
| 	endpoints.serviceStore.Store.Add(&api.Service{ | ||||
| @@ -285,7 +285,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAllNotReady(t *testing.T) { | ||||
| 		}}) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	endpoints := NewEndpointController(client, controller.NoResyncPeriodFunc) | ||||
| 	addPods(endpoints.podStore.Store, ns, 0, 1, 1) | ||||
| 	endpoints.serviceStore.Store.Add(&api.Service{ | ||||
| @@ -323,7 +323,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAllMixed(t *testing.T) { | ||||
| 		}}) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	endpoints := NewEndpointController(client, controller.NoResyncPeriodFunc) | ||||
| 	addPods(endpoints.podStore.Store, ns, 1, 1, 1) | ||||
| 	endpoints.serviceStore.Store.Add(&api.Service{ | ||||
| @@ -365,7 +365,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) { | ||||
| 		}}) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	endpoints := NewEndpointController(client, controller.NoResyncPeriodFunc) | ||||
| 	addPods(endpoints.podStore.Store, ns, 1, 1, 0) | ||||
| 	endpoints.serviceStore.Store.Add(&api.Service{ | ||||
| @@ -406,7 +406,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) { | ||||
| 		}}) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	endpoints := NewEndpointController(client, controller.NoResyncPeriodFunc) | ||||
| 	addPods(endpoints.podStore.Store, api.NamespaceDefault, 1, 1, 0) | ||||
| 	endpoints.serviceStore.Store.Add(&api.Service{ | ||||
| @@ -426,7 +426,7 @@ func TestSyncEndpointsItems(t *testing.T) { | ||||
| 		serverResponse{http.StatusOK, &api.Endpoints{}}) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	endpoints := NewEndpointController(client, controller.NoResyncPeriodFunc) | ||||
| 	addPods(endpoints.podStore.Store, ns, 3, 2, 0) | ||||
| 	addPods(endpoints.podStore.Store, "blah", 5, 2, 0) // make sure these aren't found! | ||||
| @@ -469,7 +469,7 @@ func TestSyncEndpointsItemsWithLabels(t *testing.T) { | ||||
| 		serverResponse{http.StatusOK, &api.Endpoints{}}) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	endpoints := NewEndpointController(client, controller.NoResyncPeriodFunc) | ||||
| 	addPods(endpoints.podStore.Store, ns, 3, 2, 0) | ||||
| 	serviceLabels := map[string]string{"foo": "bar"} | ||||
| @@ -530,7 +530,7 @@ func TestSyncEndpointsItemsPreexistingLabelsChange(t *testing.T) { | ||||
| 		}}) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	endpoints := NewEndpointController(client, controller.NoResyncPeriodFunc) | ||||
| 	addPods(endpoints.podStore.Store, ns, 1, 1, 0) | ||||
| 	serviceLabels := map[string]string{"baz": "blah"} | ||||
|   | ||||
| @@ -204,7 +204,7 @@ func TestControllerSyncJob(t *testing.T) { | ||||
|  | ||||
| 	for name, tc := range testCases { | ||||
| 		// job manager setup | ||||
| 		client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 		client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 		manager := NewJobController(client, controller.NoResyncPeriodFunc) | ||||
| 		fakePodControl := controller.FakePodControl{Err: tc.podControllerError} | ||||
| 		manager.podControl = &fakePodControl | ||||
| @@ -299,7 +299,7 @@ func TestSyncJobPastDeadline(t *testing.T) { | ||||
|  | ||||
| 	for name, tc := range testCases { | ||||
| 		// job manager setup | ||||
| 		client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 		client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 		manager := NewJobController(client, controller.NoResyncPeriodFunc) | ||||
| 		fakePodControl := controller.FakePodControl{} | ||||
| 		manager.podControl = &fakePodControl | ||||
| @@ -369,7 +369,7 @@ func getCondition(job *extensions.Job, condition extensions.JobConditionType) bo | ||||
| } | ||||
|  | ||||
| func TestSyncPastDeadlineJobFinished(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewJobController(client, controller.NoResyncPeriodFunc) | ||||
| 	fakePodControl := controller.FakePodControl{} | ||||
| 	manager.podControl = &fakePodControl | ||||
| @@ -403,7 +403,7 @@ func TestSyncPastDeadlineJobFinished(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestSyncJobComplete(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewJobController(client, controller.NoResyncPeriodFunc) | ||||
| 	fakePodControl := controller.FakePodControl{} | ||||
| 	manager.podControl = &fakePodControl | ||||
| @@ -428,7 +428,7 @@ func TestSyncJobComplete(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestSyncJobDeleted(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewJobController(client, controller.NoResyncPeriodFunc) | ||||
| 	fakePodControl := controller.FakePodControl{} | ||||
| 	manager.podControl = &fakePodControl | ||||
| @@ -448,7 +448,7 @@ func TestSyncJobDeleted(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestSyncJobUpdateRequeue(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewJobController(client, controller.NoResyncPeriodFunc) | ||||
| 	fakePodControl := controller.FakePodControl{} | ||||
| 	manager.podControl = &fakePodControl | ||||
| @@ -469,7 +469,7 @@ func TestSyncJobUpdateRequeue(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestJobPodLookup(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewJobController(client, controller.NoResyncPeriodFunc) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
| 	testCases := []struct { | ||||
| @@ -559,7 +559,7 @@ func (fe FakeJobExpectations) SatisfiedExpectations(controllerKey string) bool { | ||||
| // TestSyncJobExpectations tests that a pod cannot sneak in between counting active pods | ||||
| // and checking expectations. | ||||
| func TestSyncJobExpectations(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewJobController(client, controller.NoResyncPeriodFunc) | ||||
| 	fakePodControl := controller.FakePodControl{} | ||||
| 	manager.podControl = &fakePodControl | ||||
|   | ||||
| @@ -130,7 +130,7 @@ type serverResponse struct { | ||||
| } | ||||
|  | ||||
| func TestSyncReplicationControllerDoesNothing(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	fakePodControl := controller.FakePodControl{} | ||||
| 	manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, BurstReplicas) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
| @@ -146,7 +146,7 @@ func TestSyncReplicationControllerDoesNothing(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestSyncReplicationControllerDeletes(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	fakePodControl := controller.FakePodControl{} | ||||
| 	manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, BurstReplicas) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
| @@ -162,7 +162,7 @@ func TestSyncReplicationControllerDeletes(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestDeleteFinalStateUnknown(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	fakePodControl := controller.FakePodControl{} | ||||
| 	manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, BurstReplicas) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
| @@ -195,7 +195,7 @@ func TestDeleteFinalStateUnknown(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestSyncReplicationControllerCreates(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, BurstReplicas) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
|  | ||||
| @@ -218,7 +218,7 @@ func TestStatusUpdatesWithoutReplicasChange(t *testing.T) { | ||||
| 	testServer := httptest.NewServer(&fakeHandler) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, BurstReplicas) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
|  | ||||
| @@ -261,7 +261,7 @@ func TestControllerUpdateReplicas(t *testing.T) { | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
|  | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, BurstReplicas) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
|  | ||||
| @@ -300,7 +300,7 @@ func TestSyncReplicationControllerDormancy(t *testing.T) { | ||||
| 	testServer := httptest.NewServer(&fakeHandler) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
|  | ||||
| 	fakePodControl := controller.FakePodControl{} | ||||
| 	manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, BurstReplicas) | ||||
| @@ -349,7 +349,7 @@ func TestSyncReplicationControllerDormancy(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestPodControllerLookup(t *testing.T) { | ||||
| 	manager := NewReplicationManager(client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}), controller.NoResyncPeriodFunc, BurstReplicas) | ||||
| 	manager := NewReplicationManager(client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}), controller.NoResyncPeriodFunc, BurstReplicas) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
| 	testCases := []struct { | ||||
| 		inRCs     []*api.ReplicationController | ||||
| @@ -561,7 +561,7 @@ func TestControllerUpdateRequeue(t *testing.T) { | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
|  | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, BurstReplicas) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
|  | ||||
| @@ -641,7 +641,7 @@ func TestControllerUpdateStatusWithFailure(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func doTestControllerBurstReplicas(t *testing.T, burstReplicas, numReplicas int) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	fakePodControl := controller.FakePodControl{} | ||||
| 	manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, burstReplicas) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
| @@ -761,7 +761,7 @@ func (fe FakeRCExpectations) SatisfiedExpectations(controllerKey string) bool { | ||||
| // TestRCSyncExpectations tests that a pod cannot sneak in between counting active pods | ||||
| // and checking expectations. | ||||
| func TestRCSyncExpectations(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	fakePodControl := controller.FakePodControl{} | ||||
| 	manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, 2) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
| @@ -786,7 +786,7 @@ func TestRCSyncExpectations(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestDeleteControllerAndExpectations(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, 10) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
|  | ||||
| @@ -828,7 +828,7 @@ func TestDeleteControllerAndExpectations(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestRCManagerNotReady(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	fakePodControl := controller.FakePodControl{} | ||||
| 	manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, 2) | ||||
| 	manager.podControl = &fakePodControl | ||||
| @@ -865,7 +865,7 @@ func shuffle(controllers []*api.ReplicationController) []*api.ReplicationControl | ||||
| } | ||||
|  | ||||
| func TestOverlappingRCs(t *testing.T) { | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: "", ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
|  | ||||
| 	for i := 0; i < 5; i++ { | ||||
| 		manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, 10) | ||||
| @@ -908,7 +908,7 @@ func TestRCManagerInit(t *testing.T) { | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer testServer.Close() | ||||
|  | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: testServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	manager := NewReplicationManager(client, controller.NoResyncPeriodFunc, BurstReplicas) | ||||
| 	manager.rcStore.Store.Add(rc) | ||||
| 	manager.podStoreSynced = alwaysReady | ||||
|   | ||||
| @@ -392,7 +392,7 @@ func TestAnnotateErrors(t *testing.T) { | ||||
| 		f, tf, _ := NewAPIFactory() | ||||
| 		tf.Printer = &testPrinter{} | ||||
| 		tf.Namespace = "test" | ||||
| 		tf.ClientConfig = &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 		tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
|  | ||||
| 		buf := bytes.NewBuffer([]byte{}) | ||||
| 		cmd := NewCmdAnnotate(f, buf) | ||||
| @@ -448,7 +448,7 @@ func TestAnnotateObject(t *testing.T) { | ||||
| 		}), | ||||
| 	} | ||||
| 	tf.Namespace = "test" | ||||
| 	tf.ClientConfig = &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 	tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
|  | ||||
| 	buf := bytes.NewBuffer([]byte{}) | ||||
| 	cmd := NewCmdAnnotate(f, buf) | ||||
| @@ -498,7 +498,7 @@ func TestAnnotateObjectFromFile(t *testing.T) { | ||||
| 		}), | ||||
| 	} | ||||
| 	tf.Namespace = "test" | ||||
| 	tf.ClientConfig = &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 	tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
|  | ||||
| 	buf := bytes.NewBuffer([]byte{}) | ||||
| 	cmd := NewCmdAnnotate(f, buf) | ||||
| @@ -551,7 +551,7 @@ func TestAnnotateMultipleObjects(t *testing.T) { | ||||
| 		}), | ||||
| 	} | ||||
| 	tf.Namespace = "test" | ||||
| 	tf.ClientConfig = &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 	tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
|  | ||||
| 	buf := bytes.NewBuffer([]byte{}) | ||||
| 	cmd := NewCmdAnnotate(f, buf) | ||||
|   | ||||
| @@ -150,7 +150,7 @@ func TestAttach(t *testing.T) { | ||||
| 			}), | ||||
| 		} | ||||
| 		tf.Namespace = "test" | ||||
| 		tf.ClientConfig = &client.Config{GroupVersion: &unversioned.GroupVersion{Version: test.version}} | ||||
| 		tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: test.version}}} | ||||
| 		bufOut := bytes.NewBuffer([]byte{}) | ||||
| 		bufErr := bytes.NewBuffer([]byte{}) | ||||
| 		bufIn := bytes.NewBuffer([]byte{}) | ||||
| @@ -227,7 +227,7 @@ func TestAttachWarnings(t *testing.T) { | ||||
| 			}), | ||||
| 		} | ||||
| 		tf.Namespace = "test" | ||||
| 		tf.ClientConfig = &client.Config{GroupVersion: &unversioned.GroupVersion{Version: test.version}} | ||||
| 		tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: test.version}}} | ||||
| 		bufOut := bytes.NewBuffer([]byte{}) | ||||
| 		bufErr := bytes.NewBuffer([]byte{}) | ||||
| 		bufIn := bytes.NewBuffer([]byte{}) | ||||
|   | ||||
| @@ -165,7 +165,7 @@ func TestCordon(t *testing.T) { | ||||
| 				} | ||||
| 			}), | ||||
| 		} | ||||
| 		tf.ClientConfig = &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 		tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
|  | ||||
| 		buf := bytes.NewBuffer([]byte{}) | ||||
| 		cmd := test.cmd(f, buf) | ||||
| @@ -387,7 +387,7 @@ func TestDrain(t *testing.T) { | ||||
| 				} | ||||
| 			}), | ||||
| 		} | ||||
| 		tf.ClientConfig = &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 		tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
|  | ||||
| 		buf := bytes.NewBuffer([]byte{}) | ||||
| 		cmd := NewCmdDrain(f, buf) | ||||
|   | ||||
| @@ -196,7 +196,7 @@ func TestExec(t *testing.T) { | ||||
| 			}), | ||||
| 		} | ||||
| 		tf.Namespace = "test" | ||||
| 		tf.ClientConfig = &client.Config{GroupVersion: &unversioned.GroupVersion{Version: test.version}} | ||||
| 		tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: test.version}}} | ||||
| 		bufOut := bytes.NewBuffer([]byte{}) | ||||
| 		bufErr := bytes.NewBuffer([]byte{}) | ||||
| 		bufIn := bytes.NewBuffer([]byte{}) | ||||
|   | ||||
| @@ -122,7 +122,7 @@ func TestGetUnknownSchemaObject(t *testing.T) { | ||||
| 		Resp:  &http.Response{StatusCode: 200, Body: objBody(codec, &internalType{Name: "foo"})}, | ||||
| 	} | ||||
| 	tf.Namespace = "test" | ||||
| 	tf.ClientConfig = &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 	tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
| 	buf := bytes.NewBuffer([]byte{}) | ||||
|  | ||||
| 	cmd := NewCmdGet(f, buf) | ||||
| @@ -194,7 +194,7 @@ func TestGetUnknownSchemaObjectListGeneric(t *testing.T) { | ||||
| 			}), | ||||
| 		} | ||||
| 		tf.Namespace = "test" | ||||
| 		tf.ClientConfig = &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 		tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
| 		buf := bytes.NewBuffer([]byte{}) | ||||
| 		cmd := NewCmdGet(f, buf) | ||||
| 		cmd.SetOutput(buf) | ||||
| @@ -236,7 +236,7 @@ func TestGetSchemaObject(t *testing.T) { | ||||
| 		Resp:  &http.Response{StatusCode: 200, Body: objBody(codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}})}, | ||||
| 	} | ||||
| 	tf.Namespace = "test" | ||||
| 	tf.ClientConfig = &client.Config{GroupVersion: &unversioned.GroupVersion{Version: "v1"}} | ||||
| 	tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: "v1"}}} | ||||
| 	buf := bytes.NewBuffer([]byte{}) | ||||
|  | ||||
| 	cmd := NewCmdGet(f, buf) | ||||
| @@ -461,7 +461,7 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) { | ||||
| 		}), | ||||
| 	} | ||||
| 	tf.Namespace = "test" | ||||
| 	tf.ClientConfig = &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 	tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
| 	buf := bytes.NewBuffer([]byte{}) | ||||
|  | ||||
| 	cmd := NewCmdGet(f, buf) | ||||
|   | ||||
| @@ -301,7 +301,7 @@ func TestLabelErrors(t *testing.T) { | ||||
| 		f, tf, _ := NewAPIFactory() | ||||
| 		tf.Printer = &testPrinter{} | ||||
| 		tf.Namespace = "test" | ||||
| 		tf.ClientConfig = &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 		tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
|  | ||||
| 		buf := bytes.NewBuffer([]byte{}) | ||||
| 		cmd := NewCmdLabel(f, buf) | ||||
| @@ -354,7 +354,7 @@ func TestLabelForResourceFromFile(t *testing.T) { | ||||
| 		}), | ||||
| 	} | ||||
| 	tf.Namespace = "test" | ||||
| 	tf.ClientConfig = &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 	tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
|  | ||||
| 	buf := bytes.NewBuffer([]byte{}) | ||||
| 	cmd := NewCmdLabel(f, buf) | ||||
| @@ -403,7 +403,7 @@ func TestLabelMultipleObjects(t *testing.T) { | ||||
| 		}), | ||||
| 	} | ||||
| 	tf.Namespace = "test" | ||||
| 	tf.ClientConfig = &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 	tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
|  | ||||
| 	buf := bytes.NewBuffer([]byte{}) | ||||
| 	cmd := NewCmdLabel(f, buf) | ||||
|   | ||||
| @@ -66,7 +66,7 @@ func TestLog(t *testing.T) { | ||||
| 			}), | ||||
| 		} | ||||
| 		tf.Namespace = "test" | ||||
| 		tf.ClientConfig = &client.Config{GroupVersion: &unversioned.GroupVersion{Version: test.version}} | ||||
| 		tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: test.version}}} | ||||
| 		buf := bytes.NewBuffer([]byte{}) | ||||
|  | ||||
| 		cmd := NewCmdLogs(f, buf) | ||||
|   | ||||
| @@ -84,7 +84,7 @@ func TestPortForward(t *testing.T) { | ||||
| 			}), | ||||
| 		} | ||||
| 		tf.Namespace = "test" | ||||
| 		tf.ClientConfig = &client.Config{GroupVersion: &unversioned.GroupVersion{Version: test.version}} | ||||
| 		tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: test.version}}} | ||||
| 		ff := &fakePortForwarder{} | ||||
| 		if test.pfErr { | ||||
| 			ff.pfErr = fmt.Errorf("pf error") | ||||
| @@ -154,7 +154,7 @@ func TestPortForwardWithPFlag(t *testing.T) { | ||||
| 			}), | ||||
| 		} | ||||
| 		tf.Namespace = "test" | ||||
| 		tf.ClientConfig = &client.Config{GroupVersion: &unversioned.GroupVersion{Version: test.version}} | ||||
| 		tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: test.version}}} | ||||
| 		ff := &fakePortForwarder{} | ||||
| 		if test.pfErr { | ||||
| 			ff.pfErr = fmt.Errorf("pf error") | ||||
|   | ||||
| @@ -30,6 +30,7 @@ import ( | ||||
| 	"k8s.io/kubernetes/pkg/api/errors" | ||||
| 	"k8s.io/kubernetes/pkg/api/meta" | ||||
| 	"k8s.io/kubernetes/pkg/api/v1" | ||||
| 	"k8s.io/kubernetes/pkg/apimachinery/registered" | ||||
| 	"k8s.io/kubernetes/pkg/kubectl" | ||||
| 	cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" | ||||
| 	"k8s.io/kubernetes/pkg/kubectl/resource" | ||||
| @@ -234,6 +235,7 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg | ||||
| 	// than the old rc. This selector is the hash of the rc, which will differ because the new rc has a | ||||
| 	// different image. | ||||
| 	if len(image) != 0 { | ||||
| 		codec := registered.GroupOrDie(client.APIVersion().Group).Codec | ||||
| 		keepOldName = len(args) == 1 | ||||
| 		newName := findNewName(args, oldRc) | ||||
| 		if newRc, err = kubectl.LoadExistingNextReplicationController(client, cmdNamespace, newName); err != nil { | ||||
| @@ -248,14 +250,14 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg | ||||
| 			if oldRc.Spec.Template.Spec.Containers[0].Image == image { | ||||
| 				return cmdutil.UsageError(cmd, "Specified --image must be distinct from existing container image") | ||||
| 			} | ||||
| 			newRc, err = kubectl.CreateNewControllerFromCurrentController(client, client.Codec, cmdNamespace, oldName, newName, image, container, deploymentKey) | ||||
| 			newRc, err = kubectl.CreateNewControllerFromCurrentController(client, codec, cmdNamespace, oldName, newName, image, container, deploymentKey) | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 		} | ||||
| 		// Update the existing replication controller with pointers to the 'next' controller | ||||
| 		// and adding the <deploymentKey> label if necessary to distinguish it from the 'next' controller. | ||||
| 		oldHash, err := api.HashObject(oldRc, client.Codec) | ||||
| 		oldHash, err := api.HashObject(oldRc, codec) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
|   | ||||
| @@ -264,7 +264,7 @@ func TestGenerateService(t *testing.T) { | ||||
| 	for _, test := range tests { | ||||
| 		sawPOST := false | ||||
| 		f, tf, codec := NewAPIFactory() | ||||
| 		tf.ClientConfig = &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 		tf.ClientConfig = &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
| 		tf.Client = &fake.RESTClient{ | ||||
| 			Codec: codec, | ||||
| 			Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { | ||||
|   | ||||
| @@ -1328,7 +1328,7 @@ func TestUpdateWithRetries(t *testing.T) { | ||||
| 			} | ||||
| 		}), | ||||
| 	} | ||||
| 	clientConfig := &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 	clientConfig := &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
| 	client := client.NewOrDie(clientConfig) | ||||
| 	client.Client = fakeClient.Client | ||||
|  | ||||
| @@ -1425,7 +1425,7 @@ func TestAddDeploymentHash(t *testing.T) { | ||||
| 			} | ||||
| 		}), | ||||
| 	} | ||||
| 	clientConfig := &client.Config{GroupVersion: testapi.Default.GroupVersion()} | ||||
| 	clientConfig := &client.Config{ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
| 	client := client.NewOrDie(clientConfig) | ||||
| 	client.Client = fakeClient.Client | ||||
|  | ||||
|   | ||||
| @@ -45,7 +45,7 @@ func TestCreate(t *testing.T) { | ||||
| 	server := httptest.NewServer(&handler) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer server.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: server.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: server.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	factory := NewConfigFactory(client, api.DefaultSchedulerName) | ||||
| 	factory.Create() | ||||
| } | ||||
| @@ -64,7 +64,7 @@ func TestCreateFromConfig(t *testing.T) { | ||||
| 	server := httptest.NewServer(&handler) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer server.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: server.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: server.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	factory := NewConfigFactory(client, api.DefaultSchedulerName) | ||||
|  | ||||
| 	// Pre-register some predicate and priority functions | ||||
| @@ -106,7 +106,7 @@ func TestCreateFromEmptyConfig(t *testing.T) { | ||||
| 	server := httptest.NewServer(&handler) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer server.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: server.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: server.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	factory := NewConfigFactory(client, api.DefaultSchedulerName) | ||||
|  | ||||
| 	configData = []byte(`{}`) | ||||
| @@ -150,7 +150,7 @@ func TestDefaultErrorFunc(t *testing.T) { | ||||
| 	server := httptest.NewServer(mux) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer server.Close() | ||||
| 	factory := NewConfigFactory(client.NewOrDie(&client.Config{Host: server.URL, GroupVersion: testapi.Default.GroupVersion()}), api.DefaultSchedulerName) | ||||
| 	factory := NewConfigFactory(client.NewOrDie(&client.Config{Host: server.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}), api.DefaultSchedulerName) | ||||
| 	queue := cache.NewFIFO(cache.MetaNamespaceKeyFunc) | ||||
| 	podBackoff := podBackoff{ | ||||
| 		perPodBackoff:   map[types.NamespacedName]*backoffEntry{}, | ||||
| @@ -234,7 +234,7 @@ func TestBind(t *testing.T) { | ||||
| 		server := httptest.NewServer(&handler) | ||||
| 		// TODO: Uncomment when fix #19254 | ||||
| 		// defer server.Close() | ||||
| 		client := client.NewOrDie(&client.Config{Host: server.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 		client := client.NewOrDie(&client.Config{Host: server.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 		b := binder{client} | ||||
|  | ||||
| 		if err := b.Bind(item.binding); err != nil { | ||||
| @@ -320,7 +320,7 @@ func TestResponsibleForPod(t *testing.T) { | ||||
| 	server := httptest.NewServer(&handler) | ||||
| 	// TODO: Uncomment when fix #19254 | ||||
| 	// defer server.Close() | ||||
| 	client := client.NewOrDie(&client.Config{Host: server.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: server.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	// factory of "default-scheduler" | ||||
| 	factoryDefaultScheduler := NewConfigFactory(client, api.DefaultSchedulerName) | ||||
| 	// factory of "foo-scheduler" | ||||
|   | ||||
| @@ -52,7 +52,7 @@ func mustSetupScheduler() (schedulerConfigFactory *factory.ConfigFactory, destro | ||||
|  | ||||
| 	c := client.NewOrDie(&client.Config{ | ||||
| 		Host:          s.URL, | ||||
| 		GroupVersion: testapi.Default.GroupVersion(), | ||||
| 		ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}, | ||||
| 		QPS:           5000.0, | ||||
| 		Burst:         5000, | ||||
| 	}) | ||||
|   | ||||
| @@ -43,7 +43,7 @@ func TestClient(t *testing.T) { | ||||
|  | ||||
| 	ns := api.NamespaceDefault | ||||
| 	framework.DeleteAllEtcdKeys() | ||||
| 	client := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
|  | ||||
| 	info, err := client.Discovery().ServerVersion() | ||||
| 	if err != nil { | ||||
| @@ -113,7 +113,7 @@ func TestSingleWatch(t *testing.T) { | ||||
|  | ||||
| 	ns := "blargh" | ||||
| 	deleteAllEtcdKeys() | ||||
| 	client := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
|  | ||||
| 	mkEvent := func(i int) *api.Event { | ||||
| 		name := fmt.Sprintf("event-%v", i) | ||||
| @@ -197,7 +197,7 @@ func TestMultiWatch(t *testing.T) { | ||||
| 	defer s.Close() | ||||
|  | ||||
| 	ns := api.NamespaceDefault | ||||
| 	client := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
|  | ||||
| 	dummyEvent := func(i int) *api.Event { | ||||
| 		name := fmt.Sprintf("unrelated-%v", i) | ||||
|   | ||||
| @@ -197,7 +197,7 @@ func TestSchedulerExtender(t *testing.T) { | ||||
| 	masterConfig := framework.NewIntegrationTestMasterConfig() | ||||
| 	m = master.New(masterConfig) | ||||
|  | ||||
| 	restClient := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	restClient := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
|  | ||||
| 	extender1 := &Extender{ | ||||
| 		name:         "extender1", | ||||
|   | ||||
| @@ -100,7 +100,7 @@ func NewMasterComponents(c *Config) *MasterComponents { | ||||
| 	if c.DeleteEtcdKeys { | ||||
| 		DeleteAllEtcdKeys() | ||||
| 	} | ||||
| 	restClient := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion(), QPS: c.QPS, Burst: c.Burst}) | ||||
| 	restClient := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}, QPS: c.QPS, Burst: c.Burst}) | ||||
| 	rcStopCh := make(chan struct{}) | ||||
| 	controllerManager := replicationcontroller.NewReplicationManager(restClient, controller.NoResyncPeriodFunc, c.Burst) | ||||
|  | ||||
|   | ||||
| @@ -107,7 +107,7 @@ func TestApiserverMetrics(t *testing.T) { | ||||
|  | ||||
| 	// Make a request to the apiserver to ensure there's at least one data point | ||||
| 	// for the metrics we're expecting -- otherwise, they won't be exported. | ||||
| 	client := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	if _, err := client.Pods(api.NamespaceDefault).List(api.ListOptions{}); err != nil { | ||||
| 		t.Fatalf("unexpected error getting pods: %v", err) | ||||
| 	} | ||||
|   | ||||
| @@ -45,9 +45,9 @@ func TestPersistentVolumeRecycler(t *testing.T) { | ||||
| 	defer s.Close() | ||||
|  | ||||
| 	deleteAllEtcdKeys() | ||||
| 	binderClient := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	recyclerClient := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	testClient := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	binderClient := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	recyclerClient := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	testClient := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	host := volume.NewFakeVolumeHost("/tmp/fake", nil, nil) | ||||
|  | ||||
| 	plugins := []volume.VolumePlugin{&volume.FakeVolumePlugin{"plugin-name", host, volume.VolumeConfig{}, volume.VolumeOptions{}}} | ||||
|   | ||||
| @@ -64,7 +64,7 @@ func TestUnschedulableNodes(t *testing.T) { | ||||
| 	masterConfig := framework.NewIntegrationTestMasterConfig() | ||||
| 	m = master.New(masterConfig) | ||||
|  | ||||
| 	restClient := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	restClient := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
|  | ||||
| 	schedulerConfigFactory := factory.NewConfigFactory(restClient, api.DefaultSchedulerName) | ||||
| 	schedulerConfig, err := schedulerConfigFactory.Create() | ||||
| @@ -307,7 +307,7 @@ func TestMultiScheduler(t *testing.T) { | ||||
| 			- testPodNoAnnotation2 and testPodWithAnnotationFitsDefault2 shoule NOT be scheduled | ||||
| 	*/ | ||||
| 	// 1. create and start default-scheduler | ||||
| 	restClient := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	restClient := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
|  | ||||
| 	schedulerConfigFactory := factory.NewConfigFactory(restClient, api.DefaultSchedulerName) | ||||
| 	schedulerConfig, err := schedulerConfigFactory.Create() | ||||
| @@ -378,7 +378,7 @@ func TestMultiScheduler(t *testing.T) { | ||||
| 	} | ||||
|  | ||||
| 	// 5. create and start a scheduler with name "foo-scheduler" | ||||
| 	restClient2 := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	restClient2 := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
|  | ||||
| 	schedulerConfigFactory2 := factory.NewConfigFactory(restClient2, "foo-scheduler") | ||||
| 	schedulerConfig2, err := schedulerConfigFactory2.Create() | ||||
| @@ -464,7 +464,7 @@ func TestAllocatable(t *testing.T) { | ||||
| 	m = master.New(masterConfig) | ||||
|  | ||||
| 	// 1. create and start default-scheduler | ||||
| 	restClient := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	restClient := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
|  | ||||
| 	schedulerConfigFactory := factory.NewConfigFactory(restClient, api.DefaultSchedulerName) | ||||
| 	schedulerConfig, err := schedulerConfigFactory.Create() | ||||
|   | ||||
| @@ -56,7 +56,7 @@ func TestSecrets(t *testing.T) { | ||||
| 	m = master.New(masterConfig) | ||||
|  | ||||
| 	framework.DeleteAllEtcdKeys() | ||||
| 	client := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()}) | ||||
| 	client := client.NewOrDie(&client.Config{Host: s.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) | ||||
| 	DoTestSecrets(t, client) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -345,9 +345,9 @@ func startServiceAccountTestServer(t *testing.T) (*client.Client, client.Config, | ||||
| 	})) | ||||
|  | ||||
| 	// Anonymous client config | ||||
| 	clientConfig := client.Config{Host: apiServer.URL, GroupVersion: testapi.Default.GroupVersion()} | ||||
| 	clientConfig := client.Config{Host: apiServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}} | ||||
| 	// Root client | ||||
| 	rootClient := client.NewOrDie(&client.Config{Host: apiServer.URL, GroupVersion: testapi.Default.GroupVersion(), BearerToken: rootToken}) | ||||
| 	rootClient := client.NewOrDie(&client.Config{Host: apiServer.URL, ContentConfig: client.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}, BearerToken: rootToken}) | ||||
|  | ||||
| 	// Set up two authenticators: | ||||
| 	// 1. A token authenticator that maps the rootToken to the "root" user | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Clayton Coleman
					Clayton Coleman