mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 22:20:51 +00:00
Add ctx to registry test cases
This commit is contained in:
@@ -27,26 +27,26 @@ type ControllerRegistry struct {
|
||||
Controllers *api.ReplicationControllerList
|
||||
}
|
||||
|
||||
func (r *ControllerRegistry) ListControllers() (*api.ReplicationControllerList, error) {
|
||||
func (r *ControllerRegistry) ListControllers(ctx api.Context) (*api.ReplicationControllerList, error) {
|
||||
return r.Controllers, r.Err
|
||||
}
|
||||
|
||||
func (r *ControllerRegistry) GetController(ID string) (*api.ReplicationController, error) {
|
||||
func (r *ControllerRegistry) GetController(ctx api.Context, ID string) (*api.ReplicationController, error) {
|
||||
return &api.ReplicationController{}, r.Err
|
||||
}
|
||||
|
||||
func (r *ControllerRegistry) CreateController(controller *api.ReplicationController) error {
|
||||
func (r *ControllerRegistry) CreateController(ctx api.Context, controller *api.ReplicationController) error {
|
||||
return r.Err
|
||||
}
|
||||
|
||||
func (r *ControllerRegistry) UpdateController(controller *api.ReplicationController) error {
|
||||
func (r *ControllerRegistry) UpdateController(ctx api.Context, controller *api.ReplicationController) error {
|
||||
return r.Err
|
||||
}
|
||||
|
||||
func (r *ControllerRegistry) DeleteController(ID string) error {
|
||||
func (r *ControllerRegistry) DeleteController(ctx api.Context, ID string) error {
|
||||
return r.Err
|
||||
}
|
||||
|
||||
func (r *ControllerRegistry) WatchControllers(resourceVersion uint64) (watch.Interface, error) {
|
||||
func (r *ControllerRegistry) WatchControllers(ctx api.Context, resourceVersion uint64) (watch.Interface, error) {
|
||||
return nil, r.Err
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ func NewPodRegistry(pods *api.PodList) *PodRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *PodRegistry) ListPodsPredicate(filter func(*api.Pod) bool) (*api.PodList, error) {
|
||||
func (r *PodRegistry) ListPodsPredicate(ctx api.Context, filter func(*api.Pod) bool) (*api.PodList, error) {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
if r.Err != nil {
|
||||
@@ -58,23 +58,23 @@ func (r *PodRegistry) ListPodsPredicate(filter func(*api.Pod) bool) (*api.PodLis
|
||||
}
|
||||
|
||||
func (r *PodRegistry) ListPods(ctx api.Context, selector labels.Selector) (*api.PodList, error) {
|
||||
return r.ListPodsPredicate(func(pod *api.Pod) bool {
|
||||
return r.ListPodsPredicate(ctx, func(pod *api.Pod) bool {
|
||||
return selector.Matches(labels.Set(pod.Labels))
|
||||
})
|
||||
}
|
||||
|
||||
func (r *PodRegistry) WatchPods(resourceVersion uint64, filter func(*api.Pod) bool) (watch.Interface, error) {
|
||||
func (r *PodRegistry) WatchPods(ctx api.Context, resourceVersion uint64, filter func(*api.Pod) bool) (watch.Interface, error) {
|
||||
// TODO: wire filter down into the mux; it needs access to current and previous state :(
|
||||
return r.mux.Watch(), nil
|
||||
}
|
||||
|
||||
func (r *PodRegistry) GetPod(podId string) (*api.Pod, error) {
|
||||
func (r *PodRegistry) GetPod(ctx api.Context, podId string) (*api.Pod, error) {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
return r.Pod, r.Err
|
||||
}
|
||||
|
||||
func (r *PodRegistry) CreatePod(pod *api.Pod) error {
|
||||
func (r *PodRegistry) CreatePod(ctx api.Context, pod *api.Pod) error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
r.Pod = pod
|
||||
@@ -82,7 +82,7 @@ func (r *PodRegistry) CreatePod(pod *api.Pod) error {
|
||||
return r.Err
|
||||
}
|
||||
|
||||
func (r *PodRegistry) UpdatePod(pod *api.Pod) error {
|
||||
func (r *PodRegistry) UpdatePod(ctx api.Context, pod *api.Pod) error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
r.Pod = pod
|
||||
@@ -90,7 +90,7 @@ func (r *PodRegistry) UpdatePod(pod *api.Pod) error {
|
||||
return r.Err
|
||||
}
|
||||
|
||||
func (r *PodRegistry) DeletePod(podId string) error {
|
||||
func (r *PodRegistry) DeletePod(ctx api.Context, podId string) error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
r.mux.Action(watch.Deleted, r.Pod)
|
||||
|
@@ -38,49 +38,49 @@ type ServiceRegistry struct {
|
||||
UpdatedID string
|
||||
}
|
||||
|
||||
func (r *ServiceRegistry) ListServices() (*api.ServiceList, error) {
|
||||
func (r *ServiceRegistry) ListServices(ctx api.Context) (*api.ServiceList, error) {
|
||||
return &r.List, r.Err
|
||||
}
|
||||
|
||||
func (r *ServiceRegistry) CreateService(svc *api.Service) error {
|
||||
func (r *ServiceRegistry) CreateService(ctx api.Context, svc *api.Service) error {
|
||||
r.Service = svc
|
||||
r.List.Items = append(r.List.Items, *svc)
|
||||
return r.Err
|
||||
}
|
||||
|
||||
func (r *ServiceRegistry) GetService(id string) (*api.Service, error) {
|
||||
func (r *ServiceRegistry) GetService(ctx api.Context, id string) (*api.Service, error) {
|
||||
r.GottenID = id
|
||||
return r.Service, r.Err
|
||||
}
|
||||
|
||||
func (r *ServiceRegistry) DeleteService(id string) error {
|
||||
func (r *ServiceRegistry) DeleteService(ctx api.Context, id string) error {
|
||||
r.DeletedID = id
|
||||
return r.Err
|
||||
}
|
||||
|
||||
func (r *ServiceRegistry) UpdateService(svc *api.Service) error {
|
||||
func (r *ServiceRegistry) UpdateService(ctx api.Context, svc *api.Service) error {
|
||||
r.UpdatedID = svc.ID
|
||||
return r.Err
|
||||
}
|
||||
|
||||
func (r *ServiceRegistry) WatchServices(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) {
|
||||
func (r *ServiceRegistry) WatchServices(ctx api.Context, label labels.Selector, field labels.Selector, resourceVersion uint64) (watch.Interface, error) {
|
||||
return nil, r.Err
|
||||
}
|
||||
|
||||
func (r *ServiceRegistry) ListEndpoints() (*api.EndpointsList, error) {
|
||||
func (r *ServiceRegistry) ListEndpoints(ctx api.Context) (*api.EndpointsList, error) {
|
||||
return &r.EndpointsList, r.Err
|
||||
}
|
||||
|
||||
func (r *ServiceRegistry) GetEndpoints(id string) (*api.Endpoints, error) {
|
||||
func (r *ServiceRegistry) GetEndpoints(ctx api.Context, id string) (*api.Endpoints, error) {
|
||||
r.GottenID = id
|
||||
return &r.Endpoints, r.Err
|
||||
}
|
||||
|
||||
func (r *ServiceRegistry) UpdateEndpoints(e *api.Endpoints) error {
|
||||
func (r *ServiceRegistry) UpdateEndpoints(ctx api.Context, e *api.Endpoints) error {
|
||||
r.Endpoints = *e
|
||||
return r.Err
|
||||
}
|
||||
|
||||
func (r *ServiceRegistry) WatchEndpoints(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) {
|
||||
func (r *ServiceRegistry) WatchEndpoints(ctx api.Context, label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) {
|
||||
return nil, r.Err
|
||||
}
|
||||
|
Reference in New Issue
Block a user