Add singular name for the rest of types
This commit is contained in:
parent
d6532f5eb8
commit
578ddde80e
@ -41,7 +41,8 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
|||||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||||
return obj.(*admissionregistration.MutatingWebhookConfiguration).Name, nil
|
return obj.(*admissionregistration.MutatingWebhookConfiguration).Name, nil
|
||||||
},
|
},
|
||||||
DefaultQualifiedResource: admissionregistration.Resource("mutatingwebhookconfigurations"),
|
DefaultQualifiedResource: admissionregistration.Resource("mutatingwebhookconfigurations"),
|
||||||
|
SingularQualifiedResource: admissionregistration.Resource("mutatingwebhookconfiguration"),
|
||||||
|
|
||||||
CreateStrategy: mutatingwebhookconfiguration.Strategy,
|
CreateStrategy: mutatingwebhookconfiguration.Strategy,
|
||||||
UpdateStrategy: mutatingwebhookconfiguration.Strategy,
|
UpdateStrategy: mutatingwebhookconfiguration.Strategy,
|
||||||
|
@ -41,7 +41,8 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
|||||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||||
return obj.(*admissionregistration.ValidatingWebhookConfiguration).Name, nil
|
return obj.(*admissionregistration.ValidatingWebhookConfiguration).Name, nil
|
||||||
},
|
},
|
||||||
DefaultQualifiedResource: admissionregistration.Resource("validatingwebhookconfigurations"),
|
DefaultQualifiedResource: admissionregistration.Resource("validatingwebhookconfigurations"),
|
||||||
|
SingularQualifiedResource: admissionregistration.Resource("validatingwebhookconfiguration"),
|
||||||
|
|
||||||
CreateStrategy: validatingwebhookconfiguration.Strategy,
|
CreateStrategy: validatingwebhookconfiguration.Strategy,
|
||||||
UpdateStrategy: validatingwebhookconfiguration.Strategy,
|
UpdateStrategy: validatingwebhookconfiguration.Strategy,
|
||||||
|
@ -45,7 +45,8 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
|||||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||||
return obj.(*apiserverinternal.StorageVersion).Name, nil
|
return obj.(*apiserverinternal.StorageVersion).Name, nil
|
||||||
},
|
},
|
||||||
DefaultQualifiedResource: apiserverinternal.Resource("storageversions"),
|
DefaultQualifiedResource: apiserverinternal.Resource("storageversions"),
|
||||||
|
SingularQualifiedResource: apiserverinternal.Resource("storageversion"),
|
||||||
|
|
||||||
CreateStrategy: strategy.Strategy,
|
CreateStrategy: strategy.Strategy,
|
||||||
UpdateStrategy: strategy.Strategy,
|
UpdateStrategy: strategy.Strategy,
|
||||||
@ -99,3 +100,9 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -35,9 +35,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work with ControllerRevision objects.
|
// NewREST returns a RESTStorage object that will work with ControllerRevision objects.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &apps.ControllerRevision{} },
|
NewFunc: func() runtime.Object { return &apps.ControllerRevision{} },
|
||||||
NewListFunc: func() runtime.Object { return &apps.ControllerRevisionList{} },
|
NewListFunc: func() runtime.Object { return &apps.ControllerRevisionList{} },
|
||||||
DefaultQualifiedResource: apps.Resource("controllerrevisions"),
|
DefaultQualifiedResource: apps.Resource("controllerrevisions"),
|
||||||
|
SingularQualifiedResource: apps.Resource("controllerrevision"),
|
||||||
|
|
||||||
CreateStrategy: controllerrevision.Strategy,
|
CreateStrategy: controllerrevision.Strategy,
|
||||||
UpdateStrategy: controllerrevision.Strategy,
|
UpdateStrategy: controllerrevision.Strategy,
|
||||||
|
@ -40,9 +40,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against DaemonSets.
|
// NewREST returns a RESTStorage object that will work against DaemonSets.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &apps.DaemonSet{} },
|
NewFunc: func() runtime.Object { return &apps.DaemonSet{} },
|
||||||
NewListFunc: func() runtime.Object { return &apps.DaemonSetList{} },
|
NewListFunc: func() runtime.Object { return &apps.DaemonSetList{} },
|
||||||
DefaultQualifiedResource: apps.Resource("daemonsets"),
|
DefaultQualifiedResource: apps.Resource("daemonsets"),
|
||||||
|
SingularQualifiedResource: apps.Resource("daemonset"),
|
||||||
|
|
||||||
CreateStrategy: daemonset.Strategy,
|
CreateStrategy: daemonset.Strategy,
|
||||||
UpdateStrategy: daemonset.Strategy,
|
UpdateStrategy: daemonset.Strategy,
|
||||||
@ -78,13 +79,6 @@ func (r *REST) Categories() []string {
|
|||||||
return []string{"all"}
|
return []string{"all"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "daemonset"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of a daemonset
|
// StatusREST implements the REST endpoint for changing the status of a daemonset
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -121,3 +115,9 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -197,12 +197,4 @@ func TestShortNames(t *testing.T) {
|
|||||||
registrytest.AssertShortNames(t, storage, expected)
|
registrytest.AssertShortNames(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, _, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "daemonset"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO TestUpdateStatus
|
// TODO TestUpdateStatus
|
||||||
|
@ -92,9 +92,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against deployments.
|
// NewREST returns a RESTStorage object that will work against deployments.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *RollbackREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *RollbackREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &apps.Deployment{} },
|
NewFunc: func() runtime.Object { return &apps.Deployment{} },
|
||||||
NewListFunc: func() runtime.Object { return &apps.DeploymentList{} },
|
NewListFunc: func() runtime.Object { return &apps.DeploymentList{} },
|
||||||
DefaultQualifiedResource: apps.Resource("deployments"),
|
DefaultQualifiedResource: apps.Resource("deployments"),
|
||||||
|
SingularQualifiedResource: apps.Resource("deployment"),
|
||||||
|
|
||||||
CreateStrategy: deployment.Strategy,
|
CreateStrategy: deployment.Strategy,
|
||||||
UpdateStrategy: deployment.Strategy,
|
UpdateStrategy: deployment.Strategy,
|
||||||
@ -130,13 +131,6 @@ func (r *REST) Categories() []string {
|
|||||||
return []string{"all"}
|
return []string{"all"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "deployment"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of a deployment
|
// StatusREST implements the REST endpoint for changing the status of a deployment
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -174,6 +168,12 @@ func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object,
|
|||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
// RollbackREST implements the REST endpoint for initiating the rollback of a deployment
|
// RollbackREST implements the REST endpoint for initiating the rollback of a deployment
|
||||||
type RollbackREST struct {
|
type RollbackREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -204,6 +204,12 @@ func (r *RollbackREST) Destroy() {
|
|||||||
// we don't destroy it here explicitly.
|
// we don't destroy it here explicitly.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &RollbackREST{}
|
||||||
|
|
||||||
|
func (r *RollbackREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
var _ = rest.NamedCreater(&RollbackREST{})
|
var _ = rest.NamedCreater(&RollbackREST{})
|
||||||
|
|
||||||
// Create runs rollback for deployment
|
// Create runs rollback for deployment
|
||||||
@ -348,6 +354,12 @@ func (r *ScaleREST) ConvertToTable(ctx context.Context, object runtime.Object, t
|
|||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &ScaleREST{}
|
||||||
|
|
||||||
|
func (r *ScaleREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
func toScaleCreateValidation(f rest.ValidateObjectFunc) rest.ValidateObjectFunc {
|
func toScaleCreateValidation(f rest.ValidateObjectFunc) rest.ValidateObjectFunc {
|
||||||
return func(ctx context.Context, obj runtime.Object) error {
|
return func(ctx context.Context, obj runtime.Object) error {
|
||||||
scale, err := scaleFromDeployment(obj.(*apps.Deployment))
|
scale, err := scaleFromDeployment(obj.(*apps.Deployment))
|
||||||
|
@ -455,14 +455,6 @@ func TestCategories(t *testing.T) {
|
|||||||
registrytest.AssertCategories(t, storage.Deployment, expected)
|
registrytest.AssertCategories(t, storage.Deployment, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Deployment.Store.DestroyFunc()
|
|
||||||
expected := "deployment"
|
|
||||||
registrytest.AssertSingularName(t, storage.Deployment, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestScalePatchErrors(t *testing.T) {
|
func TestScalePatchErrors(t *testing.T) {
|
||||||
storage, server := newStorage(t)
|
storage, server := newStorage(t)
|
||||||
defer server.Terminate(t)
|
defer server.Terminate(t)
|
||||||
|
@ -86,10 +86,11 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against ReplicaSet.
|
// NewREST returns a RESTStorage object that will work against ReplicaSet.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &apps.ReplicaSet{} },
|
NewFunc: func() runtime.Object { return &apps.ReplicaSet{} },
|
||||||
NewListFunc: func() runtime.Object { return &apps.ReplicaSetList{} },
|
NewListFunc: func() runtime.Object { return &apps.ReplicaSetList{} },
|
||||||
PredicateFunc: replicaset.MatchReplicaSet,
|
PredicateFunc: replicaset.MatchReplicaSet,
|
||||||
DefaultQualifiedResource: apps.Resource("replicasets"),
|
DefaultQualifiedResource: apps.Resource("replicasets"),
|
||||||
|
SingularQualifiedResource: apps.Resource("replicaset"),
|
||||||
|
|
||||||
CreateStrategy: replicaset.Strategy,
|
CreateStrategy: replicaset.Strategy,
|
||||||
UpdateStrategy: replicaset.Strategy,
|
UpdateStrategy: replicaset.Strategy,
|
||||||
@ -126,13 +127,6 @@ func (r *REST) Categories() []string {
|
|||||||
return []string{"all"}
|
return []string{"all"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "replicaset"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of a ReplicaSet
|
// StatusREST implements the REST endpoint for changing the status of a ReplicaSet
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -170,6 +164,12 @@ func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object,
|
|||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
// ScaleREST implements a Scale for ReplicaSet.
|
// ScaleREST implements a Scale for ReplicaSet.
|
||||||
type ScaleREST struct {
|
type ScaleREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -244,6 +244,12 @@ func (r *ScaleREST) ConvertToTable(ctx context.Context, object runtime.Object, t
|
|||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &ScaleREST{}
|
||||||
|
|
||||||
|
func (r *ScaleREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
func toScaleCreateValidation(f rest.ValidateObjectFunc) rest.ValidateObjectFunc {
|
func toScaleCreateValidation(f rest.ValidateObjectFunc) rest.ValidateObjectFunc {
|
||||||
return func(ctx context.Context, obj runtime.Object) error {
|
return func(ctx context.Context, obj runtime.Object) error {
|
||||||
scale, err := scaleFromReplicaSet(obj.(*apps.ReplicaSet))
|
scale, err := scaleFromReplicaSet(obj.(*apps.ReplicaSet))
|
||||||
|
@ -399,14 +399,6 @@ func TestCategories(t *testing.T) {
|
|||||||
registrytest.AssertCategories(t, storage.ReplicaSet, expected)
|
registrytest.AssertCategories(t, storage.ReplicaSet, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.ReplicaSet.Store.DestroyFunc()
|
|
||||||
expected := "replicaset"
|
|
||||||
registrytest.AssertSingularName(t, storage.ReplicaSet, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestScalePatchErrors(t *testing.T) {
|
func TestScalePatchErrors(t *testing.T) {
|
||||||
storage, server := newStorage(t)
|
storage, server := newStorage(t)
|
||||||
defer server.Terminate(t)
|
defer server.Terminate(t)
|
||||||
|
@ -84,9 +84,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against statefulsets.
|
// NewREST returns a RESTStorage object that will work against statefulsets.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &apps.StatefulSet{} },
|
NewFunc: func() runtime.Object { return &apps.StatefulSet{} },
|
||||||
NewListFunc: func() runtime.Object { return &apps.StatefulSetList{} },
|
NewListFunc: func() runtime.Object { return &apps.StatefulSetList{} },
|
||||||
DefaultQualifiedResource: apps.Resource("statefulsets"),
|
DefaultQualifiedResource: apps.Resource("statefulsets"),
|
||||||
|
SingularQualifiedResource: apps.Resource("statefulset"),
|
||||||
|
|
||||||
CreateStrategy: statefulset.Strategy,
|
CreateStrategy: statefulset.Strategy,
|
||||||
UpdateStrategy: statefulset.Strategy,
|
UpdateStrategy: statefulset.Strategy,
|
||||||
@ -114,13 +115,6 @@ func (r *REST) Categories() []string {
|
|||||||
return []string{"all"}
|
return []string{"all"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "statefulset"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of an statefulSet
|
// StatusREST implements the REST endpoint for changing the status of an statefulSet
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -158,6 +152,12 @@ func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object,
|
|||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
// Implement ShortNamesProvider
|
// Implement ShortNamesProvider
|
||||||
var _ rest.ShortNamesProvider = &REST{}
|
var _ rest.ShortNamesProvider = &REST{}
|
||||||
|
|
||||||
@ -238,6 +238,12 @@ func (r *ScaleREST) ConvertToTable(ctx context.Context, object runtime.Object, t
|
|||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &ScaleREST{}
|
||||||
|
|
||||||
|
func (r *ScaleREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
func toScaleCreateValidation(f rest.ValidateObjectFunc) rest.ValidateObjectFunc {
|
func toScaleCreateValidation(f rest.ValidateObjectFunc) rest.ValidateObjectFunc {
|
||||||
return func(ctx context.Context, obj runtime.Object) error {
|
return func(ctx context.Context, obj runtime.Object) error {
|
||||||
scale, err := scaleFromStatefulSet(obj.(*apps.StatefulSet))
|
scale, err := scaleFromStatefulSet(obj.(*apps.StatefulSet))
|
||||||
|
@ -199,14 +199,6 @@ func TestCategories(t *testing.T) {
|
|||||||
registrytest.AssertCategories(t, storage.StatefulSet, expected)
|
registrytest.AssertCategories(t, storage.StatefulSet, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.StatefulSet.Store.DestroyFunc()
|
|
||||||
expected := "statefulset"
|
|
||||||
registrytest.AssertSingularName(t, storage.StatefulSet, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestShortNames(t *testing.T) {
|
func TestShortNames(t *testing.T) {
|
||||||
storage, server := newStorage(t)
|
storage, server := newStorage(t)
|
||||||
defer server.Terminate(t)
|
defer server.Terminate(t)
|
||||||
|
@ -60,6 +60,12 @@ func (r *REST) Destroy() {
|
|||||||
// here explicitly.
|
// here explicitly.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &REST{}
|
||||||
|
|
||||||
|
func (r *REST) GetSingularName() string {
|
||||||
|
return "tokenreview"
|
||||||
|
}
|
||||||
|
|
||||||
func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
||||||
tokenReview, ok := obj.(*authentication.TokenReview)
|
tokenReview, ok := obj.(*authentication.TokenReview)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -53,6 +53,12 @@ func (r *REST) Destroy() {
|
|||||||
// here explicitly.
|
// here explicitly.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &REST{}
|
||||||
|
|
||||||
|
func (r *REST) GetSingularName() string {
|
||||||
|
return "localsubjectaccessreview"
|
||||||
|
}
|
||||||
|
|
||||||
func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
||||||
localSubjectAccessReview, ok := obj.(*authorizationapi.LocalSubjectAccessReview)
|
localSubjectAccessReview, ok := obj.(*authorizationapi.LocalSubjectAccessReview)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -53,6 +53,12 @@ func (r *REST) Destroy() {
|
|||||||
// here explicitly.
|
// here explicitly.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &REST{}
|
||||||
|
|
||||||
|
func (r *REST) GetSingularName() string {
|
||||||
|
return "selfsubjectaccessreview"
|
||||||
|
}
|
||||||
|
|
||||||
func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
||||||
selfSAR, ok := obj.(*authorizationapi.SelfSubjectAccessReview)
|
selfSAR, ok := obj.(*authorizationapi.SelfSubjectAccessReview)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -95,6 +95,12 @@ func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &REST{}
|
||||||
|
|
||||||
|
func (r *REST) GetSingularName() string {
|
||||||
|
return "selfsubjectrulesreview"
|
||||||
|
}
|
||||||
|
|
||||||
func getResourceRules(infos []authorizer.ResourceRuleInfo) []authorizationapi.ResourceRule {
|
func getResourceRules(infos []authorizer.ResourceRuleInfo) []authorizationapi.ResourceRule {
|
||||||
rules := make([]authorizationapi.ResourceRule, len(infos))
|
rules := make([]authorizationapi.ResourceRule, len(infos))
|
||||||
for i, info := range infos {
|
for i, info := range infos {
|
||||||
|
@ -52,6 +52,12 @@ func (r *REST) Destroy() {
|
|||||||
// here explicitly.
|
// here explicitly.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &REST{}
|
||||||
|
|
||||||
|
func (r *REST) GetSingularName() string {
|
||||||
|
return "subjectaccessreview"
|
||||||
|
}
|
||||||
|
|
||||||
func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
||||||
subjectAccessReview, ok := obj.(*authorizationapi.SubjectAccessReview)
|
subjectAccessReview, ok := obj.(*authorizationapi.SubjectAccessReview)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -40,9 +40,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against horizontal pod autoscalers.
|
// NewREST returns a RESTStorage object that will work against horizontal pod autoscalers.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &autoscaling.HorizontalPodAutoscaler{} },
|
NewFunc: func() runtime.Object { return &autoscaling.HorizontalPodAutoscaler{} },
|
||||||
NewListFunc: func() runtime.Object { return &autoscaling.HorizontalPodAutoscalerList{} },
|
NewListFunc: func() runtime.Object { return &autoscaling.HorizontalPodAutoscalerList{} },
|
||||||
DefaultQualifiedResource: autoscaling.Resource("horizontalpodautoscalers"),
|
DefaultQualifiedResource: autoscaling.Resource("horizontalpodautoscalers"),
|
||||||
|
SingularQualifiedResource: autoscaling.Resource("horizontalpodautoscaler"),
|
||||||
|
|
||||||
CreateStrategy: horizontalpodautoscaler.Strategy,
|
CreateStrategy: horizontalpodautoscaler.Strategy,
|
||||||
UpdateStrategy: horizontalpodautoscaler.Strategy,
|
UpdateStrategy: horizontalpodautoscaler.Strategy,
|
||||||
@ -78,13 +79,6 @@ func (r *REST) Categories() []string {
|
|||||||
return []string{"all"}
|
return []string{"all"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "horizontalpodautoscaler"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of a daemonset
|
// StatusREST implements the REST endpoint for changing the status of a daemonset
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -121,3 +115,9 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -176,14 +176,6 @@ func TestCategories(t *testing.T) {
|
|||||||
registrytest.AssertCategories(t, storage, expected)
|
registrytest.AssertCategories(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, _, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "horizontalpodautoscaler"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUpdateStatus(t *testing.T) {
|
func TestUpdateStatus(t *testing.T) {
|
||||||
storage, statusStorage, server := newStorage(t)
|
storage, statusStorage, server := newStorage(t)
|
||||||
defer server.Terminate(t)
|
defer server.Terminate(t)
|
||||||
|
@ -40,9 +40,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against CronJobs.
|
// NewREST returns a RESTStorage object that will work against CronJobs.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &batch.CronJob{} },
|
NewFunc: func() runtime.Object { return &batch.CronJob{} },
|
||||||
NewListFunc: func() runtime.Object { return &batch.CronJobList{} },
|
NewListFunc: func() runtime.Object { return &batch.CronJobList{} },
|
||||||
DefaultQualifiedResource: batch.Resource("cronjobs"),
|
DefaultQualifiedResource: batch.Resource("cronjobs"),
|
||||||
|
SingularQualifiedResource: batch.Resource("cronjob"),
|
||||||
|
|
||||||
CreateStrategy: cronjob.Strategy,
|
CreateStrategy: cronjob.Strategy,
|
||||||
UpdateStrategy: cronjob.Strategy,
|
UpdateStrategy: cronjob.Strategy,
|
||||||
@ -76,13 +77,6 @@ func (r *REST) ShortNames() []string {
|
|||||||
return []string{"cj"}
|
return []string{"cj"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "cronjob"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of a resourcequota.
|
// StatusREST implements the REST endpoint for changing the status of a resourcequota.
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -119,3 +113,9 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -64,10 +64,11 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against Jobs.
|
// NewREST returns a RESTStorage object that will work against Jobs.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &batch.Job{} },
|
NewFunc: func() runtime.Object { return &batch.Job{} },
|
||||||
NewListFunc: func() runtime.Object { return &batch.JobList{} },
|
NewListFunc: func() runtime.Object { return &batch.JobList{} },
|
||||||
PredicateFunc: job.MatchJob,
|
PredicateFunc: job.MatchJob,
|
||||||
DefaultQualifiedResource: batch.Resource("jobs"),
|
DefaultQualifiedResource: batch.Resource("jobs"),
|
||||||
|
SingularQualifiedResource: batch.Resource("job"),
|
||||||
|
|
||||||
CreateStrategy: job.Strategy,
|
CreateStrategy: job.Strategy,
|
||||||
UpdateStrategy: job.Strategy,
|
UpdateStrategy: job.Strategy,
|
||||||
@ -96,13 +97,6 @@ func (r *REST) Categories() []string {
|
|||||||
return []string{"all"}
|
return []string{"all"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "job"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
|
func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
|
||||||
//nolint:staticcheck // SA1019 backwards compatibility
|
//nolint:staticcheck // SA1019 backwards compatibility
|
||||||
//nolint: staticcheck
|
//nolint: staticcheck
|
||||||
@ -162,3 +156,9 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -375,11 +375,3 @@ func TestCategories(t *testing.T) {
|
|||||||
expected := []string{"all"}
|
expected := []string{"all"}
|
||||||
registrytest.AssertCategories(t, storage.Job, expected)
|
registrytest.AssertCategories(t, storage.Job, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Job.Store.DestroyFunc()
|
|
||||||
expected := "job"
|
|
||||||
registrytest.AssertSingularName(t, storage.Job, expected)
|
|
||||||
}
|
|
||||||
|
@ -40,9 +40,10 @@ type REST struct {
|
|||||||
// NewREST returns a registry which will store CertificateSigningRequest in the given helper.
|
// NewREST returns a registry which will store CertificateSigningRequest in the given helper.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *ApprovalREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *ApprovalREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &certificates.CertificateSigningRequest{} },
|
NewFunc: func() runtime.Object { return &certificates.CertificateSigningRequest{} },
|
||||||
NewListFunc: func() runtime.Object { return &certificates.CertificateSigningRequestList{} },
|
NewListFunc: func() runtime.Object { return &certificates.CertificateSigningRequestList{} },
|
||||||
DefaultQualifiedResource: certificates.Resource("certificatesigningrequests"),
|
DefaultQualifiedResource: certificates.Resource("certificatesigningrequests"),
|
||||||
|
SingularQualifiedResource: certificates.Resource("certificatesigningrequest"),
|
||||||
|
|
||||||
CreateStrategy: csrregistry.Strategy,
|
CreateStrategy: csrregistry.Strategy,
|
||||||
UpdateStrategy: csrregistry.Strategy,
|
UpdateStrategy: csrregistry.Strategy,
|
||||||
@ -79,13 +80,6 @@ func (r *REST) ShortNames() []string {
|
|||||||
return []string{"csr"}
|
return []string{"csr"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "certificatesigningrequest"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of a CSR.
|
// StatusREST implements the REST endpoint for changing the status of a CSR.
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -123,6 +117,12 @@ func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object,
|
|||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
var _ = rest.Patcher(&StatusREST{})
|
var _ = rest.Patcher(&StatusREST{})
|
||||||
|
|
||||||
// ApprovalREST implements the REST endpoint for changing the approval state of a CSR.
|
// ApprovalREST implements the REST endpoint for changing the approval state of a CSR.
|
||||||
@ -158,4 +158,10 @@ func (r *ApprovalREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set
|
|||||||
return r.store.GetResetFields()
|
return r.store.GetResetFields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &ApprovalREST{}
|
||||||
|
|
||||||
|
func (r *ApprovalREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
var _ = rest.Patcher(&ApprovalREST{})
|
var _ = rest.Patcher(&ApprovalREST{})
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
|
||||||
coordinationapi "k8s.io/kubernetes/pkg/apis/coordination"
|
coordinationapi "k8s.io/kubernetes/pkg/apis/coordination"
|
||||||
"k8s.io/kubernetes/pkg/printers"
|
"k8s.io/kubernetes/pkg/printers"
|
||||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||||
@ -36,9 +35,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against leases.
|
// NewREST returns a RESTStorage object that will work against leases.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &coordinationapi.Lease{} },
|
NewFunc: func() runtime.Object { return &coordinationapi.Lease{} },
|
||||||
NewListFunc: func() runtime.Object { return &coordinationapi.LeaseList{} },
|
NewListFunc: func() runtime.Object { return &coordinationapi.LeaseList{} },
|
||||||
DefaultQualifiedResource: coordinationapi.Resource("leases"),
|
DefaultQualifiedResource: coordinationapi.Resource("leases"),
|
||||||
|
SingularQualifiedResource: coordinationapi.Resource("lease"),
|
||||||
|
|
||||||
CreateStrategy: lease.Strategy,
|
CreateStrategy: lease.Strategy,
|
||||||
UpdateStrategy: lease.Strategy,
|
UpdateStrategy: lease.Strategy,
|
||||||
@ -53,10 +53,3 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
|||||||
|
|
||||||
return &REST{store}, nil
|
return &REST{store}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "lease"
|
|
||||||
}
|
|
||||||
|
@ -58,6 +58,12 @@ func (rs *REST) New() runtime.Object {
|
|||||||
return &api.ComponentStatus{}
|
return &api.ComponentStatus{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &REST{}
|
||||||
|
|
||||||
|
func (rs *REST) GetSingularName() string {
|
||||||
|
return "componentstatus"
|
||||||
|
}
|
||||||
|
|
||||||
// Destroy cleans up resources on shutdown.
|
// Destroy cleans up resources on shutdown.
|
||||||
func (r *REST) Destroy() {
|
func (r *REST) Destroy() {
|
||||||
// Given no underlying store, we don't destroy anything
|
// Given no underlying store, we don't destroy anything
|
||||||
|
@ -37,10 +37,11 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work with ConfigMap objects.
|
// NewREST returns a RESTStorage object that will work with ConfigMap objects.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.ConfigMap{} },
|
NewFunc: func() runtime.Object { return &api.ConfigMap{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.ConfigMapList{} },
|
NewListFunc: func() runtime.Object { return &api.ConfigMapList{} },
|
||||||
PredicateFunc: configmap.Matcher,
|
PredicateFunc: configmap.Matcher,
|
||||||
DefaultQualifiedResource: api.Resource("configmaps"),
|
DefaultQualifiedResource: api.Resource("configmaps"),
|
||||||
|
SingularQualifiedResource: api.Resource("configmap"),
|
||||||
|
|
||||||
CreateStrategy: configmap.Strategy,
|
CreateStrategy: configmap.Strategy,
|
||||||
UpdateStrategy: configmap.Strategy,
|
UpdateStrategy: configmap.Strategy,
|
||||||
@ -66,10 +67,3 @@ var _ rest.ShortNamesProvider = &REST{}
|
|||||||
func (r *REST) ShortNames() []string {
|
func (r *REST) ShortNames() []string {
|
||||||
return []string{"cm"}
|
return []string{"cm"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "configmap"
|
|
||||||
}
|
|
||||||
|
@ -172,11 +172,3 @@ func TestShortNames(t *testing.T) {
|
|||||||
expected := []string{"cm"}
|
expected := []string{"cm"}
|
||||||
registrytest.AssertShortNames(t, storage, expected)
|
registrytest.AssertShortNames(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "configmap"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
@ -36,9 +36,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against endpoints.
|
// NewREST returns a RESTStorage object that will work against endpoints.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.Endpoints{} },
|
NewFunc: func() runtime.Object { return &api.Endpoints{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.EndpointsList{} },
|
NewListFunc: func() runtime.Object { return &api.EndpointsList{} },
|
||||||
DefaultQualifiedResource: api.Resource("endpoints"),
|
DefaultQualifiedResource: api.Resource("endpoints"),
|
||||||
|
SingularQualifiedResource: api.Resource("endpoint"),
|
||||||
|
|
||||||
CreateStrategy: endpoint.Strategy,
|
CreateStrategy: endpoint.Strategy,
|
||||||
UpdateStrategy: endpoint.Strategy,
|
UpdateStrategy: endpoint.Strategy,
|
||||||
@ -60,10 +61,3 @@ var _ rest.ShortNamesProvider = &REST{}
|
|||||||
func (r *REST) ShortNames() []string {
|
func (r *REST) ShortNames() []string {
|
||||||
return []string{"ep"}
|
return []string{"ep"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "endpoint"
|
|
||||||
}
|
|
||||||
|
@ -42,7 +42,8 @@ func NewREST(optsGetter generic.RESTOptionsGetter, ttl uint64) (*REST, error) {
|
|||||||
TTLFunc: func(runtime.Object, uint64, bool) (uint64, error) {
|
TTLFunc: func(runtime.Object, uint64, bool) (uint64, error) {
|
||||||
return ttl, nil
|
return ttl, nil
|
||||||
},
|
},
|
||||||
DefaultQualifiedResource: api.Resource("events"),
|
DefaultQualifiedResource: api.Resource("events"),
|
||||||
|
SingularQualifiedResource: api.Resource("event"),
|
||||||
|
|
||||||
CreateStrategy: event.Strategy,
|
CreateStrategy: event.Strategy,
|
||||||
UpdateStrategy: event.Strategy,
|
UpdateStrategy: event.Strategy,
|
||||||
@ -64,10 +65,3 @@ var _ rest.ShortNamesProvider = &REST{}
|
|||||||
func (r *REST) ShortNames() []string {
|
func (r *REST) ShortNames() []string {
|
||||||
return []string{"ev"}
|
return []string{"ev"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "event"
|
|
||||||
}
|
|
||||||
|
@ -123,11 +123,3 @@ func TestShortNames(t *testing.T) {
|
|||||||
expected := []string{"ev"}
|
expected := []string{"ev"}
|
||||||
registrytest.AssertShortNames(t, storage, expected)
|
registrytest.AssertShortNames(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "event"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
@ -33,9 +33,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against limit ranges.
|
// NewREST returns a RESTStorage object that will work against limit ranges.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.LimitRange{} },
|
NewFunc: func() runtime.Object { return &api.LimitRange{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.LimitRangeList{} },
|
NewListFunc: func() runtime.Object { return &api.LimitRangeList{} },
|
||||||
DefaultQualifiedResource: api.Resource("limitranges"),
|
DefaultQualifiedResource: api.Resource("limitranges"),
|
||||||
|
SingularQualifiedResource: api.Resource("limitrange"),
|
||||||
|
|
||||||
CreateStrategy: limitrange.Strategy,
|
CreateStrategy: limitrange.Strategy,
|
||||||
UpdateStrategy: limitrange.Strategy,
|
UpdateStrategy: limitrange.Strategy,
|
||||||
@ -58,10 +59,3 @@ var _ rest.ShortNamesProvider = &REST{}
|
|||||||
func (r *REST) ShortNames() []string {
|
func (r *REST) ShortNames() []string {
|
||||||
return []string{"limits"}
|
return []string{"limits"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "limitrange"
|
|
||||||
}
|
|
||||||
|
@ -171,11 +171,3 @@ func TestShortNames(t *testing.T) {
|
|||||||
expected := []string{"limits"}
|
expected := []string{"limits"}
|
||||||
registrytest.AssertShortNames(t, storage, expected)
|
registrytest.AssertShortNames(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "limitrange"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
@ -59,10 +59,11 @@ type FinalizeREST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against namespaces.
|
// NewREST returns a RESTStorage object that will work against namespaces.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *FinalizeREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *FinalizeREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.Namespace{} },
|
NewFunc: func() runtime.Object { return &api.Namespace{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.NamespaceList{} },
|
NewListFunc: func() runtime.Object { return &api.NamespaceList{} },
|
||||||
PredicateFunc: namespace.MatchNamespace,
|
PredicateFunc: namespace.MatchNamespace,
|
||||||
DefaultQualifiedResource: api.Resource("namespaces"),
|
DefaultQualifiedResource: api.Resource("namespaces"),
|
||||||
|
SingularQualifiedResource: api.Resource("namespace"),
|
||||||
|
|
||||||
CreateStrategy: namespace.Strategy,
|
CreateStrategy: namespace.Strategy,
|
||||||
UpdateStrategy: namespace.Strategy,
|
UpdateStrategy: namespace.Strategy,
|
||||||
@ -94,6 +95,12 @@ func (r *REST) NamespaceScoped() bool {
|
|||||||
return r.store.NamespaceScoped()
|
return r.store.NamespaceScoped()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &REST{}
|
||||||
|
|
||||||
|
func (r *REST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
func (r *REST) New() runtime.Object {
|
func (r *REST) New() runtime.Object {
|
||||||
return r.store.New()
|
return r.store.New()
|
||||||
}
|
}
|
||||||
@ -291,13 +298,6 @@ func (r *REST) ShortNames() []string {
|
|||||||
return []string{"ns"}
|
return []string{"ns"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "namespace"
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ rest.StorageVersionProvider = &REST{}
|
var _ rest.StorageVersionProvider = &REST{}
|
||||||
|
|
||||||
func (r *REST) StorageVersion() runtime.GroupVersioner {
|
func (r *REST) StorageVersion() runtime.GroupVersioner {
|
||||||
@ -339,6 +339,12 @@ func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object,
|
|||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
func (r *FinalizeREST) New() runtime.Object {
|
func (r *FinalizeREST) New() runtime.Object {
|
||||||
return r.store.New()
|
return r.store.New()
|
||||||
}
|
}
|
||||||
@ -360,3 +366,9 @@ func (r *FinalizeREST) Update(ctx context.Context, name string, objInfo rest.Upd
|
|||||||
func (r *FinalizeREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
func (r *FinalizeREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
||||||
return r.store.GetResetFields()
|
return r.store.GetResetFields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &FinalizeREST{}
|
||||||
|
|
||||||
|
func (r *FinalizeREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -628,11 +628,3 @@ func TestShortNames(t *testing.T) {
|
|||||||
expected := []string{"ns"}
|
expected := []string{"ns"}
|
||||||
registrytest.AssertShortNames(t, storage, expected)
|
registrytest.AssertShortNames(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.store.DestroyFunc()
|
|
||||||
expected := "namespace"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
@ -66,6 +66,12 @@ func (r *ProxyREST) NewConnectOptions() (runtime.Object, bool, string) {
|
|||||||
return &api.NodeProxyOptions{}, true, "path"
|
return &api.NodeProxyOptions{}, true, "path"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &ProxyREST{}
|
||||||
|
|
||||||
|
func (r *ProxyREST) GetSingularName() string {
|
||||||
|
return r.Store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
// Connect returns a handler for the node proxy
|
// Connect returns a handler for the node proxy
|
||||||
func (r *ProxyREST) Connect(ctx context.Context, id string, opts runtime.Object, responder rest.Responder) (http.Handler, error) {
|
func (r *ProxyREST) Connect(ctx context.Context, id string, opts runtime.Object, responder rest.Responder) (http.Handler, error) {
|
||||||
proxyOpts, ok := opts.(*api.NodeProxyOptions)
|
proxyOpts, ok := opts.(*api.NodeProxyOptions)
|
||||||
|
@ -93,13 +93,20 @@ func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object,
|
|||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
// NewStorage returns a NodeStorage object that will work against nodes.
|
// NewStorage returns a NodeStorage object that will work against nodes.
|
||||||
func NewStorage(optsGetter generic.RESTOptionsGetter, kubeletClientConfig client.KubeletClientConfig, proxyTransport http.RoundTripper) (*NodeStorage, error) {
|
func NewStorage(optsGetter generic.RESTOptionsGetter, kubeletClientConfig client.KubeletClientConfig, proxyTransport http.RoundTripper) (*NodeStorage, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.Node{} },
|
NewFunc: func() runtime.Object { return &api.Node{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.NodeList{} },
|
NewListFunc: func() runtime.Object { return &api.NodeList{} },
|
||||||
PredicateFunc: node.MatchNode,
|
PredicateFunc: node.MatchNode,
|
||||||
DefaultQualifiedResource: api.Resource("nodes"),
|
DefaultQualifiedResource: api.Resource("nodes"),
|
||||||
|
SingularQualifiedResource: api.Resource("node"),
|
||||||
|
|
||||||
CreateStrategy: node.Strategy,
|
CreateStrategy: node.Strategy,
|
||||||
UpdateStrategy: node.Strategy,
|
UpdateStrategy: node.Strategy,
|
||||||
@ -174,10 +181,3 @@ var _ rest.ShortNamesProvider = &REST{}
|
|||||||
func (r *REST) ShortNames() []string {
|
func (r *REST) ShortNames() []string {
|
||||||
return []string{"no"}
|
return []string{"no"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "node"
|
|
||||||
}
|
|
||||||
|
@ -40,10 +40,11 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against persistent volumes.
|
// NewREST returns a RESTStorage object that will work against persistent volumes.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.PersistentVolume{} },
|
NewFunc: func() runtime.Object { return &api.PersistentVolume{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.PersistentVolumeList{} },
|
NewListFunc: func() runtime.Object { return &api.PersistentVolumeList{} },
|
||||||
PredicateFunc: persistentvolume.MatchPersistentVolumes,
|
PredicateFunc: persistentvolume.MatchPersistentVolumes,
|
||||||
DefaultQualifiedResource: api.Resource("persistentvolumes"),
|
DefaultQualifiedResource: api.Resource("persistentvolumes"),
|
||||||
|
SingularQualifiedResource: api.Resource("persistentvolume"),
|
||||||
|
|
||||||
CreateStrategy: persistentvolume.Strategy,
|
CreateStrategy: persistentvolume.Strategy,
|
||||||
UpdateStrategy: persistentvolume.Strategy,
|
UpdateStrategy: persistentvolume.Strategy,
|
||||||
@ -73,13 +74,6 @@ func (r *REST) ShortNames() []string {
|
|||||||
return []string{"pv"}
|
return []string{"pv"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "persistentvolume"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of a persistentvolume.
|
// StatusREST implements the REST endpoint for changing the status of a persistentvolume.
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -116,3 +110,9 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -208,11 +208,3 @@ func TestShortNames(t *testing.T) {
|
|||||||
expected := []string{"pv"}
|
expected := []string{"pv"}
|
||||||
registrytest.AssertShortNames(t, storage, expected)
|
registrytest.AssertShortNames(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, _, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "persistentvolume"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
@ -41,10 +41,11 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against persistent volume claims.
|
// NewREST returns a RESTStorage object that will work against persistent volume claims.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.PersistentVolumeClaim{} },
|
NewFunc: func() runtime.Object { return &api.PersistentVolumeClaim{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.PersistentVolumeClaimList{} },
|
NewListFunc: func() runtime.Object { return &api.PersistentVolumeClaimList{} },
|
||||||
PredicateFunc: persistentvolumeclaim.MatchPersistentVolumeClaim,
|
PredicateFunc: persistentvolumeclaim.MatchPersistentVolumeClaim,
|
||||||
DefaultQualifiedResource: api.Resource("persistentvolumeclaims"),
|
DefaultQualifiedResource: api.Resource("persistentvolumeclaims"),
|
||||||
|
SingularQualifiedResource: api.Resource("persistentvolumeclaim"),
|
||||||
|
|
||||||
CreateStrategy: persistentvolumeclaim.Strategy,
|
CreateStrategy: persistentvolumeclaim.Strategy,
|
||||||
UpdateStrategy: persistentvolumeclaim.Strategy,
|
UpdateStrategy: persistentvolumeclaim.Strategy,
|
||||||
@ -77,13 +78,6 @@ func (r *REST) ShortNames() []string {
|
|||||||
return []string{"pvc"}
|
return []string{"pvc"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "persistentvolumeclaim"
|
|
||||||
}
|
|
||||||
|
|
||||||
// defaultOnRead sets interlinked fields that were not previously set on read.
|
// defaultOnRead sets interlinked fields that were not previously set on read.
|
||||||
// We can't do this in the normal defaulting path because that same logic
|
// We can't do this in the normal defaulting path because that same logic
|
||||||
// applies on Get, Create, and Update, but we need to distinguish between them.
|
// applies on Get, Create, and Update, but we need to distinguish between them.
|
||||||
@ -160,3 +154,9 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -212,14 +212,6 @@ func TestShortNames(t *testing.T) {
|
|||||||
registrytest.AssertShortNames(t, storage, expected)
|
registrytest.AssertShortNames(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, _, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "persistentvolumeclaim"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDefaultOnReadPvc(t *testing.T) {
|
func TestDefaultOnReadPvc(t *testing.T) {
|
||||||
storage, _, server := newStorage(t)
|
storage, _, server := newStorage(t)
|
||||||
defer server.Terminate(t)
|
defer server.Terminate(t)
|
||||||
|
@ -133,3 +133,9 @@ func (r *LogREST) OverrideMetricsVerb(oldVerb string) (newVerb string) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &LogREST{}
|
||||||
|
|
||||||
|
func (r *LogREST) GetSingularName() string {
|
||||||
|
return r.Store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -80,6 +80,12 @@ func (r *ProxyREST) Connect(ctx context.Context, id string, opts runtime.Object,
|
|||||||
return newThrottledUpgradeAwareProxyHandler(location, transport, true, false, responder), nil
|
return newThrottledUpgradeAwareProxyHandler(location, transport, true, false, responder), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &ProxyREST{}
|
||||||
|
|
||||||
|
func (r *ProxyREST) GetSingularName() string {
|
||||||
|
return r.Store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
// Support both GET and POST methods. We must support GET for browsers that want to use WebSockets.
|
// Support both GET and POST methods. We must support GET for browsers that want to use WebSockets.
|
||||||
var upgradeableMethods = []string{"GET", "POST"}
|
var upgradeableMethods = []string{"GET", "POST"}
|
||||||
|
|
||||||
@ -126,6 +132,12 @@ func (r *AttachREST) ConnectMethods() []string {
|
|||||||
return upgradeableMethods
|
return upgradeableMethods
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &AttachREST{}
|
||||||
|
|
||||||
|
func (r *AttachREST) GetSingularName() string {
|
||||||
|
return r.Store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
// ExecREST implements the exec subresource for a Pod
|
// ExecREST implements the exec subresource for a Pod
|
||||||
type ExecREST struct {
|
type ExecREST struct {
|
||||||
Store *genericregistry.Store
|
Store *genericregistry.Store
|
||||||
@ -169,6 +181,12 @@ func (r *ExecREST) ConnectMethods() []string {
|
|||||||
return upgradeableMethods
|
return upgradeableMethods
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &ExecREST{}
|
||||||
|
|
||||||
|
func (r *ExecREST) GetSingularName() string {
|
||||||
|
return r.Store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
// PortForwardREST implements the portforward subresource for a Pod
|
// PortForwardREST implements the portforward subresource for a Pod
|
||||||
type PortForwardREST struct {
|
type PortForwardREST struct {
|
||||||
Store *genericregistry.Store
|
Store *genericregistry.Store
|
||||||
@ -213,6 +231,12 @@ func (r *PortForwardREST) Connect(ctx context.Context, name string, opts runtime
|
|||||||
return newThrottledUpgradeAwareProxyHandler(location, transport, false, true, responder), nil
|
return newThrottledUpgradeAwareProxyHandler(location, transport, false, true, responder), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &PortForwardREST{}
|
||||||
|
|
||||||
|
func (r *PortForwardREST) GetSingularName() string {
|
||||||
|
return r.Store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
func newThrottledUpgradeAwareProxyHandler(location *url.URL, transport http.RoundTripper, wrapTransport, upgradeRequired bool, responder rest.Responder) *proxy.UpgradeAwareHandler {
|
func newThrottledUpgradeAwareProxyHandler(location *url.URL, transport http.RoundTripper, wrapTransport, upgradeRequired bool, responder rest.Responder) *proxy.UpgradeAwareHandler {
|
||||||
handler := proxy.NewUpgradeAwareHandler(location, transport, wrapTransport, upgradeRequired, proxy.NewErrorResponder(responder))
|
handler := proxy.NewUpgradeAwareHandler(location, transport, wrapTransport, upgradeRequired, proxy.NewErrorResponder(responder))
|
||||||
handler.MaxBytesPerSec = capabilities.Get().PerConnectionBandwidthLimitBytesPerSec
|
handler.MaxBytesPerSec = capabilities.Get().PerConnectionBandwidthLimitBytesPerSec
|
||||||
|
@ -103,6 +103,12 @@ func (r *EvictionREST) Destroy() {
|
|||||||
// we don't destroy it here explicitly.
|
// we don't destroy it here explicitly.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &EvictionREST{}
|
||||||
|
|
||||||
|
func (r *EvictionREST) GetSingularName() string {
|
||||||
|
return "pod"
|
||||||
|
}
|
||||||
|
|
||||||
// Propagate dry-run takes the dry-run option from the request and pushes it into the eviction object.
|
// Propagate dry-run takes the dry-run option from the request and pushes it into the eviction object.
|
||||||
// It returns an error if they have non-matching dry-run options.
|
// It returns an error if they have non-matching dry-run options.
|
||||||
func propagateDryRun(eviction *policy.Eviction, options *metav1.CreateOptions) (*metav1.DeleteOptions, error) {
|
func propagateDryRun(eviction *policy.Eviction, options *metav1.CreateOptions) (*metav1.DeleteOptions, error) {
|
||||||
|
@ -73,10 +73,11 @@ type REST struct {
|
|||||||
func NewStorage(optsGetter generic.RESTOptionsGetter, k client.ConnectionInfoGetter, proxyTransport http.RoundTripper, podDisruptionBudgetClient policyclient.PodDisruptionBudgetsGetter) (PodStorage, error) {
|
func NewStorage(optsGetter generic.RESTOptionsGetter, k client.ConnectionInfoGetter, proxyTransport http.RoundTripper, podDisruptionBudgetClient policyclient.PodDisruptionBudgetsGetter) (PodStorage, error) {
|
||||||
|
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.Pod{} },
|
NewFunc: func() runtime.Object { return &api.Pod{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.PodList{} },
|
NewListFunc: func() runtime.Object { return &api.PodList{} },
|
||||||
PredicateFunc: registrypod.MatchPod,
|
PredicateFunc: registrypod.MatchPod,
|
||||||
DefaultQualifiedResource: api.Resource("pods"),
|
DefaultQualifiedResource: api.Resource("pods"),
|
||||||
|
SingularQualifiedResource: api.Resource("pod"),
|
||||||
|
|
||||||
CreateStrategy: registrypod.Strategy,
|
CreateStrategy: registrypod.Strategy,
|
||||||
UpdateStrategy: registrypod.Strategy,
|
UpdateStrategy: registrypod.Strategy,
|
||||||
@ -142,13 +143,6 @@ func (r *REST) Categories() []string {
|
|||||||
return []string{"all"}
|
return []string{"all"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "pod"
|
|
||||||
}
|
|
||||||
|
|
||||||
// BindingREST implements the REST endpoint for binding pods to nodes when etcd is in use.
|
// BindingREST implements the REST endpoint for binding pods to nodes when etcd is in use.
|
||||||
type BindingREST struct {
|
type BindingREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -170,6 +164,12 @@ func (r *BindingREST) Destroy() {
|
|||||||
// we don't destroy it here explicitly.
|
// we don't destroy it here explicitly.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &BindingREST{}
|
||||||
|
|
||||||
|
func (r *BindingREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
var _ = rest.NamedCreater(&BindingREST{})
|
var _ = rest.NamedCreater(&BindingREST{})
|
||||||
|
|
||||||
// Create ensures a pod is bound to a specific host.
|
// Create ensures a pod is bound to a specific host.
|
||||||
@ -286,6 +286,12 @@ func (r *LegacyBindingREST) Destroy() {
|
|||||||
// we don't destroy it here explicitly.
|
// we don't destroy it here explicitly.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &LegacyBindingREST{}
|
||||||
|
|
||||||
|
func (r *LegacyBindingREST) GetSingularName() string {
|
||||||
|
return r.bindingRest.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
// Create ensures a pod is bound to a specific host.
|
// Create ensures a pod is bound to a specific host.
|
||||||
func (r *LegacyBindingREST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (out runtime.Object, err error) {
|
func (r *LegacyBindingREST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (out runtime.Object, err error) {
|
||||||
metadata, err := meta.Accessor(obj)
|
metadata, err := meta.Accessor(obj)
|
||||||
@ -332,6 +338,12 @@ func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object,
|
|||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
// EphemeralContainersREST implements the REST endpoint for adding EphemeralContainers
|
// EphemeralContainersREST implements the REST endpoint for adding EphemeralContainers
|
||||||
type EphemeralContainersREST struct {
|
type EphemeralContainersREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -361,3 +373,9 @@ func (r *EphemeralContainersREST) Update(ctx context.Context, name string, objIn
|
|||||||
// subresources should never allow create on update.
|
// subresources should never allow create on update.
|
||||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options)
|
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &EphemeralContainersREST{}
|
||||||
|
|
||||||
|
func (r *EphemeralContainersREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -1274,11 +1274,3 @@ func TestCategories(t *testing.T) {
|
|||||||
expected := []string{"all"}
|
expected := []string{"all"}
|
||||||
registrytest.AssertCategories(t, storage, expected)
|
registrytest.AssertCategories(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, _, _, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "pod"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/printers"
|
"k8s.io/kubernetes/pkg/printers"
|
||||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||||
@ -36,9 +35,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against pod templates.
|
// NewREST returns a RESTStorage object that will work against pod templates.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.PodTemplate{} },
|
NewFunc: func() runtime.Object { return &api.PodTemplate{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.PodTemplateList{} },
|
NewListFunc: func() runtime.Object { return &api.PodTemplateList{} },
|
||||||
DefaultQualifiedResource: api.Resource("podtemplates"),
|
DefaultQualifiedResource: api.Resource("podtemplates"),
|
||||||
|
SingularQualifiedResource: api.Resource("podtemplate"),
|
||||||
|
|
||||||
CreateStrategy: podtemplate.Strategy,
|
CreateStrategy: podtemplate.Strategy,
|
||||||
UpdateStrategy: podtemplate.Strategy,
|
UpdateStrategy: podtemplate.Strategy,
|
||||||
@ -54,10 +54,3 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
|||||||
}
|
}
|
||||||
return &REST{store}, nil
|
return &REST{store}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "podtemplate"
|
|
||||||
}
|
|
||||||
|
@ -153,11 +153,3 @@ func TestWatch(t *testing.T) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "podtemplate"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
@ -82,10 +82,11 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against replication controllers.
|
// NewREST returns a RESTStorage object that will work against replication controllers.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.ReplicationController{} },
|
NewFunc: func() runtime.Object { return &api.ReplicationController{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.ReplicationControllerList{} },
|
NewListFunc: func() runtime.Object { return &api.ReplicationControllerList{} },
|
||||||
PredicateFunc: replicationcontroller.MatchController,
|
PredicateFunc: replicationcontroller.MatchController,
|
||||||
DefaultQualifiedResource: api.Resource("replicationcontrollers"),
|
DefaultQualifiedResource: api.Resource("replicationcontrollers"),
|
||||||
|
SingularQualifiedResource: api.Resource("replicationcontroller"),
|
||||||
|
|
||||||
CreateStrategy: replicationcontroller.Strategy,
|
CreateStrategy: replicationcontroller.Strategy,
|
||||||
UpdateStrategy: replicationcontroller.Strategy,
|
UpdateStrategy: replicationcontroller.Strategy,
|
||||||
@ -122,13 +123,6 @@ func (r *REST) Categories() []string {
|
|||||||
return []string{"all"}
|
return []string{"all"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "replicationcontroller"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of a replication controller
|
// StatusREST implements the REST endpoint for changing the status of a replication controller
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -165,6 +159,12 @@ func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object,
|
|||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
type ScaleREST struct {
|
type ScaleREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
}
|
}
|
||||||
@ -223,6 +223,12 @@ func (r *ScaleREST) ConvertToTable(ctx context.Context, object runtime.Object, t
|
|||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &ScaleREST{}
|
||||||
|
|
||||||
|
func (r *ScaleREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
func toScaleCreateValidation(f rest.ValidateObjectFunc) rest.ValidateObjectFunc {
|
func toScaleCreateValidation(f rest.ValidateObjectFunc) rest.ValidateObjectFunc {
|
||||||
return func(ctx context.Context, obj runtime.Object) error {
|
return func(ctx context.Context, obj runtime.Object) error {
|
||||||
return f(ctx, scaleFromRC(obj.(*api.ReplicationController)))
|
return f(ctx, scaleFromRC(obj.(*api.ReplicationController)))
|
||||||
|
@ -352,14 +352,6 @@ func TestCategories(t *testing.T) {
|
|||||||
registrytest.AssertCategories(t, storage.Controller, expected)
|
registrytest.AssertCategories(t, storage.Controller, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Controller.Store.DestroyFunc()
|
|
||||||
expected := "replicationcontroller"
|
|
||||||
registrytest.AssertSingularName(t, storage.Controller, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestScalePatchErrors(t *testing.T) {
|
func TestScalePatchErrors(t *testing.T) {
|
||||||
storage, server := newStorage(t)
|
storage, server := newStorage(t)
|
||||||
defer server.Terminate(t)
|
defer server.Terminate(t)
|
||||||
|
@ -40,9 +40,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against resource quotas.
|
// NewREST returns a RESTStorage object that will work against resource quotas.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.ResourceQuota{} },
|
NewFunc: func() runtime.Object { return &api.ResourceQuota{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.ResourceQuotaList{} },
|
NewListFunc: func() runtime.Object { return &api.ResourceQuotaList{} },
|
||||||
DefaultQualifiedResource: api.Resource("resourcequotas"),
|
DefaultQualifiedResource: api.Resource("resourcequotas"),
|
||||||
|
SingularQualifiedResource: api.Resource("resourcequota"),
|
||||||
|
|
||||||
CreateStrategy: resourcequota.Strategy,
|
CreateStrategy: resourcequota.Strategy,
|
||||||
UpdateStrategy: resourcequota.Strategy,
|
UpdateStrategy: resourcequota.Strategy,
|
||||||
@ -72,13 +73,6 @@ func (r *REST) ShortNames() []string {
|
|||||||
return []string{"quota"}
|
return []string{"quota"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "resourcequota"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of a resourcequota.
|
// StatusREST implements the REST endpoint for changing the status of a resourcequota.
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -115,3 +109,9 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -217,11 +217,3 @@ func TestShortNames(t *testing.T) {
|
|||||||
expected := []string{"quota"}
|
expected := []string{"quota"}
|
||||||
registrytest.AssertShortNames(t, storage, expected)
|
registrytest.AssertShortNames(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, _, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "resourcequota"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
|
||||||
"k8s.io/apiserver/pkg/storage"
|
"k8s.io/apiserver/pkg/storage"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/printers"
|
"k8s.io/kubernetes/pkg/printers"
|
||||||
@ -37,10 +36,11 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against secrets.
|
// NewREST returns a RESTStorage object that will work against secrets.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.Secret{} },
|
NewFunc: func() runtime.Object { return &api.Secret{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.SecretList{} },
|
NewListFunc: func() runtime.Object { return &api.SecretList{} },
|
||||||
PredicateFunc: secret.Matcher,
|
PredicateFunc: secret.Matcher,
|
||||||
DefaultQualifiedResource: api.Resource("secrets"),
|
DefaultQualifiedResource: api.Resource("secrets"),
|
||||||
|
SingularQualifiedResource: api.Resource("secret"),
|
||||||
|
|
||||||
CreateStrategy: secret.Strategy,
|
CreateStrategy: secret.Strategy,
|
||||||
UpdateStrategy: secret.Strategy,
|
UpdateStrategy: secret.Strategy,
|
||||||
@ -58,10 +58,3 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
|||||||
}
|
}
|
||||||
return &REST{store}, nil
|
return &REST{store}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "secret"
|
|
||||||
}
|
|
||||||
|
@ -143,11 +143,3 @@ func TestWatch(t *testing.T) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "secret"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
@ -77,6 +77,12 @@ func (r *ProxyREST) Connect(ctx context.Context, id string, opts runtime.Object,
|
|||||||
return newThrottledUpgradeAwareProxyHandler(location, transport, true, false, responder), nil
|
return newThrottledUpgradeAwareProxyHandler(location, transport, true, false, responder), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &ProxyREST{}
|
||||||
|
|
||||||
|
func (r *ProxyREST) GetSingularName() string {
|
||||||
|
return "service"
|
||||||
|
}
|
||||||
|
|
||||||
func newThrottledUpgradeAwareProxyHandler(location *url.URL, transport http.RoundTripper, wrapTransport, upgradeRequired bool, responder rest.Responder) *proxy.UpgradeAwareHandler {
|
func newThrottledUpgradeAwareProxyHandler(location *url.URL, transport http.RoundTripper, wrapTransport, upgradeRequired bool, responder rest.Responder) *proxy.UpgradeAwareHandler {
|
||||||
handler := proxy.NewUpgradeAwareHandler(location, transport, wrapTransport, upgradeRequired, proxy.NewErrorResponder(responder))
|
handler := proxy.NewUpgradeAwareHandler(location, transport, wrapTransport, upgradeRequired, proxy.NewErrorResponder(responder))
|
||||||
handler.MaxBytesPerSec = capabilities.Get().PerConnectionBandwidthLimitBytesPerSec
|
handler.MaxBytesPerSec = capabilities.Get().PerConnectionBandwidthLimitBytesPerSec
|
||||||
|
@ -86,10 +86,11 @@ func NewREST(
|
|||||||
proxyTransport http.RoundTripper) (*REST, *StatusREST, *svcreg.ProxyREST, error) {
|
proxyTransport http.RoundTripper) (*REST, *StatusREST, *svcreg.ProxyREST, error) {
|
||||||
|
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.Service{} },
|
NewFunc: func() runtime.Object { return &api.Service{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.ServiceList{} },
|
NewListFunc: func() runtime.Object { return &api.ServiceList{} },
|
||||||
DefaultQualifiedResource: api.Resource("services"),
|
DefaultQualifiedResource: api.Resource("services"),
|
||||||
ReturnDeletedObject: true,
|
SingularQualifiedResource: api.Resource("service"),
|
||||||
|
ReturnDeletedObject: true,
|
||||||
|
|
||||||
CreateStrategy: svcreg.Strategy,
|
CreateStrategy: svcreg.Strategy,
|
||||||
UpdateStrategy: svcreg.Strategy,
|
UpdateStrategy: svcreg.Strategy,
|
||||||
@ -153,13 +154,6 @@ func (r *REST) Categories() []string {
|
|||||||
return []string{"all"}
|
return []string{"all"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "service"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destroy cleans up everything on shutdown.
|
// Destroy cleans up everything on shutdown.
|
||||||
func (r *REST) Destroy() {
|
func (r *REST) Destroy() {
|
||||||
r.Store.Destroy()
|
r.Store.Destroy()
|
||||||
@ -202,6 +196,12 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
return r.store.GetResetFields()
|
return r.store.GetResetFields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
|
||||||
// We have a lot of functions that take a pair of "before" and "after" or
|
// We have a lot of functions that take a pair of "before" and "after" or
|
||||||
// "oldSvc" and "newSvc" args. Convention across the codebase is to pass them
|
// "oldSvc" and "newSvc" args. Convention across the codebase is to pass them
|
||||||
// as (new, old), but it's easy to screw up when they are the same type.
|
// as (new, old), but it's easy to screw up when they are the same type.
|
||||||
|
@ -279,14 +279,6 @@ func TestGenericCategories(t *testing.T) {
|
|||||||
registrytest.AssertCategories(t, storage, expected)
|
registrytest.AssertCategories(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, _, server := newStorage(t, []api.IPFamily{api.IPv4Protocol})
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "service"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Tests of internal functions
|
// Tests of internal functions
|
||||||
//
|
//
|
||||||
|
@ -41,9 +41,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against service accounts.
|
// NewREST returns a RESTStorage object that will work against service accounts.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter, issuer token.TokenGenerator, auds authenticator.Audiences, max time.Duration, podStorage, secretStorage *genericregistry.Store, extendExpiration bool) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter, issuer token.TokenGenerator, auds authenticator.Audiences, max time.Duration, podStorage, secretStorage *genericregistry.Store, extendExpiration bool) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.ServiceAccount{} },
|
NewFunc: func() runtime.Object { return &api.ServiceAccount{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.ServiceAccountList{} },
|
NewListFunc: func() runtime.Object { return &api.ServiceAccountList{} },
|
||||||
DefaultQualifiedResource: api.Resource("serviceaccounts"),
|
DefaultQualifiedResource: api.Resource("serviceaccounts"),
|
||||||
|
SingularQualifiedResource: api.Resource("serviceaccount"),
|
||||||
|
|
||||||
CreateStrategy: serviceaccount.Strategy,
|
CreateStrategy: serviceaccount.Strategy,
|
||||||
UpdateStrategy: serviceaccount.Strategy,
|
UpdateStrategy: serviceaccount.Strategy,
|
||||||
@ -84,10 +85,3 @@ var _ rest.ShortNamesProvider = &REST{}
|
|||||||
func (r *REST) ShortNames() []string {
|
func (r *REST) ShortNames() []string {
|
||||||
return []string{"sa"}
|
return []string{"sa"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "serviceaccount"
|
|
||||||
}
|
|
||||||
|
@ -146,11 +146,3 @@ func TestShortNames(t *testing.T) {
|
|||||||
expected := []string{"sa"}
|
expected := []string{"sa"}
|
||||||
registrytest.AssertShortNames(t, storage, expected)
|
registrytest.AssertShortNames(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "serviceaccount"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
@ -49,6 +49,12 @@ func (r *TokenREST) Destroy() {
|
|||||||
// here explicitly.
|
// here explicitly.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &TokenREST{}
|
||||||
|
|
||||||
|
func (r *TokenREST) GetSingularName() string {
|
||||||
|
return "serviceaccount"
|
||||||
|
}
|
||||||
|
|
||||||
type TokenREST struct {
|
type TokenREST struct {
|
||||||
svcaccts getter
|
svcaccts getter
|
||||||
pods getter
|
pods getter
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||||
"k8s.io/kubernetes/pkg/printers"
|
"k8s.io/kubernetes/pkg/printers"
|
||||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||||
@ -36,9 +35,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against endpoint slices.
|
// NewREST returns a RESTStorage object that will work against endpoint slices.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &discovery.EndpointSlice{} },
|
NewFunc: func() runtime.Object { return &discovery.EndpointSlice{} },
|
||||||
NewListFunc: func() runtime.Object { return &discovery.EndpointSliceList{} },
|
NewListFunc: func() runtime.Object { return &discovery.EndpointSliceList{} },
|
||||||
DefaultQualifiedResource: discovery.Resource("endpointslices"),
|
DefaultQualifiedResource: discovery.Resource("endpointslices"),
|
||||||
|
SingularQualifiedResource: discovery.Resource("endpointslice"),
|
||||||
|
|
||||||
CreateStrategy: endpointslice.Strategy,
|
CreateStrategy: endpointslice.Strategy,
|
||||||
UpdateStrategy: endpointslice.Strategy,
|
UpdateStrategy: endpointslice.Strategy,
|
||||||
@ -52,10 +52,3 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
|||||||
}
|
}
|
||||||
return &REST{store}, nil
|
return &REST{store}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "endpointslice"
|
|
||||||
}
|
|
||||||
|
@ -46,9 +46,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against flow schemas.
|
// NewREST returns a RESTStorage object that will work against flow schemas.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &flowcontrol.FlowSchema{} },
|
NewFunc: func() runtime.Object { return &flowcontrol.FlowSchema{} },
|
||||||
NewListFunc: func() runtime.Object { return &flowcontrol.FlowSchemaList{} },
|
NewListFunc: func() runtime.Object { return &flowcontrol.FlowSchemaList{} },
|
||||||
DefaultQualifiedResource: flowcontrol.Resource("flowschemas"),
|
DefaultQualifiedResource: flowcontrol.Resource("flowschemas"),
|
||||||
|
SingularQualifiedResource: flowcontrol.Resource("flowschema"),
|
||||||
|
|
||||||
CreateStrategy: flowschema.Strategy,
|
CreateStrategy: flowschema.Strategy,
|
||||||
UpdateStrategy: flowschema.Strategy,
|
UpdateStrategy: flowschema.Strategy,
|
||||||
@ -107,3 +108,9 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -46,9 +46,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against priority level configuration.
|
// NewREST returns a RESTStorage object that will work against priority level configuration.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &flowcontrol.PriorityLevelConfiguration{} },
|
NewFunc: func() runtime.Object { return &flowcontrol.PriorityLevelConfiguration{} },
|
||||||
NewListFunc: func() runtime.Object { return &flowcontrol.PriorityLevelConfigurationList{} },
|
NewListFunc: func() runtime.Object { return &flowcontrol.PriorityLevelConfigurationList{} },
|
||||||
DefaultQualifiedResource: flowcontrol.Resource("prioritylevelconfigurations"),
|
DefaultQualifiedResource: flowcontrol.Resource("prioritylevelconfigurations"),
|
||||||
|
SingularQualifiedResource: flowcontrol.Resource("prioritylevelconfiguration"),
|
||||||
|
|
||||||
CreateStrategy: prioritylevelconfiguration.Strategy,
|
CreateStrategy: prioritylevelconfiguration.Strategy,
|
||||||
UpdateStrategy: prioritylevelconfiguration.Strategy,
|
UpdateStrategy: prioritylevelconfiguration.Strategy,
|
||||||
@ -107,3 +108,9 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -36,9 +36,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against ClusterCIDRs.
|
// NewREST returns a RESTStorage object that will work against ClusterCIDRs.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &networkingapi.ClusterCIDR{} },
|
NewFunc: func() runtime.Object { return &networkingapi.ClusterCIDR{} },
|
||||||
NewListFunc: func() runtime.Object { return &networkingapi.ClusterCIDRList{} },
|
NewListFunc: func() runtime.Object { return &networkingapi.ClusterCIDRList{} },
|
||||||
DefaultQualifiedResource: networkingapi.Resource("clustercidrs"),
|
DefaultQualifiedResource: networkingapi.Resource("clustercidrs"),
|
||||||
|
SingularQualifiedResource: networkingapi.Resource("clustercidr"),
|
||||||
|
|
||||||
CreateStrategy: clustercidr.Strategy,
|
CreateStrategy: clustercidr.Strategy,
|
||||||
UpdateStrategy: clustercidr.Strategy,
|
UpdateStrategy: clustercidr.Strategy,
|
||||||
|
@ -40,9 +40,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against replication controllers.
|
// NewREST returns a RESTStorage object that will work against replication controllers.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &networking.Ingress{} },
|
NewFunc: func() runtime.Object { return &networking.Ingress{} },
|
||||||
NewListFunc: func() runtime.Object { return &networking.IngressList{} },
|
NewListFunc: func() runtime.Object { return &networking.IngressList{} },
|
||||||
DefaultQualifiedResource: networking.Resource("ingresses"),
|
DefaultQualifiedResource: networking.Resource("ingresses"),
|
||||||
|
SingularQualifiedResource: networking.Resource("ingress"),
|
||||||
|
|
||||||
CreateStrategy: ingress.Strategy,
|
CreateStrategy: ingress.Strategy,
|
||||||
UpdateStrategy: ingress.Strategy,
|
UpdateStrategy: ingress.Strategy,
|
||||||
@ -70,13 +71,6 @@ func (r *REST) ShortNames() []string {
|
|||||||
return []string{"ing"}
|
return []string{"ing"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "ingress"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of an ingress
|
// StatusREST implements the REST endpoint for changing the status of an ingress
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -113,3 +107,9 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -250,12 +250,4 @@ func TestShortNames(t *testing.T) {
|
|||||||
registrytest.AssertShortNames(t, storage, expected)
|
registrytest.AssertShortNames(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, _, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "ingress"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO TestUpdateStatus
|
// TODO TestUpdateStatus
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/networking"
|
"k8s.io/kubernetes/pkg/apis/networking"
|
||||||
"k8s.io/kubernetes/pkg/printers"
|
"k8s.io/kubernetes/pkg/printers"
|
||||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||||
@ -36,9 +35,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against replication controllers.
|
// NewREST returns a RESTStorage object that will work against replication controllers.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &networking.IngressClass{} },
|
NewFunc: func() runtime.Object { return &networking.IngressClass{} },
|
||||||
NewListFunc: func() runtime.Object { return &networking.IngressClassList{} },
|
NewListFunc: func() runtime.Object { return &networking.IngressClassList{} },
|
||||||
DefaultQualifiedResource: networking.Resource("ingressclasses"),
|
DefaultQualifiedResource: networking.Resource("ingressclasses"),
|
||||||
|
SingularQualifiedResource: networking.Resource("ingressclass"),
|
||||||
|
|
||||||
CreateStrategy: ingressclass.Strategy,
|
CreateStrategy: ingressclass.Strategy,
|
||||||
UpdateStrategy: ingressclass.Strategy,
|
UpdateStrategy: ingressclass.Strategy,
|
||||||
@ -53,10 +53,3 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
|||||||
|
|
||||||
return &REST{store}, nil
|
return &REST{store}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "ingressclass"
|
|
||||||
}
|
|
||||||
|
@ -41,9 +41,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against NetworkPolicies.
|
// NewREST returns a RESTStorage object that will work against NetworkPolicies.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &networkingapi.NetworkPolicy{} },
|
NewFunc: func() runtime.Object { return &networkingapi.NetworkPolicy{} },
|
||||||
NewListFunc: func() runtime.Object { return &networkingapi.NetworkPolicyList{} },
|
NewListFunc: func() runtime.Object { return &networkingapi.NetworkPolicyList{} },
|
||||||
DefaultQualifiedResource: networkingapi.Resource("networkpolicies"),
|
DefaultQualifiedResource: networkingapi.Resource("networkpolicies"),
|
||||||
|
SingularQualifiedResource: networkingapi.Resource("networkpolicy"),
|
||||||
|
|
||||||
CreateStrategy: networkpolicy.Strategy,
|
CreateStrategy: networkpolicy.Strategy,
|
||||||
UpdateStrategy: networkpolicy.Strategy,
|
UpdateStrategy: networkpolicy.Strategy,
|
||||||
@ -72,13 +73,6 @@ func (r *REST) ShortNames() []string {
|
|||||||
return []string{"netpol"}
|
return []string{"netpol"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "networkpolicy"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of an ingress
|
// StatusREST implements the REST endpoint for changing the status of an ingress
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -111,3 +105,9 @@ func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.Updat
|
|||||||
func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
||||||
return r.store.GetResetFields()
|
return r.store.GetResetFields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -198,14 +198,6 @@ func TestShortNames(t *testing.T) {
|
|||||||
registrytest.AssertShortNames(t, storage, expected)
|
registrytest.AssertShortNames(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, _, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "networkpolicy"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestStatusUpdate(t *testing.T) {
|
func TestStatusUpdate(t *testing.T) {
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NetworkPolicyStatus, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NetworkPolicyStatus, true)()
|
||||||
storage, statusStorage, server := newStorage(t)
|
storage, statusStorage, server := newStorage(t)
|
||||||
|
@ -40,7 +40,8 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
|||||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||||
return obj.(*node.RuntimeClass).Name, nil
|
return obj.(*node.RuntimeClass).Name, nil
|
||||||
},
|
},
|
||||||
DefaultQualifiedResource: node.Resource("runtimeclasses"),
|
DefaultQualifiedResource: node.Resource("runtimeclasses"),
|
||||||
|
SingularQualifiedResource: node.Resource("runtimeclass"),
|
||||||
|
|
||||||
CreateStrategy: runtimeclass.Strategy,
|
CreateStrategy: runtimeclass.Strategy,
|
||||||
UpdateStrategy: runtimeclass.Strategy,
|
UpdateStrategy: runtimeclass.Strategy,
|
||||||
|
@ -40,9 +40,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against pod disruption budgets.
|
// NewREST returns a RESTStorage object that will work against pod disruption budgets.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &policyapi.PodDisruptionBudget{} },
|
NewFunc: func() runtime.Object { return &policyapi.PodDisruptionBudget{} },
|
||||||
NewListFunc: func() runtime.Object { return &policyapi.PodDisruptionBudgetList{} },
|
NewListFunc: func() runtime.Object { return &policyapi.PodDisruptionBudgetList{} },
|
||||||
DefaultQualifiedResource: policyapi.Resource("poddisruptionbudgets"),
|
DefaultQualifiedResource: policyapi.Resource("poddisruptionbudgets"),
|
||||||
|
SingularQualifiedResource: policyapi.Resource("poddisruptionbudget"),
|
||||||
|
|
||||||
CreateStrategy: poddisruptionbudget.Strategy,
|
CreateStrategy: poddisruptionbudget.Strategy,
|
||||||
UpdateStrategy: poddisruptionbudget.Strategy,
|
UpdateStrategy: poddisruptionbudget.Strategy,
|
||||||
@ -67,13 +68,6 @@ func (r *REST) ShortNames() []string {
|
|||||||
return []string{"pdb"}
|
return []string{"pdb"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "poddisruptionbudget"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of an podDisruptionBudget.
|
// StatusREST implements the REST endpoint for changing the status of an podDisruptionBudget.
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -110,3 +104,9 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -35,9 +35,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against PodSecurityPolicy objects.
|
// NewREST returns a RESTStorage object that will work against PodSecurityPolicy objects.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &policy.PodSecurityPolicy{} },
|
NewFunc: func() runtime.Object { return &policy.PodSecurityPolicy{} },
|
||||||
NewListFunc: func() runtime.Object { return &policy.PodSecurityPolicyList{} },
|
NewListFunc: func() runtime.Object { return &policy.PodSecurityPolicyList{} },
|
||||||
DefaultQualifiedResource: policy.Resource("podsecuritypolicies"),
|
DefaultQualifiedResource: policy.Resource("podsecuritypolicies"),
|
||||||
|
SingularQualifiedResource: policy.Resource("podsecuritypolicy"),
|
||||||
|
|
||||||
CreateStrategy: podsecuritypolicy.Strategy,
|
CreateStrategy: podsecuritypolicy.Strategy,
|
||||||
UpdateStrategy: podsecuritypolicy.Strategy,
|
UpdateStrategy: podsecuritypolicy.Strategy,
|
||||||
|
@ -124,3 +124,9 @@ func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjec
|
|||||||
func hasAggregationRule(clusterRole *rbac.ClusterRole) bool {
|
func hasAggregationRule(clusterRole *rbac.ClusterRole) bool {
|
||||||
return clusterRole.AggregationRule != nil && len(clusterRole.AggregationRule.ClusterRoleSelectors) > 0
|
return clusterRole.AggregationRule != nil && len(clusterRole.AggregationRule.ClusterRoleSelectors) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &Storage{}
|
||||||
|
|
||||||
|
func (s *Storage) GetSingularName() string {
|
||||||
|
return "clusterrole"
|
||||||
|
}
|
||||||
|
@ -33,9 +33,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against ClusterRole objects.
|
// NewREST returns a RESTStorage object that will work against ClusterRole objects.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &rbac.ClusterRole{} },
|
NewFunc: func() runtime.Object { return &rbac.ClusterRole{} },
|
||||||
NewListFunc: func() runtime.Object { return &rbac.ClusterRoleList{} },
|
NewListFunc: func() runtime.Object { return &rbac.ClusterRoleList{} },
|
||||||
DefaultQualifiedResource: rbac.Resource("clusterroles"),
|
DefaultQualifiedResource: rbac.Resource("clusterroles"),
|
||||||
|
SingularQualifiedResource: rbac.Resource("clusterrole"),
|
||||||
|
|
||||||
CreateStrategy: clusterrole.Strategy,
|
CreateStrategy: clusterrole.Strategy,
|
||||||
UpdateStrategy: clusterrole.Strategy,
|
UpdateStrategy: clusterrole.Strategy,
|
||||||
@ -51,10 +52,3 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
|||||||
|
|
||||||
return &REST{store}, nil
|
return &REST{store}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "clusterrole"
|
|
||||||
}
|
|
||||||
|
@ -127,3 +127,9 @@ func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjec
|
|||||||
|
|
||||||
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo, createValidation, updateValidation, forceAllowCreate, options)
|
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo, createValidation, updateValidation, forceAllowCreate, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &Storage{}
|
||||||
|
|
||||||
|
func (s *Storage) GetSingularName() string {
|
||||||
|
return "clusterrolebinding"
|
||||||
|
}
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/rbac"
|
"k8s.io/kubernetes/pkg/apis/rbac"
|
||||||
"k8s.io/kubernetes/pkg/printers"
|
"k8s.io/kubernetes/pkg/printers"
|
||||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||||
@ -36,9 +35,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against ClusterRoleBinding objects.
|
// NewREST returns a RESTStorage object that will work against ClusterRoleBinding objects.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &rbac.ClusterRoleBinding{} },
|
NewFunc: func() runtime.Object { return &rbac.ClusterRoleBinding{} },
|
||||||
NewListFunc: func() runtime.Object { return &rbac.ClusterRoleBindingList{} },
|
NewListFunc: func() runtime.Object { return &rbac.ClusterRoleBindingList{} },
|
||||||
DefaultQualifiedResource: rbac.Resource("clusterrolebindings"),
|
DefaultQualifiedResource: rbac.Resource("clusterrolebindings"),
|
||||||
|
SingularQualifiedResource: rbac.Resource("clusterrolebinding"),
|
||||||
|
|
||||||
CreateStrategy: clusterrolebinding.Strategy,
|
CreateStrategy: clusterrolebinding.Strategy,
|
||||||
UpdateStrategy: clusterrolebinding.Strategy,
|
UpdateStrategy: clusterrolebinding.Strategy,
|
||||||
@ -53,10 +53,3 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
|||||||
|
|
||||||
return &REST{store}, nil
|
return &REST{store}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "clusterrolebinding"
|
|
||||||
}
|
|
||||||
|
@ -99,3 +99,9 @@ func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjec
|
|||||||
|
|
||||||
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo, createValidation, updateValidation, forceAllowCreate, options)
|
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo, createValidation, updateValidation, forceAllowCreate, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &Storage{}
|
||||||
|
|
||||||
|
func (s *Storage) GetSingularName() string {
|
||||||
|
return "role"
|
||||||
|
}
|
||||||
|
@ -33,9 +33,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against Role objects.
|
// NewREST returns a RESTStorage object that will work against Role objects.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &rbac.Role{} },
|
NewFunc: func() runtime.Object { return &rbac.Role{} },
|
||||||
NewListFunc: func() runtime.Object { return &rbac.RoleList{} },
|
NewListFunc: func() runtime.Object { return &rbac.RoleList{} },
|
||||||
DefaultQualifiedResource: rbac.Resource("roles"),
|
DefaultQualifiedResource: rbac.Resource("roles"),
|
||||||
|
SingularQualifiedResource: rbac.Resource("role"),
|
||||||
|
|
||||||
CreateStrategy: role.Strategy,
|
CreateStrategy: role.Strategy,
|
||||||
UpdateStrategy: role.Strategy,
|
UpdateStrategy: role.Strategy,
|
||||||
@ -51,10 +52,3 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
|||||||
|
|
||||||
return &REST{store}, nil
|
return &REST{store}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "role"
|
|
||||||
}
|
|
||||||
|
@ -142,3 +142,9 @@ func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjec
|
|||||||
|
|
||||||
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo, createValidation, updateValidation, forceAllowCreate, options)
|
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo, createValidation, updateValidation, forceAllowCreate, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &Storage{}
|
||||||
|
|
||||||
|
func (s *Storage) GetSingularName() string {
|
||||||
|
return "rolebinding"
|
||||||
|
}
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/rbac"
|
"k8s.io/kubernetes/pkg/apis/rbac"
|
||||||
"k8s.io/kubernetes/pkg/printers"
|
"k8s.io/kubernetes/pkg/printers"
|
||||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||||
@ -36,9 +35,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against RoleBinding objects.
|
// NewREST returns a RESTStorage object that will work against RoleBinding objects.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &rbac.RoleBinding{} },
|
NewFunc: func() runtime.Object { return &rbac.RoleBinding{} },
|
||||||
NewListFunc: func() runtime.Object { return &rbac.RoleBindingList{} },
|
NewListFunc: func() runtime.Object { return &rbac.RoleBindingList{} },
|
||||||
DefaultQualifiedResource: rbac.Resource("rolebindings"),
|
DefaultQualifiedResource: rbac.Resource("rolebindings"),
|
||||||
|
SingularQualifiedResource: rbac.Resource("rolebinding"),
|
||||||
|
|
||||||
CreateStrategy: rolebinding.Strategy,
|
CreateStrategy: rolebinding.Strategy,
|
||||||
UpdateStrategy: rolebinding.Strategy,
|
UpdateStrategy: rolebinding.Strategy,
|
||||||
@ -53,10 +53,3 @@ func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
|||||||
|
|
||||||
return &REST{store}, nil
|
return &REST{store}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "rolebinding"
|
|
||||||
}
|
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2014 The Kubernetes Authors.
|
|
||||||
|
|
||||||
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 registrytest
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
|
||||||
)
|
|
||||||
|
|
||||||
func AssertSingularName(t *testing.T, storage rest.SingularNameProvider, expected string) {
|
|
||||||
actual := storage.SingularName()
|
|
||||||
if actual != expected {
|
|
||||||
t.Errorf("singular name not equal. expected = %v actual = %v", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
@ -41,9 +41,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against priority classes.
|
// NewREST returns a RESTStorage object that will work against priority classes.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &scheduling.PriorityClass{} },
|
NewFunc: func() runtime.Object { return &scheduling.PriorityClass{} },
|
||||||
NewListFunc: func() runtime.Object { return &scheduling.PriorityClassList{} },
|
NewListFunc: func() runtime.Object { return &scheduling.PriorityClassList{} },
|
||||||
DefaultQualifiedResource: scheduling.Resource("priorityclasses"),
|
DefaultQualifiedResource: scheduling.Resource("priorityclasses"),
|
||||||
|
SingularQualifiedResource: scheduling.Resource("priorityclass"),
|
||||||
|
|
||||||
CreateStrategy: priorityclass.Strategy,
|
CreateStrategy: priorityclass.Strategy,
|
||||||
UpdateStrategy: priorityclass.Strategy,
|
UpdateStrategy: priorityclass.Strategy,
|
||||||
@ -67,13 +68,6 @@ func (r *REST) ShortNames() []string {
|
|||||||
return []string{"pc"}
|
return []string{"pc"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "priorityclass"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete ensures that system priority classes are not deleted.
|
// Delete ensures that system priority classes are not deleted.
|
||||||
func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
|
func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
|
||||||
for _, spc := range schedulingapiv1.SystemPriorityClasses() {
|
for _, spc := range schedulingapiv1.SystemPriorityClasses() {
|
||||||
|
@ -179,11 +179,3 @@ func TestShortNames(t *testing.T) {
|
|||||||
expected := []string{"pc"}
|
expected := []string{"pc"}
|
||||||
registrytest.AssertShortNames(t, storage, expected)
|
registrytest.AssertShortNames(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "priorityclass"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
@ -40,9 +40,10 @@ type REST struct {
|
|||||||
// NewStorage returns a RESTStorage object that will work against CSIDrivers
|
// NewStorage returns a RESTStorage object that will work against CSIDrivers
|
||||||
func NewStorage(optsGetter generic.RESTOptionsGetter) (*CSIDriverStorage, error) {
|
func NewStorage(optsGetter generic.RESTOptionsGetter) (*CSIDriverStorage, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &storageapi.CSIDriver{} },
|
NewFunc: func() runtime.Object { return &storageapi.CSIDriver{} },
|
||||||
NewListFunc: func() runtime.Object { return &storageapi.CSIDriverList{} },
|
NewListFunc: func() runtime.Object { return &storageapi.CSIDriverList{} },
|
||||||
DefaultQualifiedResource: storageapi.Resource("csidrivers"),
|
DefaultQualifiedResource: storageapi.Resource("csidrivers"),
|
||||||
|
SingularQualifiedResource: storageapi.Resource("csidriver"),
|
||||||
|
|
||||||
CreateStrategy: csidriver.Strategy,
|
CreateStrategy: csidriver.Strategy,
|
||||||
UpdateStrategy: csidriver.Strategy,
|
UpdateStrategy: csidriver.Strategy,
|
||||||
|
@ -40,9 +40,10 @@ type REST struct {
|
|||||||
// NewStorage returns a RESTStorage object that will work against CSINodes
|
// NewStorage returns a RESTStorage object that will work against CSINodes
|
||||||
func NewStorage(optsGetter generic.RESTOptionsGetter) (*CSINodeStorage, error) {
|
func NewStorage(optsGetter generic.RESTOptionsGetter) (*CSINodeStorage, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &storageapi.CSINode{} },
|
NewFunc: func() runtime.Object { return &storageapi.CSINode{} },
|
||||||
NewListFunc: func() runtime.Object { return &storageapi.CSINodeList{} },
|
NewListFunc: func() runtime.Object { return &storageapi.CSINodeList{} },
|
||||||
DefaultQualifiedResource: storageapi.Resource("csinodes"),
|
DefaultQualifiedResource: storageapi.Resource("csinodes"),
|
||||||
|
SingularQualifiedResource: storageapi.Resource("csinode"),
|
||||||
|
|
||||||
CreateStrategy: csinode.Strategy,
|
CreateStrategy: csinode.Strategy,
|
||||||
UpdateStrategy: csinode.Strategy,
|
UpdateStrategy: csinode.Strategy,
|
||||||
|
@ -38,9 +38,10 @@ type REST struct {
|
|||||||
// NewStorage returns a RESTStorage object that will work against CSIStorageCapacity
|
// NewStorage returns a RESTStorage object that will work against CSIStorageCapacity
|
||||||
func NewStorage(optsGetter generic.RESTOptionsGetter) (*CSIStorageCapacityStorage, error) {
|
func NewStorage(optsGetter generic.RESTOptionsGetter) (*CSIStorageCapacityStorage, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &storageapi.CSIStorageCapacity{} },
|
NewFunc: func() runtime.Object { return &storageapi.CSIStorageCapacity{} },
|
||||||
NewListFunc: func() runtime.Object { return &storageapi.CSIStorageCapacityList{} },
|
NewListFunc: func() runtime.Object { return &storageapi.CSIStorageCapacityList{} },
|
||||||
DefaultQualifiedResource: storageapi.Resource("csistoragecapacities"),
|
DefaultQualifiedResource: storageapi.Resource("csistoragecapacities"),
|
||||||
|
SingularQualifiedResource: storageapi.Resource("csistoragecapacity"),
|
||||||
|
|
||||||
TableConvertor: rest.NewDefaultTableConvertor(storageapi.Resource("csistoragecapacities")),
|
TableConvertor: rest.NewDefaultTableConvertor(storageapi.Resource("csistoragecapacities")),
|
||||||
|
|
||||||
|
@ -36,9 +36,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against storage classes.
|
// NewREST returns a RESTStorage object that will work against storage classes.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &storageapi.StorageClass{} },
|
NewFunc: func() runtime.Object { return &storageapi.StorageClass{} },
|
||||||
NewListFunc: func() runtime.Object { return &storageapi.StorageClassList{} },
|
NewListFunc: func() runtime.Object { return &storageapi.StorageClassList{} },
|
||||||
DefaultQualifiedResource: storageapi.Resource("storageclasses"),
|
DefaultQualifiedResource: storageapi.Resource("storageclasses"),
|
||||||
|
SingularQualifiedResource: storageapi.Resource("storageclass"),
|
||||||
|
|
||||||
CreateStrategy: storageclass.Strategy,
|
CreateStrategy: storageclass.Strategy,
|
||||||
UpdateStrategy: storageclass.Strategy,
|
UpdateStrategy: storageclass.Strategy,
|
||||||
@ -62,10 +63,3 @@ var _ rest.ShortNamesProvider = &REST{}
|
|||||||
func (r *REST) ShortNames() []string {
|
func (r *REST) ShortNames() []string {
|
||||||
return []string{"sc"}
|
return []string{"sc"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "storageclass"
|
|
||||||
}
|
|
||||||
|
@ -160,11 +160,3 @@ func TestShortNames(t *testing.T) {
|
|||||||
expected := []string{"sc"}
|
expected := []string{"sc"}
|
||||||
registrytest.AssertShortNames(t, storage, expected)
|
registrytest.AssertShortNames(t, storage, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "storageclass"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
@ -46,9 +46,10 @@ type REST struct {
|
|||||||
// NewStorage returns a RESTStorage object that will work against VolumeAttachments
|
// NewStorage returns a RESTStorage object that will work against VolumeAttachments
|
||||||
func NewStorage(optsGetter generic.RESTOptionsGetter) (*VolumeAttachmentStorage, error) {
|
func NewStorage(optsGetter generic.RESTOptionsGetter) (*VolumeAttachmentStorage, error) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &storageapi.VolumeAttachment{} },
|
NewFunc: func() runtime.Object { return &storageapi.VolumeAttachment{} },
|
||||||
NewListFunc: func() runtime.Object { return &storageapi.VolumeAttachmentList{} },
|
NewListFunc: func() runtime.Object { return &storageapi.VolumeAttachmentList{} },
|
||||||
DefaultQualifiedResource: storageapi.Resource("volumeattachments"),
|
DefaultQualifiedResource: storageapi.Resource("volumeattachments"),
|
||||||
|
SingularQualifiedResource: storageapi.Resource("volumeattachment"),
|
||||||
|
|
||||||
CreateStrategy: volumeattachment.Strategy,
|
CreateStrategy: volumeattachment.Strategy,
|
||||||
UpdateStrategy: volumeattachment.Strategy,
|
UpdateStrategy: volumeattachment.Strategy,
|
||||||
@ -73,13 +74,6 @@ func NewStorage(optsGetter generic.RESTOptionsGetter) (*VolumeAttachmentStorage,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "volumeattachment"
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusREST implements the REST endpoint for changing the status of a VolumeAttachment
|
// StatusREST implements the REST endpoint for changing the status of a VolumeAttachment
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
@ -118,3 +112,9 @@ func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
func (r *StatusREST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
|
||||||
return r.store.ConvertToTable(ctx, object, tableOptions)
|
return r.store.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -200,11 +200,3 @@ func TestEtcdStatusUpdate(t *testing.T) {
|
|||||||
t.Errorf("objects differ: %v", diff.ObjectDiff(attachmentOut.Status, attachmentIn.Status))
|
t.Errorf("objects differ: %v", diff.ObjectDiff(attachmentOut.Status, attachmentIn.Status))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingularName(t *testing.T) {
|
|
||||||
storage, _, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
expected := "volumeattachment"
|
|
||||||
registrytest.AssertSingularName(t, storage, expected)
|
|
||||||
}
|
|
||||||
|
@ -728,6 +728,7 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
|
|||||||
parameterCodec := runtime.NewParameterCodec(parameterScheme)
|
parameterCodec := runtime.NewParameterCodec(parameterScheme)
|
||||||
|
|
||||||
resource := schema.GroupVersionResource{Group: crd.Spec.Group, Version: v.Name, Resource: crd.Status.AcceptedNames.Plural}
|
resource := schema.GroupVersionResource{Group: crd.Spec.Group, Version: v.Name, Resource: crd.Status.AcceptedNames.Plural}
|
||||||
|
singularResource := schema.GroupVersionResource{Group: crd.Spec.Group, Version: v.Name, Resource: crd.Status.AcceptedNames.Singular}
|
||||||
kind := schema.GroupVersionKind{Group: crd.Spec.Group, Version: v.Name, Kind: crd.Status.AcceptedNames.Kind}
|
kind := schema.GroupVersionKind{Group: crd.Spec.Group, Version: v.Name, Kind: crd.Status.AcceptedNames.Kind}
|
||||||
equivalentResourceRegistry.RegisterKindFor(resource, "", kind)
|
equivalentResourceRegistry.RegisterKindFor(resource, "", kind)
|
||||||
|
|
||||||
@ -797,6 +798,7 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
|
|||||||
|
|
||||||
storages[v.Name] = customresource.NewStorage(
|
storages[v.Name] = customresource.NewStorage(
|
||||||
resource.GroupResource(),
|
resource.GroupResource(),
|
||||||
|
singularResource.GroupResource(),
|
||||||
kind,
|
kind,
|
||||||
schema.GroupVersionKind{Group: crd.Spec.Group, Version: v.Name, Kind: crd.Status.AcceptedNames.ListKind},
|
schema.GroupVersionKind{Group: crd.Spec.Group, Version: v.Name, Kind: crd.Status.AcceptedNames.ListKind},
|
||||||
customresource.NewStrategy(
|
customresource.NewStrategy(
|
||||||
|
@ -41,7 +41,7 @@ type CustomResourceStorage struct {
|
|||||||
Scale *ScaleREST
|
Scale *ScaleREST
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStorage(resource schema.GroupResource, kind, listKind schema.GroupVersionKind, strategy customResourceStrategy, optsGetter generic.RESTOptionsGetter, categories []string, tableConvertor rest.TableConvertor, replicasPathMapping fieldmanager.ResourcePathMappings) CustomResourceStorage {
|
func NewStorage(resource schema.GroupResource, singularResource schema.GroupResource, kind, listKind schema.GroupVersionKind, strategy customResourceStrategy, optsGetter generic.RESTOptionsGetter, categories []string, tableConvertor rest.TableConvertor, replicasPathMapping fieldmanager.ResourcePathMappings) CustomResourceStorage {
|
||||||
var storage CustomResourceStorage
|
var storage CustomResourceStorage
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object {
|
NewFunc: func() runtime.Object {
|
||||||
@ -56,8 +56,9 @@ func NewStorage(resource schema.GroupResource, kind, listKind schema.GroupVersio
|
|||||||
ret.SetGroupVersionKind(listKind)
|
ret.SetGroupVersionKind(listKind)
|
||||||
return ret
|
return ret
|
||||||
},
|
},
|
||||||
PredicateFunc: strategy.MatchCustomResourceDefinitionStorage,
|
PredicateFunc: strategy.MatchCustomResourceDefinitionStorage,
|
||||||
DefaultQualifiedResource: resource,
|
DefaultQualifiedResource: resource,
|
||||||
|
SingularQualifiedResource: singularResource,
|
||||||
|
|
||||||
CreateStrategy: strategy,
|
CreateStrategy: strategy,
|
||||||
UpdateStrategy: strategy,
|
UpdateStrategy: strategy,
|
||||||
|
@ -93,6 +93,7 @@ func newStorage(t *testing.T) (customresource.CustomResourceStorage, *etcd3testi
|
|||||||
table, _ := tableconvertor.New(headers)
|
table, _ := tableconvertor.New(headers)
|
||||||
|
|
||||||
storage := customresource.NewStorage(
|
storage := customresource.NewStorage(
|
||||||
|
groupResource,
|
||||||
groupResource,
|
groupResource,
|
||||||
kind,
|
kind,
|
||||||
schema.GroupVersionKind{Group: "mygroup.example.com", Version: "v1beta1", Kind: "NoxuItemList"},
|
schema.GroupVersionKind{Group: "mygroup.example.com", Version: "v1beta1", Kind: "NoxuItemList"},
|
||||||
|
@ -43,10 +43,11 @@ func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (*RES
|
|||||||
strategy := NewStrategy(scheme)
|
strategy := NewStrategy(scheme)
|
||||||
|
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &apiextensions.CustomResourceDefinition{} },
|
NewFunc: func() runtime.Object { return &apiextensions.CustomResourceDefinition{} },
|
||||||
NewListFunc: func() runtime.Object { return &apiextensions.CustomResourceDefinitionList{} },
|
NewListFunc: func() runtime.Object { return &apiextensions.CustomResourceDefinitionList{} },
|
||||||
PredicateFunc: MatchCustomResourceDefinition,
|
PredicateFunc: MatchCustomResourceDefinition,
|
||||||
DefaultQualifiedResource: apiextensions.Resource("customresourcedefinitions"),
|
DefaultQualifiedResource: apiextensions.Resource("customresourcedefinitions"),
|
||||||
|
SingularQualifiedResource: apiextensions.Resource("customresourcedefinition"),
|
||||||
|
|
||||||
CreateStrategy: strategy,
|
CreateStrategy: strategy,
|
||||||
UpdateStrategy: strategy,
|
UpdateStrategy: strategy,
|
||||||
@ -79,13 +80,6 @@ func (r *REST) Categories() []string {
|
|||||||
return []string{"api-extensions"}
|
return []string{"api-extensions"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ rest.SingularNameProvider = &REST{}
|
|
||||||
|
|
||||||
// SingularName implements the SingularNameProvider interfaces. This returns singular name of core resource.
|
|
||||||
func (r *REST) SingularName() string {
|
|
||||||
return "customresourcedefinition"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete adds the CRD finalizer to the list
|
// Delete adds the CRD finalizer to the list
|
||||||
func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
|
func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
|
||||||
obj, err := r.Get(ctx, name, &metav1.GetOptions{})
|
obj, err := r.Get(ctx, name, &metav1.GetOptions{})
|
||||||
@ -224,3 +218,9 @@ func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.Updat
|
|||||||
func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
||||||
return r.store.GetResetFields()
|
return r.store.GetResetFields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &StatusREST{}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
@ -372,6 +372,10 @@ func (storage *SimpleRESTStorage) ConvertToTable(ctx context.Context, obj runtim
|
|||||||
return rest.NewDefaultTableConvertor(schema.GroupResource{Resource: "simple"}).ConvertToTable(ctx, obj, tableOptions)
|
return rest.NewDefaultTableConvertor(schema.GroupResource{Resource: "simple"}).ConvertToTable(ctx, obj, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (storate *SimpleRESTStorage) GetSingularName() string {
|
||||||
|
return "simple"
|
||||||
|
}
|
||||||
|
|
||||||
func (storage *SimpleRESTStorage) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
|
func (storage *SimpleRESTStorage) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
|
||||||
storage.checkContext(ctx)
|
storage.checkContext(ctx)
|
||||||
result := &genericapitesting.SimpleList{
|
result := &genericapitesting.SimpleList{
|
||||||
@ -575,6 +579,10 @@ func (s *ConnecterRESTStorage) NewConnectOptions() (runtime.Object, bool, string
|
|||||||
return s.emptyConnectOptions, false, ""
|
return s.emptyConnectOptions, false, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ConnecterRESTStorage) GetSingularName() string {
|
||||||
|
return "simple"
|
||||||
|
}
|
||||||
|
|
||||||
type MetadataRESTStorage struct {
|
type MetadataRESTStorage struct {
|
||||||
*SimpleRESTStorage
|
*SimpleRESTStorage
|
||||||
types []string
|
types []string
|
||||||
@ -619,6 +627,10 @@ type GetWithOptionsRootRESTStorage struct {
|
|||||||
takesPath string
|
takesPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *GetWithOptionsRootRESTStorage) GetSingularName() string {
|
||||||
|
return "simple"
|
||||||
|
}
|
||||||
|
|
||||||
func (r *GetWithOptionsRootRESTStorage) NamespaceScoped() bool {
|
func (r *GetWithOptionsRootRESTStorage) NamespaceScoped() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -687,6 +699,10 @@ func (storage *SimpleTypedStorage) checkContext(ctx context.Context) {
|
|||||||
storage.actualNamespace, storage.namespacePresent = request.NamespaceFrom(ctx)
|
storage.actualNamespace, storage.namespacePresent = request.NamespaceFrom(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (storage *SimpleTypedStorage) GetSingularName() string {
|
||||||
|
return "simple"
|
||||||
|
}
|
||||||
|
|
||||||
func bodyOrDie(response *http.Response) string {
|
func bodyOrDie(response *http.Response) string {
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
body, err := ioutil.ReadAll(response.Body)
|
body, err := ioutil.ReadAll(response.Body)
|
||||||
@ -823,6 +839,10 @@ func (UnimplementedRESTStorage) New() runtime.Object {
|
|||||||
func (UnimplementedRESTStorage) Destroy() {
|
func (UnimplementedRESTStorage) Destroy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (UnimplementedRESTStorage) GetSingularName() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// TestUnimplementedRESTStorage ensures that if a rest.Storage does not implement a given
|
// TestUnimplementedRESTStorage ensures that if a rest.Storage does not implement a given
|
||||||
// method, that it is literally not registered with the server. In the past,
|
// method, that it is literally not registered with the server. In the past,
|
||||||
// we registered everything, and returned method not supported if it didn't support
|
// we registered everything, and returned method not supported if it didn't support
|
||||||
@ -4289,6 +4309,10 @@ func (storage *SimpleXGSubresourceRESTStorage) GroupVersionKind(containingGV sch
|
|||||||
return storage.itemGVK
|
return storage.itemGVK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (storage *SimpleXGSubresourceRESTStorage) GetSingularName() string {
|
||||||
|
return "simple"
|
||||||
|
}
|
||||||
|
|
||||||
func TestXGSubresource(t *testing.T) {
|
func TestXGSubresource(t *testing.T) {
|
||||||
container := restful.NewContainer()
|
container := restful.NewContainer()
|
||||||
container.Router(restful.CurlyRouter{})
|
container.Router(restful.CurlyRouter{})
|
||||||
|
@ -1080,9 +1080,12 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
|||||||
if categoriesProvider, ok := storage.(rest.CategoriesProvider); ok {
|
if categoriesProvider, ok := storage.(rest.CategoriesProvider); ok {
|
||||||
apiResource.Categories = categoriesProvider.Categories()
|
apiResource.Categories = categoriesProvider.Categories()
|
||||||
}
|
}
|
||||||
if singularNameProvider, ok := storage.(rest.SingularNameProvider); ok {
|
singularNameProvider, ok := storage.(rest.SingularNameProvider)
|
||||||
apiResource.SingularName = singularNameProvider.SingularName()
|
if !ok {
|
||||||
|
return nil, nil, fmt.Errorf("resource %s must implement SingularNameProvider", resource)
|
||||||
}
|
}
|
||||||
|
apiResource.SingularName = singularNameProvider.GetSingularName()
|
||||||
|
|
||||||
if gvkProvider, ok := storage.(rest.GroupVersionKindProvider); ok {
|
if gvkProvider, ok := storage.(rest.GroupVersionKindProvider); ok {
|
||||||
gvk := gvkProvider.GroupVersionKind(a.group.GroupVersion)
|
gvk := gvkProvider.GroupVersionKind(a.group.GroupVersion)
|
||||||
apiResource.Group = gvk.Group
|
apiResource.Group = gvk.Group
|
||||||
|
@ -110,6 +110,9 @@ type Store struct {
|
|||||||
// See qualifiedResourceFromContext for details.
|
// See qualifiedResourceFromContext for details.
|
||||||
DefaultQualifiedResource schema.GroupResource
|
DefaultQualifiedResource schema.GroupResource
|
||||||
|
|
||||||
|
// SingularQualifiedResource is the singular name of the resource.
|
||||||
|
SingularQualifiedResource schema.GroupResource
|
||||||
|
|
||||||
// KeyRootFunc returns the root etcd key for this resource; should not
|
// KeyRootFunc returns the root etcd key for this resource; should not
|
||||||
// include trailing "/". This is used for operations that work on the
|
// include trailing "/". This is used for operations that work on the
|
||||||
// entire collection (listing and watching).
|
// entire collection (listing and watching).
|
||||||
@ -229,6 +232,8 @@ var _ rest.StandardStorage = &Store{}
|
|||||||
var _ rest.TableConvertor = &Store{}
|
var _ rest.TableConvertor = &Store{}
|
||||||
var _ GenericStore = &Store{}
|
var _ GenericStore = &Store{}
|
||||||
|
|
||||||
|
var _ rest.SingularNameProvider = &Store{}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
OptimisticLockErrorMsg = "the object has been modified; please apply your changes to the latest version and try again"
|
OptimisticLockErrorMsg = "the object has been modified; please apply your changes to the latest version and try again"
|
||||||
resourceCountPollPeriodJitter = 1.2
|
resourceCountPollPeriodJitter = 1.2
|
||||||
@ -1320,6 +1325,12 @@ func (e *Store) CompleteWithOptions(options *generic.StoreOptions) error {
|
|||||||
if e.DefaultQualifiedResource.Empty() {
|
if e.DefaultQualifiedResource.Empty() {
|
||||||
return fmt.Errorf("store %#v must have a non-empty qualified resource", e)
|
return fmt.Errorf("store %#v must have a non-empty qualified resource", e)
|
||||||
}
|
}
|
||||||
|
if e.SingularQualifiedResource.Empty() {
|
||||||
|
return fmt.Errorf("store %#v must have a non-empty singular qualified resource", e)
|
||||||
|
}
|
||||||
|
if e.DefaultQualifiedResource.Group != e.SingularQualifiedResource.Group {
|
||||||
|
return fmt.Errorf("store for %#v, singular and plural qualified resource's group name's must match", e)
|
||||||
|
}
|
||||||
if e.NewFunc == nil {
|
if e.NewFunc == nil {
|
||||||
return fmt.Errorf("store for %s must have NewFunc set", e.DefaultQualifiedResource.String())
|
return fmt.Errorf("store for %s must have NewFunc set", e.DefaultQualifiedResource.String())
|
||||||
}
|
}
|
||||||
@ -1515,6 +1526,10 @@ func (e *Store) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
|||||||
return e.ResetFieldsStrategy.GetResetFields()
|
return e.ResetFieldsStrategy.GetResetFields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *Store) GetSingularName() string {
|
||||||
|
return e.SingularQualifiedResource.Resource
|
||||||
|
}
|
||||||
|
|
||||||
// validateIndexers will check the prefix of indexers.
|
// validateIndexers will check the prefix of indexers.
|
||||||
func validateIndexers(indexers *cache.Indexers) error {
|
func validateIndexers(indexers *cache.Indexers) error {
|
||||||
if indexers == nil {
|
if indexers == nil {
|
||||||
|
@ -2339,12 +2339,13 @@ func newTestGenericStoreRegistry(t *testing.T, scheme *runtime.Scheme, hasCacheE
|
|||||||
}
|
}
|
||||||
|
|
||||||
return destroyFunc, &Store{
|
return destroyFunc, &Store{
|
||||||
NewFunc: func() runtime.Object { return &example.Pod{} },
|
NewFunc: func() runtime.Object { return &example.Pod{} },
|
||||||
NewListFunc: func() runtime.Object { return &example.PodList{} },
|
NewListFunc: func() runtime.Object { return &example.PodList{} },
|
||||||
DefaultQualifiedResource: example.Resource("pods"),
|
DefaultQualifiedResource: example.Resource("pods"),
|
||||||
CreateStrategy: strategy,
|
SingularQualifiedResource: example.Resource("pod"),
|
||||||
UpdateStrategy: strategy,
|
CreateStrategy: strategy,
|
||||||
DeleteStrategy: strategy,
|
UpdateStrategy: strategy,
|
||||||
|
DeleteStrategy: strategy,
|
||||||
KeyRootFunc: func(ctx context.Context) string {
|
KeyRootFunc: func(ctx context.Context) string {
|
||||||
return podPrefix
|
return podPrefix
|
||||||
},
|
},
|
||||||
|
@ -92,7 +92,7 @@ type CategoriesProvider interface {
|
|||||||
// SingularNameProvider returns singular name of resources. This is used by kubectl discovery to have singular
|
// SingularNameProvider returns singular name of resources. This is used by kubectl discovery to have singular
|
||||||
// name representation of resources. In case of shortcut conflicts(with CRD shortcuts) singular name should always map to this resource.
|
// name representation of resources. In case of shortcut conflicts(with CRD shortcuts) singular name should always map to this resource.
|
||||||
type SingularNameProvider interface {
|
type SingularNameProvider interface {
|
||||||
SingularName() string
|
GetSingularName() string
|
||||||
}
|
}
|
||||||
|
|
||||||
// GroupVersionKindProvider is used to specify a particular GroupVersionKind to discovery. This is used for polymorphic endpoints
|
// GroupVersionKindProvider is used to specify a particular GroupVersionKind to discovery. This is used for polymorphic endpoints
|
||||||
|
@ -551,6 +551,10 @@ func (p *testGetterStorage) Get(ctx context.Context, name string, options *metav
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *testGetterStorage) GetSingularName() string {
|
||||||
|
return "getter"
|
||||||
|
}
|
||||||
|
|
||||||
type testNoVerbsStorage struct {
|
type testNoVerbsStorage struct {
|
||||||
Version string
|
Version string
|
||||||
}
|
}
|
||||||
@ -571,6 +575,10 @@ func (p *testNoVerbsStorage) New() runtime.Object {
|
|||||||
func (p *testNoVerbsStorage) Destroy() {
|
func (p *testNoVerbsStorage) Destroy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *testNoVerbsStorage) GetSingularName() string {
|
||||||
|
return "noverb"
|
||||||
|
}
|
||||||
|
|
||||||
func fakeVersion() version.Info {
|
func fakeVersion() version.Info {
|
||||||
return version.Info{
|
return version.Info{
|
||||||
Major: "42",
|
Major: "42",
|
||||||
|
@ -41,10 +41,11 @@ type REST struct {
|
|||||||
func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) *REST {
|
func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) *REST {
|
||||||
strategy := apiservice.NewStrategy(scheme)
|
strategy := apiservice.NewStrategy(scheme)
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &apiregistration.APIService{} },
|
NewFunc: func() runtime.Object { return &apiregistration.APIService{} },
|
||||||
NewListFunc: func() runtime.Object { return &apiregistration.APIServiceList{} },
|
NewListFunc: func() runtime.Object { return &apiregistration.APIServiceList{} },
|
||||||
PredicateFunc: apiservice.MatchAPIService,
|
PredicateFunc: apiservice.MatchAPIService,
|
||||||
DefaultQualifiedResource: apiregistration.Resource("apiservices"),
|
DefaultQualifiedResource: apiregistration.Resource("apiservices"),
|
||||||
|
SingularQualifiedResource: apiregistration.Resource("apiservice"),
|
||||||
|
|
||||||
CreateStrategy: strategy,
|
CreateStrategy: strategy,
|
||||||
UpdateStrategy: strategy,
|
UpdateStrategy: strategy,
|
||||||
@ -169,3 +170,7 @@ func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.Updat
|
|||||||
func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
func (r *StatusREST) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
||||||
return r.store.GetResetFields()
|
return r.store.GetResetFields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *StatusREST) GetSingularName() string {
|
||||||
|
return r.store.GetSingularName()
|
||||||
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user