diff --git a/pkg/registry/controller/rest.go b/pkg/registry/controller/strategy.go similarity index 100% rename from pkg/registry/controller/rest.go rename to pkg/registry/controller/strategy.go diff --git a/pkg/registry/daemon/rest.go b/pkg/registry/daemon/strategy.go similarity index 100% rename from pkg/registry/daemon/rest.go rename to pkg/registry/daemon/strategy.go diff --git a/pkg/registry/endpoint/rest.go b/pkg/registry/endpoint/strategy.go similarity index 100% rename from pkg/registry/endpoint/rest.go rename to pkg/registry/endpoint/strategy.go diff --git a/pkg/registry/event/rest.go b/pkg/registry/event/strategy.go similarity index 100% rename from pkg/registry/event/rest.go rename to pkg/registry/event/strategy.go diff --git a/pkg/registry/event/rest_test.go b/pkg/registry/event/strategy_test.go similarity index 100% rename from pkg/registry/event/rest_test.go rename to pkg/registry/event/strategy_test.go diff --git a/pkg/registry/horizontalpodautoscaler/registry.go b/pkg/registry/horizontalpodautoscaler/registry.go deleted file mode 100644 index d9fb7cc2d60..00000000000 --- a/pkg/registry/horizontalpodautoscaler/registry.go +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package horizontalpodautoscaler - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/expapi" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" -) - -// Registry is an interface implemented by things that know how to store HorizontalPodAutoscaler objects. -type Registry interface { - // ListPersistentVolumes obtains a list of autoscalers having labels which match selector. - ListHorizontalPodAutoscaler(ctx api.Context, selector labels.Selector) (*expapi.HorizontalPodAutoscalerList, error) - // Get a specific autoscaler - GetHorizontalPodAutoscaler(ctx api.Context, autoscalerID string) (*expapi.HorizontalPodAutoscaler, error) - // Create an autoscaler based on a specification. - CreateHorizontalPodAutoscaler(ctx api.Context, autoscaler *expapi.HorizontalPodAutoscaler) error - // Update an existing autoscaler - UpdateHorizontalPodAutoscaler(ctx api.Context, autoscaler *expapi.HorizontalPodAutoscaler) error - // Delete an existing autoscaler - DeleteHorizontalPodAutoscaler(ctx api.Context, autoscalerID string) error -} - -// storage puts strong typing around storage calls -type storage struct { - rest.StandardStorage -} - -// NewREST returns a new Registry interface for the given Storage. Any mismatched types will panic. -func NewRegistry(s rest.StandardStorage) Registry { - return &storage{s} -} - -func (s *storage) ListHorizontalPodAutoscaler(ctx api.Context, label labels.Selector) (*expapi.HorizontalPodAutoscalerList, error) { - obj, err := s.List(ctx, label, fields.Everything()) - if err != nil { - return nil, err - } - return obj.(*expapi.HorizontalPodAutoscalerList), nil -} - -func (s *storage) GetHorizontalPodAutoscaler(ctx api.Context, autoscalerID string) (*expapi.HorizontalPodAutoscaler, error) { - obj, err := s.Get(ctx, autoscalerID) - if err != nil { - return nil, err - } - return obj.(*expapi.HorizontalPodAutoscaler), nil -} - -func (s *storage) CreateHorizontalPodAutoscaler(ctx api.Context, autoscaler *expapi.HorizontalPodAutoscaler) error { - _, err := s.Create(ctx, autoscaler) - return err -} - -func (s *storage) UpdateHorizontalPodAutoscaler(ctx api.Context, autoscaler *expapi.HorizontalPodAutoscaler) error { - _, _, err := s.Update(ctx, autoscaler) - return err -} - -func (s *storage) DeleteHorizontalPodAutoscaler(ctx api.Context, autoscalerID string) error { - _, err := s.Delete(ctx, autoscalerID, nil) - return err -} diff --git a/pkg/registry/horizontalpodautoscaler/rest.go b/pkg/registry/horizontalpodautoscaler/strategy.go similarity index 100% rename from pkg/registry/horizontalpodautoscaler/rest.go rename to pkg/registry/horizontalpodautoscaler/strategy.go diff --git a/pkg/registry/limitrange/rest.go b/pkg/registry/limitrange/strategy.go similarity index 100% rename from pkg/registry/limitrange/rest.go rename to pkg/registry/limitrange/strategy.go diff --git a/pkg/registry/minion/rest.go b/pkg/registry/minion/strategy.go similarity index 100% rename from pkg/registry/minion/rest.go rename to pkg/registry/minion/strategy.go diff --git a/pkg/registry/minion/rest_test.go b/pkg/registry/minion/strategy_test.go similarity index 100% rename from pkg/registry/minion/rest_test.go rename to pkg/registry/minion/strategy_test.go diff --git a/pkg/registry/namespace/registry_test.go b/pkg/registry/namespace/registry_test.go deleted file mode 100644 index d9e8b07a545..00000000000 --- a/pkg/registry/namespace/registry_test.go +++ /dev/null @@ -1,17 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package namespace diff --git a/pkg/registry/namespace/rest.go b/pkg/registry/namespace/strategy.go similarity index 100% rename from pkg/registry/namespace/rest.go rename to pkg/registry/namespace/strategy.go diff --git a/pkg/registry/namespace/rest_test.go b/pkg/registry/namespace/strategy_test.go similarity index 100% rename from pkg/registry/namespace/rest_test.go rename to pkg/registry/namespace/strategy_test.go diff --git a/pkg/registry/persistentvolume/registry.go b/pkg/registry/persistentvolume/registry.go deleted file mode 100644 index 88cd963ab00..00000000000 --- a/pkg/registry/persistentvolume/registry.go +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package persistentvolume - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/watch" -) - -// Registry is an interface implemented by things that know how to store PersistentVolume objects. -type Registry interface { - // ListPersistentVolumes obtains a list of persistentVolumes having labels which match selector. - ListPersistentVolumes(ctx api.Context, selector labels.Selector) (*api.PersistentVolumeList, error) - // Watch for new/changed/deleted persistentVolumes - WatchPersistentVolumes(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) - // Get a specific persistentVolume - GetPersistentVolume(ctx api.Context, persistentVolumeID string) (*api.PersistentVolume, error) - // Create a persistentVolume based on a specification. - CreatePersistentVolume(ctx api.Context, persistentVolume *api.PersistentVolume) error - // Update an existing persistentVolume - UpdatePersistentVolume(ctx api.Context, persistentVolume *api.PersistentVolume) error - // Delete an existing persistentVolume - DeletePersistentVolume(ctx api.Context, persistentVolumeID string) error -} - -// storage puts strong typing around storage calls -type storage struct { - rest.StandardStorage -} - -// NewRegistry returns a new Registry interface for the given Storage. Any mismatched -// types will panic. -func NewRegistry(s rest.StandardStorage) Registry { - return &storage{s} -} - -func (s *storage) ListPersistentVolumes(ctx api.Context, label labels.Selector) (*api.PersistentVolumeList, error) { - obj, err := s.List(ctx, label, fields.Everything()) - if err != nil { - return nil, err - } - return obj.(*api.PersistentVolumeList), nil -} - -func (s *storage) WatchPersistentVolumes(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, label, field, resourceVersion) -} - -func (s *storage) GetPersistentVolume(ctx api.Context, persistentVolumeID string) (*api.PersistentVolume, error) { - obj, err := s.Get(ctx, persistentVolumeID) - if err != nil { - return nil, err - } - return obj.(*api.PersistentVolume), nil -} - -func (s *storage) CreatePersistentVolume(ctx api.Context, persistentVolume *api.PersistentVolume) error { - _, err := s.Create(ctx, persistentVolume) - return err -} - -func (s *storage) UpdatePersistentVolume(ctx api.Context, persistentVolume *api.PersistentVolume) error { - _, _, err := s.Update(ctx, persistentVolume) - return err -} - -func (s *storage) DeletePersistentVolume(ctx api.Context, persistentVolumeID string) error { - _, err := s.Delete(ctx, persistentVolumeID, nil) - return err -} diff --git a/pkg/registry/persistentvolume/rest.go b/pkg/registry/persistentvolume/strategy.go similarity index 100% rename from pkg/registry/persistentvolume/rest.go rename to pkg/registry/persistentvolume/strategy.go diff --git a/pkg/registry/persistentvolumeclaim/registry.go b/pkg/registry/persistentvolumeclaim/registry.go deleted file mode 100644 index fdca5eb6332..00000000000 --- a/pkg/registry/persistentvolumeclaim/registry.go +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package persistentvolumeclaim - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/watch" -) - -// Registry is an interface implemented by things that know how to store PersistentVolumeClaim objects. -type Registry interface { - // ListPersistentVolumeClaims obtains a list of PVCs having labels which match selector. - ListPersistentVolumeClaims(ctx api.Context, selector labels.Selector) (*api.PersistentVolumeClaimList, error) - // Watch for new/changed/deleted PVCs - WatchPersistentVolumeClaims(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) - // Get a specific PVC - GetPersistentVolumeClaim(ctx api.Context, pvcID string) (*api.PersistentVolumeClaim, error) - // Create a PVC based on a specification. - CreatePersistentVolumeClaim(ctx api.Context, pvc *api.PersistentVolumeClaim) error - // Update an existing PVC - UpdatePersistentVolumeClaim(ctx api.Context, pvc *api.PersistentVolumeClaim) error - // Delete an existing PVC - DeletePersistentVolumeClaim(ctx api.Context, pvcID string) error -} - -// storage puts strong typing around storage calls -type storage struct { - rest.StandardStorage -} - -// NewRegistry returns a new Registry interface for the given Storage. Any mismatched -// types will panic. -func NewRegistry(s rest.StandardStorage) Registry { - return &storage{s} -} - -func (s *storage) ListPersistentVolumeClaims(ctx api.Context, label labels.Selector) (*api.PersistentVolumeClaimList, error) { - obj, err := s.List(ctx, label, fields.Everything()) - if err != nil { - return nil, err - } - return obj.(*api.PersistentVolumeClaimList), nil -} - -func (s *storage) WatchPersistentVolumeClaims(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, label, field, resourceVersion) -} - -func (s *storage) GetPersistentVolumeClaim(ctx api.Context, podID string) (*api.PersistentVolumeClaim, error) { - obj, err := s.Get(ctx, podID) - if err != nil { - return nil, err - } - return obj.(*api.PersistentVolumeClaim), nil -} - -func (s *storage) CreatePersistentVolumeClaim(ctx api.Context, pod *api.PersistentVolumeClaim) error { - _, err := s.Create(ctx, pod) - return err -} - -func (s *storage) UpdatePersistentVolumeClaim(ctx api.Context, pod *api.PersistentVolumeClaim) error { - _, _, err := s.Update(ctx, pod) - return err -} - -func (s *storage) DeletePersistentVolumeClaim(ctx api.Context, podID string) error { - _, err := s.Delete(ctx, podID, nil) - return err -} diff --git a/pkg/registry/persistentvolumeclaim/rest.go b/pkg/registry/persistentvolumeclaim/strategy.go similarity index 100% rename from pkg/registry/persistentvolumeclaim/rest.go rename to pkg/registry/persistentvolumeclaim/strategy.go diff --git a/pkg/registry/pod/etcd/etcd_test.go b/pkg/registry/pod/etcd/etcd_test.go index ad9f8ff2f99..82f66c60b89 100644 --- a/pkg/registry/pod/etcd/etcd_test.go +++ b/pkg/registry/pod/etcd/etcd_test.go @@ -30,7 +30,6 @@ import ( "k8s.io/kubernetes/pkg/api/testapi" "k8s.io/kubernetes/pkg/fields" "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/registry/pod" "k8s.io/kubernetes/pkg/registry/registrytest" "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/securitycontext" @@ -82,11 +81,6 @@ func validChangedPod() *api.Pod { return pod } -func TestStorage(t *testing.T) { - storage, _, _, _ := newStorage(t) - pod.NewRegistry(storage) -} - func TestCreate(t *testing.T) { storage, _, _, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError) diff --git a/pkg/registry/pod/registry.go b/pkg/registry/pod/registry.go deleted file mode 100644 index 23cebb09bf5..00000000000 --- a/pkg/registry/pod/registry.go +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package pod - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/watch" -) - -// 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 api.Context, label labels.Selector) (*api.PodList, error) - // Watch for new/changed/deleted pods - WatchPods(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) - // Get a specific pod - GetPod(ctx api.Context, podID string) (*api.Pod, error) - // Create a pod based on a specification. - CreatePod(ctx api.Context, pod *api.Pod) error - // Update an existing pod - UpdatePod(ctx api.Context, pod *api.Pod) error - // Delete an existing pod - DeletePod(ctx api.Context, podID string) error -} - -// storage puts strong typing around storage calls -type storage struct { - rest.StandardStorage -} - -// NewRegistry returns a new Registry interface for the given Storage. Any mismatched -// types will panic. -func NewRegistry(s rest.StandardStorage) Registry { - return &storage{s} -} - -func (s *storage) ListPods(ctx api.Context, label labels.Selector) (*api.PodList, error) { - obj, err := s.List(ctx, label, fields.Everything()) - if err != nil { - return nil, err - } - return obj.(*api.PodList), nil -} - -func (s *storage) WatchPods(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, label, field, resourceVersion) -} - -func (s *storage) GetPod(ctx api.Context, podID string) (*api.Pod, error) { - obj, err := s.Get(ctx, podID) - if err != nil { - return nil, err - } - return obj.(*api.Pod), nil -} - -func (s *storage) CreatePod(ctx api.Context, pod *api.Pod) error { - _, err := s.Create(ctx, pod) - return err -} - -func (s *storage) UpdatePod(ctx api.Context, pod *api.Pod) error { - _, _, err := s.Update(ctx, pod) - return err -} - -func (s *storage) DeletePod(ctx api.Context, podID string) error { - _, err := s.Delete(ctx, podID, nil) - return err -} diff --git a/pkg/registry/pod/rest.go b/pkg/registry/pod/strategy.go similarity index 100% rename from pkg/registry/pod/rest.go rename to pkg/registry/pod/strategy.go diff --git a/pkg/registry/podtemplate/rest.go b/pkg/registry/podtemplate/strategy.go similarity index 100% rename from pkg/registry/podtemplate/rest.go rename to pkg/registry/podtemplate/strategy.go diff --git a/pkg/registry/resourcequota/etcd/etcd_test.go b/pkg/registry/resourcequota/etcd/etcd_test.go index 19e72925ff4..1034f4628c7 100644 --- a/pkg/registry/resourcequota/etcd/etcd_test.go +++ b/pkg/registry/resourcequota/etcd/etcd_test.go @@ -28,7 +28,6 @@ import ( "k8s.io/kubernetes/pkg/fields" "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/registry/registrytest" - "k8s.io/kubernetes/pkg/registry/resourcequota" "k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/tools" "k8s.io/kubernetes/pkg/tools/etcdtest" @@ -71,11 +70,6 @@ func validChangedResourceQuota() *api.ResourceQuota { return resourcequota } -func TestStorage(t *testing.T) { - storage, _, _ := newStorage(t) - resourcequota.NewRegistry(storage) -} - func TestCreate(t *testing.T) { storage, _, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError) diff --git a/pkg/registry/resourcequota/registry.go b/pkg/registry/resourcequota/registry.go deleted file mode 100644 index 899a731a09d..00000000000 --- a/pkg/registry/resourcequota/registry.go +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resourcequota - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/watch" -) - -// Registry is an interface implemented by things that know how to store ResourceQuota objects. -type Registry interface { - // ListResourceQuotas obtains a list of resourceQuotas having labels which match selector. - ListResourceQuotas(ctx api.Context, selector labels.Selector) (*api.ResourceQuotaList, error) - // Watch for new/changed/deleted resourceQuotas - WatchResourceQuotas(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) - // Get a specific resourceQuota - GetResourceQuota(ctx api.Context, resourceQuotaID string) (*api.ResourceQuota, error) - // Create a resourceQuota based on a specification. - CreateResourceQuota(ctx api.Context, resourceQuota *api.ResourceQuota) error - // Update an existing resourceQuota - UpdateResourceQuota(ctx api.Context, resourceQuota *api.ResourceQuota) error - // Delete an existing resourceQuota - DeleteResourceQuota(ctx api.Context, resourceQuotaID string) error -} - -// storage puts strong typing around storage calls -type storage struct { - rest.StandardStorage -} - -// NewRegistry returns a new Registry interface for the given Storage. Any mismatched -// types will panic. -func NewRegistry(s rest.StandardStorage) Registry { - return &storage{s} -} - -func (s *storage) ListResourceQuotas(ctx api.Context, label labels.Selector) (*api.ResourceQuotaList, error) { - obj, err := s.List(ctx, label, fields.Everything()) - if err != nil { - return nil, err - } - return obj.(*api.ResourceQuotaList), nil -} - -func (s *storage) WatchResourceQuotas(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, label, field, resourceVersion) -} - -func (s *storage) GetResourceQuota(ctx api.Context, resourceQuotaID string) (*api.ResourceQuota, error) { - obj, err := s.Get(ctx, resourceQuotaID) - if err != nil { - return nil, err - } - return obj.(*api.ResourceQuota), nil -} - -func (s *storage) CreateResourceQuota(ctx api.Context, resourceQuota *api.ResourceQuota) error { - _, err := s.Create(ctx, resourceQuota) - return err -} - -func (s *storage) UpdateResourceQuota(ctx api.Context, resourceQuota *api.ResourceQuota) error { - _, _, err := s.Update(ctx, resourceQuota) - return err -} - -func (s *storage) DeleteResourceQuota(ctx api.Context, resourceQuotaID string) error { - _, err := s.Delete(ctx, resourceQuotaID, nil) - return err -} diff --git a/pkg/registry/resourcequota/rest.go b/pkg/registry/resourcequota/strategy.go similarity index 100% rename from pkg/registry/resourcequota/rest.go rename to pkg/registry/resourcequota/strategy.go diff --git a/pkg/registry/resourcequota/rest_test.go b/pkg/registry/resourcequota/strategy_test.go similarity index 100% rename from pkg/registry/resourcequota/rest_test.go rename to pkg/registry/resourcequota/strategy_test.go diff --git a/pkg/registry/thirdpartyresource/registry.go b/pkg/registry/thirdpartyresource/registry.go deleted file mode 100644 index d30454f5c40..00000000000 --- a/pkg/registry/thirdpartyresource/registry.go +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package thirdpartyresource - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/expapi" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/watch" -) - -// Registry is an interface implemented by things that know how to store ThirdPartyResource objects. -type Registry interface { - // ListThirdPartyResources obtains a list of ThirdPartyResources having labels which match selector. - ListThirdPartyResources(ctx api.Context, selector labels.Selector) (*expapi.ThirdPartyResourceList, error) - // Watch for new/changed/deleted ThirdPartyResources - WatchThirdPartyResources(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) - // Get a specific ThirdPartyResource - GetThirdPartyResource(ctx api.Context, name string) (*expapi.ThirdPartyResource, error) - // Create a ThirdPartyResource based on a specification. - CreateThirdPartyResource(ctx api.Context, resource *expapi.ThirdPartyResource) (*expapi.ThirdPartyResource, error) - // Update an existing ThirdPartyResource - UpdateThirdPartyResource(ctx api.Context, resource *expapi.ThirdPartyResource) (*expapi.ThirdPartyResource, error) - // Delete an existing ThirdPartyResource - DeleteThirdPartyResource(ctx api.Context, name string) error -} - -// storage puts strong typing around storage calls -type storage struct { - rest.StandardStorage -} - -// NewRegistry returns a new Registry interface for the given Storage. Any mismatched -// types will panic. -func NewRegistry(s rest.StandardStorage) Registry { - return &storage{s} -} - -func (s *storage) ListThirdPartyResources(ctx api.Context, label labels.Selector) (*expapi.ThirdPartyResourceList, error) { - obj, err := s.List(ctx, label, fields.Everything()) - if err != nil { - return nil, err - } - return obj.(*expapi.ThirdPartyResourceList), nil -} - -func (s *storage) WatchThirdPartyResources(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) { - return s.Watch(ctx, label, field, resourceVersion) -} - -func (s *storage) GetThirdPartyResource(ctx api.Context, name string) (*expapi.ThirdPartyResource, error) { - obj, err := s.Get(ctx, name) - if err != nil { - return nil, err - } - return obj.(*expapi.ThirdPartyResource), nil -} - -func (s *storage) CreateThirdPartyResource(ctx api.Context, ThirdPartyResource *expapi.ThirdPartyResource) (*expapi.ThirdPartyResource, error) { - obj, err := s.Create(ctx, ThirdPartyResource) - return obj.(*expapi.ThirdPartyResource), err -} - -func (s *storage) UpdateThirdPartyResource(ctx api.Context, ThirdPartyResource *expapi.ThirdPartyResource) (*expapi.ThirdPartyResource, error) { - obj, _, err := s.Update(ctx, ThirdPartyResource) - return obj.(*expapi.ThirdPartyResource), err -} - -func (s *storage) DeleteThirdPartyResource(ctx api.Context, name string) error { - _, err := s.Delete(ctx, name, nil) - return err -}