diff --git a/pkg/api/context.go b/pkg/api/context.go index f7101ae7fe7..e5f4e240d5f 100644 --- a/pkg/api/context.go +++ b/pkg/api/context.go @@ -20,7 +20,12 @@ import ( "code.google.com/p/go.net/context" ) -// NewContext instantiates a base context object for request flows -func NewContext() context.Context { - return context.Background() +// Context carries values across API boundaries. +type Context interface { + Value(key interface{}) interface{} +} + +// NewContext instantiates a base context object for request flows +func NewContext() Context { + return context.TODO() } diff --git a/pkg/apiserver/apiserver_test.go b/pkg/apiserver/apiserver_test.go index 273fe6a0bb9..44b24840f8a 100644 --- a/pkg/apiserver/apiserver_test.go +++ b/pkg/apiserver/apiserver_test.go @@ -30,7 +30,6 @@ import ( "testing" "time" - "code.google.com/p/go.net/context" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" apierrs "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" @@ -89,18 +88,18 @@ type SimpleRESTStorage struct { injectedFunction func(obj runtime.Object) (returnObj runtime.Object, err error) } -func (storage *SimpleRESTStorage) List(ctx context.Context, label, field labels.Selector) (runtime.Object, error) { +func (storage *SimpleRESTStorage) List(ctx api.Context, label, field labels.Selector) (runtime.Object, error) { result := &SimpleList{ Items: storage.list, } return result, storage.errors["list"] } -func (storage *SimpleRESTStorage) Get(ctx context.Context, id string) (runtime.Object, error) { +func (storage *SimpleRESTStorage) Get(ctx api.Context, id string) (runtime.Object, error) { return api.Scheme.CopyOrDie(&storage.item), storage.errors["get"] } -func (storage *SimpleRESTStorage) Delete(ctx context.Context, id string) (<-chan runtime.Object, error) { +func (storage *SimpleRESTStorage) Delete(ctx api.Context, id string) (<-chan runtime.Object, error) { storage.deleted = id if err := storage.errors["delete"]; err != nil { return nil, err @@ -117,7 +116,7 @@ func (storage *SimpleRESTStorage) New() runtime.Object { return &Simple{} } -func (storage *SimpleRESTStorage) Create(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) { +func (storage *SimpleRESTStorage) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { storage.created = obj.(*Simple) if err := storage.errors["create"]; err != nil { return nil, err @@ -130,7 +129,7 @@ func (storage *SimpleRESTStorage) Create(ctx context.Context, obj runtime.Object }), nil } -func (storage *SimpleRESTStorage) Update(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) { +func (storage *SimpleRESTStorage) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { storage.updated = obj.(*Simple) if err := storage.errors["update"]; err != nil { return nil, err @@ -144,7 +143,7 @@ func (storage *SimpleRESTStorage) Update(ctx context.Context, obj runtime.Object } // Implement ResourceWatcher. -func (storage *SimpleRESTStorage) Watch(ctx context.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) { +func (storage *SimpleRESTStorage) Watch(ctx api.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) { storage.requestedLabelSelector = label storage.requestedFieldSelector = field storage.requestedResourceVersion = resourceVersion @@ -156,7 +155,7 @@ func (storage *SimpleRESTStorage) Watch(ctx context.Context, label, field labels } // Implement Redirector. -func (storage *SimpleRESTStorage) ResourceLocation(ctx context.Context, id string) (string, error) { +func (storage *SimpleRESTStorage) ResourceLocation(ctx api.Context, id string) (string, error) { storage.requestedResourceLocationID = id if err := storage.errors["resourceLocation"]; err != nil { return "", err diff --git a/pkg/apiserver/interfaces.go b/pkg/apiserver/interfaces.go index 7f7e6d4d45a..78adc146fcd 100644 --- a/pkg/apiserver/interfaces.go +++ b/pkg/apiserver/interfaces.go @@ -17,7 +17,7 @@ limitations under the License. package apiserver import ( - "code.google.com/p/go.net/context" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" @@ -31,20 +31,20 @@ type RESTStorage interface { New() runtime.Object // List selects resources in the storage which match to the selector. - List(ctx context.Context, label, field labels.Selector) (runtime.Object, error) + List(ctx api.Context, label, field labels.Selector) (runtime.Object, error) // Get finds a resource in the storage by id and returns it. // Although it can return an arbitrary error value, IsNotFound(err) is true for the // returned error value err when the specified resource is not found. - Get(ctx context.Context, id string) (runtime.Object, error) + Get(ctx api.Context, id string) (runtime.Object, error) // Delete finds a resource in the storage and deletes it. // Although it can return an arbitrary error value, IsNotFound(err) is true for the // returned error value err when the specified resource is not found. - Delete(ctx context.Context, id string) (<-chan runtime.Object, error) + Delete(ctx api.Context, id string) (<-chan runtime.Object, error) - Create(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) - Update(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) + Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) + Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) } // ResourceWatcher should be implemented by all RESTStorage objects that @@ -54,11 +54,11 @@ type ResourceWatcher interface { // are supported; an error should be returned if 'field' tries to select on a field that // isn't supported. 'resourceVersion' allows for continuing/starting a watch at a // particular version. - Watch(ctx context.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) + Watch(ctx api.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) } // Redirector know how to return a remote resource's location. type Redirector interface { // ResourceLocation should return the remote location of the given resource, or an error. - ResourceLocation(ctx context.Context, id string) (remoteLocation string, err error) + ResourceLocation(ctx api.Context, id string) (remoteLocation string, err error) } diff --git a/pkg/master/pod_cache.go b/pkg/master/pod_cache.go index c9058cd38fa..da9bd92e582 100644 --- a/pkg/master/pod_cache.go +++ b/pkg/master/pod_cache.go @@ -19,8 +19,6 @@ package master import ( "sync" - "code.google.com/p/go.net/context" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" @@ -74,7 +72,7 @@ func (p *PodCache) updatePodInfo(host, id string) error { // UpdateAllContainers updates information about all containers. Either called by Loop() below, or one-off. func (p *PodCache) UpdateAllContainers() { - var ctx context.Context + var ctx api.Context pods, err := p.pods.ListPods(ctx, labels.Everything()) if err != nil { glog.Errorf("Error synchronizing container list: %v", err) diff --git a/pkg/registry/binding/rest.go b/pkg/registry/binding/rest.go index 276e8cfaf21..412a4da2584 100644 --- a/pkg/registry/binding/rest.go +++ b/pkg/registry/binding/rest.go @@ -19,8 +19,6 @@ package binding import ( "fmt" - "code.google.com/p/go.net/context" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" "github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver" @@ -43,17 +41,17 @@ func NewREST(bindingRegistry Registry) *REST { } // List returns an error because bindings are write-only objects. -func (*REST) List(ctx context.Context, label, field labels.Selector) (runtime.Object, error) { +func (*REST) List(ctx api.Context, label, field labels.Selector) (runtime.Object, error) { return nil, errors.NewNotFound("binding", "list") } // Get returns an error because bindings are write-only objects. -func (*REST) Get(ctx context.Context, id string) (runtime.Object, error) { +func (*REST) Get(ctx api.Context, id string) (runtime.Object, error) { return nil, errors.NewNotFound("binding", id) } // Delete returns an error because bindings are write-only objects. -func (*REST) Delete(ctx context.Context, id string) (<-chan runtime.Object, error) { +func (*REST) Delete(ctx api.Context, id string) (<-chan runtime.Object, error) { return nil, errors.NewNotFound("binding", id) } @@ -63,7 +61,7 @@ func (*REST) New() runtime.Object { } // Create attempts to make the assignment indicated by the binding it recieves. -func (b *REST) Create(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) { +func (b *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { binding, ok := obj.(*api.Binding) if !ok { return nil, fmt.Errorf("incorrect type: %#v", obj) @@ -77,6 +75,6 @@ func (b *REST) Create(ctx context.Context, obj runtime.Object) (<-chan runtime.O } // Update returns an error-- this object may not be updated. -func (b *REST) Update(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) { +func (b *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { return nil, fmt.Errorf("Bindings may not be changed.") } diff --git a/pkg/registry/binding/rest_test.go b/pkg/registry/binding/rest_test.go index 34266d05096..dc080ed19b3 100644 --- a/pkg/registry/binding/rest_test.go +++ b/pkg/registry/binding/rest_test.go @@ -22,8 +22,6 @@ import ( "reflect" "testing" - "code.google.com/p/go.net/context" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" @@ -54,7 +52,7 @@ func TestNewREST(t *testing.T) { } func TestRESTUnsupported(t *testing.T) { - var ctx context.Context + var ctx api.Context mockRegistry := MockRegistry{ OnApplyBinding: func(b *api.Binding) error { return nil }, } diff --git a/pkg/registry/controller/rest.go b/pkg/registry/controller/rest.go index 42c5ce43fbe..d9c2e3b0f97 100644 --- a/pkg/registry/controller/rest.go +++ b/pkg/registry/controller/rest.go @@ -30,12 +30,11 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "code.google.com/p/go-uuid/uuid" - "code.google.com/p/go.net/context" ) // PodLister is anything that knows how to list pods. type PodLister interface { - ListPods(ctx context.Context, labels labels.Selector) (*api.PodList, error) + ListPods(ctx api.Context, labels labels.Selector) (*api.PodList, error) } // REST implements apiserver.RESTStorage for the replication controller service. @@ -55,7 +54,7 @@ func NewREST(registry Registry, podLister PodLister) *REST { } // Create registers the given ReplicationController. -func (rs *REST) Create(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) { +func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { controller, ok := obj.(*api.ReplicationController) if !ok { return nil, fmt.Errorf("not a replication controller: %#v", obj) @@ -81,14 +80,14 @@ func (rs *REST) Create(ctx context.Context, obj runtime.Object) (<-chan runtime. } // Delete asynchronously deletes the ReplicationController specified by its id. -func (rs *REST) Delete(ctx context.Context, id string) (<-chan runtime.Object, error) { +func (rs *REST) Delete(ctx api.Context, id string) (<-chan runtime.Object, error) { return apiserver.MakeAsync(func() (runtime.Object, error) { return &api.Status{Status: api.StatusSuccess}, rs.registry.DeleteController(id) }), nil } // Get obtains the ReplicationController specified by its id. -func (rs *REST) Get(ctx context.Context, id string) (runtime.Object, error) { +func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) { controller, err := rs.registry.GetController(id) if err != nil { return nil, err @@ -98,7 +97,7 @@ func (rs *REST) Get(ctx context.Context, id string) (runtime.Object, error) { } // List obtains a list of ReplicationControllers that match selector. -func (rs *REST) List(ctx context.Context, label, field labels.Selector) (runtime.Object, error) { +func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Object, error) { if !field.Empty() { return nil, fmt.Errorf("field selector not supported yet") } @@ -124,7 +123,7 @@ func (*REST) New() runtime.Object { // Update replaces a given ReplicationController instance with an existing // instance in storage.registry. -func (rs *REST) Update(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) { +func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { controller, ok := obj.(*api.ReplicationController) if !ok { return nil, fmt.Errorf("not a replication controller: %#v", obj) @@ -143,7 +142,7 @@ func (rs *REST) Update(ctx context.Context, obj runtime.Object) (<-chan runtime. // Watch returns ReplicationController events via a watch.Interface. // It implements apiserver.ResourceWatcher. -func (rs *REST) Watch(ctx context.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) { +func (rs *REST) Watch(ctx api.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) { if !field.Empty() { return nil, fmt.Errorf("no field selector implemented for controllers") } @@ -167,7 +166,7 @@ func (rs *REST) Watch(ctx context.Context, label, field labels.Selector, resourc }), nil } -func (rs *REST) waitForController(ctx context.Context, ctrl *api.ReplicationController) (runtime.Object, error) { +func (rs *REST) waitForController(ctx api.Context, ctrl *api.ReplicationController) (runtime.Object, error) { for { pods, err := rs.podLister.ListPods(ctx, labels.Set(ctrl.DesiredState.ReplicaSelector).AsSelector()) if err != nil { @@ -181,7 +180,7 @@ func (rs *REST) waitForController(ctx context.Context, ctrl *api.ReplicationCont return ctrl, nil } -func (rs *REST) fillCurrentState(ctx context.Context, ctrl *api.ReplicationController) error { +func (rs *REST) fillCurrentState(ctx api.Context, ctrl *api.ReplicationController) error { if rs.podLister == nil { return nil } diff --git a/pkg/registry/controller/rest_test.go b/pkg/registry/controller/rest_test.go index 59e088a9de1..5a5e4e728fd 100644 --- a/pkg/registry/controller/rest_test.go +++ b/pkg/registry/controller/rest_test.go @@ -24,8 +24,6 @@ import ( "testing" "time" - "code.google.com/p/go.net/context" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" @@ -330,7 +328,7 @@ type fakePodLister struct { s labels.Selector } -func (f *fakePodLister) ListPods(ctx context.Context, s labels.Selector) (*api.PodList, error) { +func (f *fakePodLister) ListPods(ctx api.Context, s labels.Selector) (*api.PodList, error) { f.s = s return &f.l, f.e } diff --git a/pkg/registry/endpoint/rest.go b/pkg/registry/endpoint/rest.go index e3a69077d62..a11c43ce4d4 100644 --- a/pkg/registry/endpoint/rest.go +++ b/pkg/registry/endpoint/rest.go @@ -19,8 +19,6 @@ package endpoint import ( "errors" - "code.google.com/p/go.net/context" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" @@ -40,12 +38,12 @@ func NewREST(registry Registry) *REST { } // Get satisfies the RESTStorage interface. -func (rs *REST) Get(ctx context.Context, id string) (runtime.Object, error) { +func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) { return rs.registry.GetEndpoints(id) } // List satisfies the RESTStorage interface. -func (rs *REST) List(ctx context.Context, label, field labels.Selector) (runtime.Object, error) { +func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Object, error) { if !label.Empty() || !field.Empty() { return nil, errors.New("label/field selectors are not supported on endpoints") } @@ -54,22 +52,22 @@ func (rs *REST) List(ctx context.Context, label, field labels.Selector) (runtime // Watch returns Endpoint events via a watch.Interface. // It implements apiserver.ResourceWatcher. -func (rs *REST) Watch(ctx context.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) { +func (rs *REST) Watch(ctx api.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) { return rs.registry.WatchEndpoints(label, field, resourceVersion) } // Create satisfies the RESTStorage interface but is unimplemented. -func (rs *REST) Create(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) { +func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { return nil, errors.New("unimplemented") } // Update satisfies the RESTStorage interface but is unimplemented. -func (rs *REST) Update(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) { +func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { return nil, errors.New("unimplemented") } // Delete satisfies the RESTStorage interface but is unimplemented. -func (rs *REST) Delete(ctx context.Context, id string) (<-chan runtime.Object, error) { +func (rs *REST) Delete(ctx api.Context, id string) (<-chan runtime.Object, error) { return nil, errors.New("unimplemented") } diff --git a/pkg/registry/etcd/etcd.go b/pkg/registry/etcd/etcd.go index b039864ef28..16339d19c94 100644 --- a/pkg/registry/etcd/etcd.go +++ b/pkg/registry/etcd/etcd.go @@ -29,8 +29,6 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/golang/glog" - - "code.google.com/p/go.net/context" ) // TODO: Need to add a reconciler loop that makes sure that things in pods are reflected into @@ -57,7 +55,7 @@ func makePodKey(podID string) string { } // ListPods obtains a list of pods with labels that match selector. -func (r *Registry) ListPods(ctx context.Context, selector labels.Selector) (*api.PodList, error) { +func (r *Registry) ListPods(ctx api.Context, selector labels.Selector) (*api.PodList, error) { return r.ListPodsPredicate(func(pod *api.Pod) bool { return selector.Matches(labels.Set(pod.Labels)) }) diff --git a/pkg/registry/minion/rest.go b/pkg/registry/minion/rest.go index dca9e631fa5..c06f8d62464 100644 --- a/pkg/registry/minion/rest.go +++ b/pkg/registry/minion/rest.go @@ -19,8 +19,6 @@ package minion import ( "fmt" - "code.google.com/p/go.net/context" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" @@ -40,7 +38,7 @@ func NewREST(m Registry) *REST { } } -func (rs *REST) Create(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) { +func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { minion, ok := obj.(*api.Minion) if !ok { return nil, fmt.Errorf("not a minion: %#v", obj) @@ -67,7 +65,7 @@ func (rs *REST) Create(ctx context.Context, obj runtime.Object) (<-chan runtime. }), nil } -func (rs *REST) Delete(ctx context.Context, id string) (<-chan runtime.Object, error) { +func (rs *REST) Delete(ctx api.Context, id string) (<-chan runtime.Object, error) { exists, err := rs.registry.Contains(id) if !exists { return nil, ErrDoesNotExist @@ -80,7 +78,7 @@ func (rs *REST) Delete(ctx context.Context, id string) (<-chan runtime.Object, e }), nil } -func (rs *REST) Get(ctx context.Context, id string) (runtime.Object, error) { +func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) { exists, err := rs.registry.Contains(id) if !exists { return nil, ErrDoesNotExist @@ -88,7 +86,7 @@ func (rs *REST) Get(ctx context.Context, id string) (runtime.Object, error) { return rs.toApiMinion(id), err } -func (rs *REST) List(ctx context.Context, label, field labels.Selector) (runtime.Object, error) { +func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Object, error) { nameList, err := rs.registry.List() if err != nil { return nil, err @@ -104,7 +102,7 @@ func (*REST) New() runtime.Object { return &api.Minion{} } -func (rs *REST) Update(ctx context.Context, minion runtime.Object) (<-chan runtime.Object, error) { +func (rs *REST) Update(ctx api.Context, minion runtime.Object) (<-chan runtime.Object, error) { return nil, fmt.Errorf("Minions can only be created (inserted) and deleted.") } diff --git a/pkg/registry/pod/registry.go b/pkg/registry/pod/registry.go index ba2fec56f92..97cb00c03a9 100644 --- a/pkg/registry/pod/registry.go +++ b/pkg/registry/pod/registry.go @@ -17,8 +17,6 @@ limitations under the License. package pod import ( - "code.google.com/p/go.net/context" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" @@ -27,7 +25,7 @@ import ( // Registry is an interface implemented by things that know how to store Pod objects. type Registry interface { // ListPods obtains a list of pods having labels which match selector. - ListPods(ctx context.Context, selector labels.Selector) (*api.PodList, error) + ListPods(ctx api.Context, selector labels.Selector) (*api.PodList, error) // ListPodsPredicate obtains a list of pods for which filter returns true. ListPodsPredicate(filter func(*api.Pod) bool) (*api.PodList, error) // Watch for new/changed/deleted pods diff --git a/pkg/registry/pod/rest.go b/pkg/registry/pod/rest.go index 81f9c9f0e21..22e60f8b2f9 100644 --- a/pkg/registry/pod/rest.go +++ b/pkg/registry/pod/rest.go @@ -32,8 +32,6 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" - "code.google.com/p/go.net/context" - "code.google.com/p/go-uuid/uuid" "github.com/golang/glog" ) @@ -69,7 +67,7 @@ func NewREST(config *RESTConfig) *REST { } } -func (rs *REST) Create(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) { +func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { pod := obj.(*api.Pod) pod.DesiredState.Manifest.UUID = uuid.NewUUID().String() if len(pod.ID) == 0 { @@ -90,13 +88,13 @@ func (rs *REST) Create(ctx context.Context, obj runtime.Object) (<-chan runtime. }), nil } -func (rs *REST) Delete(ctx context.Context, id string) (<-chan runtime.Object, error) { +func (rs *REST) Delete(ctx api.Context, id string) (<-chan runtime.Object, error) { return apiserver.MakeAsync(func() (runtime.Object, error) { return &api.Status{Status: api.StatusSuccess}, rs.registry.DeletePod(id) }), nil } -func (rs *REST) Get(ctx context.Context, id string) (runtime.Object, error) { +func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) { pod, err := rs.registry.GetPod(id) if err != nil { return pod, err @@ -133,7 +131,7 @@ func (rs *REST) filterFunc(label, field labels.Selector) func(*api.Pod) bool { } } -func (rs *REST) List(ctx context.Context, label, field labels.Selector) (runtime.Object, error) { +func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Object, error) { pods, err := rs.registry.ListPodsPredicate(rs.filterFunc(label, field)) if err == nil { for i := range pods.Items { @@ -151,7 +149,7 @@ func (rs *REST) List(ctx context.Context, label, field labels.Selector) (runtime } // Watch begins watching for new, changed, or deleted pods. -func (rs *REST) Watch(ctx context.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) { +func (rs *REST) Watch(ctx api.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) { return rs.registry.WatchPods(resourceVersion, rs.filterFunc(label, field)) } @@ -159,7 +157,7 @@ func (*REST) New() runtime.Object { return &api.Pod{} } -func (rs *REST) Update(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) { +func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { pod := obj.(*api.Pod) if errs := validation.ValidatePod(pod); len(errs) > 0 { return nil, errors.NewInvalid("pod", pod.ID, errs) @@ -279,7 +277,7 @@ func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodStatus, } } -func (rs *REST) waitForPodRunning(ctx context.Context, pod *api.Pod) (runtime.Object, error) { +func (rs *REST) waitForPodRunning(ctx api.Context, pod *api.Pod) (runtime.Object, error) { for { podObj, err := rs.Get(ctx, pod.ID) if err != nil || podObj == nil { diff --git a/pkg/registry/registrytest/pod.go b/pkg/registry/registrytest/pod.go index ae8b938ab3e..763a1500dd3 100644 --- a/pkg/registry/registrytest/pod.go +++ b/pkg/registry/registrytest/pod.go @@ -22,8 +22,6 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" - - "code.google.com/p/go.net/context" ) type PodRegistry struct { @@ -59,7 +57,7 @@ func (r *PodRegistry) ListPodsPredicate(filter func(*api.Pod) bool) (*api.PodLis return &pods, nil } -func (r *PodRegistry) ListPods(ctx context.Context, selector labels.Selector) (*api.PodList, error) { +func (r *PodRegistry) ListPods(ctx api.Context, selector labels.Selector) (*api.PodList, error) { return r.ListPodsPredicate(func(pod *api.Pod) bool { return selector.Matches(labels.Set(pod.Labels)) }) diff --git a/pkg/registry/service/rest.go b/pkg/registry/service/rest.go index f193256bd97..b9afebf36c9 100644 --- a/pkg/registry/service/rest.go +++ b/pkg/registry/service/rest.go @@ -32,8 +32,6 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" - - "code.google.com/p/go.net/context" ) // REST adapts a service registry into apiserver's RESTStorage model. @@ -52,7 +50,7 @@ func NewREST(registry Registry, cloud cloudprovider.Interface, machines minion.R } } -func (rs *REST) Create(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) { +func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { srv := obj.(*api.Service) if errs := validation.ValidateService(srv); len(errs) > 0 { return nil, errors.NewInvalid("service", srv.ID, errs) @@ -96,7 +94,7 @@ func (rs *REST) Create(ctx context.Context, obj runtime.Object) (<-chan runtime. }), nil } -func (rs *REST) Delete(ctx context.Context, id string) (<-chan runtime.Object, error) { +func (rs *REST) Delete(ctx api.Context, id string) (<-chan runtime.Object, error) { service, err := rs.registry.GetService(id) if err != nil { return nil, err @@ -107,7 +105,7 @@ func (rs *REST) Delete(ctx context.Context, id string) (<-chan runtime.Object, e }), nil } -func (rs *REST) Get(ctx context.Context, id string) (runtime.Object, error) { +func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) { s, err := rs.registry.GetService(id) if err != nil { return nil, err @@ -116,7 +114,7 @@ func (rs *REST) Get(ctx context.Context, id string) (runtime.Object, error) { } // TODO: implement field selector? -func (rs *REST) List(ctx context.Context, label, field labels.Selector) (runtime.Object, error) { +func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Object, error) { list, err := rs.registry.ListServices() if err != nil { return nil, err @@ -133,7 +131,7 @@ func (rs *REST) List(ctx context.Context, label, field labels.Selector) (runtime // Watch returns Services events via a watch.Interface. // It implements apiserver.ResourceWatcher. -func (rs *REST) Watch(ctx context.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) { +func (rs *REST) Watch(ctx api.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) { return rs.registry.WatchServices(label, field, resourceVersion) } @@ -165,7 +163,7 @@ func GetServiceEnvironmentVariables(registry Registry, machine string) ([]api.En return result, nil } -func (rs *REST) Update(ctx context.Context, obj runtime.Object) (<-chan runtime.Object, error) { +func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) { srv := obj.(*api.Service) if errs := validation.ValidateService(srv); len(errs) > 0 { return nil, errors.NewInvalid("service", srv.ID, errs) @@ -181,7 +179,7 @@ func (rs *REST) Update(ctx context.Context, obj runtime.Object) (<-chan runtime. } // ResourceLocation returns a URL to which one can send traffic for the specified service. -func (rs *REST) ResourceLocation(ctx context.Context, id string) (string, error) { +func (rs *REST) ResourceLocation(ctx api.Context, id string) (string, error) { e, err := rs.registry.GetEndpoints(id) if err != nil { return "", err