mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 10:18:13 +00:00 
			
		
		
		
	Used Pods interface for binding.
This commit is contained in:
		| @@ -432,6 +432,17 @@ func (g TestGroup) ResourcePath(resource, namespace, name string) string { | |||||||
| 	return g.ResourcePathWithPrefix("", resource, namespace, name) | 	return g.ResourcePathWithPrefix("", resource, namespace, name) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // SubResourcePath returns the appropriate path for the given resource, namespace, | ||||||
|  | // name and subresource. | ||||||
|  | func (g TestGroup) SubResourcePath(resource, namespace, name, sub string) string { | ||||||
|  | 	path := g.ResourcePathWithPrefix("", resource, namespace, name) | ||||||
|  | 	if sub != "" { | ||||||
|  | 		path = path + "/" + sub | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return path | ||||||
|  | } | ||||||
|  |  | ||||||
| func (g TestGroup) RESTMapper() meta.RESTMapper { | func (g TestGroup) RESTMapper() meta.RESTMapper { | ||||||
| 	return api.Registry.RESTMapper() | 	return api.Registry.RESTMapper() | ||||||
| } | } | ||||||
|   | |||||||
| @@ -41,7 +41,6 @@ go_library( | |||||||
|         "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", |         "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", | ||||||
|         "//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library", |         "//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library", | ||||||
|         "//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library", |         "//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library", | ||||||
|         "//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library", |  | ||||||
|         "//vendor/k8s.io/client-go/tools/cache:go_default_library", |         "//vendor/k8s.io/client-go/tools/cache:go_default_library", | ||||||
|     ], |     ], | ||||||
| ) | ) | ||||||
|   | |||||||
| @@ -29,7 +29,6 @@ import ( | |||||||
| 	"k8s.io/apimachinery/pkg/types" | 	"k8s.io/apimachinery/pkg/types" | ||||||
| 	"k8s.io/apimachinery/pkg/util/runtime" | 	"k8s.io/apimachinery/pkg/util/runtime" | ||||||
| 	"k8s.io/apimachinery/pkg/util/sets" | 	"k8s.io/apimachinery/pkg/util/sets" | ||||||
| 	genericapirequest "k8s.io/apiserver/pkg/endpoints/request" |  | ||||||
| 	"k8s.io/client-go/tools/cache" | 	"k8s.io/client-go/tools/cache" | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	podutil "k8s.io/kubernetes/pkg/api/v1/pod" | 	podutil "k8s.io/kubernetes/pkg/api/v1/pod" | ||||||
| @@ -584,10 +583,7 @@ type binder struct { | |||||||
| // Bind just does a POST binding RPC. | // Bind just does a POST binding RPC. | ||||||
| func (b *binder) Bind(binding *v1.Binding) error { | func (b *binder) Bind(binding *v1.Binding) error { | ||||||
| 	glog.V(3).Infof("Attempting to bind %v to %v", binding.Name, binding.Target.Name) | 	glog.V(3).Infof("Attempting to bind %v to %v", binding.Name, binding.Target.Name) | ||||||
| 	ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), binding.Namespace) | 	return b.Client.CoreV1().Pods(binding.Namespace).Bind(binding) | ||||||
| 	return b.Client.Core().RESTClient().Post().Namespace(genericapirequest.NamespaceValue(ctx)).Resource("bindings").Body(binding).Do().Error() |  | ||||||
| 	// TODO: use Pods interface for binding once clusters are upgraded |  | ||||||
| 	// return b.Pods(binding.Namespace).Bind(binding) |  | ||||||
| } | } | ||||||
|  |  | ||||||
| type podConditionUpdater struct { | type podConditionUpdater struct { | ||||||
|   | |||||||
| @@ -278,7 +278,9 @@ func TestBind(t *testing.T) { | |||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
| 		expectedBody := runtime.EncodeOrDie(testapi.Default.Codec(), item.binding) | 		expectedBody := runtime.EncodeOrDie(testapi.Default.Codec(), item.binding) | ||||||
| 		handler.ValidateRequest(t, testapi.Default.ResourcePath("bindings", metav1.NamespaceDefault, ""), "POST", &expectedBody) | 		handler.ValidateRequest(t, | ||||||
|  | 			testapi.Default.SubResourcePath("pods", metav1.NamespaceDefault, "foo", "binding"), | ||||||
|  | 			"POST", &expectedBody) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Klaus Ma
					Klaus Ma