mirror of https://github.com/k3s-io/k3s
Merge pull request #13139 from wojtek-t/rename_strategy
Renaming in pkg/registry to reflect realitypull/6/head
commit
71c6e0d662
|
@ -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
|
||||
}
|
|
@ -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
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue