Commit 54fd2aae authored by Mike Danese's avatar Mike Danese

replace request.Context with context.Context

parent a0f94123
...@@ -13,7 +13,6 @@ go_library( ...@@ -13,7 +13,6 @@ go_library(
"//pkg/printers:go_default_library", "//pkg/printers:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
], ],
) )
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package storage package storage
import ( import (
"context"
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/kubernetes/pkg/printers" "k8s.io/kubernetes/pkg/printers"
) )
...@@ -27,6 +28,6 @@ type TableConvertor struct { ...@@ -27,6 +28,6 @@ type TableConvertor struct {
printers.TablePrinter printers.TablePrinter
} }
func (c TableConvertor) ConvertToTable(ctx genericapirequest.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) { func (c TableConvertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
return c.TablePrinter.PrintTable(obj, printers.PrintOptions{Wide: true}) return c.TablePrinter.PrintTable(obj, printers.PrintOptions{Wide: true})
} }
...@@ -18,7 +18,6 @@ go_library( ...@@ -18,7 +18,6 @@ go_library(
"//pkg/apis/admissionregistration/validation:go_default_library", "//pkg/apis/admissionregistration/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
) )
......
...@@ -17,11 +17,11 @@ limitations under the License. ...@@ -17,11 +17,11 @@ limitations under the License.
package initializerconfiguration package initializerconfiguration
import ( import (
"context"
"reflect" "reflect"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/admissionregistration" "k8s.io/kubernetes/pkg/apis/admissionregistration"
...@@ -43,13 +43,13 @@ func (initializerConfigurationStrategy) NamespaceScoped() bool { ...@@ -43,13 +43,13 @@ func (initializerConfigurationStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of an InitializerConfiguration before creation. // PrepareForCreate clears the status of an InitializerConfiguration before creation.
func (initializerConfigurationStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (initializerConfigurationStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
ic := obj.(*admissionregistration.InitializerConfiguration) ic := obj.(*admissionregistration.InitializerConfiguration)
ic.Generation = 1 ic.Generation = 1
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (initializerConfigurationStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (initializerConfigurationStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newIC := obj.(*admissionregistration.InitializerConfiguration) newIC := obj.(*admissionregistration.InitializerConfiguration)
oldIC := old.(*admissionregistration.InitializerConfiguration) oldIC := old.(*admissionregistration.InitializerConfiguration)
...@@ -62,7 +62,7 @@ func (initializerConfigurationStrategy) PrepareForUpdate(ctx genericapirequest.C ...@@ -62,7 +62,7 @@ func (initializerConfigurationStrategy) PrepareForUpdate(ctx genericapirequest.C
} }
// Validate validates a new InitializerConfiguration. // Validate validates a new InitializerConfiguration.
func (initializerConfigurationStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (initializerConfigurationStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
ic := obj.(*admissionregistration.InitializerConfiguration) ic := obj.(*admissionregistration.InitializerConfiguration)
return validation.ValidateInitializerConfiguration(ic) return validation.ValidateInitializerConfiguration(ic)
} }
...@@ -77,7 +77,7 @@ func (initializerConfigurationStrategy) AllowCreateOnUpdate() bool { ...@@ -77,7 +77,7 @@ func (initializerConfigurationStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (initializerConfigurationStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (initializerConfigurationStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
validationErrorList := validation.ValidateInitializerConfiguration(obj.(*admissionregistration.InitializerConfiguration)) validationErrorList := validation.ValidateInitializerConfiguration(obj.(*admissionregistration.InitializerConfiguration))
updateErrorList := validation.ValidateInitializerConfigurationUpdate(obj.(*admissionregistration.InitializerConfiguration), old.(*admissionregistration.InitializerConfiguration)) updateErrorList := validation.ValidateInitializerConfigurationUpdate(obj.(*admissionregistration.InitializerConfiguration), old.(*admissionregistration.InitializerConfiguration))
return append(validationErrorList, updateErrorList...) return append(validationErrorList, updateErrorList...)
......
...@@ -18,7 +18,6 @@ go_library( ...@@ -18,7 +18,6 @@ go_library(
"//pkg/apis/admissionregistration/validation:go_default_library", "//pkg/apis/admissionregistration/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
) )
......
...@@ -17,11 +17,11 @@ limitations under the License. ...@@ -17,11 +17,11 @@ limitations under the License.
package mutatingwebhookconfiguration package mutatingwebhookconfiguration
import ( import (
"context"
"reflect" "reflect"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/admissionregistration" "k8s.io/kubernetes/pkg/apis/admissionregistration"
...@@ -43,13 +43,13 @@ func (mutatingWebhookConfigurationStrategy) NamespaceScoped() bool { ...@@ -43,13 +43,13 @@ func (mutatingWebhookConfigurationStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of an mutatingWebhookConfiguration before creation. // PrepareForCreate clears the status of an mutatingWebhookConfiguration before creation.
func (mutatingWebhookConfigurationStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (mutatingWebhookConfigurationStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
ic := obj.(*admissionregistration.MutatingWebhookConfiguration) ic := obj.(*admissionregistration.MutatingWebhookConfiguration)
ic.Generation = 1 ic.Generation = 1
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (mutatingWebhookConfigurationStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (mutatingWebhookConfigurationStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newIC := obj.(*admissionregistration.MutatingWebhookConfiguration) newIC := obj.(*admissionregistration.MutatingWebhookConfiguration)
oldIC := old.(*admissionregistration.MutatingWebhookConfiguration) oldIC := old.(*admissionregistration.MutatingWebhookConfiguration)
...@@ -62,7 +62,7 @@ func (mutatingWebhookConfigurationStrategy) PrepareForUpdate(ctx genericapireque ...@@ -62,7 +62,7 @@ func (mutatingWebhookConfigurationStrategy) PrepareForUpdate(ctx genericapireque
} }
// Validate validates a new mutatingWebhookConfiguration. // Validate validates a new mutatingWebhookConfiguration.
func (mutatingWebhookConfigurationStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (mutatingWebhookConfigurationStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
ic := obj.(*admissionregistration.MutatingWebhookConfiguration) ic := obj.(*admissionregistration.MutatingWebhookConfiguration)
return validation.ValidateMutatingWebhookConfiguration(ic) return validation.ValidateMutatingWebhookConfiguration(ic)
} }
...@@ -77,7 +77,7 @@ func (mutatingWebhookConfigurationStrategy) AllowCreateOnUpdate() bool { ...@@ -77,7 +77,7 @@ func (mutatingWebhookConfigurationStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (mutatingWebhookConfigurationStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (mutatingWebhookConfigurationStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
validationErrorList := validation.ValidateMutatingWebhookConfiguration(obj.(*admissionregistration.MutatingWebhookConfiguration)) validationErrorList := validation.ValidateMutatingWebhookConfiguration(obj.(*admissionregistration.MutatingWebhookConfiguration))
updateErrorList := validation.ValidateMutatingWebhookConfigurationUpdate(obj.(*admissionregistration.MutatingWebhookConfiguration), old.(*admissionregistration.MutatingWebhookConfiguration)) updateErrorList := validation.ValidateMutatingWebhookConfigurationUpdate(obj.(*admissionregistration.MutatingWebhookConfiguration), old.(*admissionregistration.MutatingWebhookConfiguration))
return append(validationErrorList, updateErrorList...) return append(validationErrorList, updateErrorList...)
......
...@@ -18,7 +18,6 @@ go_library( ...@@ -18,7 +18,6 @@ go_library(
"//pkg/apis/admissionregistration/validation:go_default_library", "//pkg/apis/admissionregistration/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
) )
......
...@@ -17,11 +17,11 @@ limitations under the License. ...@@ -17,11 +17,11 @@ limitations under the License.
package validatingwebhookconfiguration package validatingwebhookconfiguration
import ( import (
"context"
"reflect" "reflect"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/admissionregistration" "k8s.io/kubernetes/pkg/apis/admissionregistration"
...@@ -43,13 +43,13 @@ func (validatingWebhookConfigurationStrategy) NamespaceScoped() bool { ...@@ -43,13 +43,13 @@ func (validatingWebhookConfigurationStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of an validatingWebhookConfiguration before creation. // PrepareForCreate clears the status of an validatingWebhookConfiguration before creation.
func (validatingWebhookConfigurationStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (validatingWebhookConfigurationStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
ic := obj.(*admissionregistration.ValidatingWebhookConfiguration) ic := obj.(*admissionregistration.ValidatingWebhookConfiguration)
ic.Generation = 1 ic.Generation = 1
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (validatingWebhookConfigurationStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (validatingWebhookConfigurationStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newIC := obj.(*admissionregistration.ValidatingWebhookConfiguration) newIC := obj.(*admissionregistration.ValidatingWebhookConfiguration)
oldIC := old.(*admissionregistration.ValidatingWebhookConfiguration) oldIC := old.(*admissionregistration.ValidatingWebhookConfiguration)
...@@ -62,7 +62,7 @@ func (validatingWebhookConfigurationStrategy) PrepareForUpdate(ctx genericapireq ...@@ -62,7 +62,7 @@ func (validatingWebhookConfigurationStrategy) PrepareForUpdate(ctx genericapireq
} }
// Validate validates a new validatingWebhookConfiguration. // Validate validates a new validatingWebhookConfiguration.
func (validatingWebhookConfigurationStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (validatingWebhookConfigurationStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
ic := obj.(*admissionregistration.ValidatingWebhookConfiguration) ic := obj.(*admissionregistration.ValidatingWebhookConfiguration)
return validation.ValidateValidatingWebhookConfiguration(ic) return validation.ValidateValidatingWebhookConfiguration(ic)
} }
...@@ -77,7 +77,7 @@ func (validatingWebhookConfigurationStrategy) AllowCreateOnUpdate() bool { ...@@ -77,7 +77,7 @@ func (validatingWebhookConfigurationStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (validatingWebhookConfigurationStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (validatingWebhookConfigurationStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
validationErrorList := validation.ValidateValidatingWebhookConfiguration(obj.(*admissionregistration.ValidatingWebhookConfiguration)) validationErrorList := validation.ValidateValidatingWebhookConfiguration(obj.(*admissionregistration.ValidatingWebhookConfiguration))
updateErrorList := validation.ValidateValidatingWebhookConfigurationUpdate(obj.(*admissionregistration.ValidatingWebhookConfiguration), old.(*admissionregistration.ValidatingWebhookConfiguration)) updateErrorList := validation.ValidateValidatingWebhookConfigurationUpdate(obj.(*admissionregistration.ValidatingWebhookConfiguration), old.(*admissionregistration.ValidatingWebhookConfiguration))
return append(validationErrorList, updateErrorList...) return append(validationErrorList, updateErrorList...)
......
...@@ -32,7 +32,6 @@ go_library( ...@@ -32,7 +32,6 @@ go_library(
"//pkg/apis/apps/validation:go_default_library", "//pkg/apis/apps/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package controllerrevision package controllerrevision
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
...@@ -54,17 +55,17 @@ func (strategy) AllowCreateOnUpdate() bool { ...@@ -54,17 +55,17 @@ func (strategy) AllowCreateOnUpdate() bool {
return false return false
} }
func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
_ = obj.(*apps.ControllerRevision) _ = obj.(*apps.ControllerRevision)
} }
func (strategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
revision := obj.(*apps.ControllerRevision) revision := obj.(*apps.ControllerRevision)
return validation.ValidateControllerRevision(revision) return validation.ValidateControllerRevision(revision)
} }
func (strategy) PrepareForUpdate(ctx genericapirequest.Context, newObj, oldObj runtime.Object) { func (strategy) PrepareForUpdate(ctx context.Context, newObj, oldObj runtime.Object) {
_ = oldObj.(*apps.ControllerRevision) _ = oldObj.(*apps.ControllerRevision)
_ = newObj.(*apps.ControllerRevision) _ = newObj.(*apps.ControllerRevision)
} }
...@@ -73,7 +74,7 @@ func (strategy) AllowUnconditionalUpdate() bool { ...@@ -73,7 +74,7 @@ func (strategy) AllowUnconditionalUpdate() bool {
return true return true
} }
func (strategy) ValidateUpdate(ctx genericapirequest.Context, newObj, oldObj runtime.Object) field.ErrorList { func (strategy) ValidateUpdate(ctx context.Context, newObj, oldObj runtime.Object) field.ErrorList {
oldRevision, newRevision := oldObj.(*apps.ControllerRevision), newObj.(*apps.ControllerRevision) oldRevision, newRevision := oldObj.(*apps.ControllerRevision), newObj.(*apps.ControllerRevision)
return validation.ValidateControllerRevisionUpdate(newRevision, oldRevision) return validation.ValidateControllerRevisionUpdate(newRevision, oldRevision)
} }
...@@ -36,7 +36,6 @@ go_library( ...@@ -36,7 +36,6 @@ go_library(
"//pkg/registry/apps/daemonset:go_default_library", "//pkg/registry/apps/daemonset:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package storage package storage
import ( import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -90,11 +91,11 @@ func (r *StatusREST) New() runtime.Object { ...@@ -90,11 +91,11 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,6 +17,8 @@ limitations under the License. ...@@ -17,6 +17,8 @@ limitations under the License.
package daemonset package daemonset
import ( import (
"context"
appsv1beta2 "k8s.io/api/apps/v1beta2" appsv1beta2 "k8s.io/api/apps/v1beta2"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1" extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
...@@ -43,7 +45,7 @@ type daemonSetStrategy struct { ...@@ -43,7 +45,7 @@ type daemonSetStrategy struct {
var Strategy = daemonSetStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} var Strategy = daemonSetStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
// DefaultGarbageCollectionPolicy returns OrphanDependents by default. For apps/v1, returns DeleteDependents. // DefaultGarbageCollectionPolicy returns OrphanDependents by default. For apps/v1, returns DeleteDependents.
func (daemonSetStrategy) DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) rest.GarbageCollectionPolicy { func (daemonSetStrategy) DefaultGarbageCollectionPolicy(ctx context.Context) rest.GarbageCollectionPolicy {
if requestInfo, found := genericapirequest.RequestInfoFrom(ctx); found { if requestInfo, found := genericapirequest.RequestInfoFrom(ctx); found {
groupVersion := schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion} groupVersion := schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion}
switch groupVersion { switch groupVersion {
...@@ -63,7 +65,7 @@ func (daemonSetStrategy) NamespaceScoped() bool { ...@@ -63,7 +65,7 @@ func (daemonSetStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of a daemon set before creation. // PrepareForCreate clears the status of a daemon set before creation.
func (daemonSetStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (daemonSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
daemonSet := obj.(*extensions.DaemonSet) daemonSet := obj.(*extensions.DaemonSet)
daemonSet.Status = extensions.DaemonSetStatus{} daemonSet.Status = extensions.DaemonSetStatus{}
...@@ -76,7 +78,7 @@ func (daemonSetStrategy) PrepareForCreate(ctx genericapirequest.Context, obj run ...@@ -76,7 +78,7 @@ func (daemonSetStrategy) PrepareForCreate(ctx genericapirequest.Context, obj run
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (daemonSetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (daemonSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newDaemonSet := obj.(*extensions.DaemonSet) newDaemonSet := obj.(*extensions.DaemonSet)
oldDaemonSet := old.(*extensions.DaemonSet) oldDaemonSet := old.(*extensions.DaemonSet)
...@@ -111,7 +113,7 @@ func (daemonSetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol ...@@ -111,7 +113,7 @@ func (daemonSetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol
} }
// Validate validates a new daemon set. // Validate validates a new daemon set.
func (daemonSetStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (daemonSetStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
daemonSet := obj.(*extensions.DaemonSet) daemonSet := obj.(*extensions.DaemonSet)
return validation.ValidateDaemonSet(daemonSet) return validation.ValidateDaemonSet(daemonSet)
} }
...@@ -127,7 +129,7 @@ func (daemonSetStrategy) AllowCreateOnUpdate() bool { ...@@ -127,7 +129,7 @@ func (daemonSetStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (daemonSetStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (daemonSetStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
newDaemonSet := obj.(*extensions.DaemonSet) newDaemonSet := obj.(*extensions.DaemonSet)
oldDaemonSet := old.(*extensions.DaemonSet) oldDaemonSet := old.(*extensions.DaemonSet)
allErrs := validation.ValidateDaemonSet(obj.(*extensions.DaemonSet)) allErrs := validation.ValidateDaemonSet(obj.(*extensions.DaemonSet))
...@@ -162,12 +164,12 @@ type daemonSetStatusStrategy struct { ...@@ -162,12 +164,12 @@ type daemonSetStatusStrategy struct {
var StatusStrategy = daemonSetStatusStrategy{Strategy} var StatusStrategy = daemonSetStatusStrategy{Strategy}
func (daemonSetStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (daemonSetStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newDaemonSet := obj.(*extensions.DaemonSet) newDaemonSet := obj.(*extensions.DaemonSet)
oldDaemonSet := old.(*extensions.DaemonSet) oldDaemonSet := old.(*extensions.DaemonSet)
newDaemonSet.Spec = oldDaemonSet.Spec newDaemonSet.Spec = oldDaemonSet.Spec
} }
func (daemonSetStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (daemonSetStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateDaemonSetStatusUpdate(obj.(*extensions.DaemonSet), old.(*extensions.DaemonSet)) return validation.ValidateDaemonSetStatusUpdate(obj.(*extensions.DaemonSet), old.(*extensions.DaemonSet))
} }
...@@ -17,22 +17,22 @@ limitations under the License. ...@@ -17,22 +17,22 @@ limitations under the License.
package deployment package deployment
import ( import (
"context"
"fmt" "fmt"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
) )
// Registry is an interface for things that know how to store Deployments. // Registry is an interface for things that know how to store Deployments.
type Registry interface { type Registry interface {
ListDeployments(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*extensions.DeploymentList, error) ListDeployments(ctx context.Context, options *metainternalversion.ListOptions) (*extensions.DeploymentList, error)
GetDeployment(ctx genericapirequest.Context, deploymentID string, options *metav1.GetOptions) (*extensions.Deployment, error) GetDeployment(ctx context.Context, deploymentID string, options *metav1.GetOptions) (*extensions.Deployment, error)
CreateDeployment(ctx genericapirequest.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc) (*extensions.Deployment, error) CreateDeployment(ctx context.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc) (*extensions.Deployment, error)
UpdateDeployment(ctx genericapirequest.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.Deployment, error) UpdateDeployment(ctx context.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.Deployment, error)
DeleteDeployment(ctx genericapirequest.Context, deploymentID string) error DeleteDeployment(ctx context.Context, deploymentID string) error
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -45,7 +45,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -45,7 +45,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListDeployments(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*extensions.DeploymentList, error) { func (s *storage) ListDeployments(ctx context.Context, options *metainternalversion.ListOptions) (*extensions.DeploymentList, error) {
if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() { if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() {
return nil, fmt.Errorf("field selector not supported yet") return nil, fmt.Errorf("field selector not supported yet")
} }
...@@ -56,7 +56,7 @@ func (s *storage) ListDeployments(ctx genericapirequest.Context, options *metain ...@@ -56,7 +56,7 @@ func (s *storage) ListDeployments(ctx genericapirequest.Context, options *metain
return obj.(*extensions.DeploymentList), err return obj.(*extensions.DeploymentList), err
} }
func (s *storage) GetDeployment(ctx genericapirequest.Context, deploymentID string, options *metav1.GetOptions) (*extensions.Deployment, error) { func (s *storage) GetDeployment(ctx context.Context, deploymentID string, options *metav1.GetOptions) (*extensions.Deployment, error) {
obj, err := s.Get(ctx, deploymentID, options) obj, err := s.Get(ctx, deploymentID, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -64,7 +64,7 @@ func (s *storage) GetDeployment(ctx genericapirequest.Context, deploymentID stri ...@@ -64,7 +64,7 @@ func (s *storage) GetDeployment(ctx genericapirequest.Context, deploymentID stri
return obj.(*extensions.Deployment), nil return obj.(*extensions.Deployment), nil
} }
func (s *storage) CreateDeployment(ctx genericapirequest.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc) (*extensions.Deployment, error) { func (s *storage) CreateDeployment(ctx context.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc) (*extensions.Deployment, error) {
obj, err := s.Create(ctx, deployment, createValidation, false) obj, err := s.Create(ctx, deployment, createValidation, false)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -72,7 +72,7 @@ func (s *storage) CreateDeployment(ctx genericapirequest.Context, deployment *ex ...@@ -72,7 +72,7 @@ func (s *storage) CreateDeployment(ctx genericapirequest.Context, deployment *ex
return obj.(*extensions.Deployment), nil return obj.(*extensions.Deployment), nil
} }
func (s *storage) UpdateDeployment(ctx genericapirequest.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.Deployment, error) { func (s *storage) UpdateDeployment(ctx context.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.Deployment, error) {
obj, _, err := s.Update(ctx, deployment.Name, rest.DefaultUpdatedObjectInfo(deployment), createValidation, updateValidation) obj, _, err := s.Update(ctx, deployment.Name, rest.DefaultUpdatedObjectInfo(deployment), createValidation, updateValidation)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -80,7 +80,7 @@ func (s *storage) UpdateDeployment(ctx genericapirequest.Context, deployment *ex ...@@ -80,7 +80,7 @@ func (s *storage) UpdateDeployment(ctx genericapirequest.Context, deployment *ex
return obj.(*extensions.Deployment), nil return obj.(*extensions.Deployment), nil
} }
func (s *storage) DeleteDeployment(ctx genericapirequest.Context, deploymentID string) error { func (s *storage) DeleteDeployment(ctx context.Context, deploymentID string) error {
_, _, err := s.Delete(ctx, deploymentID, nil) _, _, err := s.Delete(ctx, deploymentID, nil)
return err return err
} }
...@@ -53,7 +53,6 @@ go_library( ...@@ -53,7 +53,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
...@@ -24,7 +25,6 @@ import ( ...@@ -24,7 +25,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -123,12 +123,12 @@ func (r *StatusREST) New() runtime.Object { ...@@ -123,12 +123,12 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -144,7 +144,7 @@ func (r *RollbackREST) New() runtime.Object { ...@@ -144,7 +144,7 @@ func (r *RollbackREST) New() runtime.Object {
var _ = rest.Creater(&RollbackREST{}) var _ = rest.Creater(&RollbackREST{})
func (r *RollbackREST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (r *RollbackREST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
rollback, ok := obj.(*extensions.DeploymentRollback) rollback, ok := obj.(*extensions.DeploymentRollback)
if !ok { if !ok {
return nil, errors.NewBadRequest(fmt.Sprintf("not a DeploymentRollback: %#v", obj)) return nil, errors.NewBadRequest(fmt.Sprintf("not a DeploymentRollback: %#v", obj))
...@@ -166,7 +166,7 @@ func (r *RollbackREST) Create(ctx genericapirequest.Context, obj runtime.Object, ...@@ -166,7 +166,7 @@ func (r *RollbackREST) Create(ctx genericapirequest.Context, obj runtime.Object,
}, nil }, nil
} }
func (r *RollbackREST) rollbackDeployment(ctx genericapirequest.Context, deploymentID string, config *extensions.RollbackConfig, annotations map[string]string) error { func (r *RollbackREST) rollbackDeployment(ctx context.Context, deploymentID string, config *extensions.RollbackConfig, annotations map[string]string) error {
if _, err := r.setDeploymentRollback(ctx, deploymentID, config, annotations); err != nil { if _, err := r.setDeploymentRollback(ctx, deploymentID, config, annotations); err != nil {
err = storeerr.InterpretGetError(err, extensions.Resource("deployments"), deploymentID) err = storeerr.InterpretGetError(err, extensions.Resource("deployments"), deploymentID)
err = storeerr.InterpretUpdateError(err, extensions.Resource("deployments"), deploymentID) err = storeerr.InterpretUpdateError(err, extensions.Resource("deployments"), deploymentID)
...@@ -178,7 +178,7 @@ func (r *RollbackREST) rollbackDeployment(ctx genericapirequest.Context, deploym ...@@ -178,7 +178,7 @@ func (r *RollbackREST) rollbackDeployment(ctx genericapirequest.Context, deploym
return nil return nil
} }
func (r *RollbackREST) setDeploymentRollback(ctx genericapirequest.Context, deploymentID string, config *extensions.RollbackConfig, annotations map[string]string) (*extensions.Deployment, error) { func (r *RollbackREST) setDeploymentRollback(ctx context.Context, deploymentID string, config *extensions.RollbackConfig, annotations map[string]string) (*extensions.Deployment, error) {
dKey, err := r.store.KeyFunc(ctx, deploymentID) dKey, err := r.store.KeyFunc(ctx, deploymentID)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -228,7 +228,7 @@ func (r *ScaleREST) New() runtime.Object { ...@@ -228,7 +228,7 @@ func (r *ScaleREST) New() runtime.Object {
return &autoscaling.Scale{} return &autoscaling.Scale{}
} }
func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
deployment, err := r.registry.GetDeployment(ctx, name, options) deployment, err := r.registry.GetDeployment(ctx, name, options)
if err != nil { if err != nil {
return nil, errors.NewNotFound(extensions.Resource("deployments/scale"), name) return nil, errors.NewNotFound(extensions.Resource("deployments/scale"), name)
...@@ -240,7 +240,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met ...@@ -240,7 +240,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met
return scale, nil return scale, nil
} }
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
deployment, err := r.registry.GetDeployment(ctx, name, &metav1.GetOptions{}) deployment, err := r.registry.GetDeployment(ctx, name, &metav1.GetOptions{})
if err != nil { if err != nil {
return nil, false, errors.NewNotFound(extensions.Resource("deployments/scale"), name) return nil, false, errors.NewNotFound(extensions.Resource("deployments/scale"), name)
......
...@@ -17,6 +17,8 @@ limitations under the License. ...@@ -17,6 +17,8 @@ limitations under the License.
package deployment package deployment
import ( import (
"context"
appsv1beta1 "k8s.io/api/apps/v1beta1" appsv1beta1 "k8s.io/api/apps/v1beta1"
appsv1beta2 "k8s.io/api/apps/v1beta2" appsv1beta2 "k8s.io/api/apps/v1beta2"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1" extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
...@@ -45,7 +47,7 @@ type deploymentStrategy struct { ...@@ -45,7 +47,7 @@ type deploymentStrategy struct {
var Strategy = deploymentStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} var Strategy = deploymentStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
// DefaultGarbageCollectionPolicy returns OrphanDependents by default. For apps/v1, returns DeleteDependents. // DefaultGarbageCollectionPolicy returns OrphanDependents by default. For apps/v1, returns DeleteDependents.
func (deploymentStrategy) DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) rest.GarbageCollectionPolicy { func (deploymentStrategy) DefaultGarbageCollectionPolicy(ctx context.Context) rest.GarbageCollectionPolicy {
if requestInfo, found := genericapirequest.RequestInfoFrom(ctx); found { if requestInfo, found := genericapirequest.RequestInfoFrom(ctx); found {
groupVersion := schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion} groupVersion := schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion}
switch groupVersion { switch groupVersion {
...@@ -65,7 +67,7 @@ func (deploymentStrategy) NamespaceScoped() bool { ...@@ -65,7 +67,7 @@ func (deploymentStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears fields that are not allowed to be set by end users on creation. // PrepareForCreate clears fields that are not allowed to be set by end users on creation.
func (deploymentStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (deploymentStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
deployment := obj.(*extensions.Deployment) deployment := obj.(*extensions.Deployment)
deployment.Status = extensions.DeploymentStatus{} deployment.Status = extensions.DeploymentStatus{}
deployment.Generation = 1 deployment.Generation = 1
...@@ -74,7 +76,7 @@ func (deploymentStrategy) PrepareForCreate(ctx genericapirequest.Context, obj ru ...@@ -74,7 +76,7 @@ func (deploymentStrategy) PrepareForCreate(ctx genericapirequest.Context, obj ru
} }
// Validate validates a new deployment. // Validate validates a new deployment.
func (deploymentStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (deploymentStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
deployment := obj.(*extensions.Deployment) deployment := obj.(*extensions.Deployment)
return validation.ValidateDeployment(deployment) return validation.ValidateDeployment(deployment)
} }
...@@ -89,7 +91,7 @@ func (deploymentStrategy) AllowCreateOnUpdate() bool { ...@@ -89,7 +91,7 @@ func (deploymentStrategy) AllowCreateOnUpdate() bool {
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (deploymentStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (deploymentStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newDeployment := obj.(*extensions.Deployment) newDeployment := obj.(*extensions.Deployment)
oldDeployment := old.(*extensions.Deployment) oldDeployment := old.(*extensions.Deployment)
newDeployment.Status = oldDeployment.Status newDeployment.Status = oldDeployment.Status
...@@ -107,7 +109,7 @@ func (deploymentStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, o ...@@ -107,7 +109,7 @@ func (deploymentStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, o
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (deploymentStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (deploymentStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
newDeployment := obj.(*extensions.Deployment) newDeployment := obj.(*extensions.Deployment)
oldDeployment := old.(*extensions.Deployment) oldDeployment := old.(*extensions.Deployment)
allErrs := validation.ValidateDeploymentUpdate(newDeployment, oldDeployment) allErrs := validation.ValidateDeploymentUpdate(newDeployment, oldDeployment)
...@@ -142,7 +144,7 @@ type deploymentStatusStrategy struct { ...@@ -142,7 +144,7 @@ type deploymentStatusStrategy struct {
var StatusStrategy = deploymentStatusStrategy{Strategy} var StatusStrategy = deploymentStatusStrategy{Strategy}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update of status // PrepareForUpdate clears fields that are not allowed to be set by end users on update of status
func (deploymentStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (deploymentStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newDeployment := obj.(*extensions.Deployment) newDeployment := obj.(*extensions.Deployment)
oldDeployment := old.(*extensions.Deployment) oldDeployment := old.(*extensions.Deployment)
newDeployment.Spec = oldDeployment.Spec newDeployment.Spec = oldDeployment.Spec
...@@ -150,6 +152,6 @@ func (deploymentStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, ...@@ -150,6 +152,6 @@ func (deploymentStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context,
} }
// ValidateUpdate is the default update validation for an end user updating status // ValidateUpdate is the default update validation for an end user updating status
func (deploymentStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (deploymentStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateDeploymentStatusUpdate(obj.(*extensions.Deployment), old.(*extensions.Deployment)) return validation.ValidateDeploymentStatusUpdate(obj.(*extensions.Deployment), old.(*extensions.Deployment))
} }
...@@ -19,24 +19,24 @@ limitations under the License. ...@@ -19,24 +19,24 @@ limitations under the License.
package replicaset package replicaset
import ( import (
"context"
"fmt" "fmt"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
) )
// Registry is an interface for things that know how to store ReplicaSets. // Registry is an interface for things that know how to store ReplicaSets.
type Registry interface { type Registry interface {
ListReplicaSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*extensions.ReplicaSetList, error) ListReplicaSets(ctx context.Context, options *metainternalversion.ListOptions) (*extensions.ReplicaSetList, error)
WatchReplicaSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchReplicaSets(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
GetReplicaSet(ctx genericapirequest.Context, replicaSetID string, options *metav1.GetOptions) (*extensions.ReplicaSet, error) GetReplicaSet(ctx context.Context, replicaSetID string, options *metav1.GetOptions) (*extensions.ReplicaSet, error)
CreateReplicaSet(ctx genericapirequest.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc) (*extensions.ReplicaSet, error) CreateReplicaSet(ctx context.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc) (*extensions.ReplicaSet, error)
UpdateReplicaSet(ctx genericapirequest.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.ReplicaSet, error) UpdateReplicaSet(ctx context.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.ReplicaSet, error)
DeleteReplicaSet(ctx genericapirequest.Context, replicaSetID string) error DeleteReplicaSet(ctx context.Context, replicaSetID string) error
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -50,7 +50,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -50,7 +50,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListReplicaSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*extensions.ReplicaSetList, error) { func (s *storage) ListReplicaSets(ctx context.Context, options *metainternalversion.ListOptions) (*extensions.ReplicaSetList, error) {
if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() { if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() {
return nil, fmt.Errorf("field selector not supported yet") return nil, fmt.Errorf("field selector not supported yet")
} }
...@@ -61,11 +61,11 @@ func (s *storage) ListReplicaSets(ctx genericapirequest.Context, options *metain ...@@ -61,11 +61,11 @@ func (s *storage) ListReplicaSets(ctx genericapirequest.Context, options *metain
return obj.(*extensions.ReplicaSetList), err return obj.(*extensions.ReplicaSetList), err
} }
func (s *storage) WatchReplicaSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchReplicaSets(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetReplicaSet(ctx genericapirequest.Context, replicaSetID string, options *metav1.GetOptions) (*extensions.ReplicaSet, error) { func (s *storage) GetReplicaSet(ctx context.Context, replicaSetID string, options *metav1.GetOptions) (*extensions.ReplicaSet, error) {
obj, err := s.Get(ctx, replicaSetID, options) obj, err := s.Get(ctx, replicaSetID, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -73,7 +73,7 @@ func (s *storage) GetReplicaSet(ctx genericapirequest.Context, replicaSetID stri ...@@ -73,7 +73,7 @@ func (s *storage) GetReplicaSet(ctx genericapirequest.Context, replicaSetID stri
return obj.(*extensions.ReplicaSet), nil return obj.(*extensions.ReplicaSet), nil
} }
func (s *storage) CreateReplicaSet(ctx genericapirequest.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc) (*extensions.ReplicaSet, error) { func (s *storage) CreateReplicaSet(ctx context.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc) (*extensions.ReplicaSet, error) {
obj, err := s.Create(ctx, replicaSet, createValidation, false) obj, err := s.Create(ctx, replicaSet, createValidation, false)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -81,7 +81,7 @@ func (s *storage) CreateReplicaSet(ctx genericapirequest.Context, replicaSet *ex ...@@ -81,7 +81,7 @@ func (s *storage) CreateReplicaSet(ctx genericapirequest.Context, replicaSet *ex
return obj.(*extensions.ReplicaSet), nil return obj.(*extensions.ReplicaSet), nil
} }
func (s *storage) UpdateReplicaSet(ctx genericapirequest.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.ReplicaSet, error) { func (s *storage) UpdateReplicaSet(ctx context.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.ReplicaSet, error) {
obj, _, err := s.Update(ctx, replicaSet.Name, rest.DefaultUpdatedObjectInfo(replicaSet), createValidation, updateValidation) obj, _, err := s.Update(ctx, replicaSet.Name, rest.DefaultUpdatedObjectInfo(replicaSet), createValidation, updateValidation)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -89,7 +89,7 @@ func (s *storage) UpdateReplicaSet(ctx genericapirequest.Context, replicaSet *ex ...@@ -89,7 +89,7 @@ func (s *storage) UpdateReplicaSet(ctx genericapirequest.Context, replicaSet *ex
return obj.(*extensions.ReplicaSet), nil return obj.(*extensions.ReplicaSet), nil
} }
func (s *storage) DeleteReplicaSet(ctx genericapirequest.Context, replicaSetID string) error { func (s *storage) DeleteReplicaSet(ctx context.Context, replicaSetID string) error {
_, _, err := s.Delete(ctx, replicaSetID, nil) _, _, err := s.Delete(ctx, replicaSetID, nil)
return err return err
} }
...@@ -50,7 +50,6 @@ go_library( ...@@ -50,7 +50,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -19,13 +19,13 @@ limitations under the License. ...@@ -19,13 +19,13 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -121,12 +121,12 @@ func (r *StatusREST) New() runtime.Object { ...@@ -121,12 +121,12 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -156,7 +156,7 @@ func (r *ScaleREST) New() runtime.Object { ...@@ -156,7 +156,7 @@ func (r *ScaleREST) New() runtime.Object {
return &autoscaling.Scale{} return &autoscaling.Scale{}
} }
func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
rs, err := r.registry.GetReplicaSet(ctx, name, options) rs, err := r.registry.GetReplicaSet(ctx, name, options)
if err != nil { if err != nil {
return nil, errors.NewNotFound(extensions.Resource("replicasets/scale"), name) return nil, errors.NewNotFound(extensions.Resource("replicasets/scale"), name)
...@@ -168,7 +168,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met ...@@ -168,7 +168,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met
return scale, err return scale, err
} }
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
rs, err := r.registry.GetReplicaSet(ctx, name, &metav1.GetOptions{}) rs, err := r.registry.GetReplicaSet(ctx, name, &metav1.GetOptions{})
if err != nil { if err != nil {
return nil, false, errors.NewNotFound(extensions.Resource("replicasets/scale"), name) return nil, false, errors.NewNotFound(extensions.Resource("replicasets/scale"), name)
......
...@@ -19,6 +19,7 @@ limitations under the License. ...@@ -19,6 +19,7 @@ limitations under the License.
package replicaset package replicaset
import ( import (
"context"
"fmt" "fmt"
"strconv" "strconv"
...@@ -52,7 +53,7 @@ type rsStrategy struct { ...@@ -52,7 +53,7 @@ type rsStrategy struct {
var Strategy = rsStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} var Strategy = rsStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
// DefaultGarbageCollectionPolicy returns OrphanDependents by default. For apps/v1, returns DeleteDependents. // DefaultGarbageCollectionPolicy returns OrphanDependents by default. For apps/v1, returns DeleteDependents.
func (rsStrategy) DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) rest.GarbageCollectionPolicy { func (rsStrategy) DefaultGarbageCollectionPolicy(ctx context.Context) rest.GarbageCollectionPolicy {
if requestInfo, found := genericapirequest.RequestInfoFrom(ctx); found { if requestInfo, found := genericapirequest.RequestInfoFrom(ctx); found {
groupVersion := schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion} groupVersion := schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion}
switch groupVersion { switch groupVersion {
...@@ -72,7 +73,7 @@ func (rsStrategy) NamespaceScoped() bool { ...@@ -72,7 +73,7 @@ func (rsStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of a ReplicaSet before creation. // PrepareForCreate clears the status of a ReplicaSet before creation.
func (rsStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (rsStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
rs := obj.(*extensions.ReplicaSet) rs := obj.(*extensions.ReplicaSet)
rs.Status = extensions.ReplicaSetStatus{} rs.Status = extensions.ReplicaSetStatus{}
...@@ -82,7 +83,7 @@ func (rsStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Ob ...@@ -82,7 +83,7 @@ func (rsStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Ob
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (rsStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (rsStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newRS := obj.(*extensions.ReplicaSet) newRS := obj.(*extensions.ReplicaSet)
oldRS := old.(*extensions.ReplicaSet) oldRS := old.(*extensions.ReplicaSet)
// update is not allowed to set status // update is not allowed to set status
...@@ -105,7 +106,7 @@ func (rsStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runti ...@@ -105,7 +106,7 @@ func (rsStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runti
} }
// Validate validates a new ReplicaSet. // Validate validates a new ReplicaSet.
func (rsStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (rsStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
rs := obj.(*extensions.ReplicaSet) rs := obj.(*extensions.ReplicaSet)
return validation.ValidateReplicaSet(rs) return validation.ValidateReplicaSet(rs)
} }
...@@ -121,7 +122,7 @@ func (rsStrategy) AllowCreateOnUpdate() bool { ...@@ -121,7 +122,7 @@ func (rsStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (rsStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (rsStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
newReplicaSet := obj.(*extensions.ReplicaSet) newReplicaSet := obj.(*extensions.ReplicaSet)
oldReplicaSet := old.(*extensions.ReplicaSet) oldReplicaSet := old.(*extensions.ReplicaSet)
allErrs := validation.ValidateReplicaSet(obj.(*extensions.ReplicaSet)) allErrs := validation.ValidateReplicaSet(obj.(*extensions.ReplicaSet))
...@@ -184,13 +185,13 @@ type rsStatusStrategy struct { ...@@ -184,13 +185,13 @@ type rsStatusStrategy struct {
var StatusStrategy = rsStatusStrategy{Strategy} var StatusStrategy = rsStatusStrategy{Strategy}
func (rsStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (rsStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newRS := obj.(*extensions.ReplicaSet) newRS := obj.(*extensions.ReplicaSet)
oldRS := old.(*extensions.ReplicaSet) oldRS := old.(*extensions.ReplicaSet)
// update is not allowed to set spec // update is not allowed to set spec
newRS.Spec = oldRS.Spec newRS.Spec = oldRS.Spec
} }
func (rsStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (rsStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateReplicaSetStatusUpdate(obj.(*extensions.ReplicaSet), old.(*extensions.ReplicaSet)) return validation.ValidateReplicaSetStatusUpdate(obj.(*extensions.ReplicaSet), old.(*extensions.ReplicaSet))
} }
...@@ -17,25 +17,25 @@ limitations under the License. ...@@ -17,25 +17,25 @@ limitations under the License.
package statefulset package statefulset
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/kubernetes/pkg/apis/apps" "k8s.io/kubernetes/pkg/apis/apps"
) )
// Registry is an interface for things that know how to store StatefulSets. // Registry is an interface for things that know how to store StatefulSets.
type Registry interface { type Registry interface {
ListStatefulSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*apps.StatefulSetList, error) ListStatefulSets(ctx context.Context, options *metainternalversion.ListOptions) (*apps.StatefulSetList, error)
WatchStatefulSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchStatefulSets(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
GetStatefulSet(ctx genericapirequest.Context, statefulSetID string, options *metav1.GetOptions) (*apps.StatefulSet, error) GetStatefulSet(ctx context.Context, statefulSetID string, options *metav1.GetOptions) (*apps.StatefulSet, error)
CreateStatefulSet(ctx genericapirequest.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc) (*apps.StatefulSet, error) CreateStatefulSet(ctx context.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc) (*apps.StatefulSet, error)
UpdateStatefulSet(ctx genericapirequest.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*apps.StatefulSet, error) UpdateStatefulSet(ctx context.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*apps.StatefulSet, error)
DeleteStatefulSet(ctx genericapirequest.Context, statefulSetID string) error DeleteStatefulSet(ctx context.Context, statefulSetID string) error
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -49,7 +49,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -49,7 +49,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListStatefulSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*apps.StatefulSetList, error) { func (s *storage) ListStatefulSets(ctx context.Context, options *metainternalversion.ListOptions) (*apps.StatefulSetList, error) {
if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() { if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() {
return nil, fmt.Errorf("field selector not supported yet") return nil, fmt.Errorf("field selector not supported yet")
} }
...@@ -60,11 +60,11 @@ func (s *storage) ListStatefulSets(ctx genericapirequest.Context, options *metai ...@@ -60,11 +60,11 @@ func (s *storage) ListStatefulSets(ctx genericapirequest.Context, options *metai
return obj.(*apps.StatefulSetList), err return obj.(*apps.StatefulSetList), err
} }
func (s *storage) WatchStatefulSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchStatefulSets(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetStatefulSet(ctx genericapirequest.Context, statefulSetID string, options *metav1.GetOptions) (*apps.StatefulSet, error) { func (s *storage) GetStatefulSet(ctx context.Context, statefulSetID string, options *metav1.GetOptions) (*apps.StatefulSet, error) {
obj, err := s.Get(ctx, statefulSetID, options) obj, err := s.Get(ctx, statefulSetID, options)
if err != nil { if err != nil {
return nil, errors.NewNotFound(apps.Resource("statefulsets/scale"), statefulSetID) return nil, errors.NewNotFound(apps.Resource("statefulsets/scale"), statefulSetID)
...@@ -72,7 +72,7 @@ func (s *storage) GetStatefulSet(ctx genericapirequest.Context, statefulSetID st ...@@ -72,7 +72,7 @@ func (s *storage) GetStatefulSet(ctx genericapirequest.Context, statefulSetID st
return obj.(*apps.StatefulSet), nil return obj.(*apps.StatefulSet), nil
} }
func (s *storage) CreateStatefulSet(ctx genericapirequest.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc) (*apps.StatefulSet, error) { func (s *storage) CreateStatefulSet(ctx context.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc) (*apps.StatefulSet, error) {
obj, err := s.Create(ctx, statefulSet, rest.ValidateAllObjectFunc, false) obj, err := s.Create(ctx, statefulSet, rest.ValidateAllObjectFunc, false)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -80,7 +80,7 @@ func (s *storage) CreateStatefulSet(ctx genericapirequest.Context, statefulSet * ...@@ -80,7 +80,7 @@ func (s *storage) CreateStatefulSet(ctx genericapirequest.Context, statefulSet *
return obj.(*apps.StatefulSet), nil return obj.(*apps.StatefulSet), nil
} }
func (s *storage) UpdateStatefulSet(ctx genericapirequest.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*apps.StatefulSet, error) { func (s *storage) UpdateStatefulSet(ctx context.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*apps.StatefulSet, error) {
obj, _, err := s.Update(ctx, statefulSet.Name, rest.DefaultUpdatedObjectInfo(statefulSet), createValidation, updateValidation) obj, _, err := s.Update(ctx, statefulSet.Name, rest.DefaultUpdatedObjectInfo(statefulSet), createValidation, updateValidation)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -88,7 +88,7 @@ func (s *storage) UpdateStatefulSet(ctx genericapirequest.Context, statefulSet * ...@@ -88,7 +88,7 @@ func (s *storage) UpdateStatefulSet(ctx genericapirequest.Context, statefulSet *
return obj.(*apps.StatefulSet), nil return obj.(*apps.StatefulSet), nil
} }
func (s *storage) DeleteStatefulSet(ctx genericapirequest.Context, statefulSetID string) error { func (s *storage) DeleteStatefulSet(ctx context.Context, statefulSetID string) error {
_, _, err := s.Delete(ctx, statefulSetID, nil) _, _, err := s.Delete(ctx, statefulSetID, nil)
return err return err
} }
...@@ -49,7 +49,6 @@ go_library( ...@@ -49,7 +49,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,13 +17,13 @@ limitations under the License. ...@@ -17,13 +17,13 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -104,12 +104,12 @@ func (r *StatusREST) New() runtime.Object { ...@@ -104,12 +104,12 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -145,7 +145,7 @@ func (r *ScaleREST) New() runtime.Object { ...@@ -145,7 +145,7 @@ func (r *ScaleREST) New() runtime.Object {
return &autoscaling.Scale{} return &autoscaling.Scale{}
} }
func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
ss, err := r.registry.GetStatefulSet(ctx, name, options) ss, err := r.registry.GetStatefulSet(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -157,7 +157,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met ...@@ -157,7 +157,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met
return scale, err return scale, err
} }
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
ss, err := r.registry.GetStatefulSet(ctx, name, &metav1.GetOptions{}) ss, err := r.registry.GetStatefulSet(ctx, name, &metav1.GetOptions{})
if err != nil { if err != nil {
return nil, false, err return nil, false, err
......
...@@ -17,6 +17,8 @@ limitations under the License. ...@@ -17,6 +17,8 @@ limitations under the License.
package statefulset package statefulset
import ( import (
"context"
appsv1beta1 "k8s.io/api/apps/v1beta1" appsv1beta1 "k8s.io/api/apps/v1beta1"
appsv1beta2 "k8s.io/api/apps/v1beta2" appsv1beta2 "k8s.io/api/apps/v1beta2"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
...@@ -42,7 +44,7 @@ type statefulSetStrategy struct { ...@@ -42,7 +44,7 @@ type statefulSetStrategy struct {
var Strategy = statefulSetStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} var Strategy = statefulSetStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
// DefaultGarbageCollectionPolicy returns OrphanDependents by default. For apps/v1, returns DeleteDependents. // DefaultGarbageCollectionPolicy returns OrphanDependents by default. For apps/v1, returns DeleteDependents.
func (statefulSetStrategy) DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) rest.GarbageCollectionPolicy { func (statefulSetStrategy) DefaultGarbageCollectionPolicy(ctx context.Context) rest.GarbageCollectionPolicy {
if requestInfo, found := genericapirequest.RequestInfoFrom(ctx); found { if requestInfo, found := genericapirequest.RequestInfoFrom(ctx); found {
groupVersion := schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion} groupVersion := schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion}
switch groupVersion { switch groupVersion {
...@@ -62,7 +64,7 @@ func (statefulSetStrategy) NamespaceScoped() bool { ...@@ -62,7 +64,7 @@ func (statefulSetStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of an StatefulSet before creation. // PrepareForCreate clears the status of an StatefulSet before creation.
func (statefulSetStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (statefulSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
statefulSet := obj.(*apps.StatefulSet) statefulSet := obj.(*apps.StatefulSet)
// create cannot set status // create cannot set status
statefulSet.Status = apps.StatefulSetStatus{} statefulSet.Status = apps.StatefulSetStatus{}
...@@ -73,7 +75,7 @@ func (statefulSetStrategy) PrepareForCreate(ctx genericapirequest.Context, obj r ...@@ -73,7 +75,7 @@ func (statefulSetStrategy) PrepareForCreate(ctx genericapirequest.Context, obj r
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (statefulSetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (statefulSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newStatefulSet := obj.(*apps.StatefulSet) newStatefulSet := obj.(*apps.StatefulSet)
oldStatefulSet := old.(*apps.StatefulSet) oldStatefulSet := old.(*apps.StatefulSet)
// Update is not allowed to set status // Update is not allowed to set status
...@@ -92,7 +94,7 @@ func (statefulSetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ...@@ -92,7 +94,7 @@ func (statefulSetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj,
} }
// Validate validates a new StatefulSet. // Validate validates a new StatefulSet.
func (statefulSetStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (statefulSetStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
statefulSet := obj.(*apps.StatefulSet) statefulSet := obj.(*apps.StatefulSet)
return validation.ValidateStatefulSet(statefulSet) return validation.ValidateStatefulSet(statefulSet)
} }
...@@ -107,7 +109,7 @@ func (statefulSetStrategy) AllowCreateOnUpdate() bool { ...@@ -107,7 +109,7 @@ func (statefulSetStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (statefulSetStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (statefulSetStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
validationErrorList := validation.ValidateStatefulSet(obj.(*apps.StatefulSet)) validationErrorList := validation.ValidateStatefulSet(obj.(*apps.StatefulSet))
updateErrorList := validation.ValidateStatefulSetUpdate(obj.(*apps.StatefulSet), old.(*apps.StatefulSet)) updateErrorList := validation.ValidateStatefulSetUpdate(obj.(*apps.StatefulSet), old.(*apps.StatefulSet))
return append(validationErrorList, updateErrorList...) return append(validationErrorList, updateErrorList...)
...@@ -125,7 +127,7 @@ type statefulSetStatusStrategy struct { ...@@ -125,7 +127,7 @@ type statefulSetStatusStrategy struct {
var StatusStrategy = statefulSetStatusStrategy{Strategy} var StatusStrategy = statefulSetStatusStrategy{Strategy}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update of status // PrepareForUpdate clears fields that are not allowed to be set by end users on update of status
func (statefulSetStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (statefulSetStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newStatefulSet := obj.(*apps.StatefulSet) newStatefulSet := obj.(*apps.StatefulSet)
oldStatefulSet := old.(*apps.StatefulSet) oldStatefulSet := old.(*apps.StatefulSet)
// status changes are not allowed to update spec // status changes are not allowed to update spec
...@@ -133,7 +135,7 @@ func (statefulSetStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, ...@@ -133,7 +135,7 @@ func (statefulSetStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context,
} }
// ValidateUpdate is the default update validation for an end user updating status // ValidateUpdate is the default update validation for an end user updating status
func (statefulSetStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (statefulSetStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
// TODO: Validate status updates. // TODO: Validate status updates.
return validation.ValidateStatefulSetStatusUpdate(obj.(*apps.StatefulSet), old.(*apps.StatefulSet)) return validation.ValidateStatefulSetStatusUpdate(obj.(*apps.StatefulSet), old.(*apps.StatefulSet))
} }
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package tokenreview package tokenreview
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
...@@ -40,7 +41,7 @@ func (r *REST) New() runtime.Object { ...@@ -40,7 +41,7 @@ func (r *REST) New() runtime.Object {
return &authentication.TokenReview{} return &authentication.TokenReview{}
} }
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
tokenReview, ok := obj.(*authentication.TokenReview) tokenReview, ok := obj.(*authentication.TokenReview)
if !ok { if !ok {
return nil, apierrors.NewBadRequest(fmt.Sprintf("not a TokenReview: %#v", obj)) return nil, apierrors.NewBadRequest(fmt.Sprintf("not a TokenReview: %#v", obj))
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package localsubjectaccessreview package localsubjectaccessreview
import ( import (
"context"
"fmt" "fmt"
kapierrors "k8s.io/apimachinery/pkg/api/errors" kapierrors "k8s.io/apimachinery/pkg/api/errors"
...@@ -41,7 +42,7 @@ func (r *REST) New() runtime.Object { ...@@ -41,7 +42,7 @@ func (r *REST) New() runtime.Object {
return &authorizationapi.LocalSubjectAccessReview{} return &authorizationapi.LocalSubjectAccessReview{}
} }
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
localSubjectAccessReview, ok := obj.(*authorizationapi.LocalSubjectAccessReview) localSubjectAccessReview, ok := obj.(*authorizationapi.LocalSubjectAccessReview)
if !ok { if !ok {
return nil, kapierrors.NewBadRequest(fmt.Sprintf("not a LocaLocalSubjectAccessReview: %#v", obj)) return nil, kapierrors.NewBadRequest(fmt.Sprintf("not a LocaLocalSubjectAccessReview: %#v", obj))
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package selfsubjectaccessreview package selfsubjectaccessreview
import ( import (
"context"
"fmt" "fmt"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
...@@ -41,7 +42,7 @@ func (r *REST) New() runtime.Object { ...@@ -41,7 +42,7 @@ func (r *REST) New() runtime.Object {
return &authorizationapi.SelfSubjectAccessReview{} return &authorizationapi.SelfSubjectAccessReview{}
} }
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
selfSAR, ok := obj.(*authorizationapi.SelfSubjectAccessReview) selfSAR, ok := obj.(*authorizationapi.SelfSubjectAccessReview)
if !ok { if !ok {
return nil, apierrors.NewBadRequest(fmt.Sprintf("not a SelfSubjectAccessReview: %#v", obj)) return nil, apierrors.NewBadRequest(fmt.Sprintf("not a SelfSubjectAccessReview: %#v", obj))
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package selfsubjectrulesreview package selfsubjectrulesreview
import ( import (
"context"
"fmt" "fmt"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
...@@ -43,7 +44,7 @@ func (r *REST) New() runtime.Object { ...@@ -43,7 +44,7 @@ func (r *REST) New() runtime.Object {
} }
// Create attempts to get self subject rules in specific namespace. // Create attempts to get self subject rules in specific namespace.
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
selfSRR, ok := obj.(*authorizationapi.SelfSubjectRulesReview) selfSRR, ok := obj.(*authorizationapi.SelfSubjectRulesReview)
if !ok { if !ok {
return nil, apierrors.NewBadRequest(fmt.Sprintf("not a SelfSubjectRulesReview: %#v", obj)) return nil, apierrors.NewBadRequest(fmt.Sprintf("not a SelfSubjectRulesReview: %#v", obj))
......
...@@ -17,7 +17,6 @@ go_library( ...@@ -17,7 +17,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library", "//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library", "//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
], ],
) )
......
...@@ -17,12 +17,12 @@ limitations under the License. ...@@ -17,12 +17,12 @@ limitations under the License.
package subjectaccessreview package subjectaccessreview
import ( import (
"context"
"fmt" "fmt"
kapierrors "k8s.io/apimachinery/pkg/api/errors" kapierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/authorization/authorizer" "k8s.io/apiserver/pkg/authorization/authorizer"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
authorizationapi "k8s.io/kubernetes/pkg/apis/authorization" authorizationapi "k8s.io/kubernetes/pkg/apis/authorization"
authorizationvalidation "k8s.io/kubernetes/pkg/apis/authorization/validation" authorizationvalidation "k8s.io/kubernetes/pkg/apis/authorization/validation"
...@@ -41,7 +41,7 @@ func (r *REST) New() runtime.Object { ...@@ -41,7 +41,7 @@ func (r *REST) New() runtime.Object {
return &authorizationapi.SubjectAccessReview{} return &authorizationapi.SubjectAccessReview{}
} }
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
subjectAccessReview, ok := obj.(*authorizationapi.SubjectAccessReview) subjectAccessReview, ok := obj.(*authorizationapi.SubjectAccessReview)
if !ok { if !ok {
return nil, kapierrors.NewBadRequest(fmt.Sprintf("not a SubjectAccessReview: %#v", obj)) return nil, kapierrors.NewBadRequest(fmt.Sprintf("not a SubjectAccessReview: %#v", obj))
......
...@@ -18,7 +18,6 @@ go_library( ...@@ -18,7 +18,6 @@ go_library(
"//pkg/apis/autoscaling/validation:go_default_library", "//pkg/apis/autoscaling/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
) )
......
...@@ -41,7 +41,6 @@ go_library( ...@@ -41,7 +41,6 @@ go_library(
"//pkg/registry/autoscaling/horizontalpodautoscaler:go_default_library", "//pkg/registry/autoscaling/horizontalpodautoscaler:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package storage package storage
import ( import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -83,11 +84,11 @@ func (r *StatusREST) New() runtime.Object { ...@@ -83,11 +84,11 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package horizontalpodautoscaler package horizontalpodautoscaler
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/autoscaling" "k8s.io/kubernetes/pkg/apis/autoscaling"
...@@ -42,7 +43,7 @@ func (autoscalerStrategy) NamespaceScoped() bool { ...@@ -42,7 +43,7 @@ func (autoscalerStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears fields that are not allowed to be set by end users on creation. // PrepareForCreate clears fields that are not allowed to be set by end users on creation.
func (autoscalerStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (autoscalerStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
newHPA := obj.(*autoscaling.HorizontalPodAutoscaler) newHPA := obj.(*autoscaling.HorizontalPodAutoscaler)
// create cannot set status // create cannot set status
...@@ -50,7 +51,7 @@ func (autoscalerStrategy) PrepareForCreate(ctx genericapirequest.Context, obj ru ...@@ -50,7 +51,7 @@ func (autoscalerStrategy) PrepareForCreate(ctx genericapirequest.Context, obj ru
} }
// Validate validates a new autoscaler. // Validate validates a new autoscaler.
func (autoscalerStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (autoscalerStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
autoscaler := obj.(*autoscaling.HorizontalPodAutoscaler) autoscaler := obj.(*autoscaling.HorizontalPodAutoscaler)
return validation.ValidateHorizontalPodAutoscaler(autoscaler) return validation.ValidateHorizontalPodAutoscaler(autoscaler)
} }
...@@ -65,7 +66,7 @@ func (autoscalerStrategy) AllowCreateOnUpdate() bool { ...@@ -65,7 +66,7 @@ func (autoscalerStrategy) AllowCreateOnUpdate() bool {
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (autoscalerStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (autoscalerStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newHPA := obj.(*autoscaling.HorizontalPodAutoscaler) newHPA := obj.(*autoscaling.HorizontalPodAutoscaler)
oldHPA := old.(*autoscaling.HorizontalPodAutoscaler) oldHPA := old.(*autoscaling.HorizontalPodAutoscaler)
// Update is not allowed to set status // Update is not allowed to set status
...@@ -73,7 +74,7 @@ func (autoscalerStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, o ...@@ -73,7 +74,7 @@ func (autoscalerStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, o
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (autoscalerStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (autoscalerStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateHorizontalPodAutoscalerUpdate(obj.(*autoscaling.HorizontalPodAutoscaler), old.(*autoscaling.HorizontalPodAutoscaler)) return validation.ValidateHorizontalPodAutoscalerUpdate(obj.(*autoscaling.HorizontalPodAutoscaler), old.(*autoscaling.HorizontalPodAutoscaler))
} }
...@@ -87,13 +88,13 @@ type autoscalerStatusStrategy struct { ...@@ -87,13 +88,13 @@ type autoscalerStatusStrategy struct {
var StatusStrategy = autoscalerStatusStrategy{Strategy} var StatusStrategy = autoscalerStatusStrategy{Strategy}
func (autoscalerStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (autoscalerStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newAutoscaler := obj.(*autoscaling.HorizontalPodAutoscaler) newAutoscaler := obj.(*autoscaling.HorizontalPodAutoscaler)
oldAutoscaler := old.(*autoscaling.HorizontalPodAutoscaler) oldAutoscaler := old.(*autoscaling.HorizontalPodAutoscaler)
// status changes are not allowed to update spec // status changes are not allowed to update spec
newAutoscaler.Spec = oldAutoscaler.Spec newAutoscaler.Spec = oldAutoscaler.Spec
} }
func (autoscalerStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (autoscalerStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateHorizontalPodAutoscalerStatusUpdate(obj.(*autoscaling.HorizontalPodAutoscaler), old.(*autoscaling.HorizontalPodAutoscaler)) return validation.ValidateHorizontalPodAutoscalerStatusUpdate(obj.(*autoscaling.HorizontalPodAutoscaler), old.(*autoscaling.HorizontalPodAutoscaler))
} }
...@@ -20,7 +20,6 @@ go_library( ...@@ -20,7 +20,6 @@ go_library(
"//pkg/apis/batch/validation:go_default_library", "//pkg/apis/batch/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
......
...@@ -38,7 +38,6 @@ go_library( ...@@ -38,7 +38,6 @@ go_library(
"//pkg/registry/batch/cronjob:go_default_library", "//pkg/registry/batch/cronjob:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package storage package storage
import ( import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -82,11 +83,11 @@ func (r *StatusREST) New() runtime.Object { ...@@ -82,11 +83,11 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package cronjob package cronjob
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
...@@ -39,7 +40,7 @@ var Strategy = cronJobStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} ...@@ -39,7 +40,7 @@ var Strategy = cronJobStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
// DefaultGarbageCollectionPolicy returns Orphan because that was the default // DefaultGarbageCollectionPolicy returns Orphan because that was the default
// behavior before the server-side garbage collection was implemented. // behavior before the server-side garbage collection was implemented.
func (cronJobStrategy) DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) rest.GarbageCollectionPolicy { func (cronJobStrategy) DefaultGarbageCollectionPolicy(ctx context.Context) rest.GarbageCollectionPolicy {
return rest.OrphanDependents return rest.OrphanDependents
} }
...@@ -49,7 +50,7 @@ func (cronJobStrategy) NamespaceScoped() bool { ...@@ -49,7 +50,7 @@ func (cronJobStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of a scheduled job before creation. // PrepareForCreate clears the status of a scheduled job before creation.
func (cronJobStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (cronJobStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
cronJob := obj.(*batch.CronJob) cronJob := obj.(*batch.CronJob)
cronJob.Status = batch.CronJobStatus{} cronJob.Status = batch.CronJobStatus{}
...@@ -57,7 +58,7 @@ func (cronJobStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runti ...@@ -57,7 +58,7 @@ func (cronJobStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runti
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (cronJobStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (cronJobStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newCronJob := obj.(*batch.CronJob) newCronJob := obj.(*batch.CronJob)
oldCronJob := old.(*batch.CronJob) oldCronJob := old.(*batch.CronJob)
newCronJob.Status = oldCronJob.Status newCronJob.Status = oldCronJob.Status
...@@ -67,7 +68,7 @@ func (cronJobStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old ...@@ -67,7 +68,7 @@ func (cronJobStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old
} }
// Validate validates a new scheduled job. // Validate validates a new scheduled job.
func (cronJobStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (cronJobStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
cronJob := obj.(*batch.CronJob) cronJob := obj.(*batch.CronJob)
return validation.ValidateCronJob(cronJob) return validation.ValidateCronJob(cronJob)
} }
...@@ -86,7 +87,7 @@ func (cronJobStrategy) AllowCreateOnUpdate() bool { ...@@ -86,7 +87,7 @@ func (cronJobStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (cronJobStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (cronJobStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateCronJobUpdate(obj.(*batch.CronJob), old.(*batch.CronJob)) return validation.ValidateCronJobUpdate(obj.(*batch.CronJob), old.(*batch.CronJob))
} }
...@@ -96,12 +97,12 @@ type cronJobStatusStrategy struct { ...@@ -96,12 +97,12 @@ type cronJobStatusStrategy struct {
var StatusStrategy = cronJobStatusStrategy{Strategy} var StatusStrategy = cronJobStatusStrategy{Strategy}
func (cronJobStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (cronJobStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newJob := obj.(*batch.CronJob) newJob := obj.(*batch.CronJob)
oldJob := old.(*batch.CronJob) oldJob := old.(*batch.CronJob)
newJob.Spec = oldJob.Spec newJob.Spec = oldJob.Spec
} }
func (cronJobStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (cronJobStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return field.ErrorList{} return field.ErrorList{}
} }
...@@ -23,7 +23,6 @@ go_library( ...@@ -23,7 +23,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
......
...@@ -36,7 +36,6 @@ go_library( ...@@ -36,7 +36,6 @@ go_library(
"//pkg/registry/batch/job:go_default_library", "//pkg/registry/batch/job:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package storage package storage
import ( import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -93,11 +94,11 @@ func (r *StatusREST) New() runtime.Object { ...@@ -93,11 +94,11 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package job package job
import ( import (
"context"
"fmt" "fmt"
"strconv" "strconv"
...@@ -25,7 +26,6 @@ import ( ...@@ -25,7 +26,6 @@ import (
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage"
...@@ -47,7 +47,7 @@ var Strategy = jobStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} ...@@ -47,7 +47,7 @@ var Strategy = jobStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
// DefaultGarbageCollectionPolicy returns Orphan because that was the default // DefaultGarbageCollectionPolicy returns Orphan because that was the default
// behavior before the server-side garbage collection was implemented. // behavior before the server-side garbage collection was implemented.
func (jobStrategy) DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) rest.GarbageCollectionPolicy { func (jobStrategy) DefaultGarbageCollectionPolicy(ctx context.Context) rest.GarbageCollectionPolicy {
return rest.OrphanDependents return rest.OrphanDependents
} }
...@@ -57,7 +57,7 @@ func (jobStrategy) NamespaceScoped() bool { ...@@ -57,7 +57,7 @@ func (jobStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of a job before creation. // PrepareForCreate clears the status of a job before creation.
func (jobStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (jobStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
job := obj.(*batch.Job) job := obj.(*batch.Job)
job.Status = batch.JobStatus{} job.Status = batch.JobStatus{}
...@@ -65,7 +65,7 @@ func (jobStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.O ...@@ -65,7 +65,7 @@ func (jobStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.O
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (jobStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (jobStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newJob := obj.(*batch.Job) newJob := obj.(*batch.Job)
oldJob := old.(*batch.Job) oldJob := old.(*batch.Job)
newJob.Status = oldJob.Status newJob.Status = oldJob.Status
...@@ -75,7 +75,7 @@ func (jobStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runt ...@@ -75,7 +75,7 @@ func (jobStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runt
} }
// Validate validates a new job. // Validate validates a new job.
func (jobStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (jobStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
job := obj.(*batch.Job) job := obj.(*batch.Job)
// TODO: move UID generation earlier and do this in defaulting logic? // TODO: move UID generation earlier and do this in defaulting logic?
if job.Spec.ManualSelector == nil || *job.Spec.ManualSelector == false { if job.Spec.ManualSelector == nil || *job.Spec.ManualSelector == false {
...@@ -148,7 +148,7 @@ func (jobStrategy) AllowCreateOnUpdate() bool { ...@@ -148,7 +148,7 @@ func (jobStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (jobStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (jobStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
validationErrorList := validation.ValidateJob(obj.(*batch.Job)) validationErrorList := validation.ValidateJob(obj.(*batch.Job))
updateErrorList := validation.ValidateJobUpdate(obj.(*batch.Job), old.(*batch.Job)) updateErrorList := validation.ValidateJobUpdate(obj.(*batch.Job), old.(*batch.Job))
return append(validationErrorList, updateErrorList...) return append(validationErrorList, updateErrorList...)
...@@ -160,13 +160,13 @@ type jobStatusStrategy struct { ...@@ -160,13 +160,13 @@ type jobStatusStrategy struct {
var StatusStrategy = jobStatusStrategy{Strategy} var StatusStrategy = jobStatusStrategy{Strategy}
func (jobStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (jobStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newJob := obj.(*batch.Job) newJob := obj.(*batch.Job)
oldJob := old.(*batch.Job) oldJob := old.(*batch.Job)
newJob.Spec = oldJob.Spec newJob.Spec = oldJob.Spec
} }
func (jobStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (jobStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateJobUpdateStatus(obj.(*batch.Job), old.(*batch.Job)) return validation.ValidateJobUpdateStatus(obj.(*batch.Job), old.(*batch.Job))
} }
......
...@@ -17,22 +17,23 @@ limitations under the License. ...@@ -17,22 +17,23 @@ limitations under the License.
package certificates package certificates
import ( import (
"context"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/kubernetes/pkg/apis/certificates" "k8s.io/kubernetes/pkg/apis/certificates"
) )
// Registry is an interface for things that know how to store CSRs. // Registry is an interface for things that know how to store CSRs.
type Registry interface { type Registry interface {
ListCSRs(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*certificates.CertificateSigningRequestList, error) ListCSRs(ctx context.Context, options *metainternalversion.ListOptions) (*certificates.CertificateSigningRequestList, error)
CreateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc) error CreateCSR(ctx context.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc) error
UpdateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error UpdateCSR(ctx context.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
GetCSR(ctx genericapirequest.Context, csrID string, options *metav1.GetOptions) (*certificates.CertificateSigningRequest, error) GetCSR(ctx context.Context, csrID string, options *metav1.GetOptions) (*certificates.CertificateSigningRequest, error)
DeleteCSR(ctx genericapirequest.Context, csrID string) error DeleteCSR(ctx context.Context, csrID string) error
WatchCSRs(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchCSRs(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListCSRs(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*certificates.CertificateSigningRequestList, error) { func (s *storage) ListCSRs(ctx context.Context, options *metainternalversion.ListOptions) (*certificates.CertificateSigningRequestList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -55,21 +56,21 @@ func (s *storage) ListCSRs(ctx genericapirequest.Context, options *metainternalv ...@@ -55,21 +56,21 @@ func (s *storage) ListCSRs(ctx genericapirequest.Context, options *metainternalv
return obj.(*certificates.CertificateSigningRequestList), nil return obj.(*certificates.CertificateSigningRequestList), nil
} }
func (s *storage) CreateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc) error { func (s *storage) CreateCSR(ctx context.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc) error {
_, err := s.Create(ctx, csr, createValidation, false) _, err := s.Create(ctx, csr, createValidation, false)
return err return err
} }
func (s *storage) UpdateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error { func (s *storage) UpdateCSR(ctx context.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
_, _, err := s.Update(ctx, csr.Name, rest.DefaultUpdatedObjectInfo(csr), createValidation, updateValidation) _, _, err := s.Update(ctx, csr.Name, rest.DefaultUpdatedObjectInfo(csr), createValidation, updateValidation)
return err return err
} }
func (s *storage) WatchCSRs(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchCSRs(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetCSR(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*certificates.CertificateSigningRequest, error) { func (s *storage) GetCSR(ctx context.Context, name string, options *metav1.GetOptions) (*certificates.CertificateSigningRequest, error) {
obj, err := s.Get(ctx, name, options) obj, err := s.Get(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -77,7 +78,7 @@ func (s *storage) GetCSR(ctx genericapirequest.Context, name string, options *me ...@@ -77,7 +78,7 @@ func (s *storage) GetCSR(ctx genericapirequest.Context, name string, options *me
return obj.(*certificates.CertificateSigningRequest), nil return obj.(*certificates.CertificateSigningRequest), nil
} }
func (s *storage) DeleteCSR(ctx genericapirequest.Context, name string) error { func (s *storage) DeleteCSR(ctx context.Context, name string) error {
_, _, err := s.Delete(ctx, name, nil) _, _, err := s.Delete(ctx, name, nil)
return err return err
} }
...@@ -16,7 +16,6 @@ go_library( ...@@ -16,7 +16,6 @@ go_library(
"//pkg/printers/storage:go_default_library", "//pkg/printers/storage:go_default_library",
"//pkg/registry/certificates/certificates:go_default_library", "//pkg/registry/certificates/certificates:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,8 +17,9 @@ limitations under the License. ...@@ -17,8 +17,9 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -83,7 +84,7 @@ func (r *StatusREST) New() runtime.Object { ...@@ -83,7 +84,7 @@ func (r *StatusREST) New() runtime.Object {
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -97,6 +98,6 @@ func (r *ApprovalREST) New() runtime.Object { ...@@ -97,6 +98,6 @@ func (r *ApprovalREST) New() runtime.Object {
} }
// Update alters the approval subset of an object. // Update alters the approval subset of an object.
func (r *ApprovalREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *ApprovalREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package certificates package certificates
import ( import (
"context"
"fmt" "fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
...@@ -51,7 +52,7 @@ func (csrStrategy) AllowCreateOnUpdate() bool { ...@@ -51,7 +52,7 @@ func (csrStrategy) AllowCreateOnUpdate() bool {
// PrepareForCreate clears fields that are not allowed to be set by end users // PrepareForCreate clears fields that are not allowed to be set by end users
// on creation. // on creation.
func (csrStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (csrStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
csr := obj.(*certificates.CertificateSigningRequest) csr := obj.(*certificates.CertificateSigningRequest)
// Clear any user-specified info // Clear any user-specified info
...@@ -79,7 +80,7 @@ func (csrStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.O ...@@ -79,7 +80,7 @@ func (csrStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.O
// PrepareForUpdate clears fields that are not allowed to be set by end users // PrepareForUpdate clears fields that are not allowed to be set by end users
// on update. Certificate requests are immutable after creation except via subresources. // on update. Certificate requests are immutable after creation except via subresources.
func (csrStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (csrStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newCSR := obj.(*certificates.CertificateSigningRequest) newCSR := obj.(*certificates.CertificateSigningRequest)
oldCSR := old.(*certificates.CertificateSigningRequest) oldCSR := old.(*certificates.CertificateSigningRequest)
...@@ -88,7 +89,7 @@ func (csrStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runt ...@@ -88,7 +89,7 @@ func (csrStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runt
} }
// Validate validates a new CSR. Validation must check for a correct signature. // Validate validates a new CSR. Validation must check for a correct signature.
func (csrStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (csrStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
csr := obj.(*certificates.CertificateSigningRequest) csr := obj.(*certificates.CertificateSigningRequest)
return validation.ValidateCertificateSigningRequest(csr) return validation.ValidateCertificateSigningRequest(csr)
} }
...@@ -97,7 +98,7 @@ func (csrStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) f ...@@ -97,7 +98,7 @@ func (csrStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) f
func (csrStrategy) Canonicalize(obj runtime.Object) {} func (csrStrategy) Canonicalize(obj runtime.Object) {}
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (csrStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (csrStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
oldCSR := old.(*certificates.CertificateSigningRequest) oldCSR := old.(*certificates.CertificateSigningRequest)
newCSR := obj.(*certificates.CertificateSigningRequest) newCSR := obj.(*certificates.CertificateSigningRequest)
return validation.ValidateCertificateSigningRequestUpdate(newCSR, oldCSR) return validation.ValidateCertificateSigningRequestUpdate(newCSR, oldCSR)
...@@ -112,7 +113,7 @@ func (csrStrategy) AllowUnconditionalUpdate() bool { ...@@ -112,7 +113,7 @@ func (csrStrategy) AllowUnconditionalUpdate() bool {
return true return true
} }
func (s csrStrategy) Export(ctx genericapirequest.Context, obj runtime.Object, exact bool) error { func (s csrStrategy) Export(ctx context.Context, obj runtime.Object, exact bool) error {
csr, ok := obj.(*certificates.CertificateSigningRequest) csr, ok := obj.(*certificates.CertificateSigningRequest)
if !ok { if !ok {
// unexpected programmer error // unexpected programmer error
...@@ -134,7 +135,7 @@ type csrStatusStrategy struct { ...@@ -134,7 +135,7 @@ type csrStatusStrategy struct {
var StatusStrategy = csrStatusStrategy{Strategy} var StatusStrategy = csrStatusStrategy{Strategy}
func (csrStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (csrStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newCSR := obj.(*certificates.CertificateSigningRequest) newCSR := obj.(*certificates.CertificateSigningRequest)
oldCSR := old.(*certificates.CertificateSigningRequest) oldCSR := old.(*certificates.CertificateSigningRequest)
...@@ -150,7 +151,7 @@ func (csrStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol ...@@ -150,7 +151,7 @@ func (csrStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol
} }
} }
func (csrStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (csrStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateCertificateSigningRequestUpdate(obj.(*certificates.CertificateSigningRequest), old.(*certificates.CertificateSigningRequest)) return validation.ValidateCertificateSigningRequestUpdate(obj.(*certificates.CertificateSigningRequest), old.(*certificates.CertificateSigningRequest))
} }
...@@ -168,7 +169,7 @@ var ApprovalStrategy = csrApprovalStrategy{Strategy} ...@@ -168,7 +169,7 @@ var ApprovalStrategy = csrApprovalStrategy{Strategy}
// PrepareForUpdate prepares the new certificate signing request by limiting // PrepareForUpdate prepares the new certificate signing request by limiting
// the data that is updated to only the conditions. Also, if there is no // the data that is updated to only the conditions. Also, if there is no
// existing LastUpdateTime on a condition, the current date/time will be set. // existing LastUpdateTime on a condition, the current date/time will be set.
func (csrApprovalStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (csrApprovalStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newCSR := obj.(*certificates.CertificateSigningRequest) newCSR := obj.(*certificates.CertificateSigningRequest)
oldCSR := old.(*certificates.CertificateSigningRequest) oldCSR := old.(*certificates.CertificateSigningRequest)
...@@ -186,6 +187,6 @@ func (csrApprovalStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ...@@ -186,6 +187,6 @@ func (csrApprovalStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj,
newCSR.Status = oldCSR.Status newCSR.Status = oldCSR.Status
} }
func (csrApprovalStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (csrApprovalStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateCertificateSigningRequestUpdate(obj.(*certificates.CertificateSigningRequest), old.(*certificates.CertificateSigningRequest)) return validation.ValidateCertificateSigningRequestUpdate(obj.(*certificates.CertificateSigningRequest), old.(*certificates.CertificateSigningRequest))
} }
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package certificates package certificates
import ( import (
"context"
"reflect" "reflect"
"testing" "testing"
...@@ -29,7 +30,7 @@ import ( ...@@ -29,7 +30,7 @@ import (
func TestStrategyCreate(t *testing.T) { func TestStrategyCreate(t *testing.T) {
tests := map[string]struct { tests := map[string]struct {
ctx genericapirequest.Context ctx context.Context
obj runtime.Object obj runtime.Object
expectedObj runtime.Object expectedObj runtime.Object
}{ }{
......
...@@ -22,7 +22,6 @@ go_library( ...@@ -22,7 +22,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
], ],
) )
......
...@@ -17,13 +17,13 @@ limitations under the License. ...@@ -17,13 +17,13 @@ limitations under the License.
package componentstatus package componentstatus
import ( import (
"context"
"fmt" "fmt"
"sync" "sync"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/probe" "k8s.io/kubernetes/pkg/probe"
...@@ -50,7 +50,7 @@ func (rs *REST) NewList() runtime.Object { ...@@ -50,7 +50,7 @@ func (rs *REST) NewList() runtime.Object {
// Returns the list of component status. Note that the label and field are both ignored. // Returns the list of component status. Note that the label and field are both ignored.
// Note that this call doesn't support labels or selectors. // Note that this call doesn't support labels or selectors.
func (rs *REST) List(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (runtime.Object, error) { func (rs *REST) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
servers := rs.GetServersToValidate() servers := rs.GetServersToValidate()
wait := sync.WaitGroup{} wait := sync.WaitGroup{}
...@@ -73,7 +73,7 @@ func (rs *REST) List(ctx genericapirequest.Context, options *metainternalversion ...@@ -73,7 +73,7 @@ func (rs *REST) List(ctx genericapirequest.Context, options *metainternalversion
return &api.ComponentStatusList{Items: reply}, nil return &api.ComponentStatusList{Items: reply}, nil
} }
func (rs *REST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (rs *REST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
servers := rs.GetServersToValidate() servers := rs.GetServersToValidate()
if server, ok := servers[name]; !ok { if server, ok := servers[name]; !ok {
......
...@@ -23,7 +23,6 @@ go_library( ...@@ -23,7 +23,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
......
...@@ -17,22 +17,23 @@ limitations under the License. ...@@ -17,22 +17,23 @@ limitations under the License.
package configmap package configmap
import ( import (
"context"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
) )
// Registry is an interface for things that know how to store ConfigMaps. // Registry is an interface for things that know how to store ConfigMaps.
type Registry interface { type Registry interface {
ListConfigMaps(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ConfigMapList, error) ListConfigMaps(ctx context.Context, options *metainternalversion.ListOptions) (*api.ConfigMapList, error)
WatchConfigMaps(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchConfigMaps(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
GetConfigMap(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.ConfigMap, error) GetConfigMap(ctx context.Context, name string, options *metav1.GetOptions) (*api.ConfigMap, error)
CreateConfigMap(ctx genericapirequest.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc) (*api.ConfigMap, error) CreateConfigMap(ctx context.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc) (*api.ConfigMap, error)
UpdateConfigMap(ctx genericapirequest.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ConfigMap, error) UpdateConfigMap(ctx context.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ConfigMap, error)
DeleteConfigMap(ctx genericapirequest.Context, name string) error DeleteConfigMap(ctx context.Context, name string) error
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListConfigMaps(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ConfigMapList, error) { func (s *storage) ListConfigMaps(ctx context.Context, options *metainternalversion.ListOptions) (*api.ConfigMapList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -55,11 +56,11 @@ func (s *storage) ListConfigMaps(ctx genericapirequest.Context, options *metaint ...@@ -55,11 +56,11 @@ func (s *storage) ListConfigMaps(ctx genericapirequest.Context, options *metaint
return obj.(*api.ConfigMapList), err return obj.(*api.ConfigMapList), err
} }
func (s *storage) WatchConfigMaps(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchConfigMaps(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetConfigMap(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.ConfigMap, error) { func (s *storage) GetConfigMap(ctx context.Context, name string, options *metav1.GetOptions) (*api.ConfigMap, error) {
obj, err := s.Get(ctx, name, options) obj, err := s.Get(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -68,7 +69,7 @@ func (s *storage) GetConfigMap(ctx genericapirequest.Context, name string, optio ...@@ -68,7 +69,7 @@ func (s *storage) GetConfigMap(ctx genericapirequest.Context, name string, optio
return obj.(*api.ConfigMap), nil return obj.(*api.ConfigMap), nil
} }
func (s *storage) CreateConfigMap(ctx genericapirequest.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc) (*api.ConfigMap, error) { func (s *storage) CreateConfigMap(ctx context.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc) (*api.ConfigMap, error) {
obj, err := s.Create(ctx, cfg, createValidation, false) obj, err := s.Create(ctx, cfg, createValidation, false)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -77,7 +78,7 @@ func (s *storage) CreateConfigMap(ctx genericapirequest.Context, cfg *api.Config ...@@ -77,7 +78,7 @@ func (s *storage) CreateConfigMap(ctx genericapirequest.Context, cfg *api.Config
return obj.(*api.ConfigMap), nil return obj.(*api.ConfigMap), nil
} }
func (s *storage) UpdateConfigMap(ctx genericapirequest.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ConfigMap, error) { func (s *storage) UpdateConfigMap(ctx context.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ConfigMap, error) {
obj, _, err := s.Update(ctx, cfg.Name, rest.DefaultUpdatedObjectInfo(cfg), createValidation, updateValidation) obj, _, err := s.Update(ctx, cfg.Name, rest.DefaultUpdatedObjectInfo(cfg), createValidation, updateValidation)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -86,7 +87,7 @@ func (s *storage) UpdateConfigMap(ctx genericapirequest.Context, cfg *api.Config ...@@ -86,7 +87,7 @@ func (s *storage) UpdateConfigMap(ctx genericapirequest.Context, cfg *api.Config
return obj.(*api.ConfigMap), nil return obj.(*api.ConfigMap), nil
} }
func (s *storage) DeleteConfigMap(ctx genericapirequest.Context, name string) error { func (s *storage) DeleteConfigMap(ctx context.Context, name string) error {
_, _, err := s.Delete(ctx, name, nil) _, _, err := s.Delete(ctx, name, nil)
return err return err
} }
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package configmap package configmap
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
...@@ -47,11 +48,11 @@ func (strategy) NamespaceScoped() bool { ...@@ -47,11 +48,11 @@ func (strategy) NamespaceScoped() bool {
return true return true
} }
func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
_ = obj.(*api.ConfigMap) _ = obj.(*api.ConfigMap)
} }
func (strategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
cfg := obj.(*api.ConfigMap) cfg := obj.(*api.ConfigMap)
return validation.ValidateConfigMap(cfg) return validation.ValidateConfigMap(cfg)
...@@ -65,7 +66,7 @@ func (strategy) AllowCreateOnUpdate() bool { ...@@ -65,7 +66,7 @@ func (strategy) AllowCreateOnUpdate() bool {
return false return false
} }
func (strategy) PrepareForUpdate(ctx genericapirequest.Context, newObj, oldObj runtime.Object) { func (strategy) PrepareForUpdate(ctx context.Context, newObj, oldObj runtime.Object) {
_ = oldObj.(*api.ConfigMap) _ = oldObj.(*api.ConfigMap)
_ = newObj.(*api.ConfigMap) _ = newObj.(*api.ConfigMap)
} }
...@@ -74,7 +75,7 @@ func (strategy) AllowUnconditionalUpdate() bool { ...@@ -74,7 +75,7 @@ func (strategy) AllowUnconditionalUpdate() bool {
return true return true
} }
func (strategy) ValidateUpdate(ctx genericapirequest.Context, newObj, oldObj runtime.Object) field.ErrorList { func (strategy) ValidateUpdate(ctx context.Context, newObj, oldObj runtime.Object) field.ErrorList {
oldCfg, newCfg := oldObj.(*api.ConfigMap), newObj.(*api.ConfigMap) oldCfg, newCfg := oldObj.(*api.ConfigMap), newObj.(*api.ConfigMap)
return validation.ValidateConfigMapUpdate(newCfg, oldCfg) return validation.ValidateConfigMapUpdate(newCfg, oldCfg)
......
...@@ -23,7 +23,6 @@ go_library( ...@@ -23,7 +23,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
......
...@@ -17,21 +17,22 @@ limitations under the License. ...@@ -17,21 +17,22 @@ limitations under the License.
package endpoint package endpoint
import ( import (
"context"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
) )
// Registry is an interface for things that know how to store endpoints. // Registry is an interface for things that know how to store endpoints.
type Registry interface { type Registry interface {
ListEndpoints(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.EndpointsList, error) ListEndpoints(ctx context.Context, options *metainternalversion.ListOptions) (*api.EndpointsList, error)
GetEndpoints(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.Endpoints, error) GetEndpoints(ctx context.Context, name string, options *metav1.GetOptions) (*api.Endpoints, error)
WatchEndpoints(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchEndpoints(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
UpdateEndpoints(ctx genericapirequest.Context, e *api.Endpoints, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error UpdateEndpoints(ctx context.Context, e *api.Endpoints, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
DeleteEndpoints(ctx genericapirequest.Context, name string) error DeleteEndpoints(ctx context.Context, name string) error
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -45,7 +46,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -45,7 +46,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListEndpoints(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.EndpointsList, error) { func (s *storage) ListEndpoints(ctx context.Context, options *metainternalversion.ListOptions) (*api.EndpointsList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -53,11 +54,11 @@ func (s *storage) ListEndpoints(ctx genericapirequest.Context, options *metainte ...@@ -53,11 +54,11 @@ func (s *storage) ListEndpoints(ctx genericapirequest.Context, options *metainte
return obj.(*api.EndpointsList), nil return obj.(*api.EndpointsList), nil
} }
func (s *storage) WatchEndpoints(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchEndpoints(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetEndpoints(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.Endpoints, error) { func (s *storage) GetEndpoints(ctx context.Context, name string, options *metav1.GetOptions) (*api.Endpoints, error) {
obj, err := s.Get(ctx, name, options) obj, err := s.Get(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -65,12 +66,12 @@ func (s *storage) GetEndpoints(ctx genericapirequest.Context, name string, optio ...@@ -65,12 +66,12 @@ func (s *storage) GetEndpoints(ctx genericapirequest.Context, name string, optio
return obj.(*api.Endpoints), nil return obj.(*api.Endpoints), nil
} }
func (s *storage) UpdateEndpoints(ctx genericapirequest.Context, endpoints *api.Endpoints, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error { func (s *storage) UpdateEndpoints(ctx context.Context, endpoints *api.Endpoints, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
_, _, err := s.Update(ctx, endpoints.Name, rest.DefaultUpdatedObjectInfo(endpoints), createValidation, updateValidation) _, _, err := s.Update(ctx, endpoints.Name, rest.DefaultUpdatedObjectInfo(endpoints), createValidation, updateValidation)
return err return err
} }
func (s *storage) DeleteEndpoints(ctx genericapirequest.Context, name string) error { func (s *storage) DeleteEndpoints(ctx context.Context, name string) error {
_, _, err := s.Delete(ctx, name, nil) _, _, err := s.Delete(ctx, name, nil)
return err return err
} }
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package endpoint package endpoint
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
endptspkg "k8s.io/kubernetes/pkg/api/endpoints" endptspkg "k8s.io/kubernetes/pkg/api/endpoints"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
...@@ -43,15 +44,15 @@ func (endpointsStrategy) NamespaceScoped() bool { ...@@ -43,15 +44,15 @@ func (endpointsStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears fields that are not allowed to be set by end users on creation. // PrepareForCreate clears fields that are not allowed to be set by end users on creation.
func (endpointsStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (endpointsStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (endpointsStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (endpointsStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
} }
// Validate validates a new endpoints. // Validate validates a new endpoints.
func (endpointsStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (endpointsStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
return validation.ValidateEndpoints(obj.(*api.Endpoints)) return validation.ValidateEndpoints(obj.(*api.Endpoints))
} }
...@@ -67,7 +68,7 @@ func (endpointsStrategy) AllowCreateOnUpdate() bool { ...@@ -67,7 +68,7 @@ func (endpointsStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (endpointsStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (endpointsStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
errorList := validation.ValidateEndpoints(obj.(*api.Endpoints)) errorList := validation.ValidateEndpoints(obj.(*api.Endpoints))
return append(errorList, validation.ValidateEndpointsUpdate(obj.(*api.Endpoints), old.(*api.Endpoints))...) return append(errorList, validation.ValidateEndpointsUpdate(obj.(*api.Endpoints), old.(*api.Endpoints))...)
} }
......
...@@ -21,7 +21,6 @@ go_library( ...@@ -21,7 +21,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
......
...@@ -17,13 +17,13 @@ limitations under the License. ...@@ -17,13 +17,13 @@ limitations under the License.
package event package event
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage"
...@@ -42,7 +42,7 @@ type eventStrategy struct { ...@@ -42,7 +42,7 @@ type eventStrategy struct {
// Event objects via the REST API. // Event objects via the REST API.
var Strategy = eventStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} var Strategy = eventStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
func (eventStrategy) DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) rest.GarbageCollectionPolicy { func (eventStrategy) DefaultGarbageCollectionPolicy(ctx context.Context) rest.GarbageCollectionPolicy {
return rest.Unsupported return rest.Unsupported
} }
...@@ -50,13 +50,13 @@ func (eventStrategy) NamespaceScoped() bool { ...@@ -50,13 +50,13 @@ func (eventStrategy) NamespaceScoped() bool {
return true return true
} }
func (eventStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (eventStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
} }
func (eventStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (eventStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
} }
func (eventStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (eventStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
event := obj.(*api.Event) event := obj.(*api.Event)
return validation.ValidateEvent(event) return validation.ValidateEvent(event)
} }
...@@ -69,7 +69,7 @@ func (eventStrategy) AllowCreateOnUpdate() bool { ...@@ -69,7 +69,7 @@ func (eventStrategy) AllowCreateOnUpdate() bool {
return true return true
} }
func (eventStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (eventStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
event := obj.(*api.Event) event := obj.(*api.Event)
return validation.ValidateEvent(event) return validation.ValidateEvent(event)
} }
......
...@@ -19,7 +19,6 @@ go_library( ...@@ -19,7 +19,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/uuid:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/uuid:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
) )
......
...@@ -17,10 +17,11 @@ limitations under the License. ...@@ -17,10 +17,11 @@ limitations under the License.
package limitrange package limitrange
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
...@@ -40,17 +41,17 @@ func (limitrangeStrategy) NamespaceScoped() bool { ...@@ -40,17 +41,17 @@ func (limitrangeStrategy) NamespaceScoped() bool {
return true return true
} }
func (limitrangeStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (limitrangeStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
limitRange := obj.(*api.LimitRange) limitRange := obj.(*api.LimitRange)
if len(limitRange.Name) == 0 { if len(limitRange.Name) == 0 {
limitRange.Name = string(uuid.NewUUID()) limitRange.Name = string(uuid.NewUUID())
} }
} }
func (limitrangeStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (limitrangeStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
} }
func (limitrangeStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (limitrangeStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
limitRange := obj.(*api.LimitRange) limitRange := obj.(*api.LimitRange)
return validation.ValidateLimitRange(limitRange) return validation.ValidateLimitRange(limitRange)
} }
...@@ -63,7 +64,7 @@ func (limitrangeStrategy) AllowCreateOnUpdate() bool { ...@@ -63,7 +64,7 @@ func (limitrangeStrategy) AllowCreateOnUpdate() bool {
return true return true
} }
func (limitrangeStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (limitrangeStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
limitRange := obj.(*api.LimitRange) limitRange := obj.(*api.LimitRange)
return validation.ValidateLimitRange(limitRange) return validation.ValidateLimitRange(limitRange)
} }
...@@ -72,7 +73,7 @@ func (limitrangeStrategy) AllowUnconditionalUpdate() bool { ...@@ -72,7 +73,7 @@ func (limitrangeStrategy) AllowUnconditionalUpdate() bool {
return true return true
} }
func (limitrangeStrategy) Export(genericapirequest.Context, runtime.Object, bool) error { func (limitrangeStrategy) Export(context.Context, runtime.Object, bool) error {
// Copied from OpenShift exporter // Copied from OpenShift exporter
// TODO: this needs to be fixed // TODO: this needs to be fixed
// limitrange.Strategy.PrepareForCreate(ctx, obj) // limitrange.Strategy.PrepareForCreate(ctx, obj)
......
...@@ -25,7 +25,6 @@ go_library( ...@@ -25,7 +25,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
......
...@@ -17,22 +17,23 @@ limitations under the License. ...@@ -17,22 +17,23 @@ limitations under the License.
package namespace package namespace
import ( import (
"context"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
) )
// Registry is an interface implemented by things that know how to store Namespace objects. // Registry is an interface implemented by things that know how to store Namespace objects.
type Registry interface { type Registry interface {
ListNamespaces(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.NamespaceList, error) ListNamespaces(ctx context.Context, options *metainternalversion.ListOptions) (*api.NamespaceList, error)
WatchNamespaces(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchNamespaces(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
GetNamespace(ctx genericapirequest.Context, namespaceID string, options *metav1.GetOptions) (*api.Namespace, error) GetNamespace(ctx context.Context, namespaceID string, options *metav1.GetOptions) (*api.Namespace, error)
CreateNamespace(ctx genericapirequest.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc) error CreateNamespace(ctx context.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc) error
UpdateNamespace(ctx genericapirequest.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error UpdateNamespace(ctx context.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
DeleteNamespace(ctx genericapirequest.Context, namespaceID string) error DeleteNamespace(ctx context.Context, namespaceID string) error
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListNamespaces(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.NamespaceList, error) { func (s *storage) ListNamespaces(ctx context.Context, options *metainternalversion.ListOptions) (*api.NamespaceList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -54,11 +55,11 @@ func (s *storage) ListNamespaces(ctx genericapirequest.Context, options *metaint ...@@ -54,11 +55,11 @@ func (s *storage) ListNamespaces(ctx genericapirequest.Context, options *metaint
return obj.(*api.NamespaceList), nil return obj.(*api.NamespaceList), nil
} }
func (s *storage) WatchNamespaces(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchNamespaces(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetNamespace(ctx genericapirequest.Context, namespaceName string, options *metav1.GetOptions) (*api.Namespace, error) { func (s *storage) GetNamespace(ctx context.Context, namespaceName string, options *metav1.GetOptions) (*api.Namespace, error) {
obj, err := s.Get(ctx, namespaceName, options) obj, err := s.Get(ctx, namespaceName, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -66,17 +67,17 @@ func (s *storage) GetNamespace(ctx genericapirequest.Context, namespaceName stri ...@@ -66,17 +67,17 @@ func (s *storage) GetNamespace(ctx genericapirequest.Context, namespaceName stri
return obj.(*api.Namespace), nil return obj.(*api.Namespace), nil
} }
func (s *storage) CreateNamespace(ctx genericapirequest.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc) error { func (s *storage) CreateNamespace(ctx context.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc) error {
_, err := s.Create(ctx, namespace, createValidation, false) _, err := s.Create(ctx, namespace, createValidation, false)
return err return err
} }
func (s *storage) UpdateNamespace(ctx genericapirequest.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error { func (s *storage) UpdateNamespace(ctx context.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
_, _, err := s.Update(ctx, namespace.Name, rest.DefaultUpdatedObjectInfo(namespace), createValidation, updateValidation) _, _, err := s.Update(ctx, namespace.Name, rest.DefaultUpdatedObjectInfo(namespace), createValidation, updateValidation)
return err return err
} }
func (s *storage) DeleteNamespace(ctx genericapirequest.Context, namespaceID string) error { func (s *storage) DeleteNamespace(ctx context.Context, namespaceID string) error {
_, _, err := s.Delete(ctx, namespaceID, nil) _, _, err := s.Delete(ctx, namespaceID, nil)
return err return err
} }
...@@ -40,7 +40,6 @@ go_library( ...@@ -40,7 +40,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"fmt" "fmt"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
...@@ -25,7 +26,6 @@ import ( ...@@ -25,7 +26,6 @@ import (
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -92,32 +92,32 @@ func (r *REST) NewList() runtime.Object { ...@@ -92,32 +92,32 @@ func (r *REST) NewList() runtime.Object {
return r.store.NewList() return r.store.NewList()
} }
func (r *REST) List(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (runtime.Object, error) { func (r *REST) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
return r.store.List(ctx, options) return r.store.List(ctx, options)
} }
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
return r.store.Create(ctx, obj, createValidation, includeUninitialized) return r.store.Create(ctx, obj, createValidation, includeUninitialized)
} }
func (r *REST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *REST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
func (r *REST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *REST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
func (r *REST) Watch(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (r *REST) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return r.store.Watch(ctx, options) return r.store.Watch(ctx, options)
} }
func (r *REST) Export(ctx genericapirequest.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) { func (r *REST) Export(ctx context.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) {
return r.store.Export(ctx, name, opts) return r.store.Export(ctx, name, opts)
} }
// Delete enforces life-cycle rules for namespace termination // Delete enforces life-cycle rules for namespace termination
func (r *REST) Delete(ctx genericapirequest.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) { func (r *REST) Delete(ctx context.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
nsObj, err := r.Get(ctx, name, &metav1.GetOptions{}) nsObj, err := r.Get(ctx, name, &metav1.GetOptions{})
if err != nil { if err != nil {
return nil, false, err return nil, false, err
...@@ -208,7 +208,7 @@ func (r *REST) Delete(ctx genericapirequest.Context, name string, options *metav ...@@ -208,7 +208,7 @@ func (r *REST) Delete(ctx genericapirequest.Context, name string, options *metav
return r.store.Delete(ctx, name, options) return r.store.Delete(ctx, name, options)
} }
func (e *REST) ConvertToTable(ctx genericapirequest.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) { func (e *REST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
return e.store.ConvertToTable(ctx, object, tableOptions) return e.store.ConvertToTable(ctx, object, tableOptions)
} }
...@@ -225,12 +225,12 @@ func (r *StatusREST) New() runtime.Object { ...@@ -225,12 +225,12 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -239,6 +239,6 @@ func (r *FinalizeREST) New() runtime.Object { ...@@ -239,6 +239,6 @@ func (r *FinalizeREST) New() runtime.Object {
} }
// Update alters the status finalizers subset of an object. // Update alters the status finalizers subset of an object.
func (r *FinalizeREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *FinalizeREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,13 +17,13 @@ limitations under the License. ...@@ -17,13 +17,13 @@ limitations under the License.
package namespace package namespace
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
apistorage "k8s.io/apiserver/pkg/storage" apistorage "k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
...@@ -48,7 +48,7 @@ func (namespaceStrategy) NamespaceScoped() bool { ...@@ -48,7 +48,7 @@ func (namespaceStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears fields that are not allowed to be set by end users on creation. // PrepareForCreate clears fields that are not allowed to be set by end users on creation.
func (namespaceStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (namespaceStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
// on create, status is active // on create, status is active
namespace := obj.(*api.Namespace) namespace := obj.(*api.Namespace)
namespace.Status = api.NamespaceStatus{ namespace.Status = api.NamespaceStatus{
...@@ -73,7 +73,7 @@ func (namespaceStrategy) PrepareForCreate(ctx genericapirequest.Context, obj run ...@@ -73,7 +73,7 @@ func (namespaceStrategy) PrepareForCreate(ctx genericapirequest.Context, obj run
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (namespaceStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (namespaceStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newNamespace := obj.(*api.Namespace) newNamespace := obj.(*api.Namespace)
oldNamespace := old.(*api.Namespace) oldNamespace := old.(*api.Namespace)
newNamespace.Spec.Finalizers = oldNamespace.Spec.Finalizers newNamespace.Spec.Finalizers = oldNamespace.Spec.Finalizers
...@@ -81,7 +81,7 @@ func (namespaceStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol ...@@ -81,7 +81,7 @@ func (namespaceStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol
} }
// Validate validates a new namespace. // Validate validates a new namespace.
func (namespaceStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (namespaceStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
namespace := obj.(*api.Namespace) namespace := obj.(*api.Namespace)
return validation.ValidateNamespace(namespace) return validation.ValidateNamespace(namespace)
} }
...@@ -96,7 +96,7 @@ func (namespaceStrategy) AllowCreateOnUpdate() bool { ...@@ -96,7 +96,7 @@ func (namespaceStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (namespaceStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (namespaceStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
errorList := validation.ValidateNamespace(obj.(*api.Namespace)) errorList := validation.ValidateNamespace(obj.(*api.Namespace))
return append(errorList, validation.ValidateNamespaceUpdate(obj.(*api.Namespace), old.(*api.Namespace))...) return append(errorList, validation.ValidateNamespaceUpdate(obj.(*api.Namespace), old.(*api.Namespace))...)
} }
...@@ -111,13 +111,13 @@ type namespaceStatusStrategy struct { ...@@ -111,13 +111,13 @@ type namespaceStatusStrategy struct {
var StatusStrategy = namespaceStatusStrategy{Strategy} var StatusStrategy = namespaceStatusStrategy{Strategy}
func (namespaceStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (namespaceStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newNamespace := obj.(*api.Namespace) newNamespace := obj.(*api.Namespace)
oldNamespace := old.(*api.Namespace) oldNamespace := old.(*api.Namespace)
newNamespace.Spec = oldNamespace.Spec newNamespace.Spec = oldNamespace.Spec
} }
func (namespaceStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (namespaceStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateNamespaceStatusUpdate(obj.(*api.Namespace), old.(*api.Namespace)) return validation.ValidateNamespaceStatusUpdate(obj.(*api.Namespace), old.(*api.Namespace))
} }
...@@ -127,12 +127,12 @@ type namespaceFinalizeStrategy struct { ...@@ -127,12 +127,12 @@ type namespaceFinalizeStrategy struct {
var FinalizeStrategy = namespaceFinalizeStrategy{Strategy} var FinalizeStrategy = namespaceFinalizeStrategy{Strategy}
func (namespaceFinalizeStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (namespaceFinalizeStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateNamespaceFinalizeUpdate(obj.(*api.Namespace), old.(*api.Namespace)) return validation.ValidateNamespaceFinalizeUpdate(obj.(*api.Namespace), old.(*api.Namespace))
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (namespaceFinalizeStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (namespaceFinalizeStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newNamespace := obj.(*api.Namespace) newNamespace := obj.(*api.Namespace)
oldNamespace := old.(*api.Namespace) oldNamespace := old.(*api.Namespace)
newNamespace.Status = oldNamespace.Status newNamespace.Status = oldNamespace.Status
......
...@@ -30,7 +30,6 @@ go_library( ...@@ -30,7 +30,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
......
...@@ -17,22 +17,23 @@ limitations under the License. ...@@ -17,22 +17,23 @@ limitations under the License.
package node package node
import ( import (
"context"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
) )
// Registry is an interface for things that know how to store node. // Registry is an interface for things that know how to store node.
type Registry interface { type Registry interface {
ListNodes(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.NodeList, error) ListNodes(ctx context.Context, options *metainternalversion.ListOptions) (*api.NodeList, error)
CreateNode(ctx genericapirequest.Context, node *api.Node, createValidation rest.ValidateObjectFunc) error CreateNode(ctx context.Context, node *api.Node, createValidation rest.ValidateObjectFunc) error
UpdateNode(ctx genericapirequest.Context, node *api.Node, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error UpdateNode(ctx context.Context, node *api.Node, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
GetNode(ctx genericapirequest.Context, nodeID string, options *metav1.GetOptions) (*api.Node, error) GetNode(ctx context.Context, nodeID string, options *metav1.GetOptions) (*api.Node, error)
DeleteNode(ctx genericapirequest.Context, nodeID string) error DeleteNode(ctx context.Context, nodeID string) error
WatchNodes(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchNodes(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListNodes(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.NodeList, error) { func (s *storage) ListNodes(ctx context.Context, options *metainternalversion.ListOptions) (*api.NodeList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -55,21 +56,21 @@ func (s *storage) ListNodes(ctx genericapirequest.Context, options *metainternal ...@@ -55,21 +56,21 @@ func (s *storage) ListNodes(ctx genericapirequest.Context, options *metainternal
return obj.(*api.NodeList), nil return obj.(*api.NodeList), nil
} }
func (s *storage) CreateNode(ctx genericapirequest.Context, node *api.Node, createValidation rest.ValidateObjectFunc) error { func (s *storage) CreateNode(ctx context.Context, node *api.Node, createValidation rest.ValidateObjectFunc) error {
_, err := s.Create(ctx, node, createValidation, false) _, err := s.Create(ctx, node, createValidation, false)
return err return err
} }
func (s *storage) UpdateNode(ctx genericapirequest.Context, node *api.Node, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error { func (s *storage) UpdateNode(ctx context.Context, node *api.Node, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
_, _, err := s.Update(ctx, node.Name, rest.DefaultUpdatedObjectInfo(node), createValidation, updateValidation) _, _, err := s.Update(ctx, node.Name, rest.DefaultUpdatedObjectInfo(node), createValidation, updateValidation)
return err return err
} }
func (s *storage) WatchNodes(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchNodes(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetNode(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.Node, error) { func (s *storage) GetNode(ctx context.Context, name string, options *metav1.GetOptions) (*api.Node, error) {
obj, err := s.Get(ctx, name, options) obj, err := s.Get(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -77,7 +78,7 @@ func (s *storage) GetNode(ctx genericapirequest.Context, name string, options *m ...@@ -77,7 +78,7 @@ func (s *storage) GetNode(ctx genericapirequest.Context, name string, options *m
return obj.(*api.Node), nil return obj.(*api.Node), nil
} }
func (s *storage) DeleteNode(ctx genericapirequest.Context, name string) error { func (s *storage) DeleteNode(ctx context.Context, name string) error {
_, _, err := s.Delete(ctx, name, nil) _, _, err := s.Delete(ctx, name, nil)
return err return err
} }
...@@ -17,7 +17,6 @@ go_library( ...@@ -17,7 +17,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/proxy:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/proxy:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
], ],
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package node package node
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"net/url" "net/url"
...@@ -24,7 +25,6 @@ import ( ...@@ -24,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/util/proxy" "k8s.io/apimachinery/pkg/util/proxy"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
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/registry/rest"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
...@@ -61,7 +61,7 @@ func (r *ProxyREST) NewConnectOptions() (runtime.Object, bool, string) { ...@@ -61,7 +61,7 @@ func (r *ProxyREST) NewConnectOptions() (runtime.Object, bool, string) {
} }
// Connect returns a handler for the node proxy // Connect returns a handler for the node proxy
func (r *ProxyREST) Connect(ctx genericapirequest.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)
if !ok { if !ok {
return nil, fmt.Errorf("Invalid options object: %#v", opts) return nil, fmt.Errorf("Invalid options object: %#v", opts)
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"net/url" "net/url"
...@@ -63,12 +64,12 @@ func (r *StatusREST) New() runtime.Object { ...@@ -63,12 +64,12 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -137,7 +138,7 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, kubeletClientConfig client ...@@ -137,7 +138,7 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, kubeletClientConfig client
var _ = rest.Redirector(&REST{}) var _ = rest.Redirector(&REST{})
// ResourceLocation returns a URL to which one can send traffic for the specified node. // ResourceLocation returns a URL to which one can send traffic for the specified node.
func (r *REST) ResourceLocation(ctx genericapirequest.Context, id string) (*url.URL, http.RoundTripper, error) { func (r *REST) ResourceLocation(ctx context.Context, id string) (*url.URL, http.RoundTripper, error) {
return node.ResourceLocation(r, r.connection, r.proxyTransport, ctx, id) return node.ResourceLocation(r, r.connection, r.proxyTransport, ctx, id)
} }
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package node package node
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
...@@ -30,7 +31,6 @@ import ( ...@@ -30,7 +31,6 @@ import (
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
utilnet "k8s.io/apimachinery/pkg/util/net" utilnet "k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
pkgstorage "k8s.io/apiserver/pkg/storage" pkgstorage "k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
...@@ -63,7 +63,7 @@ func (nodeStrategy) AllowCreateOnUpdate() bool { ...@@ -63,7 +63,7 @@ func (nodeStrategy) AllowCreateOnUpdate() bool {
} }
// PrepareForCreate clears fields that are not allowed to be set by end users on creation. // PrepareForCreate clears fields that are not allowed to be set by end users on creation.
func (nodeStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (nodeStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
node := obj.(*api.Node) node := obj.(*api.Node)
// Nodes allow *all* fields, including status, to be set on create. // Nodes allow *all* fields, including status, to be set on create.
...@@ -73,7 +73,7 @@ func (nodeStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime. ...@@ -73,7 +73,7 @@ func (nodeStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (nodeStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (nodeStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newNode := obj.(*api.Node) newNode := obj.(*api.Node)
oldNode := old.(*api.Node) oldNode := old.(*api.Node)
newNode.Status = oldNode.Status newNode.Status = oldNode.Status
...@@ -85,7 +85,7 @@ func (nodeStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old run ...@@ -85,7 +85,7 @@ func (nodeStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old run
} }
// Validate validates a new node. // Validate validates a new node.
func (nodeStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (nodeStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
node := obj.(*api.Node) node := obj.(*api.Node)
return validation.ValidateNode(node) return validation.ValidateNode(node)
} }
...@@ -95,7 +95,7 @@ func (nodeStrategy) Canonicalize(obj runtime.Object) { ...@@ -95,7 +95,7 @@ func (nodeStrategy) Canonicalize(obj runtime.Object) {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (nodeStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (nodeStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
errorList := validation.ValidateNode(obj.(*api.Node)) errorList := validation.ValidateNode(obj.(*api.Node))
return append(errorList, validation.ValidateNodeUpdate(obj.(*api.Node), old.(*api.Node))...) return append(errorList, validation.ValidateNodeUpdate(obj.(*api.Node), old.(*api.Node))...)
} }
...@@ -104,7 +104,7 @@ func (nodeStrategy) AllowUnconditionalUpdate() bool { ...@@ -104,7 +104,7 @@ func (nodeStrategy) AllowUnconditionalUpdate() bool {
return true return true
} }
func (ns nodeStrategy) Export(ctx genericapirequest.Context, obj runtime.Object, exact bool) error { func (ns nodeStrategy) Export(ctx context.Context, obj runtime.Object, exact bool) error {
n, ok := obj.(*api.Node) n, ok := obj.(*api.Node)
if !ok { if !ok {
// unexpected programmer error // unexpected programmer error
...@@ -126,18 +126,18 @@ type nodeStatusStrategy struct { ...@@ -126,18 +126,18 @@ type nodeStatusStrategy struct {
var StatusStrategy = nodeStatusStrategy{Strategy} var StatusStrategy = nodeStatusStrategy{Strategy}
func (nodeStatusStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (nodeStatusStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
_ = obj.(*api.Node) _ = obj.(*api.Node)
// Nodes allow *all* fields, including status, to be set on create. // Nodes allow *all* fields, including status, to be set on create.
} }
func (nodeStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (nodeStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newNode := obj.(*api.Node) newNode := obj.(*api.Node)
oldNode := old.(*api.Node) oldNode := old.(*api.Node)
newNode.Spec = oldNode.Spec newNode.Spec = oldNode.Spec
} }
func (nodeStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (nodeStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateNodeUpdate(obj.(*api.Node), old.(*api.Node)) return validation.ValidateNodeUpdate(obj.(*api.Node), old.(*api.Node))
} }
...@@ -147,7 +147,7 @@ func (nodeStatusStrategy) Canonicalize(obj runtime.Object) { ...@@ -147,7 +147,7 @@ func (nodeStatusStrategy) Canonicalize(obj runtime.Object) {
// ResourceGetter is an interface for retrieving resources by ResourceLocation. // ResourceGetter is an interface for retrieving resources by ResourceLocation.
type ResourceGetter interface { type ResourceGetter interface {
Get(genericapirequest.Context, string, *metav1.GetOptions) (runtime.Object, error) Get(context.Context, string, *metav1.GetOptions) (runtime.Object, error)
} }
// NodeToSelectableFields returns a field set that represents the object. // NodeToSelectableFields returns a field set that represents the object.
...@@ -185,7 +185,7 @@ func NodeNameTriggerFunc(obj runtime.Object) []pkgstorage.MatchValue { ...@@ -185,7 +185,7 @@ func NodeNameTriggerFunc(obj runtime.Object) []pkgstorage.MatchValue {
} }
// ResourceLocation returns a URL and transport which one can use to send traffic for the specified node. // ResourceLocation returns a URL and transport which one can use to send traffic for the specified node.
func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGetter, proxyTransport http.RoundTripper, ctx genericapirequest.Context, id string) (*url.URL, http.RoundTripper, error) { func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGetter, proxyTransport http.RoundTripper, ctx context.Context, id string) (*url.URL, http.RoundTripper, error) {
schemeReq, name, portReq, valid := utilnet.SplitSchemeNamePort(id) schemeReq, name, portReq, valid := utilnet.SplitSchemeNamePort(id)
if !valid { if !valid {
return nil, nil, errors.NewBadRequest(fmt.Sprintf("invalid node request %q", id)) return nil, nil, errors.NewBadRequest(fmt.Sprintf("invalid node request %q", id))
......
...@@ -23,7 +23,6 @@ go_library( ...@@ -23,7 +23,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
......
...@@ -40,7 +40,6 @@ go_library( ...@@ -40,7 +40,6 @@ go_library(
"//pkg/registry/core/persistentvolume:go_default_library", "//pkg/registry/core/persistentvolume:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package storage package storage
import ( import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -78,11 +79,11 @@ func (r *StatusREST) New() runtime.Object { ...@@ -78,11 +79,11 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,13 +17,13 @@ limitations under the License. ...@@ -17,13 +17,13 @@ limitations under the License.
package persistentvolume package persistentvolume
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
...@@ -49,14 +49,14 @@ func (persistentvolumeStrategy) NamespaceScoped() bool { ...@@ -49,14 +49,14 @@ func (persistentvolumeStrategy) NamespaceScoped() bool {
} }
// ResetBeforeCreate clears the Status field which is not allowed to be set by end users on creation. // ResetBeforeCreate clears the Status field which is not allowed to be set by end users on creation.
func (persistentvolumeStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (persistentvolumeStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
pv := obj.(*api.PersistentVolume) pv := obj.(*api.PersistentVolume)
pv.Status = api.PersistentVolumeStatus{} pv.Status = api.PersistentVolumeStatus{}
pvutil.DropDisabledAlphaFields(&pv.Spec) pvutil.DropDisabledAlphaFields(&pv.Spec)
} }
func (persistentvolumeStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (persistentvolumeStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
persistentvolume := obj.(*api.PersistentVolume) persistentvolume := obj.(*api.PersistentVolume)
errorList := validation.ValidatePersistentVolume(persistentvolume) errorList := validation.ValidatePersistentVolume(persistentvolume)
return append(errorList, volumevalidation.ValidatePersistentVolume(persistentvolume)...) return append(errorList, volumevalidation.ValidatePersistentVolume(persistentvolume)...)
...@@ -71,7 +71,7 @@ func (persistentvolumeStrategy) AllowCreateOnUpdate() bool { ...@@ -71,7 +71,7 @@ func (persistentvolumeStrategy) AllowCreateOnUpdate() bool {
} }
// PrepareForUpdate sets the Status fields which is not allowed to be set by an end user updating a PV // PrepareForUpdate sets the Status fields which is not allowed to be set by an end user updating a PV
func (persistentvolumeStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (persistentvolumeStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newPv := obj.(*api.PersistentVolume) newPv := obj.(*api.PersistentVolume)
oldPv := old.(*api.PersistentVolume) oldPv := old.(*api.PersistentVolume)
newPv.Status = oldPv.Status newPv.Status = oldPv.Status
...@@ -80,7 +80,7 @@ func (persistentvolumeStrategy) PrepareForUpdate(ctx genericapirequest.Context, ...@@ -80,7 +80,7 @@ func (persistentvolumeStrategy) PrepareForUpdate(ctx genericapirequest.Context,
pvutil.DropDisabledAlphaFields(&oldPv.Spec) pvutil.DropDisabledAlphaFields(&oldPv.Spec)
} }
func (persistentvolumeStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (persistentvolumeStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
newPv := obj.(*api.PersistentVolume) newPv := obj.(*api.PersistentVolume)
errorList := validation.ValidatePersistentVolume(newPv) errorList := validation.ValidatePersistentVolume(newPv)
errorList = append(errorList, volumevalidation.ValidatePersistentVolume(newPv)...) errorList = append(errorList, volumevalidation.ValidatePersistentVolume(newPv)...)
...@@ -98,13 +98,13 @@ type persistentvolumeStatusStrategy struct { ...@@ -98,13 +98,13 @@ type persistentvolumeStatusStrategy struct {
var StatusStrategy = persistentvolumeStatusStrategy{Strategy} var StatusStrategy = persistentvolumeStatusStrategy{Strategy}
// PrepareForUpdate sets the Spec field which is not allowed to be changed when updating a PV's Status // PrepareForUpdate sets the Spec field which is not allowed to be changed when updating a PV's Status
func (persistentvolumeStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (persistentvolumeStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newPv := obj.(*api.PersistentVolume) newPv := obj.(*api.PersistentVolume)
oldPv := old.(*api.PersistentVolume) oldPv := old.(*api.PersistentVolume)
newPv.Spec = oldPv.Spec newPv.Spec = oldPv.Spec
} }
func (persistentvolumeStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (persistentvolumeStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidatePersistentVolumeStatusUpdate(obj.(*api.PersistentVolume), old.(*api.PersistentVolume)) return validation.ValidatePersistentVolumeStatusUpdate(obj.(*api.PersistentVolume), old.(*api.PersistentVolume))
} }
......
...@@ -22,7 +22,6 @@ go_library( ...@@ -22,7 +22,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
......
...@@ -40,7 +40,6 @@ go_library( ...@@ -40,7 +40,6 @@ go_library(
"//pkg/registry/core/persistentvolumeclaim:go_default_library", "//pkg/registry/core/persistentvolumeclaim:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package storage package storage
import ( import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -78,11 +79,11 @@ func (r *StatusREST) New() runtime.Object { ...@@ -78,11 +79,11 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,13 +17,13 @@ limitations under the License. ...@@ -17,13 +17,13 @@ limitations under the License.
package persistentvolumeclaim package persistentvolumeclaim
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
...@@ -48,14 +48,14 @@ func (persistentvolumeclaimStrategy) NamespaceScoped() bool { ...@@ -48,14 +48,14 @@ func (persistentvolumeclaimStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the Status field which is not allowed to be set by end users on creation. // PrepareForCreate clears the Status field which is not allowed to be set by end users on creation.
func (persistentvolumeclaimStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (persistentvolumeclaimStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
pvc := obj.(*api.PersistentVolumeClaim) pvc := obj.(*api.PersistentVolumeClaim)
pvc.Status = api.PersistentVolumeClaimStatus{} pvc.Status = api.PersistentVolumeClaimStatus{}
pvcutil.DropDisabledAlphaFields(&pvc.Spec) pvcutil.DropDisabledAlphaFields(&pvc.Spec)
} }
func (persistentvolumeclaimStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (persistentvolumeclaimStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
pvc := obj.(*api.PersistentVolumeClaim) pvc := obj.(*api.PersistentVolumeClaim)
return validation.ValidatePersistentVolumeClaim(pvc) return validation.ValidatePersistentVolumeClaim(pvc)
} }
...@@ -69,7 +69,7 @@ func (persistentvolumeclaimStrategy) AllowCreateOnUpdate() bool { ...@@ -69,7 +69,7 @@ func (persistentvolumeclaimStrategy) AllowCreateOnUpdate() bool {
} }
// PrepareForUpdate sets the Status field which is not allowed to be set by end users on update // PrepareForUpdate sets the Status field which is not allowed to be set by end users on update
func (persistentvolumeclaimStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (persistentvolumeclaimStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newPvc := obj.(*api.PersistentVolumeClaim) newPvc := obj.(*api.PersistentVolumeClaim)
oldPvc := old.(*api.PersistentVolumeClaim) oldPvc := old.(*api.PersistentVolumeClaim)
newPvc.Status = oldPvc.Status newPvc.Status = oldPvc.Status
...@@ -78,7 +78,7 @@ func (persistentvolumeclaimStrategy) PrepareForUpdate(ctx genericapirequest.Cont ...@@ -78,7 +78,7 @@ func (persistentvolumeclaimStrategy) PrepareForUpdate(ctx genericapirequest.Cont
pvcutil.DropDisabledAlphaFields(&oldPvc.Spec) pvcutil.DropDisabledAlphaFields(&oldPvc.Spec)
} }
func (persistentvolumeclaimStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (persistentvolumeclaimStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
errorList := validation.ValidatePersistentVolumeClaim(obj.(*api.PersistentVolumeClaim)) errorList := validation.ValidatePersistentVolumeClaim(obj.(*api.PersistentVolumeClaim))
return append(errorList, validation.ValidatePersistentVolumeClaimUpdate(obj.(*api.PersistentVolumeClaim), old.(*api.PersistentVolumeClaim))...) return append(errorList, validation.ValidatePersistentVolumeClaimUpdate(obj.(*api.PersistentVolumeClaim), old.(*api.PersistentVolumeClaim))...)
} }
...@@ -94,13 +94,13 @@ type persistentvolumeclaimStatusStrategy struct { ...@@ -94,13 +94,13 @@ type persistentvolumeclaimStatusStrategy struct {
var StatusStrategy = persistentvolumeclaimStatusStrategy{Strategy} var StatusStrategy = persistentvolumeclaimStatusStrategy{Strategy}
// PrepareForUpdate sets the Spec field which is not allowed to be changed when updating a PV's Status // PrepareForUpdate sets the Spec field which is not allowed to be changed when updating a PV's Status
func (persistentvolumeclaimStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (persistentvolumeclaimStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newPv := obj.(*api.PersistentVolumeClaim) newPv := obj.(*api.PersistentVolumeClaim)
oldPv := old.(*api.PersistentVolumeClaim) oldPv := old.(*api.PersistentVolumeClaim)
newPv.Spec = oldPv.Spec newPv.Spec = oldPv.Spec
} }
func (persistentvolumeclaimStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (persistentvolumeclaimStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidatePersistentVolumeClaimStatusUpdate(obj.(*api.PersistentVolumeClaim), old.(*api.PersistentVolumeClaim)) return validation.ValidatePersistentVolumeClaimStatusUpdate(obj.(*api.PersistentVolumeClaim), old.(*api.PersistentVolumeClaim))
} }
......
...@@ -30,7 +30,6 @@ go_library( ...@@ -30,7 +30,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library", "//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/features:go_default_library", "//vendor/k8s.io/apiserver/pkg/features:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
......
...@@ -23,7 +23,6 @@ go_library( ...@@ -23,7 +23,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/proxy:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/proxy:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/features:go_default_library", "//vendor/k8s.io/apiserver/pkg/features:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/rest:go_default_library",
......
...@@ -17,11 +17,11 @@ limitations under the License. ...@@ -17,11 +17,11 @@ limitations under the License.
package rest package rest
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
genericrest "k8s.io/apiserver/pkg/registry/generic/rest" genericrest "k8s.io/apiserver/pkg/registry/generic/rest"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
...@@ -62,7 +62,7 @@ func (r *LogREST) ProducesObject(verb string) interface{} { ...@@ -62,7 +62,7 @@ func (r *LogREST) ProducesObject(verb string) interface{} {
} }
// Get retrieves a runtime.Object that will stream the contents of the pod log // Get retrieves a runtime.Object that will stream the contents of the pod log
func (r *LogREST) Get(ctx genericapirequest.Context, name string, opts runtime.Object) (runtime.Object, error) { func (r *LogREST) Get(ctx context.Context, name string, opts runtime.Object) (runtime.Object, error) {
logOpts, ok := opts.(*api.PodLogOptions) logOpts, ok := opts.(*api.PodLogOptions)
if !ok { if !ok {
return nil, fmt.Errorf("invalid options object: %#v", opts) return nil, fmt.Errorf("invalid options object: %#v", opts)
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package rest package rest
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"net/url" "net/url"
...@@ -24,7 +25,6 @@ import ( ...@@ -24,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/util/proxy" "k8s.io/apimachinery/pkg/util/proxy"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
genericfeatures "k8s.io/apiserver/pkg/features" genericfeatures "k8s.io/apiserver/pkg/features"
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/registry/rest"
...@@ -62,7 +62,7 @@ func (r *ProxyREST) NewConnectOptions() (runtime.Object, bool, string) { ...@@ -62,7 +62,7 @@ func (r *ProxyREST) NewConnectOptions() (runtime.Object, bool, string) {
} }
// Connect returns a handler for the pod proxy // Connect returns a handler for the pod proxy
func (r *ProxyREST) Connect(ctx genericapirequest.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.PodProxyOptions) proxyOpts, ok := opts.(*api.PodProxyOptions)
if !ok { if !ok {
return nil, fmt.Errorf("Invalid options object: %#v", opts) return nil, fmt.Errorf("Invalid options object: %#v", opts)
...@@ -94,7 +94,7 @@ func (r *AttachREST) New() runtime.Object { ...@@ -94,7 +94,7 @@ func (r *AttachREST) New() runtime.Object {
} }
// Connect returns a handler for the pod exec proxy // Connect returns a handler for the pod exec proxy
func (r *AttachREST) Connect(ctx genericapirequest.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) { func (r *AttachREST) Connect(ctx context.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) {
attachOpts, ok := opts.(*api.PodAttachOptions) attachOpts, ok := opts.(*api.PodAttachOptions)
if !ok { if !ok {
return nil, fmt.Errorf("Invalid options object: %#v", opts) return nil, fmt.Errorf("Invalid options object: %#v", opts)
...@@ -131,7 +131,7 @@ func (r *ExecREST) New() runtime.Object { ...@@ -131,7 +131,7 @@ func (r *ExecREST) New() runtime.Object {
} }
// Connect returns a handler for the pod exec proxy // Connect returns a handler for the pod exec proxy
func (r *ExecREST) Connect(ctx genericapirequest.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) { func (r *ExecREST) Connect(ctx context.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) {
execOpts, ok := opts.(*api.PodExecOptions) execOpts, ok := opts.(*api.PodExecOptions)
if !ok { if !ok {
return nil, fmt.Errorf("invalid options object: %#v", opts) return nil, fmt.Errorf("invalid options object: %#v", opts)
...@@ -179,7 +179,7 @@ func (r *PortForwardREST) ConnectMethods() []string { ...@@ -179,7 +179,7 @@ func (r *PortForwardREST) ConnectMethods() []string {
} }
// Connect returns a handler for the pod portforward proxy // Connect returns a handler for the pod portforward proxy
func (r *PortForwardREST) Connect(ctx genericapirequest.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) { func (r *PortForwardREST) Connect(ctx context.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) {
portForwardOpts, ok := opts.(*api.PodPortForwardOptions) portForwardOpts, ok := opts.(*api.PodPortForwardOptions)
if !ok { if !ok {
return nil, fmt.Errorf("invalid options object: %#v", opts) return nil, fmt.Errorf("invalid options object: %#v", opts)
......
...@@ -61,7 +61,6 @@ go_library( ...@@ -61,7 +61,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"fmt" "fmt"
"time" "time"
...@@ -26,7 +27,6 @@ import ( ...@@ -26,7 +27,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
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/registry/rest"
"k8s.io/client-go/util/retry" "k8s.io/client-go/util/retry"
...@@ -78,7 +78,7 @@ func (r *EvictionREST) New() runtime.Object { ...@@ -78,7 +78,7 @@ func (r *EvictionREST) New() runtime.Object {
} }
// Create attempts to create a new eviction. That is, it tries to evict a pod. // Create attempts to create a new eviction. That is, it tries to evict a pod.
func (r *EvictionREST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (r *EvictionREST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
eviction := obj.(*policy.Eviction) eviction := obj.(*policy.Eviction)
obj, err := r.store.Get(ctx, eviction.Name, &metav1.GetOptions{}) obj, err := r.store.Get(ctx, eviction.Name, &metav1.GetOptions{})
...@@ -177,7 +177,7 @@ func (r *EvictionREST) checkAndDecrement(namespace string, podName string, pdb p ...@@ -177,7 +177,7 @@ func (r *EvictionREST) checkAndDecrement(namespace string, podName string, pdb p
} }
// getPodDisruptionBudgets returns any PDBs that match the pod or err if there's an error. // getPodDisruptionBudgets returns any PDBs that match the pod or err if there's an error.
func (r *EvictionREST) getPodDisruptionBudgets(ctx genericapirequest.Context, pod *api.Pod) ([]policy.PodDisruptionBudget, error) { func (r *EvictionREST) getPodDisruptionBudgets(ctx context.Context, pod *api.Pod) ([]policy.PodDisruptionBudget, error) {
if len(pod.Labels) == 0 { if len(pod.Labels) == 0 {
return nil, nil return nil, nil
} }
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"net/url" "net/url"
...@@ -24,7 +25,6 @@ import ( ...@@ -24,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -102,7 +102,7 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, k client.ConnectionInfoGet ...@@ -102,7 +102,7 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, k client.ConnectionInfoGet
var _ = rest.Redirector(&REST{}) var _ = rest.Redirector(&REST{})
// ResourceLocation returns a pods location from its HostIP // ResourceLocation returns a pods location from its HostIP
func (r *REST) ResourceLocation(ctx genericapirequest.Context, name string) (*url.URL, http.RoundTripper, error) { func (r *REST) ResourceLocation(ctx context.Context, name string) (*url.URL, http.RoundTripper, error) {
return pod.ResourceLocation(r, r.proxyTransport, ctx, name) return pod.ResourceLocation(r, r.proxyTransport, ctx, name)
} }
...@@ -135,7 +135,7 @@ func (r *BindingREST) New() runtime.Object { ...@@ -135,7 +135,7 @@ func (r *BindingREST) New() runtime.Object {
var _ = rest.Creater(&BindingREST{}) var _ = rest.Creater(&BindingREST{})
// Create ensures a pod is bound to a specific host. // Create ensures a pod is bound to a specific host.
func (r *BindingREST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (out runtime.Object, err error) { func (r *BindingREST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (out runtime.Object, err error) {
binding := obj.(*api.Binding) binding := obj.(*api.Binding)
// TODO: move me to a binding strategy // TODO: move me to a binding strategy
...@@ -151,7 +151,7 @@ func (r *BindingREST) Create(ctx genericapirequest.Context, obj runtime.Object, ...@@ -151,7 +151,7 @@ func (r *BindingREST) Create(ctx genericapirequest.Context, obj runtime.Object,
// setPodHostAndAnnotations sets the given pod's host to 'machine' if and only if it was // setPodHostAndAnnotations sets the given pod's host to 'machine' if and only if it was
// previously 'oldMachine' and merges the provided annotations with those of the pod. // previously 'oldMachine' and merges the provided annotations with those of the pod.
// Returns the current state of the pod, or an error. // Returns the current state of the pod, or an error.
func (r *BindingREST) setPodHostAndAnnotations(ctx genericapirequest.Context, podID, oldMachine, machine string, annotations map[string]string) (finalPod *api.Pod, err error) { func (r *BindingREST) setPodHostAndAnnotations(ctx context.Context, podID, oldMachine, machine string, annotations map[string]string) (finalPod *api.Pod, err error) {
podKey, err := r.store.KeyFunc(ctx, podID) podKey, err := r.store.KeyFunc(ctx, podID)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -185,7 +185,7 @@ func (r *BindingREST) setPodHostAndAnnotations(ctx genericapirequest.Context, po ...@@ -185,7 +185,7 @@ func (r *BindingREST) setPodHostAndAnnotations(ctx genericapirequest.Context, po
} }
// assignPod assigns the given pod to the given machine. // assignPod assigns the given pod to the given machine.
func (r *BindingREST) assignPod(ctx genericapirequest.Context, podID string, machine string, annotations map[string]string) (err error) { func (r *BindingREST) assignPod(ctx context.Context, podID string, machine string, annotations map[string]string) (err error) {
if _, err = r.setPodHostAndAnnotations(ctx, podID, "", machine, annotations); err != nil { if _, err = r.setPodHostAndAnnotations(ctx, podID, "", machine, annotations); err != nil {
err = storeerr.InterpretGetError(err, api.Resource("pods"), podID) err = storeerr.InterpretGetError(err, api.Resource("pods"), podID)
err = storeerr.InterpretUpdateError(err, api.Resource("pods"), podID) err = storeerr.InterpretUpdateError(err, api.Resource("pods"), podID)
...@@ -207,11 +207,11 @@ func (r *StatusREST) New() runtime.Object { ...@@ -207,11 +207,11 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package pod package pod
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
...@@ -35,7 +36,6 @@ import ( ...@@ -35,7 +36,6 @@ import (
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
utilnet "k8s.io/apimachinery/pkg/util/net" utilnet "k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/features" "k8s.io/apiserver/pkg/features"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage"
...@@ -65,7 +65,7 @@ func (podStrategy) NamespaceScoped() bool { ...@@ -65,7 +65,7 @@ func (podStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears fields that are not allowed to be set by end users on creation. // PrepareForCreate clears fields that are not allowed to be set by end users on creation.
func (podStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (podStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
pod := obj.(*api.Pod) pod := obj.(*api.Pod)
pod.Status = api.PodStatus{ pod.Status = api.PodStatus{
Phase: api.PodPending, Phase: api.PodPending,
...@@ -76,7 +76,7 @@ func (podStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.O ...@@ -76,7 +76,7 @@ func (podStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.O
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (podStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (podStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newPod := obj.(*api.Pod) newPod := obj.(*api.Pod)
oldPod := old.(*api.Pod) oldPod := old.(*api.Pod)
newPod.Status = oldPod.Status newPod.Status = oldPod.Status
...@@ -86,7 +86,7 @@ func (podStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runt ...@@ -86,7 +86,7 @@ func (podStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runt
} }
// Validate validates a new pod. // Validate validates a new pod.
func (podStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (podStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
pod := obj.(*api.Pod) pod := obj.(*api.Pod)
return validation.ValidatePod(pod) return validation.ValidatePod(pod)
} }
...@@ -116,7 +116,7 @@ func isUpdatingUninitializedPod(old runtime.Object) (bool, error) { ...@@ -116,7 +116,7 @@ func isUpdatingUninitializedPod(old runtime.Object) (bool, error) {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (podStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (podStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
errorList := validation.ValidatePod(obj.(*api.Pod)) errorList := validation.ValidatePod(obj.(*api.Pod))
uninitializedUpdate, err := isUpdatingUninitializedPod(old) uninitializedUpdate, err := isUpdatingUninitializedPod(old)
if err != nil { if err != nil {
...@@ -135,7 +135,7 @@ func (podStrategy) AllowUnconditionalUpdate() bool { ...@@ -135,7 +135,7 @@ func (podStrategy) AllowUnconditionalUpdate() bool {
// CheckGracefulDelete allows a pod to be gracefully deleted. It updates the DeleteOptions to // CheckGracefulDelete allows a pod to be gracefully deleted. It updates the DeleteOptions to
// reflect the desired grace value. // reflect the desired grace value.
func (podStrategy) CheckGracefulDelete(ctx genericapirequest.Context, obj runtime.Object, options *metav1.DeleteOptions) bool { func (podStrategy) CheckGracefulDelete(ctx context.Context, obj runtime.Object, options *metav1.DeleteOptions) bool {
if options == nil { if options == nil {
return false return false
} }
...@@ -168,7 +168,7 @@ type podStrategyWithoutGraceful struct { ...@@ -168,7 +168,7 @@ type podStrategyWithoutGraceful struct {
} }
// CheckGracefulDelete prohibits graceful deletion. // CheckGracefulDelete prohibits graceful deletion.
func (podStrategyWithoutGraceful) CheckGracefulDelete(ctx genericapirequest.Context, obj runtime.Object, options *metav1.DeleteOptions) bool { func (podStrategyWithoutGraceful) CheckGracefulDelete(ctx context.Context, obj runtime.Object, options *metav1.DeleteOptions) bool {
return false return false
} }
...@@ -181,7 +181,7 @@ type podStatusStrategy struct { ...@@ -181,7 +181,7 @@ type podStatusStrategy struct {
var StatusStrategy = podStatusStrategy{Strategy} var StatusStrategy = podStatusStrategy{Strategy}
func (podStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (podStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newPod := obj.(*api.Pod) newPod := obj.(*api.Pod)
oldPod := old.(*api.Pod) oldPod := old.(*api.Pod)
newPod.Spec = oldPod.Spec newPod.Spec = oldPod.Spec
...@@ -192,7 +192,7 @@ func (podStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol ...@@ -192,7 +192,7 @@ func (podStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol
newPod.OwnerReferences = oldPod.OwnerReferences newPod.OwnerReferences = oldPod.OwnerReferences
} }
func (podStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (podStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
var errorList field.ErrorList var errorList field.ErrorList
uninitializedUpdate, err := isUpdatingUninitializedPod(old) uninitializedUpdate, err := isUpdatingUninitializedPod(old)
if err != nil { if err != nil {
...@@ -249,10 +249,10 @@ func PodToSelectableFields(pod *api.Pod) fields.Set { ...@@ -249,10 +249,10 @@ func PodToSelectableFields(pod *api.Pod) fields.Set {
// ResourceGetter is an interface for retrieving resources by ResourceLocation. // ResourceGetter is an interface for retrieving resources by ResourceLocation.
type ResourceGetter interface { type ResourceGetter interface {
Get(genericapirequest.Context, string, *metav1.GetOptions) (runtime.Object, error) Get(context.Context, string, *metav1.GetOptions) (runtime.Object, error)
} }
func getPod(getter ResourceGetter, ctx genericapirequest.Context, name string) (*api.Pod, error) { func getPod(getter ResourceGetter, ctx context.Context, name string) (*api.Pod, error) {
obj, err := getter.Get(ctx, name, &metav1.GetOptions{}) obj, err := getter.Get(ctx, name, &metav1.GetOptions{})
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -265,7 +265,7 @@ func getPod(getter ResourceGetter, ctx genericapirequest.Context, name string) ( ...@@ -265,7 +265,7 @@ func getPod(getter ResourceGetter, ctx genericapirequest.Context, name string) (
} }
// ResourceLocation returns a URL to which one can send traffic for the specified pod. // ResourceLocation returns a URL to which one can send traffic for the specified pod.
func ResourceLocation(getter ResourceGetter, rt http.RoundTripper, ctx genericapirequest.Context, id string) (*url.URL, http.RoundTripper, error) { func ResourceLocation(getter ResourceGetter, rt http.RoundTripper, ctx context.Context, id string) (*url.URL, http.RoundTripper, error) {
// Allow ID as "podname" or "podname:port" or "scheme:podname:port". // Allow ID as "podname" or "podname:port" or "scheme:podname:port".
// If port is not specified, try to use the first defined port on the pod. // If port is not specified, try to use the first defined port on the pod.
scheme, name, port, valid := utilnet.SplitSchemeNamePort(id) scheme, name, port, valid := utilnet.SplitSchemeNamePort(id)
...@@ -314,7 +314,7 @@ func getContainerNames(containers []api.Container) string { ...@@ -314,7 +314,7 @@ func getContainerNames(containers []api.Container) string {
func LogLocation( func LogLocation(
getter ResourceGetter, getter ResourceGetter,
connInfo client.ConnectionInfoGetter, connInfo client.ConnectionInfoGetter,
ctx genericapirequest.Context, ctx context.Context,
name string, name string,
opts *api.PodLogOptions, opts *api.PodLogOptions,
) (*url.URL, http.RoundTripper, error) { ) (*url.URL, http.RoundTripper, error) {
...@@ -450,7 +450,7 @@ func streamParams(params url.Values, opts runtime.Object) error { ...@@ -450,7 +450,7 @@ func streamParams(params url.Values, opts runtime.Object) error {
func AttachLocation( func AttachLocation(
getter ResourceGetter, getter ResourceGetter,
connInfo client.ConnectionInfoGetter, connInfo client.ConnectionInfoGetter,
ctx genericapirequest.Context, ctx context.Context,
name string, name string,
opts *api.PodAttachOptions, opts *api.PodAttachOptions,
) (*url.URL, http.RoundTripper, error) { ) (*url.URL, http.RoundTripper, error) {
...@@ -462,7 +462,7 @@ func AttachLocation( ...@@ -462,7 +462,7 @@ func AttachLocation(
func ExecLocation( func ExecLocation(
getter ResourceGetter, getter ResourceGetter,
connInfo client.ConnectionInfoGetter, connInfo client.ConnectionInfoGetter,
ctx genericapirequest.Context, ctx context.Context,
name string, name string,
opts *api.PodExecOptions, opts *api.PodExecOptions,
) (*url.URL, http.RoundTripper, error) { ) (*url.URL, http.RoundTripper, error) {
...@@ -472,7 +472,7 @@ func ExecLocation( ...@@ -472,7 +472,7 @@ func ExecLocation(
func streamLocation( func streamLocation(
getter ResourceGetter, getter ResourceGetter,
connInfo client.ConnectionInfoGetter, connInfo client.ConnectionInfoGetter,
ctx genericapirequest.Context, ctx context.Context,
name string, name string,
opts runtime.Object, opts runtime.Object,
container, container,
...@@ -531,7 +531,7 @@ func streamLocation( ...@@ -531,7 +531,7 @@ func streamLocation(
func PortForwardLocation( func PortForwardLocation(
getter ResourceGetter, getter ResourceGetter,
connInfo client.ConnectionInfoGetter, connInfo client.ConnectionInfoGetter,
ctx genericapirequest.Context, ctx context.Context,
name string, name string,
opts *api.PodPortForwardOptions, opts *api.PodPortForwardOptions,
) (*url.URL, http.RoundTripper, error) { ) (*url.URL, http.RoundTripper, error) {
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package pod package pod
import ( import (
"context"
"net/url" "net/url"
"reflect" "reflect"
"testing" "testing"
...@@ -268,7 +269,7 @@ type mockPodGetter struct { ...@@ -268,7 +269,7 @@ type mockPodGetter struct {
pod *api.Pod pod *api.Pod
} }
func (g mockPodGetter) Get(genericapirequest.Context, string, *metav1.GetOptions) (runtime.Object, error) { func (g mockPodGetter) Get(context.Context, string, *metav1.GetOptions) (runtime.Object, error) {
return g.pod, nil return g.pod, nil
} }
......
...@@ -19,7 +19,6 @@ go_library( ...@@ -19,7 +19,6 @@ go_library(
"//pkg/apis/core/validation:go_default_library", "//pkg/apis/core/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
) )
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package podtemplate package podtemplate
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/api/pod" "k8s.io/kubernetes/pkg/api/pod"
...@@ -43,14 +44,14 @@ func (podTemplateStrategy) NamespaceScoped() bool { ...@@ -43,14 +44,14 @@ func (podTemplateStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears fields that are not allowed to be set by end users on creation. // PrepareForCreate clears fields that are not allowed to be set by end users on creation.
func (podTemplateStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (podTemplateStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
template := obj.(*api.PodTemplate) template := obj.(*api.PodTemplate)
pod.DropDisabledAlphaFields(&template.Template.Spec) pod.DropDisabledAlphaFields(&template.Template.Spec)
} }
// Validate validates a new pod template. // Validate validates a new pod template.
func (podTemplateStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (podTemplateStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
pod := obj.(*api.PodTemplate) pod := obj.(*api.PodTemplate)
return validation.ValidatePodTemplate(pod) return validation.ValidatePodTemplate(pod)
} }
...@@ -65,7 +66,7 @@ func (podTemplateStrategy) AllowCreateOnUpdate() bool { ...@@ -65,7 +66,7 @@ func (podTemplateStrategy) AllowCreateOnUpdate() bool {
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (podTemplateStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (podTemplateStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newTemplate := obj.(*api.PodTemplate) newTemplate := obj.(*api.PodTemplate)
oldTemplate := old.(*api.PodTemplate) oldTemplate := old.(*api.PodTemplate)
...@@ -74,7 +75,7 @@ func (podTemplateStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ...@@ -74,7 +75,7 @@ func (podTemplateStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj,
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (podTemplateStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (podTemplateStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidatePodTemplateUpdate(obj.(*api.PodTemplate), old.(*api.PodTemplate)) return validation.ValidatePodTemplateUpdate(obj.(*api.PodTemplate), old.(*api.PodTemplate))
} }
...@@ -82,7 +83,7 @@ func (podTemplateStrategy) AllowUnconditionalUpdate() bool { ...@@ -82,7 +83,7 @@ func (podTemplateStrategy) AllowUnconditionalUpdate() bool {
return true return true
} }
func (podTemplateStrategy) Export(ctx genericapirequest.Context, obj runtime.Object, exact bool) error { func (podTemplateStrategy) Export(ctx context.Context, obj runtime.Object, exact bool) error {
// Do nothing // Do nothing
return nil return nil
} }
...@@ -28,7 +28,6 @@ go_library( ...@@ -28,7 +28,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
......
...@@ -19,24 +19,24 @@ limitations under the License. ...@@ -19,24 +19,24 @@ limitations under the License.
package replicationcontroller package replicationcontroller
import ( import (
"context"
"fmt" "fmt"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
) )
// Registry is an interface for things that know how to store ReplicationControllers. // Registry is an interface for things that know how to store ReplicationControllers.
type Registry interface { type Registry interface {
ListControllers(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ReplicationControllerList, error) ListControllers(ctx context.Context, options *metainternalversion.ListOptions) (*api.ReplicationControllerList, error)
WatchControllers(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchControllers(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
GetController(ctx genericapirequest.Context, controllerID string, options *metav1.GetOptions) (*api.ReplicationController, error) GetController(ctx context.Context, controllerID string, options *metav1.GetOptions) (*api.ReplicationController, error)
CreateController(ctx genericapirequest.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc) (*api.ReplicationController, error) CreateController(ctx context.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc) (*api.ReplicationController, error)
UpdateController(ctx genericapirequest.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ReplicationController, error) UpdateController(ctx context.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ReplicationController, error)
DeleteController(ctx genericapirequest.Context, controllerID string) error DeleteController(ctx context.Context, controllerID string) error
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -50,7 +50,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -50,7 +50,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListControllers(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ReplicationControllerList, error) { func (s *storage) ListControllers(ctx context.Context, options *metainternalversion.ListOptions) (*api.ReplicationControllerList, error) {
if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() { if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() {
return nil, fmt.Errorf("field selector not supported yet") return nil, fmt.Errorf("field selector not supported yet")
} }
...@@ -61,11 +61,11 @@ func (s *storage) ListControllers(ctx genericapirequest.Context, options *metain ...@@ -61,11 +61,11 @@ func (s *storage) ListControllers(ctx genericapirequest.Context, options *metain
return obj.(*api.ReplicationControllerList), err return obj.(*api.ReplicationControllerList), err
} }
func (s *storage) WatchControllers(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchControllers(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetController(ctx genericapirequest.Context, controllerID string, options *metav1.GetOptions) (*api.ReplicationController, error) { func (s *storage) GetController(ctx context.Context, controllerID string, options *metav1.GetOptions) (*api.ReplicationController, error) {
obj, err := s.Get(ctx, controllerID, options) obj, err := s.Get(ctx, controllerID, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -73,7 +73,7 @@ func (s *storage) GetController(ctx genericapirequest.Context, controllerID stri ...@@ -73,7 +73,7 @@ func (s *storage) GetController(ctx genericapirequest.Context, controllerID stri
return obj.(*api.ReplicationController), nil return obj.(*api.ReplicationController), nil
} }
func (s *storage) CreateController(ctx genericapirequest.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc) (*api.ReplicationController, error) { func (s *storage) CreateController(ctx context.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc) (*api.ReplicationController, error) {
obj, err := s.Create(ctx, controller, createValidation, false) obj, err := s.Create(ctx, controller, createValidation, false)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -81,7 +81,7 @@ func (s *storage) CreateController(ctx genericapirequest.Context, controller *ap ...@@ -81,7 +81,7 @@ func (s *storage) CreateController(ctx genericapirequest.Context, controller *ap
return obj.(*api.ReplicationController), nil return obj.(*api.ReplicationController), nil
} }
func (s *storage) UpdateController(ctx genericapirequest.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ReplicationController, error) { func (s *storage) UpdateController(ctx context.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ReplicationController, error) {
obj, _, err := s.Update(ctx, controller.Name, rest.DefaultUpdatedObjectInfo(controller), createValidation, updateValidation) obj, _, err := s.Update(ctx, controller.Name, rest.DefaultUpdatedObjectInfo(controller), createValidation, updateValidation)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -89,7 +89,7 @@ func (s *storage) UpdateController(ctx genericapirequest.Context, controller *ap ...@@ -89,7 +89,7 @@ func (s *storage) UpdateController(ctx genericapirequest.Context, controller *ap
return obj.(*api.ReplicationController), nil return obj.(*api.ReplicationController), nil
} }
func (s *storage) DeleteController(ctx genericapirequest.Context, controllerID string) error { func (s *storage) DeleteController(ctx context.Context, controllerID string) error {
_, _, err := s.Delete(ctx, controllerID, nil) _, _, err := s.Delete(ctx, controllerID, nil)
return err return err
} }
...@@ -48,7 +48,6 @@ go_library( ...@@ -48,7 +48,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -19,6 +19,7 @@ limitations under the License. ...@@ -19,6 +19,7 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
...@@ -26,7 +27,6 @@ import ( ...@@ -26,7 +27,6 @@ import (
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -114,12 +114,12 @@ func (r *StatusREST) New() runtime.Object { ...@@ -114,12 +114,12 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -145,7 +145,7 @@ func (r *ScaleREST) New() runtime.Object { ...@@ -145,7 +145,7 @@ func (r *ScaleREST) New() runtime.Object {
return &autoscaling.Scale{} return &autoscaling.Scale{}
} }
func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
rc, err := r.registry.GetController(ctx, name, options) rc, err := r.registry.GetController(ctx, name, options)
if err != nil { if err != nil {
return nil, errors.NewNotFound(autoscaling.Resource("replicationcontrollers/scale"), name) return nil, errors.NewNotFound(autoscaling.Resource("replicationcontrollers/scale"), name)
...@@ -153,7 +153,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met ...@@ -153,7 +153,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met
return scaleFromRC(rc), nil return scaleFromRC(rc), nil
} }
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
rc, err := r.registry.GetController(ctx, name, &metav1.GetOptions{}) rc, err := r.registry.GetController(ctx, name, &metav1.GetOptions{})
if err != nil { if err != nil {
return nil, false, errors.NewNotFound(autoscaling.Resource("replicationcontrollers/scale"), name) return nil, false, errors.NewNotFound(autoscaling.Resource("replicationcontrollers/scale"), name)
......
...@@ -19,6 +19,7 @@ limitations under the License. ...@@ -19,6 +19,7 @@ limitations under the License.
package replicationcontroller package replicationcontroller
import ( import (
"context"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
...@@ -28,7 +29,6 @@ import ( ...@@ -28,7 +29,6 @@ import (
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
apistorage "k8s.io/apiserver/pkg/storage" apistorage "k8s.io/apiserver/pkg/storage"
...@@ -51,7 +51,7 @@ var Strategy = rcStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} ...@@ -51,7 +51,7 @@ var Strategy = rcStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
// DefaultGarbageCollectionPolicy returns Orphan because that was the default // DefaultGarbageCollectionPolicy returns Orphan because that was the default
// behavior before the server-side garbage collection was implemented. // behavior before the server-side garbage collection was implemented.
func (rcStrategy) DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) rest.GarbageCollectionPolicy { func (rcStrategy) DefaultGarbageCollectionPolicy(ctx context.Context) rest.GarbageCollectionPolicy {
return rest.OrphanDependents return rest.OrphanDependents
} }
...@@ -61,7 +61,7 @@ func (rcStrategy) NamespaceScoped() bool { ...@@ -61,7 +61,7 @@ func (rcStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of a replication controller before creation. // PrepareForCreate clears the status of a replication controller before creation.
func (rcStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (rcStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
controller := obj.(*api.ReplicationController) controller := obj.(*api.ReplicationController)
controller.Status = api.ReplicationControllerStatus{} controller.Status = api.ReplicationControllerStatus{}
...@@ -73,7 +73,7 @@ func (rcStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Ob ...@@ -73,7 +73,7 @@ func (rcStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Ob
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (rcStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (rcStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newController := obj.(*api.ReplicationController) newController := obj.(*api.ReplicationController)
oldController := old.(*api.ReplicationController) oldController := old.(*api.ReplicationController)
// update is not allowed to set status // update is not allowed to set status
...@@ -100,7 +100,7 @@ func (rcStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runti ...@@ -100,7 +100,7 @@ func (rcStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runti
} }
// Validate validates a new replication controller. // Validate validates a new replication controller.
func (rcStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (rcStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
controller := obj.(*api.ReplicationController) controller := obj.(*api.ReplicationController)
return validation.ValidateReplicationController(controller) return validation.ValidateReplicationController(controller)
} }
...@@ -116,7 +116,7 @@ func (rcStrategy) AllowCreateOnUpdate() bool { ...@@ -116,7 +116,7 @@ func (rcStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (rcStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (rcStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
oldRc := old.(*api.ReplicationController) oldRc := old.(*api.ReplicationController)
newRc := obj.(*api.ReplicationController) newRc := obj.(*api.ReplicationController)
...@@ -183,13 +183,13 @@ type rcStatusStrategy struct { ...@@ -183,13 +183,13 @@ type rcStatusStrategy struct {
var StatusStrategy = rcStatusStrategy{Strategy} var StatusStrategy = rcStatusStrategy{Strategy}
func (rcStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (rcStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newRc := obj.(*api.ReplicationController) newRc := obj.(*api.ReplicationController)
oldRc := old.(*api.ReplicationController) oldRc := old.(*api.ReplicationController)
// update is not allowed to set spec // update is not allowed to set spec
newRc.Spec = oldRc.Spec newRc.Spec = oldRc.Spec
} }
func (rcStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (rcStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateReplicationControllerStatusUpdate(obj.(*api.ReplicationController), old.(*api.ReplicationController)) return validation.ValidateReplicationControllerStatusUpdate(obj.(*api.ReplicationController), old.(*api.ReplicationController))
} }
...@@ -19,7 +19,6 @@ go_library( ...@@ -19,7 +19,6 @@ go_library(
"//pkg/apis/core/validation:go_default_library", "//pkg/apis/core/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
) )
......
...@@ -36,7 +36,6 @@ go_library( ...@@ -36,7 +36,6 @@ go_library(
"//pkg/registry/core/resourcequota:go_default_library", "//pkg/registry/core/resourcequota:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package storage package storage
import ( import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -72,11 +73,11 @@ func (r *StatusREST) New() runtime.Object { ...@@ -72,11 +73,11 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package resourcequota package resourcequota
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
...@@ -42,20 +43,20 @@ func (resourcequotaStrategy) NamespaceScoped() bool { ...@@ -42,20 +43,20 @@ func (resourcequotaStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears fields that are not allowed to be set by end users on creation. // PrepareForCreate clears fields that are not allowed to be set by end users on creation.
func (resourcequotaStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (resourcequotaStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
resourcequota := obj.(*api.ResourceQuota) resourcequota := obj.(*api.ResourceQuota)
resourcequota.Status = api.ResourceQuotaStatus{} resourcequota.Status = api.ResourceQuotaStatus{}
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (resourcequotaStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (resourcequotaStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newResourcequota := obj.(*api.ResourceQuota) newResourcequota := obj.(*api.ResourceQuota)
oldResourcequota := old.(*api.ResourceQuota) oldResourcequota := old.(*api.ResourceQuota)
newResourcequota.Status = oldResourcequota.Status newResourcequota.Status = oldResourcequota.Status
} }
// Validate validates a new resourcequota. // Validate validates a new resourcequota.
func (resourcequotaStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (resourcequotaStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
resourcequota := obj.(*api.ResourceQuota) resourcequota := obj.(*api.ResourceQuota)
return validation.ValidateResourceQuota(resourcequota) return validation.ValidateResourceQuota(resourcequota)
} }
...@@ -70,7 +71,7 @@ func (resourcequotaStrategy) AllowCreateOnUpdate() bool { ...@@ -70,7 +71,7 @@ func (resourcequotaStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (resourcequotaStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (resourcequotaStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
errorList := validation.ValidateResourceQuota(obj.(*api.ResourceQuota)) errorList := validation.ValidateResourceQuota(obj.(*api.ResourceQuota))
return append(errorList, validation.ValidateResourceQuotaUpdate(obj.(*api.ResourceQuota), old.(*api.ResourceQuota))...) return append(errorList, validation.ValidateResourceQuotaUpdate(obj.(*api.ResourceQuota), old.(*api.ResourceQuota))...)
} }
...@@ -85,12 +86,12 @@ type resourcequotaStatusStrategy struct { ...@@ -85,12 +86,12 @@ type resourcequotaStatusStrategy struct {
var StatusStrategy = resourcequotaStatusStrategy{Strategy} var StatusStrategy = resourcequotaStatusStrategy{Strategy}
func (resourcequotaStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (resourcequotaStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newResourcequota := obj.(*api.ResourceQuota) newResourcequota := obj.(*api.ResourceQuota)
oldResourcequota := old.(*api.ResourceQuota) oldResourcequota := old.(*api.ResourceQuota)
newResourcequota.Spec = oldResourcequota.Spec newResourcequota.Spec = oldResourcequota.Spec
} }
func (resourcequotaStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (resourcequotaStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateResourceQuotaStatusUpdate(obj.(*api.ResourceQuota), old.(*api.ResourceQuota)) return validation.ValidateResourceQuotaStatusUpdate(obj.(*api.ResourceQuota), old.(*api.ResourceQuota))
} }
...@@ -22,7 +22,6 @@ go_library( ...@@ -22,7 +22,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package secret package secret
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
...@@ -24,7 +25,6 @@ import ( ...@@ -24,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
apistorage "k8s.io/apiserver/pkg/storage" apistorage "k8s.io/apiserver/pkg/storage"
...@@ -52,10 +52,10 @@ func (strategy) NamespaceScoped() bool { ...@@ -52,10 +52,10 @@ func (strategy) NamespaceScoped() bool {
return true return true
} }
func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
} }
func (strategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
return validation.ValidateSecret(obj.(*api.Secret)) return validation.ValidateSecret(obj.(*api.Secret))
} }
...@@ -66,10 +66,10 @@ func (strategy) AllowCreateOnUpdate() bool { ...@@ -66,10 +66,10 @@ func (strategy) AllowCreateOnUpdate() bool {
return false return false
} }
func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
} }
func (strategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (strategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateSecretUpdate(obj.(*api.Secret), old.(*api.Secret)) return validation.ValidateSecretUpdate(obj.(*api.Secret), old.(*api.Secret))
} }
...@@ -77,7 +77,7 @@ func (strategy) AllowUnconditionalUpdate() bool { ...@@ -77,7 +77,7 @@ func (strategy) AllowUnconditionalUpdate() bool {
return true return true
} }
func (s strategy) Export(ctx genericapirequest.Context, obj runtime.Object, exact bool) error { func (s strategy) Export(ctx context.Context, obj runtime.Object, exact bool) error {
t, ok := obj.(*api.Secret) t, ok := obj.(*api.Secret)
if !ok { if !ok {
// unexpected programmer error // unexpected programmer error
......
...@@ -27,7 +27,6 @@ go_library( ...@@ -27,7 +27,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/util/proxy:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/proxy:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package service package service
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"net/url" "net/url"
...@@ -24,7 +25,6 @@ import ( ...@@ -24,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/util/proxy" "k8s.io/apimachinery/pkg/util/proxy"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/capabilities" "k8s.io/kubernetes/pkg/capabilities"
...@@ -57,7 +57,7 @@ func (r *ProxyREST) NewConnectOptions() (runtime.Object, bool, string) { ...@@ -57,7 +57,7 @@ func (r *ProxyREST) NewConnectOptions() (runtime.Object, bool, string) {
} }
// Connect returns a handler for the service proxy // Connect returns a handler for the service proxy
func (r *ProxyREST) Connect(ctx genericapirequest.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.ServiceProxyOptions) proxyOpts, ok := opts.(*api.ServiceProxyOptions)
if !ok { if !ok {
return nil, fmt.Errorf("Invalid options object: %#v", opts) return nil, fmt.Errorf("Invalid options object: %#v", opts)
......
...@@ -17,25 +17,25 @@ limitations under the License. ...@@ -17,25 +17,25 @@ limitations under the License.
package service package service
import ( import (
"context"
"fmt" "fmt"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
) )
// Registry is an interface for things that know how to store services. // Registry is an interface for things that know how to store services.
type Registry interface { type Registry interface {
ListServices(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ServiceList, error) ListServices(ctx context.Context, options *metainternalversion.ListOptions) (*api.ServiceList, error)
CreateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc) (*api.Service, error) CreateService(ctx context.Context, svc *api.Service, createValidation rest.ValidateObjectFunc) (*api.Service, error)
GetService(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.Service, error) GetService(ctx context.Context, name string, options *metav1.GetOptions) (*api.Service, error)
DeleteService(ctx genericapirequest.Context, name string) error DeleteService(ctx context.Context, name string) error
UpdateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.Service, error) UpdateService(ctx context.Context, svc *api.Service, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.Service, error)
WatchServices(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchServices(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
ExportService(ctx genericapirequest.Context, name string, options metav1.ExportOptions) (*api.Service, error) ExportService(ctx context.Context, name string, options metav1.ExportOptions) (*api.Service, error)
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -49,7 +49,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -49,7 +49,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListServices(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ServiceList, error) { func (s *storage) ListServices(ctx context.Context, options *metainternalversion.ListOptions) (*api.ServiceList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -57,7 +57,7 @@ func (s *storage) ListServices(ctx genericapirequest.Context, options *metainter ...@@ -57,7 +57,7 @@ func (s *storage) ListServices(ctx genericapirequest.Context, options *metainter
return obj.(*api.ServiceList), nil return obj.(*api.ServiceList), nil
} }
func (s *storage) CreateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc) (*api.Service, error) { func (s *storage) CreateService(ctx context.Context, svc *api.Service, createValidation rest.ValidateObjectFunc) (*api.Service, error) {
obj, err := s.Create(ctx, svc, createValidation, false) obj, err := s.Create(ctx, svc, createValidation, false)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -65,7 +65,7 @@ func (s *storage) CreateService(ctx genericapirequest.Context, svc *api.Service, ...@@ -65,7 +65,7 @@ func (s *storage) CreateService(ctx genericapirequest.Context, svc *api.Service,
return obj.(*api.Service), nil return obj.(*api.Service), nil
} }
func (s *storage) GetService(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.Service, error) { func (s *storage) GetService(ctx context.Context, name string, options *metav1.GetOptions) (*api.Service, error) {
obj, err := s.Get(ctx, name, options) obj, err := s.Get(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -73,12 +73,12 @@ func (s *storage) GetService(ctx genericapirequest.Context, name string, options ...@@ -73,12 +73,12 @@ func (s *storage) GetService(ctx genericapirequest.Context, name string, options
return obj.(*api.Service), nil return obj.(*api.Service), nil
} }
func (s *storage) DeleteService(ctx genericapirequest.Context, name string) error { func (s *storage) DeleteService(ctx context.Context, name string) error {
_, _, err := s.Delete(ctx, name, nil) _, _, err := s.Delete(ctx, name, nil)
return err return err
} }
func (s *storage) UpdateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.Service, error) { func (s *storage) UpdateService(ctx context.Context, svc *api.Service, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.Service, error) {
obj, _, err := s.Update(ctx, svc.Name, rest.DefaultUpdatedObjectInfo(svc), createValidation, updateValidation) obj, _, err := s.Update(ctx, svc.Name, rest.DefaultUpdatedObjectInfo(svc), createValidation, updateValidation)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -86,13 +86,13 @@ func (s *storage) UpdateService(ctx genericapirequest.Context, svc *api.Service, ...@@ -86,13 +86,13 @@ func (s *storage) UpdateService(ctx genericapirequest.Context, svc *api.Service,
return obj.(*api.Service), nil return obj.(*api.Service), nil
} }
func (s *storage) WatchServices(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchServices(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
// If StandardStorage implements rest.Exporter, returns exported service. // If StandardStorage implements rest.Exporter, returns exported service.
// Otherwise export is not supported. // Otherwise export is not supported.
func (s *storage) ExportService(ctx genericapirequest.Context, name string, options metav1.ExportOptions) (*api.Service, error) { func (s *storage) ExportService(ctx context.Context, name string, options metav1.ExportOptions) (*api.Service, error) {
exporter, isExporter := s.StandardStorage.(rest.Exporter) exporter, isExporter := s.StandardStorage.(rest.Exporter)
if !isExporter { if !isExporter {
return nil, fmt.Errorf("export is not supported") return nil, fmt.Errorf("export is not supported")
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"fmt" "fmt"
"math/rand" "math/rand"
"net" "net"
...@@ -130,23 +131,23 @@ func (rs *REST) NewList() runtime.Object { ...@@ -130,23 +131,23 @@ func (rs *REST) NewList() runtime.Object {
return rs.services.NewList() return rs.services.NewList()
} }
func (rs *REST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (rs *REST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return rs.services.Get(ctx, name, options) return rs.services.Get(ctx, name, options)
} }
func (rs *REST) List(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (runtime.Object, error) { func (rs *REST) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
return rs.services.List(ctx, options) return rs.services.List(ctx, options)
} }
func (rs *REST) Watch(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (rs *REST) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return rs.services.Watch(ctx, options) return rs.services.Watch(ctx, options)
} }
func (rs *REST) Export(ctx genericapirequest.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) { func (rs *REST) Export(ctx context.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) {
return rs.services.Export(ctx, name, opts) return rs.services.Export(ctx, name, opts)
} }
func (rs *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (rs *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
service := obj.(*api.Service) service := obj.(*api.Service)
if err := rest.BeforeCreate(registry.Strategy, ctx, obj); err != nil { if err := rest.BeforeCreate(registry.Strategy, ctx, obj); err != nil {
...@@ -207,7 +208,7 @@ func (rs *REST) Create(ctx genericapirequest.Context, obj runtime.Object, create ...@@ -207,7 +208,7 @@ func (rs *REST) Create(ctx genericapirequest.Context, obj runtime.Object, create
return out, err return out, err
} }
func (rs *REST) Delete(ctx genericapirequest.Context, id string, options *metav1.DeleteOptions) (runtime.Object, bool, error) { func (rs *REST) Delete(ctx context.Context, id string, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
// TODO: handle graceful // TODO: handle graceful
obj, _, err := rs.services.Delete(ctx, id, options) obj, _, err := rs.services.Delete(ctx, id, options)
if err != nil { if err != nil {
...@@ -320,7 +321,7 @@ func (rs *REST) healthCheckNodePortUpdate(oldService, service *api.Service, node ...@@ -320,7 +321,7 @@ func (rs *REST) healthCheckNodePortUpdate(oldService, service *api.Service, node
return true, nil return true, nil
} }
func (rs *REST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (rs *REST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
oldObj, err := rs.services.Get(ctx, name, &metav1.GetOptions{}) oldObj, err := rs.services.Get(ctx, name, &metav1.GetOptions{})
if err != nil { if err != nil {
return nil, false, err return nil, false, err
...@@ -413,7 +414,7 @@ func (rs *REST) Update(ctx genericapirequest.Context, name string, objInfo rest. ...@@ -413,7 +414,7 @@ func (rs *REST) Update(ctx genericapirequest.Context, name string, objInfo rest.
var _ = rest.Redirector(&REST{}) var _ = rest.Redirector(&REST{})
// ResourceLocation returns a URL to which one can send traffic for the specified service. // ResourceLocation returns a URL to which one can send traffic for the specified service.
func (rs *REST) ResourceLocation(ctx genericapirequest.Context, id string) (*url.URL, http.RoundTripper, error) { func (rs *REST) ResourceLocation(ctx context.Context, id string) (*url.URL, http.RoundTripper, error) {
// Allow ID as "svcname", "svcname:port", or "scheme:svcname:port". // Allow ID as "svcname", "svcname:port", or "scheme:svcname:port".
svcScheme, svcName, portStr, valid := utilnet.SplitSchemeNamePort(id) svcScheme, svcName, portStr, valid := utilnet.SplitSchemeNamePort(id)
if !valid { if !valid {
...@@ -486,11 +487,11 @@ func (rs *REST) ResourceLocation(ctx genericapirequest.Context, id string) (*url ...@@ -486,11 +487,11 @@ func (rs *REST) ResourceLocation(ctx genericapirequest.Context, id string) (*url
return nil, nil, errors.NewServiceUnavailable(fmt.Sprintf("no endpoints available for service %q", id)) return nil, nil, errors.NewServiceUnavailable(fmt.Sprintf("no endpoints available for service %q", id))
} }
func (r *REST) ConvertToTable(ctx genericapirequest.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) { func (r *REST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
return r.services.ConvertToTable(ctx, object, tableOptions) return r.services.ConvertToTable(ctx, object, tableOptions)
} }
func isValidAddress(ctx genericapirequest.Context, addr *api.EndpointAddress, pods rest.Getter) error { func isValidAddress(ctx context.Context, addr *api.EndpointAddress, pods rest.Getter) error {
if addr.TargetRef == nil { if addr.TargetRef == nil {
return fmt.Errorf("Address has no target ref, skipping: %v", addr) return fmt.Errorf("Address has no target ref, skipping: %v", addr)
} }
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"net" "net"
"reflect" "reflect"
"strings" "strings"
...@@ -64,12 +65,12 @@ type serviceStorage struct { ...@@ -64,12 +65,12 @@ type serviceStorage struct {
Err error Err error
} }
func (s *serviceStorage) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (s *serviceStorage) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
s.GottenID = name s.GottenID = name
return s.Service, s.Err return s.Service, s.Err
} }
func (s *serviceStorage) GetService(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.Service, error) { func (s *serviceStorage) GetService(ctx context.Context, name string, options *metav1.GetOptions) (*api.Service, error) {
return s.Service, s.Err return s.Service, s.Err
} }
...@@ -77,7 +78,7 @@ func (s *serviceStorage) NewList() runtime.Object { ...@@ -77,7 +78,7 @@ func (s *serviceStorage) NewList() runtime.Object {
panic("not implemented") panic("not implemented")
} }
func (s *serviceStorage) List(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (runtime.Object, error) { func (s *serviceStorage) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
ns, _ := genericapirequest.NamespaceFrom(ctx) ns, _ := genericapirequest.NamespaceFrom(ctx)
// Copy metadata from internal list into result // Copy metadata from internal list into result
...@@ -102,7 +103,7 @@ func (s *serviceStorage) New() runtime.Object { ...@@ -102,7 +103,7 @@ func (s *serviceStorage) New() runtime.Object {
panic("not implemented") panic("not implemented")
} }
func (s *serviceStorage) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (s *serviceStorage) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
svc := obj.(*api.Service) svc := obj.(*api.Service)
s.CreatedID = obj.(metav1.Object).GetName() s.CreatedID = obj.(metav1.Object).GetName()
s.Service = svc.DeepCopy() s.Service = svc.DeepCopy()
...@@ -115,7 +116,7 @@ func (s *serviceStorage) Create(ctx genericapirequest.Context, obj runtime.Objec ...@@ -115,7 +116,7 @@ func (s *serviceStorage) Create(ctx genericapirequest.Context, obj runtime.Objec
return svc, s.Err return svc, s.Err
} }
func (s *serviceStorage) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (s *serviceStorage) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
s.UpdatedID = name s.UpdatedID = name
obj, err := objInfo.UpdatedObject(ctx, s.OldService) obj, err := objInfo.UpdatedObject(ctx, s.OldService)
if err != nil { if err != nil {
...@@ -125,24 +126,24 @@ func (s *serviceStorage) Update(ctx genericapirequest.Context, name string, objI ...@@ -125,24 +126,24 @@ func (s *serviceStorage) Update(ctx genericapirequest.Context, name string, objI
return s.Service, s.Created, s.Err return s.Service, s.Created, s.Err
} }
func (s *serviceStorage) Delete(ctx genericapirequest.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) { func (s *serviceStorage) Delete(ctx context.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
s.DeletedID = name s.DeletedID = name
return s.Service, s.DeletedImmediately, s.Err return s.Service, s.DeletedImmediately, s.Err
} }
func (s *serviceStorage) DeleteCollection(ctx genericapirequest.Context, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error) { func (s *serviceStorage) DeleteCollection(ctx context.Context, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error) {
panic("not implemented") panic("not implemented")
} }
func (s *serviceStorage) Watch(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *serviceStorage) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
panic("not implemented") panic("not implemented")
} }
func (s *serviceStorage) ConvertToTable(ctx genericapirequest.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) { func (s *serviceStorage) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
panic("not implemented") panic("not implemented")
} }
func (s *serviceStorage) Export(ctx genericapirequest.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) { func (s *serviceStorage) Export(ctx context.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) {
panic("not implemented") panic("not implemented")
} }
...@@ -207,7 +208,7 @@ func makeIPNet(t *testing.T) *net.IPNet { ...@@ -207,7 +208,7 @@ func makeIPNet(t *testing.T) *net.IPNet {
return net return net
} }
func releaseServiceNodePorts(t *testing.T, ctx genericapirequest.Context, svcName string, rest *REST, registry ServiceStorage) { func releaseServiceNodePorts(t *testing.T, ctx context.Context, svcName string, rest *REST, registry ServiceStorage) {
obj, err := registry.Get(ctx, svcName, &metav1.GetOptions{}) obj, err := registry.Get(ctx, svcName, &metav1.GetOptions{})
if err != nil { if err != nil {
t.Errorf("Unexpected error: %v", err) t.Errorf("Unexpected error: %v", err)
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package storage package storage
import ( import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -84,11 +85,11 @@ func (r *StatusREST) New() runtime.Object { ...@@ -84,11 +85,11 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,11 +17,11 @@ limitations under the License. ...@@ -17,11 +17,11 @@ limitations under the License.
package service package service
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
...@@ -44,20 +44,20 @@ func (svcStrategy) NamespaceScoped() bool { ...@@ -44,20 +44,20 @@ func (svcStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears fields that are not allowed to be set by end users on creation. // PrepareForCreate clears fields that are not allowed to be set by end users on creation.
func (svcStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (svcStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
service := obj.(*api.Service) service := obj.(*api.Service)
service.Status = api.ServiceStatus{} service.Status = api.ServiceStatus{}
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (svcStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (svcStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newService := obj.(*api.Service) newService := obj.(*api.Service)
oldService := old.(*api.Service) oldService := old.(*api.Service)
newService.Status = oldService.Status newService.Status = oldService.Status
} }
// Validate validates a new service. // Validate validates a new service.
func (svcStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (svcStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
service := obj.(*api.Service) service := obj.(*api.Service)
return validation.ValidateService(service) return validation.ValidateService(service)
} }
...@@ -70,7 +70,7 @@ func (svcStrategy) AllowCreateOnUpdate() bool { ...@@ -70,7 +70,7 @@ func (svcStrategy) AllowCreateOnUpdate() bool {
return true return true
} }
func (svcStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (svcStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateServiceUpdate(obj.(*api.Service), old.(*api.Service)) return validation.ValidateServiceUpdate(obj.(*api.Service), old.(*api.Service))
} }
...@@ -78,7 +78,7 @@ func (svcStrategy) AllowUnconditionalUpdate() bool { ...@@ -78,7 +78,7 @@ func (svcStrategy) AllowUnconditionalUpdate() bool {
return true return true
} }
func (svcStrategy) Export(ctx genericapirequest.Context, obj runtime.Object, exact bool) error { func (svcStrategy) Export(ctx context.Context, obj runtime.Object, exact bool) error {
t, ok := obj.(*api.Service) t, ok := obj.(*api.Service)
if !ok { if !ok {
// unexpected programmer error // unexpected programmer error
...@@ -108,7 +108,7 @@ type serviceStatusStrategy struct { ...@@ -108,7 +108,7 @@ type serviceStatusStrategy struct {
var StatusStrategy = serviceStatusStrategy{Strategy} var StatusStrategy = serviceStatusStrategy{Strategy}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update of status // PrepareForUpdate clears fields that are not allowed to be set by end users on update of status
func (serviceStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (serviceStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newService := obj.(*api.Service) newService := obj.(*api.Service)
oldService := old.(*api.Service) oldService := old.(*api.Service)
// status changes are not allowed to update spec // status changes are not allowed to update spec
...@@ -116,6 +116,6 @@ func (serviceStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj ...@@ -116,6 +116,6 @@ func (serviceStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj
} }
// ValidateUpdate is the default update validation for an end user updating status // ValidateUpdate is the default update validation for an end user updating status
func (serviceStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (serviceStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateServiceStatusUpdate(obj.(*api.Service), old.(*api.Service)) return validation.ValidateServiceStatusUpdate(obj.(*api.Service), old.(*api.Service))
} }
...@@ -18,7 +18,6 @@ go_library( ...@@ -18,7 +18,6 @@ go_library(
"//pkg/apis/core/validation:go_default_library", "//pkg/apis/core/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
) )
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"fmt" "fmt"
authenticationapiv1 "k8s.io/api/authentication/v1" authenticationapiv1 "k8s.io/api/authentication/v1"
...@@ -46,7 +47,7 @@ type TokenREST struct { ...@@ -46,7 +47,7 @@ type TokenREST struct {
var _ = rest.NamedCreater(&TokenREST{}) var _ = rest.NamedCreater(&TokenREST{})
func (r *TokenREST) Create(ctx genericapirequest.Context, name string, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (r *TokenREST) Create(ctx context.Context, name string, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
if err := createValidation(obj); err != nil { if err := createValidation(obj); err != nil {
return nil, err return nil, err
} }
...@@ -120,11 +121,11 @@ func (r *TokenREST) GroupVersionKind(containingGV schema.GroupVersion) schema.Gr ...@@ -120,11 +121,11 @@ func (r *TokenREST) GroupVersionKind(containingGV schema.GroupVersion) schema.Gr
} }
type getter interface { type getter interface {
Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error)
} }
// newContext return a copy of ctx in which new RequestInfo is set // newContext return a copy of ctx in which new RequestInfo is set
func newContext(ctx genericapirequest.Context, resource, name string, gvk schema.GroupVersionKind) genericapirequest.Context { func newContext(ctx context.Context, resource, name string, gvk schema.GroupVersionKind) context.Context {
oldInfo, found := genericapirequest.RequestInfoFrom(ctx) oldInfo, found := genericapirequest.RequestInfoFrom(ctx)
if !found { if !found {
return ctx return ctx
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package serviceaccount package serviceaccount
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
...@@ -40,11 +41,11 @@ func (strategy) NamespaceScoped() bool { ...@@ -40,11 +41,11 @@ func (strategy) NamespaceScoped() bool {
return true return true
} }
func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
cleanSecretReferences(obj.(*api.ServiceAccount)) cleanSecretReferences(obj.(*api.ServiceAccount))
} }
func (strategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
return validation.ValidateServiceAccount(obj.(*api.ServiceAccount)) return validation.ValidateServiceAccount(obj.(*api.ServiceAccount))
} }
...@@ -56,7 +57,7 @@ func (strategy) AllowCreateOnUpdate() bool { ...@@ -56,7 +57,7 @@ func (strategy) AllowCreateOnUpdate() bool {
return false return false
} }
func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
cleanSecretReferences(obj.(*api.ServiceAccount)) cleanSecretReferences(obj.(*api.ServiceAccount))
} }
...@@ -66,7 +67,7 @@ func cleanSecretReferences(serviceAccount *api.ServiceAccount) { ...@@ -66,7 +67,7 @@ func cleanSecretReferences(serviceAccount *api.ServiceAccount) {
} }
} }
func (strategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (strategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateServiceAccountUpdate(obj.(*api.ServiceAccount), old.(*api.ServiceAccount)) return validation.ValidateServiceAccountUpdate(obj.(*api.ServiceAccount), old.(*api.ServiceAccount))
} }
......
...@@ -16,7 +16,6 @@ go_library( ...@@ -16,7 +16,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
......
...@@ -17,13 +17,13 @@ limitations under the License. ...@@ -17,13 +17,13 @@ limitations under the License.
package event package event
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
apistorage "k8s.io/apiserver/pkg/storage" apistorage "k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
...@@ -47,15 +47,15 @@ func (eventStrategy) NamespaceScoped() bool { ...@@ -47,15 +47,15 @@ func (eventStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of a Pod Preset before creation. // PrepareForCreate clears the status of a Pod Preset before creation.
func (eventStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (eventStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (eventStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (eventStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
} }
// Validate validates a new Event. // Validate validates a new Event.
func (eventStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (eventStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
event := obj.(*api.Event) event := obj.(*api.Event)
return validation.ValidateEvent(event) return validation.ValidateEvent(event)
} }
...@@ -69,7 +69,7 @@ func (eventStrategy) AllowCreateOnUpdate() bool { ...@@ -69,7 +69,7 @@ func (eventStrategy) AllowCreateOnUpdate() bool {
func (eventStrategy) Canonicalize(obj runtime.Object) {} func (eventStrategy) Canonicalize(obj runtime.Object) {}
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (eventStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (eventStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
event := obj.(*api.Event) event := obj.(*api.Event)
return validation.ValidateEvent(event) return validation.ValidateEvent(event)
} }
......
...@@ -39,7 +39,6 @@ go_library( ...@@ -39,7 +39,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
], ],
......
...@@ -17,13 +17,13 @@ limitations under the License. ...@@ -17,13 +17,13 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/kubernetes/pkg/apis/autoscaling" "k8s.io/kubernetes/pkg/apis/autoscaling"
...@@ -63,7 +63,7 @@ func (r *ScaleREST) New() runtime.Object { ...@@ -63,7 +63,7 @@ func (r *ScaleREST) New() runtime.Object {
return &autoscaling.Scale{} return &autoscaling.Scale{}
} }
func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
rc, err := (*r.registry).GetController(ctx, name, options) rc, err := (*r.registry).GetController(ctx, name, options)
if err != nil { if err != nil {
return nil, errors.NewNotFound(extensions.Resource("replicationcontrollers/scale"), name) return nil, errors.NewNotFound(extensions.Resource("replicationcontrollers/scale"), name)
...@@ -71,7 +71,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met ...@@ -71,7 +71,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met
return scaleFromRC(rc), nil return scaleFromRC(rc), nil
} }
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
rc, err := (*r.registry).GetController(ctx, name, &metav1.GetOptions{}) rc, err := (*r.registry).GetController(ctx, name, &metav1.GetOptions{})
if err != nil { if err != nil {
return nil, false, errors.NewNotFound(extensions.Resource("replicationcontrollers/scale"), name) return nil, false, errors.NewNotFound(extensions.Resource("replicationcontrollers/scale"), name)
......
...@@ -20,7 +20,6 @@ go_library( ...@@ -20,7 +20,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library", "//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
) )
......
...@@ -37,7 +37,6 @@ go_library( ...@@ -37,7 +37,6 @@ go_library(
"//pkg/registry/extensions/ingress:go_default_library", "//pkg/registry/extensions/ingress:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package storage package storage
import ( import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -76,11 +77,11 @@ func (r *StatusREST) New() runtime.Object { ...@@ -76,11 +77,11 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,10 +17,11 @@ limitations under the License. ...@@ -17,10 +17,11 @@ limitations under the License.
package ingress package ingress
import ( import (
"context"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
...@@ -42,7 +43,7 @@ func (ingressStrategy) NamespaceScoped() bool { ...@@ -42,7 +43,7 @@ func (ingressStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of an Ingress before creation. // PrepareForCreate clears the status of an Ingress before creation.
func (ingressStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (ingressStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
ingress := obj.(*extensions.Ingress) ingress := obj.(*extensions.Ingress)
// create cannot set status // create cannot set status
ingress.Status = extensions.IngressStatus{} ingress.Status = extensions.IngressStatus{}
...@@ -51,7 +52,7 @@ func (ingressStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runti ...@@ -51,7 +52,7 @@ func (ingressStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runti
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (ingressStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (ingressStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newIngress := obj.(*extensions.Ingress) newIngress := obj.(*extensions.Ingress)
oldIngress := old.(*extensions.Ingress) oldIngress := old.(*extensions.Ingress)
// Update is not allowed to set status // Update is not allowed to set status
...@@ -67,7 +68,7 @@ func (ingressStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old ...@@ -67,7 +68,7 @@ func (ingressStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old
} }
// Validate validates a new Ingress. // Validate validates a new Ingress.
func (ingressStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (ingressStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
ingress := obj.(*extensions.Ingress) ingress := obj.(*extensions.Ingress)
err := validation.ValidateIngress(ingress) err := validation.ValidateIngress(ingress)
return err return err
...@@ -83,7 +84,7 @@ func (ingressStrategy) AllowCreateOnUpdate() bool { ...@@ -83,7 +84,7 @@ func (ingressStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (ingressStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (ingressStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
validationErrorList := validation.ValidateIngress(obj.(*extensions.Ingress)) validationErrorList := validation.ValidateIngress(obj.(*extensions.Ingress))
updateErrorList := validation.ValidateIngressUpdate(obj.(*extensions.Ingress), old.(*extensions.Ingress)) updateErrorList := validation.ValidateIngressUpdate(obj.(*extensions.Ingress), old.(*extensions.Ingress))
return append(validationErrorList, updateErrorList...) return append(validationErrorList, updateErrorList...)
...@@ -101,7 +102,7 @@ type ingressStatusStrategy struct { ...@@ -101,7 +102,7 @@ type ingressStatusStrategy struct {
var StatusStrategy = ingressStatusStrategy{Strategy} var StatusStrategy = ingressStatusStrategy{Strategy}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update of status // PrepareForUpdate clears fields that are not allowed to be set by end users on update of status
func (ingressStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (ingressStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newIngress := obj.(*extensions.Ingress) newIngress := obj.(*extensions.Ingress)
oldIngress := old.(*extensions.Ingress) oldIngress := old.(*extensions.Ingress)
// status changes are not allowed to update spec // status changes are not allowed to update spec
...@@ -109,6 +110,6 @@ func (ingressStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj ...@@ -109,6 +110,6 @@ func (ingressStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj
} }
// ValidateUpdate is the default update validation for an end user updating status // ValidateUpdate is the default update validation for an end user updating status
func (ingressStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (ingressStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateIngressStatusUpdate(obj.(*extensions.Ingress), old.(*extensions.Ingress)) return validation.ValidateIngressStatusUpdate(obj.(*extensions.Ingress), old.(*extensions.Ingress))
} }
...@@ -22,7 +22,6 @@ go_library( ...@@ -22,7 +22,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
......
...@@ -17,22 +17,23 @@ limitations under the License. ...@@ -17,22 +17,23 @@ limitations under the License.
package networkpolicy package networkpolicy
import ( import (
"context"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/kubernetes/pkg/apis/networking" "k8s.io/kubernetes/pkg/apis/networking"
) )
// Registry is an interface for things that know how to store NetworkPolicies. // Registry is an interface for things that know how to store NetworkPolicies.
type Registry interface { type Registry interface {
ListNetworkPolicies(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*networking.NetworkPolicyList, error) ListNetworkPolicies(ctx context.Context, options *metainternalversion.ListOptions) (*networking.NetworkPolicyList, error)
CreateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc) error CreateNetworkPolicy(ctx context.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc) error
UpdateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error UpdateNetworkPolicy(ctx context.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
GetNetworkPolicy(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*networking.NetworkPolicy, error) GetNetworkPolicy(ctx context.Context, name string, options *metav1.GetOptions) (*networking.NetworkPolicy, error)
DeleteNetworkPolicy(ctx genericapirequest.Context, name string) error DeleteNetworkPolicy(ctx context.Context, name string) error
WatchNetworkPolicies(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchNetworkPolicies(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListNetworkPolicies(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*networking.NetworkPolicyList, error) { func (s *storage) ListNetworkPolicies(ctx context.Context, options *metainternalversion.ListOptions) (*networking.NetworkPolicyList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -55,21 +56,21 @@ func (s *storage) ListNetworkPolicies(ctx genericapirequest.Context, options *me ...@@ -55,21 +56,21 @@ func (s *storage) ListNetworkPolicies(ctx genericapirequest.Context, options *me
return obj.(*networking.NetworkPolicyList), nil return obj.(*networking.NetworkPolicyList), nil
} }
func (s *storage) CreateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc) error { func (s *storage) CreateNetworkPolicy(ctx context.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc) error {
_, err := s.Create(ctx, np, createValidation, false) _, err := s.Create(ctx, np, createValidation, false)
return err return err
} }
func (s *storage) UpdateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error { func (s *storage) UpdateNetworkPolicy(ctx context.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
_, _, err := s.Update(ctx, np.Name, rest.DefaultUpdatedObjectInfo(np), createValidation, updateValidation) _, _, err := s.Update(ctx, np.Name, rest.DefaultUpdatedObjectInfo(np), createValidation, updateValidation)
return err return err
} }
func (s *storage) WatchNetworkPolicies(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchNetworkPolicies(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetNetworkPolicy(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*networking.NetworkPolicy, error) { func (s *storage) GetNetworkPolicy(ctx context.Context, name string, options *metav1.GetOptions) (*networking.NetworkPolicy, error) {
obj, err := s.Get(ctx, name, options) obj, err := s.Get(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -77,7 +78,7 @@ func (s *storage) GetNetworkPolicy(ctx genericapirequest.Context, name string, o ...@@ -77,7 +78,7 @@ func (s *storage) GetNetworkPolicy(ctx genericapirequest.Context, name string, o
return obj.(*networking.NetworkPolicy), nil return obj.(*networking.NetworkPolicy), nil
} }
func (s *storage) DeleteNetworkPolicy(ctx genericapirequest.Context, name string) error { func (s *storage) DeleteNetworkPolicy(ctx context.Context, name string) error {
_, _, err := s.Delete(ctx, name, nil) _, _, err := s.Delete(ctx, name, nil)
return err return err
} }
...@@ -17,11 +17,11 @@ limitations under the License. ...@@ -17,11 +17,11 @@ limitations under the License.
package networkpolicy package networkpolicy
import ( import (
"context"
"reflect" "reflect"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/networking" "k8s.io/kubernetes/pkg/apis/networking"
...@@ -43,13 +43,13 @@ func (networkPolicyStrategy) NamespaceScoped() bool { ...@@ -43,13 +43,13 @@ func (networkPolicyStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of a NetworkPolicy before creation. // PrepareForCreate clears the status of a NetworkPolicy before creation.
func (networkPolicyStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (networkPolicyStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
networkPolicy := obj.(*networking.NetworkPolicy) networkPolicy := obj.(*networking.NetworkPolicy)
networkPolicy.Generation = 1 networkPolicy.Generation = 1
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (networkPolicyStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (networkPolicyStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newNetworkPolicy := obj.(*networking.NetworkPolicy) newNetworkPolicy := obj.(*networking.NetworkPolicy)
oldNetworkPolicy := old.(*networking.NetworkPolicy) oldNetworkPolicy := old.(*networking.NetworkPolicy)
...@@ -62,7 +62,7 @@ func (networkPolicyStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj ...@@ -62,7 +62,7 @@ func (networkPolicyStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj
} }
// Validate validates a new NetworkPolicy. // Validate validates a new NetworkPolicy.
func (networkPolicyStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (networkPolicyStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
networkPolicy := obj.(*networking.NetworkPolicy) networkPolicy := obj.(*networking.NetworkPolicy)
return validation.ValidateNetworkPolicy(networkPolicy) return validation.ValidateNetworkPolicy(networkPolicy)
} }
...@@ -76,7 +76,7 @@ func (networkPolicyStrategy) AllowCreateOnUpdate() bool { ...@@ -76,7 +76,7 @@ func (networkPolicyStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (networkPolicyStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (networkPolicyStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
validationErrorList := validation.ValidateNetworkPolicy(obj.(*networking.NetworkPolicy)) validationErrorList := validation.ValidateNetworkPolicy(obj.(*networking.NetworkPolicy))
updateErrorList := validation.ValidateNetworkPolicyUpdate(obj.(*networking.NetworkPolicy), old.(*networking.NetworkPolicy)) updateErrorList := validation.ValidateNetworkPolicyUpdate(obj.(*networking.NetworkPolicy), old.(*networking.NetworkPolicy))
return append(validationErrorList, updateErrorList...) return append(validationErrorList, updateErrorList...)
......
...@@ -20,7 +20,6 @@ go_library( ...@@ -20,7 +20,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library", "//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
) )
......
...@@ -37,7 +37,6 @@ go_library( ...@@ -37,7 +37,6 @@ go_library(
"//pkg/registry/policy/poddisruptionbudget:go_default_library", "//pkg/registry/policy/poddisruptionbudget:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package storage package storage
import ( import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -73,11 +74,11 @@ func (r *StatusREST) New() runtime.Object { ...@@ -73,11 +74,11 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,10 +17,11 @@ limitations under the License. ...@@ -17,10 +17,11 @@ limitations under the License.
package poddisruptionbudget package poddisruptionbudget
import ( import (
"context"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/policy" "k8s.io/kubernetes/pkg/apis/policy"
...@@ -42,7 +43,7 @@ func (podDisruptionBudgetStrategy) NamespaceScoped() bool { ...@@ -42,7 +43,7 @@ func (podDisruptionBudgetStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of an PodDisruptionBudget before creation. // PrepareForCreate clears the status of an PodDisruptionBudget before creation.
func (podDisruptionBudgetStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (podDisruptionBudgetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
podDisruptionBudget := obj.(*policy.PodDisruptionBudget) podDisruptionBudget := obj.(*policy.PodDisruptionBudget)
// create cannot set status // create cannot set status
podDisruptionBudget.Status = policy.PodDisruptionBudgetStatus{} podDisruptionBudget.Status = policy.PodDisruptionBudgetStatus{}
...@@ -51,7 +52,7 @@ func (podDisruptionBudgetStrategy) PrepareForCreate(ctx genericapirequest.Contex ...@@ -51,7 +52,7 @@ func (podDisruptionBudgetStrategy) PrepareForCreate(ctx genericapirequest.Contex
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (podDisruptionBudgetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (podDisruptionBudgetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newPodDisruptionBudget := obj.(*policy.PodDisruptionBudget) newPodDisruptionBudget := obj.(*policy.PodDisruptionBudget)
oldPodDisruptionBudget := old.(*policy.PodDisruptionBudget) oldPodDisruptionBudget := old.(*policy.PodDisruptionBudget)
// Update is not allowed to set status // Update is not allowed to set status
...@@ -66,7 +67,7 @@ func (podDisruptionBudgetStrategy) PrepareForUpdate(ctx genericapirequest.Contex ...@@ -66,7 +67,7 @@ func (podDisruptionBudgetStrategy) PrepareForUpdate(ctx genericapirequest.Contex
} }
// Validate validates a new PodDisruptionBudget. // Validate validates a new PodDisruptionBudget.
func (podDisruptionBudgetStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (podDisruptionBudgetStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
podDisruptionBudget := obj.(*policy.PodDisruptionBudget) podDisruptionBudget := obj.(*policy.PodDisruptionBudget)
return validation.ValidatePodDisruptionBudget(podDisruptionBudget) return validation.ValidatePodDisruptionBudget(podDisruptionBudget)
} }
...@@ -81,7 +82,7 @@ func (podDisruptionBudgetStrategy) AllowCreateOnUpdate() bool { ...@@ -81,7 +82,7 @@ func (podDisruptionBudgetStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (podDisruptionBudgetStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (podDisruptionBudgetStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
validationErrorList := validation.ValidatePodDisruptionBudget(obj.(*policy.PodDisruptionBudget)) validationErrorList := validation.ValidatePodDisruptionBudget(obj.(*policy.PodDisruptionBudget))
updateErrorList := validation.ValidatePodDisruptionBudgetUpdate(obj.(*policy.PodDisruptionBudget), old.(*policy.PodDisruptionBudget)) updateErrorList := validation.ValidatePodDisruptionBudgetUpdate(obj.(*policy.PodDisruptionBudget), old.(*policy.PodDisruptionBudget))
return append(validationErrorList, updateErrorList...) return append(validationErrorList, updateErrorList...)
...@@ -100,7 +101,7 @@ type podDisruptionBudgetStatusStrategy struct { ...@@ -100,7 +101,7 @@ type podDisruptionBudgetStatusStrategy struct {
var StatusStrategy = podDisruptionBudgetStatusStrategy{Strategy} var StatusStrategy = podDisruptionBudgetStatusStrategy{Strategy}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update of status // PrepareForUpdate clears fields that are not allowed to be set by end users on update of status
func (podDisruptionBudgetStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (podDisruptionBudgetStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newPodDisruptionBudget := obj.(*policy.PodDisruptionBudget) newPodDisruptionBudget := obj.(*policy.PodDisruptionBudget)
oldPodDisruptionBudget := old.(*policy.PodDisruptionBudget) oldPodDisruptionBudget := old.(*policy.PodDisruptionBudget)
// status changes are not allowed to update spec // status changes are not allowed to update spec
...@@ -108,7 +109,7 @@ func (podDisruptionBudgetStatusStrategy) PrepareForUpdate(ctx genericapirequest. ...@@ -108,7 +109,7 @@ func (podDisruptionBudgetStatusStrategy) PrepareForUpdate(ctx genericapirequest.
} }
// ValidateUpdate is the default update validation for an end user updating status // ValidateUpdate is the default update validation for an end user updating status
func (podDisruptionBudgetStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (podDisruptionBudgetStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
// TODO: Validate status updates. // TODO: Validate status updates.
return field.ErrorList{} return field.ErrorList{}
// return validation.ValidatePodDisruptionBudgetStatusUpdate(obj.(*policy.PodDisruptionBudget), old.(*policy.PodDisruptionBudget)) // return validation.ValidatePodDisruptionBudgetStatusUpdate(obj.(*policy.PodDisruptionBudget), old.(*policy.PodDisruptionBudget))
......
...@@ -18,7 +18,6 @@ go_library( ...@@ -18,7 +18,6 @@ go_library(
"//pkg/apis/policy/validation:go_default_library", "//pkg/apis/policy/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package podsecuritypolicy package podsecuritypolicy
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
...@@ -53,19 +54,19 @@ func (strategy) AllowUnconditionalUpdate() bool { ...@@ -53,19 +54,19 @@ func (strategy) AllowUnconditionalUpdate() bool {
return true return true
} }
func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
} }
func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
} }
func (strategy) Canonicalize(obj runtime.Object) { func (strategy) Canonicalize(obj runtime.Object) {
} }
func (strategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
return validation.ValidatePodSecurityPolicy(obj.(*policy.PodSecurityPolicy)) return validation.ValidatePodSecurityPolicy(obj.(*policy.PodSecurityPolicy))
} }
func (strategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (strategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidatePodSecurityPolicyUpdate(old.(*policy.PodSecurityPolicy), obj.(*policy.PodSecurityPolicy)) return validation.ValidatePodSecurityPolicyUpdate(old.(*policy.PodSecurityPolicy), obj.(*policy.PodSecurityPolicy))
} }
...@@ -16,7 +16,6 @@ go_library( ...@@ -16,7 +16,6 @@ go_library(
"//pkg/registry/rbac/validation:go_default_library", "//pkg/registry/rbac/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library", "//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
], ],
) )
......
...@@ -18,11 +18,11 @@ limitations under the License. ...@@ -18,11 +18,11 @@ limitations under the License.
package policybased package policybased
import ( import (
"context"
"errors" "errors"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
kapihelper "k8s.io/kubernetes/pkg/apis/core/helper" kapihelper "k8s.io/kubernetes/pkg/apis/core/helper"
"k8s.io/kubernetes/pkg/apis/rbac" "k8s.io/kubernetes/pkg/apis/rbac"
...@@ -47,7 +47,7 @@ var fullAuthority = []rbac.PolicyRule{ ...@@ -47,7 +47,7 @@ var fullAuthority = []rbac.PolicyRule{
rbac.NewRule("*").URLs("*").RuleOrDie(), rbac.NewRule("*").URLs("*").RuleOrDie(),
} }
func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, createValidatingAdmission rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (s *Storage) Create(ctx context.Context, obj runtime.Object, createValidatingAdmission rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
if rbacregistry.EscalationAllowed(ctx) { if rbacregistry.EscalationAllowed(ctx) {
return s.StandardStorage.Create(ctx, obj, createValidatingAdmission, includeUninitialized) return s.StandardStorage.Create(ctx, obj, createValidatingAdmission, includeUninitialized)
} }
...@@ -67,12 +67,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, crea ...@@ -67,12 +67,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, crea
return s.StandardStorage.Create(ctx, obj, createValidatingAdmission, includeUninitialized) return s.StandardStorage.Create(ctx, obj, createValidatingAdmission, includeUninitialized)
} }
func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
if rbacregistry.EscalationAllowed(ctx) { if rbacregistry.EscalationAllowed(ctx) {
return s.StandardStorage.Update(ctx, name, obj, createValidation, updateValidation) return s.StandardStorage.Update(ctx, name, obj, createValidation, updateValidation)
} }
nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx genericapirequest.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) { nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx context.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
clusterRole := obj.(*rbac.ClusterRole) clusterRole := obj.(*rbac.ClusterRole)
oldClusterRole := oldObj.(*rbac.ClusterRole) oldClusterRole := oldObj.(*rbac.ClusterRole)
......
...@@ -17,6 +17,8 @@ limitations under the License. ...@@ -17,6 +17,8 @@ limitations under the License.
package clusterrole package clusterrole
import ( import (
"context"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
...@@ -27,12 +29,12 @@ import ( ...@@ -27,12 +29,12 @@ import (
// Registry is an interface for things that know how to store ClusterRoles. // Registry is an interface for things that know how to store ClusterRoles.
type Registry interface { type Registry interface {
ListClusterRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleList, error) ListClusterRoles(ctx context.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleList, error)
CreateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc) error CreateClusterRole(ctx context.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc) error
UpdateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error UpdateClusterRole(ctx context.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
GetClusterRole(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRole, error) GetClusterRole(ctx context.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRole, error)
DeleteClusterRole(ctx genericapirequest.Context, name string) error DeleteClusterRole(ctx context.Context, name string) error
WatchClusterRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchClusterRoles(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -46,7 +48,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -46,7 +48,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListClusterRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleList, error) { func (s *storage) ListClusterRoles(ctx context.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -55,21 +57,21 @@ func (s *storage) ListClusterRoles(ctx genericapirequest.Context, options *metai ...@@ -55,21 +57,21 @@ func (s *storage) ListClusterRoles(ctx genericapirequest.Context, options *metai
return obj.(*rbac.ClusterRoleList), nil return obj.(*rbac.ClusterRoleList), nil
} }
func (s *storage) CreateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc) error { func (s *storage) CreateClusterRole(ctx context.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc) error {
_, err := s.Create(ctx, clusterRole, createValidation, false) _, err := s.Create(ctx, clusterRole, createValidation, false)
return err return err
} }
func (s *storage) UpdateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error { func (s *storage) UpdateClusterRole(ctx context.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
_, _, err := s.Update(ctx, clusterRole.Name, rest.DefaultUpdatedObjectInfo(clusterRole), createValidation, updateValidation) _, _, err := s.Update(ctx, clusterRole.Name, rest.DefaultUpdatedObjectInfo(clusterRole), createValidation, updateValidation)
return err return err
} }
func (s *storage) WatchClusterRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchClusterRoles(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetClusterRole(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRole, error) { func (s *storage) GetClusterRole(ctx context.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRole, error) {
obj, err := s.Get(ctx, name, options) obj, err := s.Get(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -77,7 +79,7 @@ func (s *storage) GetClusterRole(ctx genericapirequest.Context, name string, opt ...@@ -77,7 +79,7 @@ func (s *storage) GetClusterRole(ctx genericapirequest.Context, name string, opt
return obj.(*rbac.ClusterRole), nil return obj.(*rbac.ClusterRole), nil
} }
func (s *storage) DeleteClusterRole(ctx genericapirequest.Context, name string) error { func (s *storage) DeleteClusterRole(ctx context.Context, name string) error {
_, _, err := s.Delete(ctx, name, nil) _, _, err := s.Delete(ctx, name, nil)
return err return err
} }
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package clusterrole package clusterrole
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
...@@ -55,12 +56,12 @@ func (strategy) AllowCreateOnUpdate() bool { ...@@ -55,12 +56,12 @@ func (strategy) AllowCreateOnUpdate() bool {
// PrepareForCreate clears fields that are not allowed to be set by end users // PrepareForCreate clears fields that are not allowed to be set by end users
// on creation. // on creation.
func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
_ = obj.(*rbac.ClusterRole) _ = obj.(*rbac.ClusterRole)
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newClusterRole := obj.(*rbac.ClusterRole) newClusterRole := obj.(*rbac.ClusterRole)
oldClusterRole := old.(*rbac.ClusterRole) oldClusterRole := old.(*rbac.ClusterRole)
...@@ -68,7 +69,7 @@ func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime ...@@ -68,7 +69,7 @@ func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime
} }
// Validate validates a new ClusterRole. Validation must check for a correct signature. // Validate validates a new ClusterRole. Validation must check for a correct signature.
func (strategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
clusterRole := obj.(*rbac.ClusterRole) clusterRole := obj.(*rbac.ClusterRole)
return validation.ValidateClusterRole(clusterRole) return validation.ValidateClusterRole(clusterRole)
} }
...@@ -79,7 +80,7 @@ func (strategy) Canonicalize(obj runtime.Object) { ...@@ -79,7 +80,7 @@ func (strategy) Canonicalize(obj runtime.Object) {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (strategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (strategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
newObj := obj.(*rbac.ClusterRole) newObj := obj.(*rbac.ClusterRole)
errorList := validation.ValidateClusterRole(newObj) errorList := validation.ValidateClusterRole(newObj)
return append(errorList, validation.ValidateClusterRoleUpdate(newObj, old.(*rbac.ClusterRole))...) return append(errorList, validation.ValidateClusterRoleUpdate(newObj, old.(*rbac.ClusterRole))...)
......
...@@ -18,7 +18,6 @@ go_library( ...@@ -18,7 +18,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library", "//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
], ],
) )
......
...@@ -18,11 +18,12 @@ limitations under the License. ...@@ -18,11 +18,12 @@ limitations under the License.
package policybased package policybased
import ( import (
"context"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/authorization/authorizer" "k8s.io/apiserver/pkg/authorization/authorizer"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
kapihelper "k8s.io/kubernetes/pkg/apis/core/helper" kapihelper "k8s.io/kubernetes/pkg/apis/core/helper"
"k8s.io/kubernetes/pkg/apis/rbac" "k8s.io/kubernetes/pkg/apis/rbac"
...@@ -44,7 +45,7 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe ...@@ -44,7 +45,7 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe
return &Storage{s, authorizer, ruleResolver} return &Storage{s, authorizer, ruleResolver}
} }
func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (s *Storage) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
if rbacregistry.EscalationAllowed(ctx) { if rbacregistry.EscalationAllowed(ctx) {
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized) return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
} }
...@@ -64,12 +65,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, crea ...@@ -64,12 +65,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, crea
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized) return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
} }
func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
if rbacregistry.EscalationAllowed(ctx) { if rbacregistry.EscalationAllowed(ctx) {
return s.StandardStorage.Update(ctx, name, obj, createValidation, updateValidation) return s.StandardStorage.Update(ctx, name, obj, createValidation, updateValidation)
} }
nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx genericapirequest.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) { nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx context.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
clusterRoleBinding := obj.(*rbac.ClusterRoleBinding) clusterRoleBinding := obj.(*rbac.ClusterRoleBinding)
// if we're only mutating fields needed for the GC to eventually delete this obj, return // if we're only mutating fields needed for the GC to eventually delete this obj, return
......
...@@ -17,6 +17,8 @@ limitations under the License. ...@@ -17,6 +17,8 @@ limitations under the License.
package clusterrolebinding package clusterrolebinding
import ( import (
"context"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
...@@ -27,12 +29,12 @@ import ( ...@@ -27,12 +29,12 @@ import (
// Registry is an interface for things that know how to store ClusterRoleBindings. // Registry is an interface for things that know how to store ClusterRoleBindings.
type Registry interface { type Registry interface {
ListClusterRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleBindingList, error) ListClusterRoleBindings(ctx context.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleBindingList, error)
CreateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc) error CreateClusterRoleBinding(ctx context.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc) error
UpdateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error UpdateClusterRoleBinding(ctx context.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
GetClusterRoleBinding(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRoleBinding, error) GetClusterRoleBinding(ctx context.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRoleBinding, error)
DeleteClusterRoleBinding(ctx genericapirequest.Context, name string) error DeleteClusterRoleBinding(ctx context.Context, name string) error
WatchClusterRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchClusterRoleBindings(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -46,7 +48,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -46,7 +48,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListClusterRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleBindingList, error) { func (s *storage) ListClusterRoleBindings(ctx context.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleBindingList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -55,21 +57,21 @@ func (s *storage) ListClusterRoleBindings(ctx genericapirequest.Context, options ...@@ -55,21 +57,21 @@ func (s *storage) ListClusterRoleBindings(ctx genericapirequest.Context, options
return obj.(*rbac.ClusterRoleBindingList), nil return obj.(*rbac.ClusterRoleBindingList), nil
} }
func (s *storage) CreateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc) error { func (s *storage) CreateClusterRoleBinding(ctx context.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc) error {
_, err := s.Create(ctx, clusterRoleBinding, createValidation, false) _, err := s.Create(ctx, clusterRoleBinding, createValidation, false)
return err return err
} }
func (s *storage) UpdateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error { func (s *storage) UpdateClusterRoleBinding(ctx context.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
_, _, err := s.Update(ctx, clusterRoleBinding.Name, rest.DefaultUpdatedObjectInfo(clusterRoleBinding), createValidation, updateValidation) _, _, err := s.Update(ctx, clusterRoleBinding.Name, rest.DefaultUpdatedObjectInfo(clusterRoleBinding), createValidation, updateValidation)
return err return err
} }
func (s *storage) WatchClusterRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchClusterRoleBindings(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetClusterRoleBinding(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRoleBinding, error) { func (s *storage) GetClusterRoleBinding(ctx context.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRoleBinding, error) {
obj, err := s.Get(ctx, name, options) obj, err := s.Get(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -77,7 +79,7 @@ func (s *storage) GetClusterRoleBinding(ctx genericapirequest.Context, name stri ...@@ -77,7 +79,7 @@ func (s *storage) GetClusterRoleBinding(ctx genericapirequest.Context, name stri
return obj.(*rbac.ClusterRoleBinding), nil return obj.(*rbac.ClusterRoleBinding), nil
} }
func (s *storage) DeleteClusterRoleBinding(ctx genericapirequest.Context, name string) error { func (s *storage) DeleteClusterRoleBinding(ctx context.Context, name string) error {
_, _, err := s.Delete(ctx, name, nil) _, _, err := s.Delete(ctx, name, nil)
return err return err
} }
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package clusterrolebinding package clusterrolebinding
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
...@@ -55,12 +56,12 @@ func (strategy) AllowCreateOnUpdate() bool { ...@@ -55,12 +56,12 @@ func (strategy) AllowCreateOnUpdate() bool {
// PrepareForCreate clears fields that are not allowed to be set by end users // PrepareForCreate clears fields that are not allowed to be set by end users
// on creation. // on creation.
func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
_ = obj.(*rbac.ClusterRoleBinding) _ = obj.(*rbac.ClusterRoleBinding)
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newClusterRoleBinding := obj.(*rbac.ClusterRoleBinding) newClusterRoleBinding := obj.(*rbac.ClusterRoleBinding)
oldClusterRoleBinding := old.(*rbac.ClusterRoleBinding) oldClusterRoleBinding := old.(*rbac.ClusterRoleBinding)
...@@ -68,7 +69,7 @@ func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime ...@@ -68,7 +69,7 @@ func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime
} }
// Validate validates a new ClusterRoleBinding. Validation must check for a correct signature. // Validate validates a new ClusterRoleBinding. Validation must check for a correct signature.
func (strategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
clusterRoleBinding := obj.(*rbac.ClusterRoleBinding) clusterRoleBinding := obj.(*rbac.ClusterRoleBinding)
return validation.ValidateClusterRoleBinding(clusterRoleBinding) return validation.ValidateClusterRoleBinding(clusterRoleBinding)
} }
...@@ -79,7 +80,7 @@ func (strategy) Canonicalize(obj runtime.Object) { ...@@ -79,7 +80,7 @@ func (strategy) Canonicalize(obj runtime.Object) {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (strategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (strategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
newObj := obj.(*rbac.ClusterRoleBinding) newObj := obj.(*rbac.ClusterRoleBinding)
errorList := validation.ValidateClusterRoleBinding(newObj) errorList := validation.ValidateClusterRoleBinding(newObj)
return append(errorList, validation.ValidateClusterRoleBindingUpdate(newObj, old.(*rbac.ClusterRoleBinding))...) return append(errorList, validation.ValidateClusterRoleBindingUpdate(newObj, old.(*rbac.ClusterRoleBinding))...)
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package rbac package rbac
import ( import (
"context"
"fmt" "fmt"
utilruntime "k8s.io/apimachinery/pkg/util/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime"
...@@ -26,7 +27,7 @@ import ( ...@@ -26,7 +27,7 @@ import (
"k8s.io/kubernetes/pkg/apis/rbac" "k8s.io/kubernetes/pkg/apis/rbac"
) )
func EscalationAllowed(ctx genericapirequest.Context) bool { func EscalationAllowed(ctx context.Context) bool {
u, ok := genericapirequest.UserFrom(ctx) u, ok := genericapirequest.UserFrom(ctx)
if !ok { if !ok {
return false return false
...@@ -44,7 +45,7 @@ func EscalationAllowed(ctx genericapirequest.Context) bool { ...@@ -44,7 +45,7 @@ func EscalationAllowed(ctx genericapirequest.Context) bool {
} }
// BindingAuthorized returns true if the user associated with the context is explicitly authorized to bind the specified roleRef // BindingAuthorized returns true if the user associated with the context is explicitly authorized to bind the specified roleRef
func BindingAuthorized(ctx genericapirequest.Context, roleRef rbac.RoleRef, bindingNamespace string, a authorizer.Authorizer) bool { func BindingAuthorized(ctx context.Context, roleRef rbac.RoleRef, bindingNamespace string, a authorizer.Authorizer) bool {
if a == nil { if a == nil {
return false return false
} }
......
...@@ -16,7 +16,6 @@ go_library( ...@@ -16,7 +16,6 @@ go_library(
"//pkg/registry/rbac/validation:go_default_library", "//pkg/registry/rbac/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library", "//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
], ],
) )
......
...@@ -18,9 +18,10 @@ limitations under the License. ...@@ -18,9 +18,10 @@ limitations under the License.
package policybased package policybased
import ( import (
"context"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
kapihelper "k8s.io/kubernetes/pkg/apis/core/helper" kapihelper "k8s.io/kubernetes/pkg/apis/core/helper"
"k8s.io/kubernetes/pkg/apis/rbac" "k8s.io/kubernetes/pkg/apis/rbac"
...@@ -40,7 +41,7 @@ func NewStorage(s rest.StandardStorage, ruleResolver rbacregistryvalidation.Auth ...@@ -40,7 +41,7 @@ func NewStorage(s rest.StandardStorage, ruleResolver rbacregistryvalidation.Auth
return &Storage{s, ruleResolver} return &Storage{s, ruleResolver}
} }
func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (s *Storage) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
if rbacregistry.EscalationAllowed(ctx) { if rbacregistry.EscalationAllowed(ctx) {
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized) return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
} }
...@@ -53,12 +54,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, crea ...@@ -53,12 +54,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, crea
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized) return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
} }
func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
if rbacregistry.EscalationAllowed(ctx) { if rbacregistry.EscalationAllowed(ctx) {
return s.StandardStorage.Update(ctx, name, obj, createValidation, updateValidation) return s.StandardStorage.Update(ctx, name, obj, createValidation, updateValidation)
} }
nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx genericapirequest.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) { nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx context.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
role := obj.(*rbac.Role) role := obj.(*rbac.Role)
// if we're only mutating fields needed for the GC to eventually delete this obj, return // if we're only mutating fields needed for the GC to eventually delete this obj, return
......
...@@ -17,6 +17,8 @@ limitations under the License. ...@@ -17,6 +17,8 @@ limitations under the License.
package role package role
import ( import (
"context"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
...@@ -27,12 +29,12 @@ import ( ...@@ -27,12 +29,12 @@ import (
// Registry is an interface for things that know how to store Roles. // Registry is an interface for things that know how to store Roles.
type Registry interface { type Registry interface {
ListRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.RoleList, error) ListRoles(ctx context.Context, options *metainternalversion.ListOptions) (*rbac.RoleList, error)
CreateRole(ctx genericapirequest.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc) error CreateRole(ctx context.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc) error
UpdateRole(ctx genericapirequest.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error UpdateRole(ctx context.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
GetRole(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.Role, error) GetRole(ctx context.Context, name string, options *metav1.GetOptions) (*rbac.Role, error)
DeleteRole(ctx genericapirequest.Context, name string) error DeleteRole(ctx context.Context, name string) error
WatchRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchRoles(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -46,7 +48,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -46,7 +48,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.RoleList, error) { func (s *storage) ListRoles(ctx context.Context, options *metainternalversion.ListOptions) (*rbac.RoleList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -55,22 +57,22 @@ func (s *storage) ListRoles(ctx genericapirequest.Context, options *metainternal ...@@ -55,22 +57,22 @@ func (s *storage) ListRoles(ctx genericapirequest.Context, options *metainternal
return obj.(*rbac.RoleList), nil return obj.(*rbac.RoleList), nil
} }
func (s *storage) CreateRole(ctx genericapirequest.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc) error { func (s *storage) CreateRole(ctx context.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc) error {
_, err := s.Create(ctx, role, createValidation, false) _, err := s.Create(ctx, role, createValidation, false)
return err return err
} }
func (s *storage) UpdateRole(ctx genericapirequest.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error { func (s *storage) UpdateRole(ctx context.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
// TODO: any admission? // TODO: any admission?
_, _, err := s.Update(ctx, role.Name, rest.DefaultUpdatedObjectInfo(role), createValidation, updateValidation) _, _, err := s.Update(ctx, role.Name, rest.DefaultUpdatedObjectInfo(role), createValidation, updateValidation)
return err return err
} }
func (s *storage) WatchRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchRoles(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetRole(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.Role, error) { func (s *storage) GetRole(ctx context.Context, name string, options *metav1.GetOptions) (*rbac.Role, error) {
obj, err := s.Get(ctx, name, options) obj, err := s.Get(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -78,7 +80,7 @@ func (s *storage) GetRole(ctx genericapirequest.Context, name string, options *m ...@@ -78,7 +80,7 @@ func (s *storage) GetRole(ctx genericapirequest.Context, name string, options *m
return obj.(*rbac.Role), nil return obj.(*rbac.Role), nil
} }
func (s *storage) DeleteRole(ctx genericapirequest.Context, name string) error { func (s *storage) DeleteRole(ctx context.Context, name string) error {
_, _, err := s.Delete(ctx, name, nil) _, _, err := s.Delete(ctx, name, nil)
return err return err
} }
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package role package role
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
...@@ -55,12 +56,12 @@ func (strategy) AllowCreateOnUpdate() bool { ...@@ -55,12 +56,12 @@ func (strategy) AllowCreateOnUpdate() bool {
// PrepareForCreate clears fields that are not allowed to be set by end users // PrepareForCreate clears fields that are not allowed to be set by end users
// on creation. // on creation.
func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
_ = obj.(*rbac.Role) _ = obj.(*rbac.Role)
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newRole := obj.(*rbac.Role) newRole := obj.(*rbac.Role)
oldRole := old.(*rbac.Role) oldRole := old.(*rbac.Role)
...@@ -68,7 +69,7 @@ func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime ...@@ -68,7 +69,7 @@ func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime
} }
// Validate validates a new Role. Validation must check for a correct signature. // Validate validates a new Role. Validation must check for a correct signature.
func (strategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
role := obj.(*rbac.Role) role := obj.(*rbac.Role)
return validation.ValidateRole(role) return validation.ValidateRole(role)
} }
...@@ -79,7 +80,7 @@ func (strategy) Canonicalize(obj runtime.Object) { ...@@ -79,7 +80,7 @@ func (strategy) Canonicalize(obj runtime.Object) {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (strategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (strategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
newObj := obj.(*rbac.Role) newObj := obj.(*rbac.Role)
errorList := validation.ValidateRole(newObj) errorList := validation.ValidateRole(newObj)
return append(errorList, validation.ValidateRoleUpdate(newObj, old.(*rbac.Role))...) return append(errorList, validation.ValidateRoleUpdate(newObj, old.(*rbac.Role))...)
......
...@@ -18,6 +18,8 @@ limitations under the License. ...@@ -18,6 +18,8 @@ limitations under the License.
package policybased package policybased
import ( import (
"context"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/authorization/authorizer" "k8s.io/apiserver/pkg/authorization/authorizer"
...@@ -43,7 +45,7 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe ...@@ -43,7 +45,7 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe
return &Storage{s, authorizer, ruleResolver} return &Storage{s, authorizer, ruleResolver}
} }
func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (s *Storage) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
if rbacregistry.EscalationAllowed(ctx) { if rbacregistry.EscalationAllowed(ctx) {
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized) return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
} }
...@@ -70,12 +72,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, crea ...@@ -70,12 +72,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, crea
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized) return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
} }
func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
if rbacregistry.EscalationAllowed(ctx) { if rbacregistry.EscalationAllowed(ctx) {
return s.StandardStorage.Update(ctx, name, obj, createValidation, updateValidation) return s.StandardStorage.Update(ctx, name, obj, createValidation, updateValidation)
} }
nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx genericapirequest.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) { nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx context.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
// Get the namespace from the context (populated from the URL). // Get the namespace from the context (populated from the URL).
// The namespace in the object can be empty until StandardStorage.Update()->BeforeUpdate() populates it from the context. // The namespace in the object can be empty until StandardStorage.Update()->BeforeUpdate() populates it from the context.
namespace, ok := genericapirequest.NamespaceFrom(ctx) namespace, ok := genericapirequest.NamespaceFrom(ctx)
......
...@@ -17,6 +17,8 @@ limitations under the License. ...@@ -17,6 +17,8 @@ limitations under the License.
package rolebinding package rolebinding
import ( import (
"context"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
...@@ -27,12 +29,12 @@ import ( ...@@ -27,12 +29,12 @@ import (
// Registry is an interface for things that know how to store RoleBindings. // Registry is an interface for things that know how to store RoleBindings.
type Registry interface { type Registry interface {
ListRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.RoleBindingList, error) ListRoleBindings(ctx context.Context, options *metainternalversion.ListOptions) (*rbac.RoleBindingList, error)
CreateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc) error CreateRoleBinding(ctx context.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc) error
UpdateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error UpdateRoleBinding(ctx context.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
GetRoleBinding(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.RoleBinding, error) GetRoleBinding(ctx context.Context, name string, options *metav1.GetOptions) (*rbac.RoleBinding, error)
DeleteRoleBinding(ctx genericapirequest.Context, name string) error DeleteRoleBinding(ctx context.Context, name string) error
WatchRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchRoleBindings(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -46,7 +48,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -46,7 +48,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.RoleBindingList, error) { func (s *storage) ListRoleBindings(ctx context.Context, options *metainternalversion.ListOptions) (*rbac.RoleBindingList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -55,22 +57,22 @@ func (s *storage) ListRoleBindings(ctx genericapirequest.Context, options *metai ...@@ -55,22 +57,22 @@ func (s *storage) ListRoleBindings(ctx genericapirequest.Context, options *metai
return obj.(*rbac.RoleBindingList), nil return obj.(*rbac.RoleBindingList), nil
} }
func (s *storage) CreateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc) error { func (s *storage) CreateRoleBinding(ctx context.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc) error {
// TODO(ericchiang): add additional validation // TODO(ericchiang): add additional validation
_, err := s.Create(ctx, roleBinding, createValidation, false) _, err := s.Create(ctx, roleBinding, createValidation, false)
return err return err
} }
func (s *storage) UpdateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error { func (s *storage) UpdateRoleBinding(ctx context.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
_, _, err := s.Update(ctx, roleBinding.Name, rest.DefaultUpdatedObjectInfo(roleBinding), createValidation, updateValidation) _, _, err := s.Update(ctx, roleBinding.Name, rest.DefaultUpdatedObjectInfo(roleBinding), createValidation, updateValidation)
return err return err
} }
func (s *storage) WatchRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchRoleBindings(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetRoleBinding(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.RoleBinding, error) { func (s *storage) GetRoleBinding(ctx context.Context, name string, options *metav1.GetOptions) (*rbac.RoleBinding, error) {
obj, err := s.Get(ctx, name, options) obj, err := s.Get(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -78,7 +80,7 @@ func (s *storage) GetRoleBinding(ctx genericapirequest.Context, name string, opt ...@@ -78,7 +80,7 @@ func (s *storage) GetRoleBinding(ctx genericapirequest.Context, name string, opt
return obj.(*rbac.RoleBinding), nil return obj.(*rbac.RoleBinding), nil
} }
func (s *storage) DeleteRoleBinding(ctx genericapirequest.Context, name string) error { func (s *storage) DeleteRoleBinding(ctx context.Context, name string) error {
_, _, err := s.Delete(ctx, name, nil) _, _, err := s.Delete(ctx, name, nil)
return err return err
} }
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package rolebinding package rolebinding
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
...@@ -55,12 +56,12 @@ func (strategy) AllowCreateOnUpdate() bool { ...@@ -55,12 +56,12 @@ func (strategy) AllowCreateOnUpdate() bool {
// PrepareForCreate clears fields that are not allowed to be set by end users // PrepareForCreate clears fields that are not allowed to be set by end users
// on creation. // on creation.
func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
_ = obj.(*rbac.RoleBinding) _ = obj.(*rbac.RoleBinding)
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newRoleBinding := obj.(*rbac.RoleBinding) newRoleBinding := obj.(*rbac.RoleBinding)
oldRoleBinding := old.(*rbac.RoleBinding) oldRoleBinding := old.(*rbac.RoleBinding)
...@@ -68,7 +69,7 @@ func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime ...@@ -68,7 +69,7 @@ func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime
} }
// Validate validates a new RoleBinding. Validation must check for a correct signature. // Validate validates a new RoleBinding. Validation must check for a correct signature.
func (strategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
roleBinding := obj.(*rbac.RoleBinding) roleBinding := obj.(*rbac.RoleBinding)
return validation.ValidateRoleBinding(roleBinding) return validation.ValidateRoleBinding(roleBinding)
} }
...@@ -79,7 +80,7 @@ func (strategy) Canonicalize(obj runtime.Object) { ...@@ -79,7 +80,7 @@ func (strategy) Canonicalize(obj runtime.Object) {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (strategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (strategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
newObj := obj.(*rbac.RoleBinding) newObj := obj.(*rbac.RoleBinding)
errorList := validation.ValidateRoleBinding(newObj) errorList := validation.ValidateRoleBinding(newObj)
return append(errorList, validation.ValidateRoleBindingUpdate(newObj, old.(*rbac.RoleBinding))...) return append(errorList, validation.ValidateRoleBindingUpdate(newObj, old.(*rbac.RoleBinding))...)
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package validation package validation
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
...@@ -46,7 +47,7 @@ type AuthorizationRuleResolver interface { ...@@ -46,7 +47,7 @@ type AuthorizationRuleResolver interface {
} }
// ConfirmNoEscalation determines if the roles for a given user in a given namespace encompass the provided role. // ConfirmNoEscalation determines if the roles for a given user in a given namespace encompass the provided role.
func ConfirmNoEscalation(ctx genericapirequest.Context, ruleResolver AuthorizationRuleResolver, rules []rbac.PolicyRule) error { func ConfirmNoEscalation(ctx context.Context, ruleResolver AuthorizationRuleResolver, rules []rbac.PolicyRule) error {
ruleResolutionErrors := []error{} ruleResolutionErrors := []error{}
user, ok := genericapirequest.UserFrom(ctx) user, ok := genericapirequest.UserFrom(ctx)
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package registrytest package registrytest
import ( import (
"context"
"fmt" "fmt"
"sync" "sync"
...@@ -24,7 +25,6 @@ import ( ...@@ -24,7 +25,6 @@ import (
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
) )
...@@ -38,7 +38,7 @@ type EndpointRegistry struct { ...@@ -38,7 +38,7 @@ type EndpointRegistry struct {
lock sync.Mutex lock sync.Mutex
} }
func (e *EndpointRegistry) ListEndpoints(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.EndpointsList, error) { func (e *EndpointRegistry) ListEndpoints(ctx context.Context, options *metainternalversion.ListOptions) (*api.EndpointsList, error) {
// TODO: support namespaces in this mock // TODO: support namespaces in this mock
e.lock.Lock() e.lock.Lock()
defer e.lock.Unlock() defer e.lock.Unlock()
...@@ -46,7 +46,7 @@ func (e *EndpointRegistry) ListEndpoints(ctx genericapirequest.Context, options ...@@ -46,7 +46,7 @@ func (e *EndpointRegistry) ListEndpoints(ctx genericapirequest.Context, options
return e.Endpoints, e.Err return e.Endpoints, e.Err
} }
func (e *EndpointRegistry) GetEndpoints(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.Endpoints, error) { func (e *EndpointRegistry) GetEndpoints(ctx context.Context, name string, options *metav1.GetOptions) (*api.Endpoints, error) {
// TODO: support namespaces in this mock // TODO: support namespaces in this mock
e.lock.Lock() e.lock.Lock()
defer e.lock.Unlock() defer e.lock.Unlock()
...@@ -63,11 +63,11 @@ func (e *EndpointRegistry) GetEndpoints(ctx genericapirequest.Context, name stri ...@@ -63,11 +63,11 @@ func (e *EndpointRegistry) GetEndpoints(ctx genericapirequest.Context, name stri
return nil, errors.NewNotFound(api.Resource("endpoints"), name) return nil, errors.NewNotFound(api.Resource("endpoints"), name)
} }
func (e *EndpointRegistry) WatchEndpoints(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (e *EndpointRegistry) WatchEndpoints(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return nil, fmt.Errorf("unimplemented!") return nil, fmt.Errorf("unimplemented!")
} }
func (e *EndpointRegistry) UpdateEndpoints(ctx genericapirequest.Context, endpoints *api.Endpoints, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error { func (e *EndpointRegistry) UpdateEndpoints(ctx context.Context, endpoints *api.Endpoints, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
// TODO: support namespaces in this mock // TODO: support namespaces in this mock
e.lock.Lock() e.lock.Lock()
defer e.lock.Unlock() defer e.lock.Unlock()
...@@ -94,7 +94,7 @@ func (e *EndpointRegistry) UpdateEndpoints(ctx genericapirequest.Context, endpoi ...@@ -94,7 +94,7 @@ func (e *EndpointRegistry) UpdateEndpoints(ctx genericapirequest.Context, endpoi
return nil return nil
} }
func (e *EndpointRegistry) DeleteEndpoints(ctx genericapirequest.Context, name string) error { func (e *EndpointRegistry) DeleteEndpoints(ctx context.Context, name string) error {
// TODO: support namespaces in this mock // TODO: support namespaces in this mock
e.lock.Lock() e.lock.Lock()
defer e.lock.Unlock() defer e.lock.Unlock()
......
...@@ -17,13 +17,13 @@ limitations under the License. ...@@ -17,13 +17,13 @@ limitations under the License.
package registrytest package registrytest
import ( import (
"context"
"sync" "sync"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
) )
...@@ -60,13 +60,13 @@ func (r *NodeRegistry) SetError(err error) { ...@@ -60,13 +60,13 @@ func (r *NodeRegistry) SetError(err error) {
r.Err = err r.Err = err
} }
func (r *NodeRegistry) ListNodes(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.NodeList, error) { func (r *NodeRegistry) ListNodes(ctx context.Context, options *metainternalversion.ListOptions) (*api.NodeList, error) {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
return &r.Nodes, r.Err return &r.Nodes, r.Err
} }
func (r *NodeRegistry) CreateNode(ctx genericapirequest.Context, node *api.Node) error { func (r *NodeRegistry) CreateNode(ctx context.Context, node *api.Node) error {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
r.Node = node.Name r.Node = node.Name
...@@ -74,7 +74,7 @@ func (r *NodeRegistry) CreateNode(ctx genericapirequest.Context, node *api.Node) ...@@ -74,7 +74,7 @@ func (r *NodeRegistry) CreateNode(ctx genericapirequest.Context, node *api.Node)
return r.Err return r.Err
} }
func (r *NodeRegistry) UpdateNode(ctx genericapirequest.Context, node *api.Node) error { func (r *NodeRegistry) UpdateNode(ctx context.Context, node *api.Node) error {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
for i, item := range r.Nodes.Items { for i, item := range r.Nodes.Items {
...@@ -86,7 +86,7 @@ func (r *NodeRegistry) UpdateNode(ctx genericapirequest.Context, node *api.Node) ...@@ -86,7 +86,7 @@ func (r *NodeRegistry) UpdateNode(ctx genericapirequest.Context, node *api.Node)
return r.Err return r.Err
} }
func (r *NodeRegistry) GetNode(ctx genericapirequest.Context, nodeID string, options *metav1.GetOptions) (*api.Node, error) { func (r *NodeRegistry) GetNode(ctx context.Context, nodeID string, options *metav1.GetOptions) (*api.Node, error) {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
if r.Err != nil { if r.Err != nil {
...@@ -100,7 +100,7 @@ func (r *NodeRegistry) GetNode(ctx genericapirequest.Context, nodeID string, opt ...@@ -100,7 +100,7 @@ func (r *NodeRegistry) GetNode(ctx genericapirequest.Context, nodeID string, opt
return nil, errors.NewNotFound(api.Resource("nodes"), nodeID) return nil, errors.NewNotFound(api.Resource("nodes"), nodeID)
} }
func (r *NodeRegistry) DeleteNode(ctx genericapirequest.Context, nodeID string) error { func (r *NodeRegistry) DeleteNode(ctx context.Context, nodeID string) error {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
var newList []api.Node var newList []api.Node
...@@ -113,6 +113,6 @@ func (r *NodeRegistry) DeleteNode(ctx genericapirequest.Context, nodeID string) ...@@ -113,6 +113,6 @@ func (r *NodeRegistry) DeleteNode(ctx genericapirequest.Context, nodeID string)
return r.Err return r.Err
} }
func (r *NodeRegistry) WatchNodes(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (r *NodeRegistry) WatchNodes(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return nil, r.Err return nil, r.Err
} }
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package registrytest package registrytest
import ( import (
"context"
"sync" "sync"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
...@@ -49,7 +50,7 @@ func (r *ServiceRegistry) SetError(err error) { ...@@ -49,7 +50,7 @@ func (r *ServiceRegistry) SetError(err error) {
r.Err = err r.Err = err
} }
func (r *ServiceRegistry) ListServices(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ServiceList, error) { func (r *ServiceRegistry) ListServices(ctx context.Context, options *metainternalversion.ListOptions) (*api.ServiceList, error) {
r.mu.Lock() r.mu.Lock()
defer r.mu.Unlock() defer r.mu.Unlock()
...@@ -73,7 +74,7 @@ func (r *ServiceRegistry) ListServices(ctx genericapirequest.Context, options *m ...@@ -73,7 +74,7 @@ func (r *ServiceRegistry) ListServices(ctx genericapirequest.Context, options *m
return res, r.Err return res, r.Err
} }
func (r *ServiceRegistry) CreateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc) (*api.Service, error) { func (r *ServiceRegistry) CreateService(ctx context.Context, svc *api.Service, createValidation rest.ValidateObjectFunc) (*api.Service, error) {
r.mu.Lock() r.mu.Lock()
defer r.mu.Unlock() defer r.mu.Unlock()
...@@ -83,7 +84,7 @@ func (r *ServiceRegistry) CreateService(ctx genericapirequest.Context, svc *api. ...@@ -83,7 +84,7 @@ func (r *ServiceRegistry) CreateService(ctx genericapirequest.Context, svc *api.
return svc, r.Err return svc, r.Err
} }
func (r *ServiceRegistry) GetService(ctx genericapirequest.Context, id string, options *metav1.GetOptions) (*api.Service, error) { func (r *ServiceRegistry) GetService(ctx context.Context, id string, options *metav1.GetOptions) (*api.Service, error) {
r.mu.Lock() r.mu.Lock()
defer r.mu.Unlock() defer r.mu.Unlock()
...@@ -91,7 +92,7 @@ func (r *ServiceRegistry) GetService(ctx genericapirequest.Context, id string, o ...@@ -91,7 +92,7 @@ func (r *ServiceRegistry) GetService(ctx genericapirequest.Context, id string, o
return r.Service, r.Err return r.Service, r.Err
} }
func (r *ServiceRegistry) DeleteService(ctx genericapirequest.Context, id string) error { func (r *ServiceRegistry) DeleteService(ctx context.Context, id string) error {
r.mu.Lock() r.mu.Lock()
defer r.mu.Unlock() defer r.mu.Unlock()
...@@ -100,7 +101,7 @@ func (r *ServiceRegistry) DeleteService(ctx genericapirequest.Context, id string ...@@ -100,7 +101,7 @@ func (r *ServiceRegistry) DeleteService(ctx genericapirequest.Context, id string
return r.Err return r.Err
} }
func (r *ServiceRegistry) UpdateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.Service, error) { func (r *ServiceRegistry) UpdateService(ctx context.Context, svc *api.Service, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.Service, error) {
r.mu.Lock() r.mu.Lock()
defer r.mu.Unlock() defer r.mu.Unlock()
...@@ -110,14 +111,14 @@ func (r *ServiceRegistry) UpdateService(ctx genericapirequest.Context, svc *api. ...@@ -110,14 +111,14 @@ func (r *ServiceRegistry) UpdateService(ctx genericapirequest.Context, svc *api.
return svc, r.Err return svc, r.Err
} }
func (r *ServiceRegistry) WatchServices(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (r *ServiceRegistry) WatchServices(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
r.mu.Lock() r.mu.Lock()
defer r.mu.Unlock() defer r.mu.Unlock()
return nil, r.Err return nil, r.Err
} }
func (r *ServiceRegistry) ExportService(ctx genericapirequest.Context, name string, options metav1.ExportOptions) (*api.Service, error) { func (r *ServiceRegistry) ExportService(ctx context.Context, name string, options metav1.ExportOptions) (*api.Service, error) {
r.mu.Lock() r.mu.Lock()
defer r.mu.Unlock() defer r.mu.Unlock()
......
...@@ -34,7 +34,6 @@ go_library( ...@@ -34,7 +34,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
......
...@@ -17,22 +17,23 @@ limitations under the License. ...@@ -17,22 +17,23 @@ limitations under the License.
package priorityclass package priorityclass
import ( import (
"context"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/kubernetes/pkg/apis/scheduling" "k8s.io/kubernetes/pkg/apis/scheduling"
) )
// Registry is an interface for things that know how to store PriorityClass. // Registry is an interface for things that know how to store PriorityClass.
type Registry interface { type Registry interface {
ListPriorityClasses(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*scheduling.PriorityClassList, error) ListPriorityClasses(ctx context.Context, options *metainternalversion.ListOptions) (*scheduling.PriorityClassList, error)
CreatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc) error CreatePriorityClass(ctx context.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc) error
UpdatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error UpdatePriorityClass(ctx context.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
GetPriorityClass(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*scheduling.PriorityClass, error) GetPriorityClass(ctx context.Context, name string, options *metav1.GetOptions) (*scheduling.PriorityClass, error)
DeletePriorityClass(ctx genericapirequest.Context, name string) error DeletePriorityClass(ctx context.Context, name string) error
WatchPriorityClasses(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchPriorityClasses(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListPriorityClasses(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*scheduling.PriorityClassList, error) { func (s *storage) ListPriorityClasses(ctx context.Context, options *metainternalversion.ListOptions) (*scheduling.PriorityClassList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -55,21 +56,21 @@ func (s *storage) ListPriorityClasses(ctx genericapirequest.Context, options *me ...@@ -55,21 +56,21 @@ func (s *storage) ListPriorityClasses(ctx genericapirequest.Context, options *me
return obj.(*scheduling.PriorityClassList), nil return obj.(*scheduling.PriorityClassList), nil
} }
func (s *storage) CreatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc) error { func (s *storage) CreatePriorityClass(ctx context.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc) error {
_, err := s.Create(ctx, pc, createValidation, false) _, err := s.Create(ctx, pc, createValidation, false)
return err return err
} }
func (s *storage) UpdatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error { func (s *storage) UpdatePriorityClass(ctx context.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
_, _, err := s.Update(ctx, pc.Name, rest.DefaultUpdatedObjectInfo(pc), createValidation, updateValidation) _, _, err := s.Update(ctx, pc.Name, rest.DefaultUpdatedObjectInfo(pc), createValidation, updateValidation)
return err return err
} }
func (s *storage) WatchPriorityClasses(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchPriorityClasses(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetPriorityClass(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*scheduling.PriorityClass, error) { func (s *storage) GetPriorityClass(ctx context.Context, name string, options *metav1.GetOptions) (*scheduling.PriorityClass, error) {
obj, err := s.Get(ctx, name, options) obj, err := s.Get(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -77,7 +78,7 @@ func (s *storage) GetPriorityClass(ctx genericapirequest.Context, name string, o ...@@ -77,7 +78,7 @@ func (s *storage) GetPriorityClass(ctx genericapirequest.Context, name string, o
return obj.(*scheduling.PriorityClass), nil return obj.(*scheduling.PriorityClass), nil
} }
func (s *storage) DeletePriorityClass(ctx genericapirequest.Context, name string) error { func (s *storage) DeletePriorityClass(ctx context.Context, name string) error {
_, _, err := s.Delete(ctx, name, nil) _, _, err := s.Delete(ctx, name, nil)
return err return err
} }
...@@ -34,7 +34,6 @@ go_library( ...@@ -34,7 +34,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library", "//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,12 +17,12 @@ limitations under the License. ...@@ -17,12 +17,12 @@ limitations under the License.
package storage package storage
import ( import (
"context"
"errors" "errors"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -63,7 +63,7 @@ func (r *REST) ShortNames() []string { ...@@ -63,7 +63,7 @@ func (r *REST) ShortNames() []string {
} }
// Delete ensures that system priority classes are not deleted. // Delete ensures that system priority classes are not deleted.
func (r *REST) Delete(ctx genericapirequest.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) { func (r *REST) Delete(ctx context.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
for _, spc := range scheduling.SystemPriorityClasses() { for _, spc := range scheduling.SystemPriorityClasses() {
if name == spc.Name { if name == spc.Name {
return nil, false, apierrors.NewForbidden(scheduling.Resource("priorityclasses"), spc.Name, errors.New("this is a system priority class and cannot be deleted")) return nil, false, apierrors.NewForbidden(scheduling.Resource("priorityclasses"), spc.Name, errors.New("this is a system priority class and cannot be deleted"))
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package priorityclass package priorityclass
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/scheduling" "k8s.io/kubernetes/pkg/apis/scheduling"
...@@ -41,19 +42,19 @@ func (priorityClassStrategy) NamespaceScoped() bool { ...@@ -41,19 +42,19 @@ func (priorityClassStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of a PriorityClass before creation. // PrepareForCreate clears the status of a PriorityClass before creation.
func (priorityClassStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (priorityClassStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
pc := obj.(*scheduling.PriorityClass) pc := obj.(*scheduling.PriorityClass)
pc.Generation = 1 pc.Generation = 1
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (priorityClassStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (priorityClassStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
_ = obj.(*scheduling.PriorityClass) _ = obj.(*scheduling.PriorityClass)
_ = old.(*scheduling.PriorityClass) _ = old.(*scheduling.PriorityClass)
} }
// Validate validates a new PriorityClass. // Validate validates a new PriorityClass.
func (priorityClassStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (priorityClassStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
pc := obj.(*scheduling.PriorityClass) pc := obj.(*scheduling.PriorityClass)
return validation.ValidatePriorityClass(pc) return validation.ValidatePriorityClass(pc)
} }
...@@ -67,7 +68,7 @@ func (priorityClassStrategy) AllowCreateOnUpdate() bool { ...@@ -67,7 +68,7 @@ func (priorityClassStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (priorityClassStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (priorityClassStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidatePriorityClassUpdate(obj.(*scheduling.PriorityClass), old.(*scheduling.PriorityClass)) return validation.ValidatePriorityClassUpdate(obj.(*scheduling.PriorityClass), old.(*scheduling.PriorityClass))
} }
......
...@@ -23,7 +23,6 @@ go_library( ...@@ -23,7 +23,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
......
...@@ -17,22 +17,23 @@ limitations under the License. ...@@ -17,22 +17,23 @@ limitations under the License.
package podpreset package podpreset
import ( import (
"context"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/kubernetes/pkg/apis/settings" "k8s.io/kubernetes/pkg/apis/settings"
) )
// Registry is an interface for things that know how to store PodPresets. // Registry is an interface for things that know how to store PodPresets.
type Registry interface { type Registry interface {
ListPodPresets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*settings.PodPresetList, error) ListPodPresets(ctx context.Context, options *metainternalversion.ListOptions) (*settings.PodPresetList, error)
CreatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc) error CreatePodPreset(ctx context.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc) error
UpdatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error UpdatePodPreset(ctx context.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
GetPodPreset(ctx genericapirequest.Context, ppID string, options *metav1.GetOptions) (*settings.PodPreset, error) GetPodPreset(ctx context.Context, ppID string, options *metav1.GetOptions) (*settings.PodPreset, error)
DeletePodPreset(ctx genericapirequest.Context, ppID string) error DeletePodPreset(ctx context.Context, ppID string) error
WatchPodPresets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchPodPresets(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListPodPresets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*settings.PodPresetList, error) { func (s *storage) ListPodPresets(ctx context.Context, options *metainternalversion.ListOptions) (*settings.PodPresetList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -55,21 +56,21 @@ func (s *storage) ListPodPresets(ctx genericapirequest.Context, options *metaint ...@@ -55,21 +56,21 @@ func (s *storage) ListPodPresets(ctx genericapirequest.Context, options *metaint
return obj.(*settings.PodPresetList), nil return obj.(*settings.PodPresetList), nil
} }
func (s *storage) CreatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc) error { func (s *storage) CreatePodPreset(ctx context.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc) error {
_, err := s.Create(ctx, pp, createValidation, false) _, err := s.Create(ctx, pp, createValidation, false)
return err return err
} }
func (s *storage) UpdatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error { func (s *storage) UpdatePodPreset(ctx context.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
_, _, err := s.Update(ctx, pp.Name, rest.DefaultUpdatedObjectInfo(pp), createValidation, updateValidation) _, _, err := s.Update(ctx, pp.Name, rest.DefaultUpdatedObjectInfo(pp), createValidation, updateValidation)
return err return err
} }
func (s *storage) WatchPodPresets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchPodPresets(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetPodPreset(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*settings.PodPreset, error) { func (s *storage) GetPodPreset(ctx context.Context, name string, options *metav1.GetOptions) (*settings.PodPreset, error) {
obj, err := s.Get(ctx, name, options) obj, err := s.Get(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -77,7 +78,7 @@ func (s *storage) GetPodPreset(ctx genericapirequest.Context, name string, optio ...@@ -77,7 +78,7 @@ func (s *storage) GetPodPreset(ctx genericapirequest.Context, name string, optio
return obj.(*settings.PodPreset), nil return obj.(*settings.PodPreset), nil
} }
func (s *storage) DeletePodPreset(ctx genericapirequest.Context, name string) error { func (s *storage) DeletePodPreset(ctx context.Context, name string) error {
_, _, err := s.Delete(ctx, name, nil) _, _, err := s.Delete(ctx, name, nil)
return err return err
} }
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package podpreset package podpreset
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/api/pod" "k8s.io/kubernetes/pkg/api/pod"
...@@ -42,7 +43,7 @@ func (podPresetStrategy) NamespaceScoped() bool { ...@@ -42,7 +43,7 @@ func (podPresetStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of a Pod Preset before creation. // PrepareForCreate clears the status of a Pod Preset before creation.
func (podPresetStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (podPresetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
pip := obj.(*settings.PodPreset) pip := obj.(*settings.PodPreset)
pip.Generation = 1 pip.Generation = 1
...@@ -50,7 +51,7 @@ func (podPresetStrategy) PrepareForCreate(ctx genericapirequest.Context, obj run ...@@ -50,7 +51,7 @@ func (podPresetStrategy) PrepareForCreate(ctx genericapirequest.Context, obj run
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (podPresetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (podPresetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newPodPreset := obj.(*settings.PodPreset) newPodPreset := obj.(*settings.PodPreset)
oldPodPreset := old.(*settings.PodPreset) oldPodPreset := old.(*settings.PodPreset)
...@@ -62,7 +63,7 @@ func (podPresetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol ...@@ -62,7 +63,7 @@ func (podPresetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol
} }
// Validate validates a new PodPreset. // Validate validates a new PodPreset.
func (podPresetStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (podPresetStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
pip := obj.(*settings.PodPreset) pip := obj.(*settings.PodPreset)
return validation.ValidatePodPreset(pip) return validation.ValidatePodPreset(pip)
} }
...@@ -76,7 +77,7 @@ func (podPresetStrategy) AllowCreateOnUpdate() bool { ...@@ -76,7 +77,7 @@ func (podPresetStrategy) AllowCreateOnUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user. // ValidateUpdate is the default update validation for an end user.
func (podPresetStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (podPresetStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
validationErrorList := validation.ValidatePodPreset(obj.(*settings.PodPreset)) validationErrorList := validation.ValidatePodPreset(obj.(*settings.PodPreset))
updateErrorList := validation.ValidatePodPresetUpdate(obj.(*settings.PodPreset), old.(*settings.PodPreset)) updateErrorList := validation.ValidatePodPresetUpdate(obj.(*settings.PodPreset), old.(*settings.PodPreset))
return append(validationErrorList, updateErrorList...) return append(validationErrorList, updateErrorList...)
......
...@@ -21,7 +21,6 @@ go_library( ...@@ -21,7 +21,6 @@ go_library(
"//pkg/features:go_default_library", "//pkg/features:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library", "//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
], ],
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package storageclass package storageclass
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
...@@ -44,7 +45,7 @@ func (storageClassStrategy) NamespaceScoped() bool { ...@@ -44,7 +45,7 @@ func (storageClassStrategy) NamespaceScoped() bool {
} }
// ResetBeforeCreate clears the Status field which is not allowed to be set by end users on creation. // ResetBeforeCreate clears the Status field which is not allowed to be set by end users on creation.
func (storageClassStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (storageClassStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
class := obj.(*storage.StorageClass) class := obj.(*storage.StorageClass)
if !utilfeature.DefaultFeatureGate.Enabled(features.ExpandPersistentVolumes) { if !utilfeature.DefaultFeatureGate.Enabled(features.ExpandPersistentVolumes) {
...@@ -54,7 +55,7 @@ func (storageClassStrategy) PrepareForCreate(ctx genericapirequest.Context, obj ...@@ -54,7 +55,7 @@ func (storageClassStrategy) PrepareForCreate(ctx genericapirequest.Context, obj
storageutil.DropDisabledAlphaFields(class) storageutil.DropDisabledAlphaFields(class)
} }
func (storageClassStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (storageClassStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
storageClass := obj.(*storage.StorageClass) storageClass := obj.(*storage.StorageClass)
return validation.ValidateStorageClass(storageClass) return validation.ValidateStorageClass(storageClass)
} }
...@@ -68,7 +69,7 @@ func (storageClassStrategy) AllowCreateOnUpdate() bool { ...@@ -68,7 +69,7 @@ func (storageClassStrategy) AllowCreateOnUpdate() bool {
} }
// PrepareForUpdate sets the Status fields which is not allowed to be set by an end user updating a PV // PrepareForUpdate sets the Status fields which is not allowed to be set by an end user updating a PV
func (storageClassStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (storageClassStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newClass := obj.(*storage.StorageClass) newClass := obj.(*storage.StorageClass)
oldClass := old.(*storage.StorageClass) oldClass := old.(*storage.StorageClass)
...@@ -80,7 +81,7 @@ func (storageClassStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ...@@ -80,7 +81,7 @@ func (storageClassStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj,
storageutil.DropDisabledAlphaFields(newClass) storageutil.DropDisabledAlphaFields(newClass)
} }
func (storageClassStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (storageClassStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
errorList := validation.ValidateStorageClass(obj.(*storage.StorageClass)) errorList := validation.ValidateStorageClass(obj.(*storage.StorageClass))
return append(errorList, validation.ValidateStorageClassUpdate(obj.(*storage.StorageClass), old.(*storage.StorageClass))...) return append(errorList, validation.ValidateStorageClassUpdate(obj.(*storage.StorageClass), old.(*storage.StorageClass))...)
} }
......
...@@ -14,7 +14,6 @@ go_library( ...@@ -14,7 +14,6 @@ go_library(
"//pkg/apis/storage/validation:go_default_library", "//pkg/apis/storage/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
], ],
) )
......
...@@ -17,9 +17,10 @@ limitations under the License. ...@@ -17,9 +17,10 @@ limitations under the License.
package volumeattachment package volumeattachment
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/storage" "k8s.io/kubernetes/pkg/apis/storage"
...@@ -41,10 +42,10 @@ func (volumeAttachmentStrategy) NamespaceScoped() bool { ...@@ -41,10 +42,10 @@ func (volumeAttachmentStrategy) NamespaceScoped() bool {
} }
// ResetBeforeCreate clears the Status field which is not allowed to be set by end users on creation. // ResetBeforeCreate clears the Status field which is not allowed to be set by end users on creation.
func (volumeAttachmentStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (volumeAttachmentStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
} }
func (volumeAttachmentStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (volumeAttachmentStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
volumeAttachment := obj.(*storage.VolumeAttachment) volumeAttachment := obj.(*storage.VolumeAttachment)
return validation.ValidateVolumeAttachment(volumeAttachment) return validation.ValidateVolumeAttachment(volumeAttachment)
} }
...@@ -58,10 +59,10 @@ func (volumeAttachmentStrategy) AllowCreateOnUpdate() bool { ...@@ -58,10 +59,10 @@ func (volumeAttachmentStrategy) AllowCreateOnUpdate() bool {
} }
// PrepareForUpdate sets the Status fields which is not allowed to be set by an end user updating a PV // PrepareForUpdate sets the Status fields which is not allowed to be set by an end user updating a PV
func (volumeAttachmentStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (volumeAttachmentStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
} }
func (volumeAttachmentStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (volumeAttachmentStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
newVolumeAttachmentObj := obj.(*storage.VolumeAttachment) newVolumeAttachmentObj := obj.(*storage.VolumeAttachment)
oldVolumeAttachmentObj := old.(*storage.VolumeAttachment) oldVolumeAttachmentObj := old.(*storage.VolumeAttachment)
errorList := validation.ValidateVolumeAttachment(newVolumeAttachmentObj) errorList := validation.ValidateVolumeAttachment(newVolumeAttachmentObj)
......
...@@ -35,7 +35,6 @@ go_library( ...@@ -35,7 +35,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package customresource package customresource
import ( import (
"context"
"fmt" "fmt"
"strings" "strings"
...@@ -26,7 +27,6 @@ import ( ...@@ -26,7 +27,6 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -121,12 +121,12 @@ func (r *StatusREST) New() runtime.Object { ...@@ -121,12 +121,12 @@ func (r *StatusREST) New() runtime.Object {
} }
// Get retrieves the object from the storage. It is required to support Patch. // Get retrieves the object from the storage. It is required to support Patch.
func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return r.store.Get(ctx, name, options) return r.store.Get(ctx, name, options)
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -150,7 +150,7 @@ func (r *ScaleREST) New() runtime.Object { ...@@ -150,7 +150,7 @@ func (r *ScaleREST) New() runtime.Object {
return &autoscalingv1.Scale{} return &autoscalingv1.Scale{}
} }
func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
cr, err := r.registry.GetCustomResource(ctx, name, options) cr, err := r.registry.GetCustomResource(ctx, name, options)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -166,7 +166,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met ...@@ -166,7 +166,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met
return scaleObject, err return scaleObject, err
} }
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
cr, err := r.registry.GetCustomResource(ctx, name, &metav1.GetOptions{}) cr, err := r.registry.GetCustomResource(ctx, name, &metav1.GetOptions{})
if err != nil { if err != nil {
return nil, false, err return nil, false, err
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package customresource package customresource
import ( import (
"context"
"fmt" "fmt"
"strings" "strings"
...@@ -26,18 +27,17 @@ import ( ...@@ -26,18 +27,17 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
) )
// Registry is an interface for things that know how to store CustomResources. // Registry is an interface for things that know how to store CustomResources.
type Registry interface { type Registry interface {
ListCustomResources(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*unstructured.UnstructuredList, error) ListCustomResources(ctx context.Context, options *metainternalversion.ListOptions) (*unstructured.UnstructuredList, error)
WatchCustomResources(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) WatchCustomResources(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
GetCustomResource(ctx genericapirequest.Context, customResourceID string, options *metav1.GetOptions) (*unstructured.Unstructured, error) GetCustomResource(ctx context.Context, customResourceID string, options *metav1.GetOptions) (*unstructured.Unstructured, error)
CreateCustomResource(ctx genericapirequest.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc) (*unstructured.Unstructured, error) CreateCustomResource(ctx context.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc) (*unstructured.Unstructured, error)
UpdateCustomResource(ctx genericapirequest.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*unstructured.Unstructured, error) UpdateCustomResource(ctx context.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*unstructured.Unstructured, error)
DeleteCustomResource(ctx genericapirequest.Context, customResourceID string) error DeleteCustomResource(ctx context.Context, customResourceID string) error
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
...@@ -51,7 +51,7 @@ func NewRegistry(s rest.StandardStorage) Registry { ...@@ -51,7 +51,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListCustomResources(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*unstructured.UnstructuredList, error) { func (s *storage) ListCustomResources(ctx context.Context, options *metainternalversion.ListOptions) (*unstructured.UnstructuredList, error) {
if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() { if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() {
return nil, fmt.Errorf("field selector not supported yet") return nil, fmt.Errorf("field selector not supported yet")
} }
...@@ -62,11 +62,11 @@ func (s *storage) ListCustomResources(ctx genericapirequest.Context, options *me ...@@ -62,11 +62,11 @@ func (s *storage) ListCustomResources(ctx genericapirequest.Context, options *me
return obj.(*unstructured.UnstructuredList), err return obj.(*unstructured.UnstructuredList), err
} }
func (s *storage) WatchCustomResources(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (s *storage) WatchCustomResources(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }
func (s *storage) GetCustomResource(ctx genericapirequest.Context, customResourceID string, options *metav1.GetOptions) (*unstructured.Unstructured, error) { func (s *storage) GetCustomResource(ctx context.Context, customResourceID string, options *metav1.GetOptions) (*unstructured.Unstructured, error) {
obj, err := s.Get(ctx, customResourceID, options) obj, err := s.Get(ctx, customResourceID, options)
customResource, ok := obj.(*unstructured.Unstructured) customResource, ok := obj.(*unstructured.Unstructured)
if !ok { if !ok {
...@@ -82,7 +82,7 @@ func (s *storage) GetCustomResource(ctx genericapirequest.Context, customResourc ...@@ -82,7 +82,7 @@ func (s *storage) GetCustomResource(ctx genericapirequest.Context, customResourc
return customResource, nil return customResource, nil
} }
func (s *storage) CreateCustomResource(ctx genericapirequest.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc) (*unstructured.Unstructured, error) { func (s *storage) CreateCustomResource(ctx context.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc) (*unstructured.Unstructured, error) {
obj, err := s.Create(ctx, customResource, rest.ValidateAllObjectFunc, false) obj, err := s.Create(ctx, customResource, rest.ValidateAllObjectFunc, false)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -90,7 +90,7 @@ func (s *storage) CreateCustomResource(ctx genericapirequest.Context, customReso ...@@ -90,7 +90,7 @@ func (s *storage) CreateCustomResource(ctx genericapirequest.Context, customReso
return obj.(*unstructured.Unstructured), nil return obj.(*unstructured.Unstructured), nil
} }
func (s *storage) UpdateCustomResource(ctx genericapirequest.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*unstructured.Unstructured, error) { func (s *storage) UpdateCustomResource(ctx context.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*unstructured.Unstructured, error) {
obj, _, err := s.Update(ctx, customResource.GetName(), rest.DefaultUpdatedObjectInfo(customResource), createValidation, updateValidation) obj, _, err := s.Update(ctx, customResource.GetName(), rest.DefaultUpdatedObjectInfo(customResource), createValidation, updateValidation)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -98,7 +98,7 @@ func (s *storage) UpdateCustomResource(ctx genericapirequest.Context, customReso ...@@ -98,7 +98,7 @@ func (s *storage) UpdateCustomResource(ctx genericapirequest.Context, customReso
return obj.(*unstructured.Unstructured), nil return obj.(*unstructured.Unstructured), nil
} }
func (s *storage) DeleteCustomResource(ctx genericapirequest.Context, customResourceID string) error { func (s *storage) DeleteCustomResource(ctx context.Context, customResourceID string) error {
_, _, err := s.Delete(ctx, customResourceID, nil) _, _, err := s.Delete(ctx, customResourceID, nil)
return err return err
} }
...@@ -17,10 +17,11 @@ limitations under the License. ...@@ -17,10 +17,11 @@ limitations under the License.
package customresource package customresource
import ( import (
"context"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
) )
type statusStrategy struct { type statusStrategy struct {
...@@ -31,7 +32,7 @@ func NewStatusStrategy(strategy customResourceStrategy) statusStrategy { ...@@ -31,7 +32,7 @@ func NewStatusStrategy(strategy customResourceStrategy) statusStrategy {
return statusStrategy{strategy} return statusStrategy{strategy}
} }
func (a statusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (a statusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newCustomResourceObject := obj.(*unstructured.Unstructured) newCustomResourceObject := obj.(*unstructured.Unstructured)
oldCustomResourceObject := old.(*unstructured.Unstructured) oldCustomResourceObject := old.(*unstructured.Unstructured)
...@@ -57,6 +58,6 @@ func (a statusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old ...@@ -57,6 +58,6 @@ func (a statusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old
} }
// ValidateUpdate is the default update validation for an end user updating status. // ValidateUpdate is the default update validation for an end user updating status.
func (a statusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (a statusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return a.customResourceStrategy.validator.ValidateStatusUpdate(ctx, obj, old, a.scale) return a.customResourceStrategy.validator.ValidateStatusUpdate(ctx, obj, old, a.scale)
} }
...@@ -17,6 +17,8 @@ limitations under the License. ...@@ -17,6 +17,8 @@ limitations under the License.
package customresource package customresource
import ( import (
"context"
"github.com/go-openapi/validate" "github.com/go-openapi/validate"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
...@@ -28,7 +30,6 @@ import ( ...@@ -28,7 +30,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
apiserverstorage "k8s.io/apiserver/pkg/storage" apiserverstorage "k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
...@@ -69,7 +70,7 @@ func (a customResourceStrategy) NamespaceScoped() bool { ...@@ -69,7 +70,7 @@ func (a customResourceStrategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of a CustomResource before creation. // PrepareForCreate clears the status of a CustomResource before creation.
func (a customResourceStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (a customResourceStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
if utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) && a.status != nil { if utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) && a.status != nil {
customResourceObject := obj.(*unstructured.Unstructured) customResourceObject := obj.(*unstructured.Unstructured)
customResource := customResourceObject.UnstructuredContent() customResource := customResourceObject.UnstructuredContent()
...@@ -85,7 +86,7 @@ func (a customResourceStrategy) PrepareForCreate(ctx genericapirequest.Context, ...@@ -85,7 +86,7 @@ func (a customResourceStrategy) PrepareForCreate(ctx genericapirequest.Context,
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (a customResourceStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (a customResourceStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) || a.status == nil { if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) || a.status == nil {
return return
} }
...@@ -126,7 +127,7 @@ func (a customResourceStrategy) PrepareForUpdate(ctx genericapirequest.Context, ...@@ -126,7 +127,7 @@ func (a customResourceStrategy) PrepareForUpdate(ctx genericapirequest.Context,
} }
// Validate validates a new CustomResource. // Validate validates a new CustomResource.
func (a customResourceStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (a customResourceStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
return a.validator.Validate(ctx, obj, a.scale) return a.validator.Validate(ctx, obj, a.scale)
} }
...@@ -146,7 +147,7 @@ func (customResourceStrategy) AllowUnconditionalUpdate() bool { ...@@ -146,7 +147,7 @@ func (customResourceStrategy) AllowUnconditionalUpdate() bool {
} }
// ValidateUpdate is the default update validation for an end user updating status. // ValidateUpdate is the default update validation for an end user updating status.
func (a customResourceStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (a customResourceStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return a.validator.ValidateUpdate(ctx, obj, old, a.scale) return a.validator.ValidateUpdate(ctx, obj, old, a.scale)
} }
......
...@@ -12,7 +12,6 @@ go_library( ...@@ -12,7 +12,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/client-go/util/jsonpath:go_default_library", "//vendor/k8s.io/client-go/util/jsonpath:go_default_library",
], ],
......
...@@ -18,6 +18,7 @@ package tableconvertor ...@@ -18,6 +18,7 @@ package tableconvertor
import ( import (
"bytes" "bytes"
"context"
"fmt" "fmt"
"strings" "strings"
...@@ -28,7 +29,6 @@ import ( ...@@ -28,7 +29,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
"k8s.io/client-go/util/jsonpath" "k8s.io/client-go/util/jsonpath"
) )
...@@ -85,7 +85,7 @@ type convertor struct { ...@@ -85,7 +85,7 @@ type convertor struct {
columns []*jsonpath.JSONPath columns []*jsonpath.JSONPath
} }
func (c *convertor) ConvertToTable(ctx genericapirequest.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) { func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
table := &metav1beta1.Table{ table := &metav1beta1.Table{
ColumnDefinitions: c.headers, ColumnDefinitions: c.headers,
} }
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package customresource package customresource
import ( import (
"context"
"fmt" "fmt"
"math" "math"
"strings" "strings"
...@@ -29,7 +30,6 @@ import ( ...@@ -29,7 +30,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
apiservervalidation "k8s.io/apiextensions-apiserver/pkg/apiserver/validation" apiservervalidation "k8s.io/apiextensions-apiserver/pkg/apiserver/validation"
...@@ -42,7 +42,7 @@ type customResourceValidator struct { ...@@ -42,7 +42,7 @@ type customResourceValidator struct {
statusSchemaValidator *validate.SchemaValidator statusSchemaValidator *validate.SchemaValidator
} }
func (a customResourceValidator) Validate(ctx genericapirequest.Context, obj runtime.Object, scale *apiextensions.CustomResourceSubresourceScale) field.ErrorList { func (a customResourceValidator) Validate(ctx context.Context, obj runtime.Object, scale *apiextensions.CustomResourceSubresourceScale) field.ErrorList {
accessor, err := meta.Accessor(obj) accessor, err := meta.Accessor(obj)
if err != nil { if err != nil {
return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())} return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())}
...@@ -109,7 +109,7 @@ func (a customResourceValidator) Validate(ctx genericapirequest.Context, obj run ...@@ -109,7 +109,7 @@ func (a customResourceValidator) Validate(ctx genericapirequest.Context, obj run
return validation.ValidateObjectMetaAccessor(accessor, a.namespaceScoped, validation.NameIsDNSSubdomain, field.NewPath("metadata")) return validation.ValidateObjectMetaAccessor(accessor, a.namespaceScoped, validation.NameIsDNSSubdomain, field.NewPath("metadata"))
} }
func (a customResourceValidator) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object, scale *apiextensions.CustomResourceSubresourceScale) field.ErrorList { func (a customResourceValidator) ValidateUpdate(ctx context.Context, obj, old runtime.Object, scale *apiextensions.CustomResourceSubresourceScale) field.ErrorList {
objAccessor, err := meta.Accessor(obj) objAccessor, err := meta.Accessor(obj)
if err != nil { if err != nil {
return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())} return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())}
...@@ -180,7 +180,7 @@ func (a customResourceValidator) ValidateUpdate(ctx genericapirequest.Context, o ...@@ -180,7 +180,7 @@ func (a customResourceValidator) ValidateUpdate(ctx genericapirequest.Context, o
return validation.ValidateObjectMetaAccessorUpdate(objAccessor, oldAccessor, field.NewPath("metadata")) return validation.ValidateObjectMetaAccessorUpdate(objAccessor, oldAccessor, field.NewPath("metadata"))
} }
func (a customResourceValidator) ValidateStatusUpdate(ctx genericapirequest.Context, obj, old runtime.Object, scale *apiextensions.CustomResourceSubresourceScale) field.ErrorList { func (a customResourceValidator) ValidateStatusUpdate(ctx context.Context, obj, old runtime.Object, scale *apiextensions.CustomResourceSubresourceScale) field.ErrorList {
objAccessor, err := meta.Accessor(obj) objAccessor, err := meta.Accessor(obj)
if err != nil { if err != nil {
return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())} return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())}
......
...@@ -23,7 +23,6 @@ go_library( ...@@ -23,7 +23,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,13 +17,13 @@ limitations under the License. ...@@ -17,13 +17,13 @@ limitations under the License.
package customresourcedefinition package customresourcedefinition
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -66,7 +66,7 @@ func (r *REST) ShortNames() []string { ...@@ -66,7 +66,7 @@ func (r *REST) ShortNames() []string {
} }
// Delete adds the CRD finalizer to the list // Delete adds the CRD finalizer to the list
func (r *REST) Delete(ctx genericapirequest.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) { func (r *REST) Delete(ctx context.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
obj, err := r.Get(ctx, name, &metav1.GetOptions{}) obj, err := r.Get(ctx, name, &metav1.GetOptions{})
if err != nil { if err != nil {
return nil, false, err return nil, false, err
...@@ -167,6 +167,6 @@ func (r *StatusREST) New() runtime.Object { ...@@ -167,6 +167,6 @@ func (r *StatusREST) New() runtime.Object {
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package customresourcedefinition package customresourcedefinition
import ( import (
"context"
"fmt" "fmt"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
...@@ -24,7 +25,6 @@ import ( ...@@ -24,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
...@@ -50,7 +50,7 @@ func (strategy) NamespaceScoped() bool { ...@@ -50,7 +50,7 @@ func (strategy) NamespaceScoped() bool {
} }
// PrepareForCreate clears the status of a CustomResourceDefinition before creation. // PrepareForCreate clears the status of a CustomResourceDefinition before creation.
func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
crd := obj.(*apiextensions.CustomResourceDefinition) crd := obj.(*apiextensions.CustomResourceDefinition)
crd.Status = apiextensions.CustomResourceDefinitionStatus{} crd.Status = apiextensions.CustomResourceDefinitionStatus{}
crd.Generation = 1 crd.Generation = 1
...@@ -65,7 +65,7 @@ func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Obje ...@@ -65,7 +65,7 @@ func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Obje
} }
// PrepareForUpdate clears fields that are not allowed to be set by end users on update. // PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newCRD := obj.(*apiextensions.CustomResourceDefinition) newCRD := obj.(*apiextensions.CustomResourceDefinition)
oldCRD := old.(*apiextensions.CustomResourceDefinition) oldCRD := old.(*apiextensions.CustomResourceDefinition)
newCRD.Status = oldCRD.Status newCRD.Status = oldCRD.Status
...@@ -93,7 +93,7 @@ func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime ...@@ -93,7 +93,7 @@ func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime
} }
// Validate validates a new CustomResourceDefinition. // Validate validates a new CustomResourceDefinition.
func (strategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
return validation.ValidateCustomResourceDefinition(obj.(*apiextensions.CustomResourceDefinition)) return validation.ValidateCustomResourceDefinition(obj.(*apiextensions.CustomResourceDefinition))
} }
...@@ -113,7 +113,7 @@ func (strategy) Canonicalize(obj runtime.Object) { ...@@ -113,7 +113,7 @@ func (strategy) Canonicalize(obj runtime.Object) {
} }
// ValidateUpdate is the default update validation for an end user updating status. // ValidateUpdate is the default update validation for an end user updating status.
func (strategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (strategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateCustomResourceDefinitionUpdate(obj.(*apiextensions.CustomResourceDefinition), old.(*apiextensions.CustomResourceDefinition)) return validation.ValidateCustomResourceDefinitionUpdate(obj.(*apiextensions.CustomResourceDefinition), old.(*apiextensions.CustomResourceDefinition))
} }
...@@ -130,7 +130,7 @@ func (statusStrategy) NamespaceScoped() bool { ...@@ -130,7 +130,7 @@ func (statusStrategy) NamespaceScoped() bool {
return false return false
} }
func (statusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (statusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newObj := obj.(*apiextensions.CustomResourceDefinition) newObj := obj.(*apiextensions.CustomResourceDefinition)
oldObj := old.(*apiextensions.CustomResourceDefinition) oldObj := old.(*apiextensions.CustomResourceDefinition)
newObj.Spec = oldObj.Spec newObj.Spec = oldObj.Spec
...@@ -155,7 +155,7 @@ func (statusStrategy) AllowUnconditionalUpdate() bool { ...@@ -155,7 +155,7 @@ func (statusStrategy) AllowUnconditionalUpdate() bool {
func (statusStrategy) Canonicalize(obj runtime.Object) { func (statusStrategy) Canonicalize(obj runtime.Object) {
} }
func (statusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (statusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateUpdateCustomResourceDefinitionStatus(obj.(*apiextensions.CustomResourceDefinition), old.(*apiextensions.CustomResourceDefinition)) return validation.ValidateUpdateCustomResourceDefinitionStatus(obj.(*apiextensions.CustomResourceDefinition), old.(*apiextensions.CustomResourceDefinition))
} }
......
...@@ -19,6 +19,7 @@ package endpoints ...@@ -19,6 +19,7 @@ package endpoints
import ( import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"context"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
...@@ -414,7 +415,7 @@ type SimpleRESTStorage struct { ...@@ -414,7 +415,7 @@ type SimpleRESTStorage struct {
injectedFunction func(obj runtime.Object) (returnObj runtime.Object, err error) injectedFunction func(obj runtime.Object) (returnObj runtime.Object, err error)
} }
func (storage *SimpleRESTStorage) Export(ctx request.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) { func (storage *SimpleRESTStorage) Export(ctx context.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) {
obj, err := storage.Get(ctx, name, &metav1.GetOptions{}) obj, err := storage.Get(ctx, name, &metav1.GetOptions{})
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -429,11 +430,11 @@ func (storage *SimpleRESTStorage) Export(ctx request.Context, name string, opts ...@@ -429,11 +430,11 @@ func (storage *SimpleRESTStorage) Export(ctx request.Context, name string, opts
return obj, storage.errors["export"] return obj, storage.errors["export"]
} }
func (storage *SimpleRESTStorage) ConvertToTable(ctx request.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) { func (storage *SimpleRESTStorage) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
return rest.NewDefaultTableConvertor(schema.GroupResource{Resource: "simple"}).ConvertToTable(ctx, obj, tableOptions) return rest.NewDefaultTableConvertor(schema.GroupResource{Resource: "simple"}).ConvertToTable(ctx, obj, tableOptions)
} }
func (storage *SimpleRESTStorage) List(ctx request.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{
ListMeta: metav1.ListMeta{ ListMeta: metav1.ListMeta{
...@@ -488,7 +489,7 @@ func (h *OutputConnect) ServeHTTP(w http.ResponseWriter, req *http.Request) { ...@@ -488,7 +489,7 @@ func (h *OutputConnect) ServeHTTP(w http.ResponseWriter, req *http.Request) {
w.Write([]byte(h.response)) w.Write([]byte(h.response))
} }
func (storage *SimpleRESTStorage) Get(ctx request.Context, id string, options *metav1.GetOptions) (runtime.Object, error) { func (storage *SimpleRESTStorage) Get(ctx context.Context, id string, options *metav1.GetOptions) (runtime.Object, error) {
storage.checkContext(ctx) storage.checkContext(ctx)
if id == "binary" { if id == "binary" {
return storage.stream, storage.errors["get"] return storage.stream, storage.errors["get"]
...@@ -496,11 +497,11 @@ func (storage *SimpleRESTStorage) Get(ctx request.Context, id string, options *m ...@@ -496,11 +497,11 @@ func (storage *SimpleRESTStorage) Get(ctx request.Context, id string, options *m
return storage.item.DeepCopy(), storage.errors["get"] return storage.item.DeepCopy(), storage.errors["get"]
} }
func (storage *SimpleRESTStorage) checkContext(ctx request.Context) { func (storage *SimpleRESTStorage) checkContext(ctx context.Context) {
storage.actualNamespace, storage.namespacePresent = request.NamespaceFrom(ctx) storage.actualNamespace, storage.namespacePresent = request.NamespaceFrom(ctx)
} }
func (storage *SimpleRESTStorage) Delete(ctx request.Context, id string, options *metav1.DeleteOptions) (runtime.Object, bool, error) { func (storage *SimpleRESTStorage) Delete(ctx context.Context, id string, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
storage.checkContext(ctx) storage.checkContext(ctx)
storage.deleted = id storage.deleted = id
storage.deleteOptions = options storage.deleteOptions = options
...@@ -523,7 +524,7 @@ func (storage *SimpleRESTStorage) NewList() runtime.Object { ...@@ -523,7 +524,7 @@ func (storage *SimpleRESTStorage) NewList() runtime.Object {
return &genericapitesting.SimpleList{} return &genericapitesting.SimpleList{}
} }
func (storage *SimpleRESTStorage) Create(ctx request.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (storage *SimpleRESTStorage) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
storage.checkContext(ctx) storage.checkContext(ctx)
storage.created = obj.(*genericapitesting.Simple) storage.created = obj.(*genericapitesting.Simple)
if err := storage.errors["create"]; err != nil { if err := storage.errors["create"]; err != nil {
...@@ -539,7 +540,7 @@ func (storage *SimpleRESTStorage) Create(ctx request.Context, obj runtime.Object ...@@ -539,7 +540,7 @@ func (storage *SimpleRESTStorage) Create(ctx request.Context, obj runtime.Object
return obj, err return obj, err
} }
func (storage *SimpleRESTStorage) Update(ctx request.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (storage *SimpleRESTStorage) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
storage.checkContext(ctx) storage.checkContext(ctx)
obj, err := objInfo.UpdatedObject(ctx, &storage.item) obj, err := objInfo.UpdatedObject(ctx, &storage.item)
if err != nil { if err != nil {
...@@ -559,7 +560,7 @@ func (storage *SimpleRESTStorage) Update(ctx request.Context, name string, objIn ...@@ -559,7 +560,7 @@ func (storage *SimpleRESTStorage) Update(ctx request.Context, name string, objIn
} }
// Implement ResourceWatcher. // Implement ResourceWatcher.
func (storage *SimpleRESTStorage) Watch(ctx request.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (storage *SimpleRESTStorage) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
storage.lock.Lock() storage.lock.Lock()
defer storage.lock.Unlock() defer storage.lock.Unlock()
storage.checkContext(ctx) storage.checkContext(ctx)
...@@ -608,7 +609,7 @@ func (s *ConnecterRESTStorage) New() runtime.Object { ...@@ -608,7 +609,7 @@ func (s *ConnecterRESTStorage) New() runtime.Object {
return &genericapitesting.Simple{} return &genericapitesting.Simple{}
} }
func (s *ConnecterRESTStorage) Connect(ctx request.Context, id string, options runtime.Object, responder rest.Responder) (http.Handler, error) { func (s *ConnecterRESTStorage) Connect(ctx context.Context, id string, options runtime.Object, responder rest.Responder) (http.Handler, error) {
s.receivedConnectOptions = options s.receivedConnectOptions = options
s.receivedID = id s.receivedID = id
s.receivedResponder = responder s.receivedResponder = responder
...@@ -633,7 +634,7 @@ type LegacyRESTStorage struct { ...@@ -633,7 +634,7 @@ type LegacyRESTStorage struct {
*SimpleRESTStorage *SimpleRESTStorage
} }
func (storage LegacyRESTStorage) Delete(ctx request.Context, id string) (runtime.Object, error) { func (storage LegacyRESTStorage) Delete(ctx context.Context, id string) (runtime.Object, error) {
obj, _, err := storage.SimpleRESTStorage.Delete(ctx, id, nil) obj, _, err := storage.SimpleRESTStorage.Delete(ctx, id, nil)
return obj, err return obj, err
} }
...@@ -659,7 +660,7 @@ type GetWithOptionsRESTStorage struct { ...@@ -659,7 +660,7 @@ type GetWithOptionsRESTStorage struct {
takesPath string takesPath string
} }
func (r *GetWithOptionsRESTStorage) Get(ctx request.Context, name string, options runtime.Object) (runtime.Object, error) { func (r *GetWithOptionsRESTStorage) Get(ctx context.Context, name string, options runtime.Object) (runtime.Object, error) {
if _, ok := options.(*genericapitesting.SimpleGetOptions); !ok { if _, ok := options.(*genericapitesting.SimpleGetOptions); !ok {
return nil, fmt.Errorf("Unexpected options object: %#v", options) return nil, fmt.Errorf("Unexpected options object: %#v", options)
} }
...@@ -682,7 +683,7 @@ type GetWithOptionsRootRESTStorage struct { ...@@ -682,7 +683,7 @@ type GetWithOptionsRootRESTStorage struct {
takesPath string takesPath string
} }
func (r *GetWithOptionsRootRESTStorage) Get(ctx request.Context, name string, options runtime.Object) (runtime.Object, error) { func (r *GetWithOptionsRootRESTStorage) Get(ctx context.Context, name string, options runtime.Object) (runtime.Object, error) {
if _, ok := options.(*genericapitesting.SimpleGetOptions); !ok { if _, ok := options.(*genericapitesting.SimpleGetOptions); !ok {
return nil, fmt.Errorf("Unexpected options object: %#v", options) return nil, fmt.Errorf("Unexpected options object: %#v", options)
} }
...@@ -704,7 +705,7 @@ type NamedCreaterRESTStorage struct { ...@@ -704,7 +705,7 @@ type NamedCreaterRESTStorage struct {
createdName string createdName string
} }
func (storage *NamedCreaterRESTStorage) Create(ctx request.Context, name string, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (storage *NamedCreaterRESTStorage) Create(ctx context.Context, name string, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
storage.checkContext(ctx) storage.checkContext(ctx)
storage.created = obj.(*genericapitesting.Simple) storage.created = obj.(*genericapitesting.Simple)
storage.createdName = name storage.createdName = name
...@@ -734,12 +735,12 @@ func (storage *SimpleTypedStorage) New() runtime.Object { ...@@ -734,12 +735,12 @@ func (storage *SimpleTypedStorage) New() runtime.Object {
return storage.baseType return storage.baseType
} }
func (storage *SimpleTypedStorage) Get(ctx request.Context, id string, options *metav1.GetOptions) (runtime.Object, error) { func (storage *SimpleTypedStorage) Get(ctx context.Context, id string, options *metav1.GetOptions) (runtime.Object, error) {
storage.checkContext(ctx) storage.checkContext(ctx)
return storage.item.DeepCopyObject(), storage.errors["get"] return storage.item.DeepCopyObject(), storage.errors["get"]
} }
func (storage *SimpleTypedStorage) checkContext(ctx request.Context) { func (storage *SimpleTypedStorage) checkContext(ctx context.Context) {
storage.actualNamespace, storage.namespacePresent = request.NamespaceFrom(ctx) storage.actualNamespace, storage.namespacePresent = request.NamespaceFrom(ctx)
} }
...@@ -3831,7 +3832,7 @@ func (storage *SimpleXGSubresourceRESTStorage) New() runtime.Object { ...@@ -3831,7 +3832,7 @@ func (storage *SimpleXGSubresourceRESTStorage) New() runtime.Object {
return &genericapitesting.SimpleXGSubresource{} return &genericapitesting.SimpleXGSubresource{}
} }
func (storage *SimpleXGSubresourceRESTStorage) Get(ctx request.Context, id string, options *metav1.GetOptions) (runtime.Object, error) { func (storage *SimpleXGSubresourceRESTStorage) Get(ctx context.Context, id string, options *metav1.GetOptions) (runtime.Object, error) {
return storage.item.DeepCopyObject(), nil return storage.item.DeepCopyObject(), nil
} }
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package filters package filters
import ( import (
"context"
"errors" "errors"
"net/http" "net/http"
...@@ -76,7 +77,7 @@ func WithAuthorization(handler http.Handler, a authorizer.Authorizer, s runtime. ...@@ -76,7 +77,7 @@ func WithAuthorization(handler http.Handler, a authorizer.Authorizer, s runtime.
}) })
} }
func GetAuthorizerAttributes(ctx request.Context) (authorizer.Attributes, error) { func GetAuthorizerAttributes(ctx context.Context) (authorizer.Attributes, error) {
attribs := authorizer.AttributesRecord{} attribs := authorizer.AttributesRecord{}
user, ok := request.UserFrom(ctx) user, ok := request.UserFrom(ctx)
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package filters package filters
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
...@@ -308,7 +309,7 @@ func TestImpersonationFilter(t *testing.T) { ...@@ -308,7 +309,7 @@ func TestImpersonationFilter(t *testing.T) {
}, },
} }
var ctx request.Context var ctx context.Context
var actualUser user.Info var actualUser user.Info
var lock sync.Mutex var lock sync.Mutex
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package handlers package handlers
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"time" "time"
...@@ -163,6 +164,6 @@ type namedCreaterAdapter struct { ...@@ -163,6 +164,6 @@ type namedCreaterAdapter struct {
rest.Creater rest.Creater
} }
func (c *namedCreaterAdapter) Create(ctx request.Context, name string, obj runtime.Object, createValidatingAdmission rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (c *namedCreaterAdapter) Create(ctx context.Context, name string, obj runtime.Object, createValidatingAdmission rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
return c.Creater.Create(ctx, obj, createValidatingAdmission, includeUninitialized) return c.Creater.Create(ctx, obj, createValidatingAdmission, includeUninitialized)
} }
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package handlers package handlers
import ( import (
"context"
"fmt" "fmt"
"math/rand" "math/rand"
"net/http" "net/http"
...@@ -40,7 +41,7 @@ import ( ...@@ -40,7 +41,7 @@ import (
// getterFunc performs a get request with the given context and object name. The request // getterFunc performs a get request with the given context and object name. The request
// may be used to deserialize an options object to pass to the getter. // may be used to deserialize an options object to pass to the getter.
type getterFunc func(ctx request.Context, name string, req *http.Request, trace *utiltrace.Trace) (runtime.Object, error) type getterFunc func(ctx context.Context, name string, req *http.Request, trace *utiltrace.Trace) (runtime.Object, error)
// getResourceHandler is an HTTP handler function for get requests. It delegates to the // getResourceHandler is an HTTP handler function for get requests. It delegates to the
// passed-in getterFunc to perform the actual get. // passed-in getterFunc to perform the actual get.
...@@ -80,7 +81,7 @@ func getResourceHandler(scope RequestScope, getter getterFunc) http.HandlerFunc ...@@ -80,7 +81,7 @@ func getResourceHandler(scope RequestScope, getter getterFunc) http.HandlerFunc
// GetResource returns a function that handles retrieving a single resource from a rest.Storage object. // GetResource returns a function that handles retrieving a single resource from a rest.Storage object.
func GetResource(r rest.Getter, e rest.Exporter, scope RequestScope) http.HandlerFunc { func GetResource(r rest.Getter, e rest.Exporter, scope RequestScope) http.HandlerFunc {
return getResourceHandler(scope, return getResourceHandler(scope,
func(ctx request.Context, name string, req *http.Request, trace *utiltrace.Trace) (runtime.Object, error) { func(ctx context.Context, name string, req *http.Request, trace *utiltrace.Trace) (runtime.Object, error) {
// check for export // check for export
options := metav1.GetOptions{} options := metav1.GetOptions{}
if values := req.URL.Query(); len(values) > 0 { if values := req.URL.Query(); len(values) > 0 {
...@@ -110,7 +111,7 @@ func GetResource(r rest.Getter, e rest.Exporter, scope RequestScope) http.Handle ...@@ -110,7 +111,7 @@ func GetResource(r rest.Getter, e rest.Exporter, scope RequestScope) http.Handle
// GetResourceWithOptions returns a function that handles retrieving a single resource from a rest.Storage object. // GetResourceWithOptions returns a function that handles retrieving a single resource from a rest.Storage object.
func GetResourceWithOptions(r rest.GetterWithOptions, scope RequestScope, isSubresource bool) http.HandlerFunc { func GetResourceWithOptions(r rest.GetterWithOptions, scope RequestScope, isSubresource bool) http.HandlerFunc {
return getResourceHandler(scope, return getResourceHandler(scope,
func(ctx request.Context, name string, req *http.Request, trace *utiltrace.Trace) (runtime.Object, error) { func(ctx context.Context, name string, req *http.Request, trace *utiltrace.Trace) (runtime.Object, error) {
opts, subpath, subpathKey := r.NewGetOptions() opts, subpath, subpathKey := r.NewGetOptions()
trace.Step("About to process Get options") trace.Step("About to process Get options")
if err := getRequestOptions(req, scope, opts, subpath, subpathKey, isSubresource); err != nil { if err := getRequestOptions(req, scope, opts, subpath, subpathKey, isSubresource); err != nil {
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package handlers package handlers
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"strings" "strings"
...@@ -151,7 +152,7 @@ type mutateObjectUpdateFunc func(obj, old runtime.Object) error ...@@ -151,7 +152,7 @@ type mutateObjectUpdateFunc func(obj, old runtime.Object) error
// patchResource divides PatchResource for easier unit testing // patchResource divides PatchResource for easier unit testing
func patchResource( func patchResource(
ctx request.Context, ctx context.Context,
updateMutation mutateObjectUpdateFunc, updateMutation mutateObjectUpdateFunc,
createValidation rest.ValidateObjectFunc, createValidation rest.ValidateObjectFunc,
updateValidation rest.ValidateObjectUpdateFunc, updateValidation rest.ValidateObjectUpdateFunc,
...@@ -184,7 +185,7 @@ func patchResource( ...@@ -184,7 +185,7 @@ func patchResource(
// applyPatch is called every time GuaranteedUpdate asks for the updated object, // applyPatch is called every time GuaranteedUpdate asks for the updated object,
// and is given the currently persisted object as input. // and is given the currently persisted object as input.
applyPatch := func(_ request.Context, _, currentObject runtime.Object) (runtime.Object, error) { applyPatch := func(_ context.Context, _, currentObject runtime.Object) (runtime.Object, error) {
// Make sure we actually have a persisted currentObject // Make sure we actually have a persisted currentObject
trace.Step("About to apply patch") trace.Step("About to apply patch")
if hasUID, err := hasUID(currentObject); err != nil { if hasUID, err := hasUID(currentObject); err != nil {
...@@ -373,7 +374,7 @@ func patchResource( ...@@ -373,7 +374,7 @@ func patchResource(
// applyAdmission is called every time GuaranteedUpdate asks for the updated object, // applyAdmission is called every time GuaranteedUpdate asks for the updated object,
// and is given the currently persisted object and the patched object as input. // and is given the currently persisted object and the patched object as input.
applyAdmission := func(ctx request.Context, patchedObject runtime.Object, currentObject runtime.Object) (runtime.Object, error) { applyAdmission := func(ctx context.Context, patchedObject runtime.Object, currentObject runtime.Object) (runtime.Object, error) {
trace.Step("About to check admission control") trace.Step("About to check admission control")
return patchedObject, updateMutation(patchedObject, currentObject) return patchedObject, updateMutation(patchedObject, currentObject)
} }
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package handlers package handlers
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
...@@ -28,12 +29,11 @@ import ( ...@@ -28,12 +29,11 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/endpoints/handlers/negotiation" "k8s.io/apiserver/pkg/endpoints/handlers/negotiation"
"k8s.io/apiserver/pkg/endpoints/handlers/responsewriters" "k8s.io/apiserver/pkg/endpoints/handlers/responsewriters"
"k8s.io/apiserver/pkg/endpoints/request"
) )
// transformResponseObject takes an object loaded from storage and performs any necessary transformations. // transformResponseObject takes an object loaded from storage and performs any necessary transformations.
// Will write the complete response object. // Will write the complete response object.
func transformResponseObject(ctx request.Context, scope RequestScope, req *http.Request, w http.ResponseWriter, statusCode int, result runtime.Object) { func transformResponseObject(ctx context.Context, scope RequestScope, req *http.Request, w http.ResponseWriter, statusCode int, result runtime.Object) {
// TODO: fetch the media type much earlier in request processing and pass it into this method. // TODO: fetch the media type much earlier in request processing and pass it into this method.
mediaType, _, err := negotiation.NegotiateOutputMediaType(req, scope.Serializer, &scope) mediaType, _, err := negotiation.NegotiateOutputMediaType(req, scope.Serializer, &scope)
if err != nil { if err != nil {
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package responsewriters package responsewriters
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"strings" "strings"
...@@ -26,7 +27,6 @@ import ( ...@@ -26,7 +27,6 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
utilruntime "k8s.io/apimachinery/pkg/util/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apiserver/pkg/authorization/authorizer" "k8s.io/apiserver/pkg/authorization/authorizer"
"k8s.io/apiserver/pkg/endpoints/request"
) )
// Avoid emitting errors that look like valid HTML. Quotes are okay. // Avoid emitting errors that look like valid HTML. Quotes are okay.
...@@ -41,7 +41,7 @@ func BadGatewayError(w http.ResponseWriter, req *http.Request) { ...@@ -41,7 +41,7 @@ func BadGatewayError(w http.ResponseWriter, req *http.Request) {
} }
// Forbidden renders a simple forbidden error // Forbidden renders a simple forbidden error
func Forbidden(ctx request.Context, attributes authorizer.Attributes, w http.ResponseWriter, req *http.Request, reason string, s runtime.NegotiatedSerializer) { func Forbidden(ctx context.Context, attributes authorizer.Attributes, w http.ResponseWriter, req *http.Request, reason string, s runtime.NegotiatedSerializer) {
msg := sanitizer.Replace(forbiddenMessage(attributes)) msg := sanitizer.Replace(forbiddenMessage(attributes))
w.Header().Set("X-Content-Type-Options", "nosniff") w.Header().Set("X-Content-Type-Options", "nosniff")
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package handlers package handlers
import ( import (
"context"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
...@@ -263,7 +264,7 @@ func checkName(obj runtime.Object, name, namespace string, namer ScopeNamer) err ...@@ -263,7 +264,7 @@ func checkName(obj runtime.Object, name, namespace string, namer ScopeNamer) err
// setListSelfLink sets the self link of a list to the base URL, then sets the self links // setListSelfLink sets the self link of a list to the base URL, then sets the self links
// on all child objects returned. Returns the number of items in the list. // on all child objects returned. Returns the number of items in the list.
func setListSelfLink(obj runtime.Object, ctx request.Context, req *http.Request, namer ScopeNamer) (int, error) { func setListSelfLink(obj runtime.Object, ctx context.Context, req *http.Request, namer ScopeNamer) (int, error) {
if !meta.IsListType(obj) { if !meta.IsListType(obj) {
return 0, nil return 0, nil
} }
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package handlers package handlers
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"net/http" "net/http"
...@@ -171,7 +172,7 @@ func (p *testPatcher) New() runtime.Object { ...@@ -171,7 +172,7 @@ func (p *testPatcher) New() runtime.Object {
return &example.Pod{} return &example.Pod{}
} }
func (p *testPatcher) Update(ctx request.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (p *testPatcher) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
currentPod := p.startingPod currentPod := p.startingPod
if p.numUpdates > 0 { if p.numUpdates > 0 {
currentPod = p.updatePod currentPod = p.updatePod
...@@ -200,7 +201,7 @@ func (p *testPatcher) Update(ctx request.Context, name string, objInfo rest.Upda ...@@ -200,7 +201,7 @@ func (p *testPatcher) Update(ctx request.Context, name string, objInfo rest.Upda
return inPod, false, nil return inPod, false, nil
} }
func (p *testPatcher) Get(ctx request.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (p *testPatcher) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
p.t.Fatal("Unexpected call to testPatcher.Get") p.t.Fatal("Unexpected call to testPatcher.Get")
return nil, errors.New("Unexpected call to testPatcher.Get") return nil, errors.New("Unexpected call to testPatcher.Get")
} }
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package handlers package handlers
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"time" "time"
...@@ -90,7 +91,7 @@ func UpdateResource(r rest.Updater, scope RequestScope, typer runtime.ObjectType ...@@ -90,7 +91,7 @@ func UpdateResource(r rest.Updater, scope RequestScope, typer runtime.ObjectType
staticAdmissionAttributes := admission.NewAttributesRecord(nil, nil, scope.Kind, namespace, name, scope.Resource, scope.Subresource, admission.Update, userInfo) staticAdmissionAttributes := admission.NewAttributesRecord(nil, nil, scope.Kind, namespace, name, scope.Resource, scope.Subresource, admission.Update, userInfo)
var transformers []rest.TransformFunc var transformers []rest.TransformFunc
if mutatingAdmission, ok := admit.(admission.MutationInterface); ok && mutatingAdmission.Handles(admission.Update) { if mutatingAdmission, ok := admit.(admission.MutationInterface); ok && mutatingAdmission.Handles(admission.Update) {
transformers = append(transformers, func(ctx request.Context, newObj, oldObj runtime.Object) (runtime.Object, error) { transformers = append(transformers, func(ctx context.Context, newObj, oldObj runtime.Object) (runtime.Object, error) {
return newObj, mutatingAdmission.Admit(admission.NewAttributesRecord(newObj, oldObj, scope.Kind, namespace, name, scope.Resource, scope.Subresource, admission.Update, userInfo)) return newObj, mutatingAdmission.Admit(admission.NewAttributesRecord(newObj, oldObj, scope.Kind, namespace, name, scope.Resource, scope.Subresource, admission.Update, userInfo))
}) })
} }
......
...@@ -18,8 +18,6 @@ package request ...@@ -18,8 +18,6 @@ package request
import ( import (
"context" "context"
"errors"
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
...@@ -27,28 +25,6 @@ import ( ...@@ -27,28 +25,6 @@ import (
"k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"
) )
// Context carries values across API boundaries.
// This context matches the context.Context interface
// (https://blog.golang.org/context), for the purposes
// of passing the api.Context through to the storage tier.
// TODO: Determine the extent that this abstraction+interface
// is used by the api, and whether we can remove.
type Context interface {
// Value returns the value associated with key or nil if none.
Value(key interface{}) interface{}
// Deadline returns the time when this Context will be canceled, if any.
Deadline() (deadline time.Time, ok bool)
// Done returns a channel that is closed when this Context is canceled
// or times out.
Done() <-chan struct{}
// Err indicates why this context was canceled, after the Done channel
// is closed.
Err() error
}
// The key type is unexported to prevent collisions // The key type is unexported to prevent collisions
type key int type key int
...@@ -70,43 +46,39 @@ const ( ...@@ -70,43 +46,39 @@ const (
) )
// NewContext instantiates a base context object for request flows. // NewContext instantiates a base context object for request flows.
func NewContext() Context { func NewContext() context.Context {
return context.TODO() return context.TODO()
} }
// NewDefaultContext instantiates a base context object for request flows in the default namespace // NewDefaultContext instantiates a base context object for request flows in the default namespace
func NewDefaultContext() Context { func NewDefaultContext() context.Context {
return WithNamespace(NewContext(), metav1.NamespaceDefault) return WithNamespace(NewContext(), metav1.NamespaceDefault)
} }
// WithValue returns a copy of parent in which the value associated with key is val. // WithValue returns a copy of parent in which the value associated with key is val.
func WithValue(parent Context, key interface{}, val interface{}) Context { func WithValue(parent context.Context, key interface{}, val interface{}) context.Context {
internalCtx, ok := parent.(context.Context) return context.WithValue(parent, key, val)
if !ok {
panic(errors.New("Invalid context type"))
}
return context.WithValue(internalCtx, key, val)
} }
// WithNamespace returns a copy of parent in which the namespace value is set // WithNamespace returns a copy of parent in which the namespace value is set
func WithNamespace(parent Context, namespace string) Context { func WithNamespace(parent context.Context, namespace string) context.Context {
return WithValue(parent, namespaceKey, namespace) return WithValue(parent, namespaceKey, namespace)
} }
// NamespaceFrom returns the value of the namespace key on the ctx // NamespaceFrom returns the value of the namespace key on the ctx
func NamespaceFrom(ctx Context) (string, bool) { func NamespaceFrom(ctx context.Context) (string, bool) {
namespace, ok := ctx.Value(namespaceKey).(string) namespace, ok := ctx.Value(namespaceKey).(string)
return namespace, ok return namespace, ok
} }
// NamespaceValue returns the value of the namespace key on the ctx, or the empty string if none // NamespaceValue returns the value of the namespace key on the ctx, or the empty string if none
func NamespaceValue(ctx Context) string { func NamespaceValue(ctx context.Context) string {
namespace, _ := NamespaceFrom(ctx) namespace, _ := NamespaceFrom(ctx)
return namespace return namespace
} }
// WithNamespaceDefaultIfNone returns a context whose namespace is the default if and only if the parent context has no namespace value // WithNamespaceDefaultIfNone returns a context whose namespace is the default if and only if the parent context has no namespace value
func WithNamespaceDefaultIfNone(parent Context) Context { func WithNamespaceDefaultIfNone(parent context.Context) context.Context {
namespace, ok := NamespaceFrom(parent) namespace, ok := NamespaceFrom(parent)
if !ok || len(namespace) == 0 { if !ok || len(namespace) == 0 {
return WithNamespace(parent, metav1.NamespaceDefault) return WithNamespace(parent, metav1.NamespaceDefault)
...@@ -115,34 +87,34 @@ func WithNamespaceDefaultIfNone(parent Context) Context { ...@@ -115,34 +87,34 @@ func WithNamespaceDefaultIfNone(parent Context) Context {
} }
// WithUser returns a copy of parent in which the user value is set // WithUser returns a copy of parent in which the user value is set
func WithUser(parent Context, user user.Info) Context { func WithUser(parent context.Context, user user.Info) context.Context {
return WithValue(parent, userKey, user) return WithValue(parent, userKey, user)
} }
// UserFrom returns the value of the user key on the ctx // UserFrom returns the value of the user key on the ctx
func UserFrom(ctx Context) (user.Info, bool) { func UserFrom(ctx context.Context) (user.Info, bool) {
user, ok := ctx.Value(userKey).(user.Info) user, ok := ctx.Value(userKey).(user.Info)
return user, ok return user, ok
} }
// WithUID returns a copy of parent in which the uid value is set // WithUID returns a copy of parent in which the uid value is set
func WithUID(parent Context, uid types.UID) Context { func WithUID(parent context.Context, uid types.UID) context.Context {
return WithValue(parent, uidKey, uid) return WithValue(parent, uidKey, uid)
} }
// UIDFrom returns the value of the uid key on the ctx // UIDFrom returns the value of the uid key on the ctx
func UIDFrom(ctx Context) (types.UID, bool) { func UIDFrom(ctx context.Context) (types.UID, bool) {
uid, ok := ctx.Value(uidKey).(types.UID) uid, ok := ctx.Value(uidKey).(types.UID)
return uid, ok return uid, ok
} }
// WithAuditEvent returns set audit event struct. // WithAuditEvent returns set audit event struct.
func WithAuditEvent(parent Context, ev *audit.Event) Context { func WithAuditEvent(parent context.Context, ev *audit.Event) context.Context {
return WithValue(parent, auditKey, ev) return WithValue(parent, auditKey, ev)
} }
// AuditEventFrom returns the audit event struct on the ctx // AuditEventFrom returns the audit event struct on the ctx
func AuditEventFrom(ctx Context) *audit.Event { func AuditEventFrom(ctx context.Context) *audit.Event {
ev, _ := ctx.Value(auditKey).(*audit.Event) ev, _ := ctx.Value(auditKey).(*audit.Event)
return ev return ev
} }
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package request package request
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"strings" "strings"
...@@ -232,12 +233,12 @@ type requestInfoKeyType int ...@@ -232,12 +233,12 @@ type requestInfoKeyType int
const requestInfoKey requestInfoKeyType = iota const requestInfoKey requestInfoKeyType = iota
// WithRequestInfo returns a copy of parent in which the request info value is set // WithRequestInfo returns a copy of parent in which the request info value is set
func WithRequestInfo(parent Context, info *RequestInfo) Context { func WithRequestInfo(parent context.Context, info *RequestInfo) context.Context {
return WithValue(parent, requestInfoKey, info) return WithValue(parent, requestInfoKey, info)
} }
// RequestInfoFrom returns the value of the RequestInfo key on the ctx // RequestInfoFrom returns the value of the RequestInfo key on the ctx
func RequestInfoFrom(ctx Context) (*RequestInfo, bool) { func RequestInfoFrom(ctx context.Context) (*RequestInfo, bool) {
info, ok := ctx.Value(requestInfoKey).(*RequestInfo) info, ok := ctx.Value(requestInfoKey).(*RequestInfo)
return info, ok return info, ok
} }
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package registry package registry
import ( import (
"context"
"fmt" "fmt"
"reflect" "reflect"
"strings" "strings"
...@@ -99,14 +100,14 @@ type Store struct { ...@@ -99,14 +100,14 @@ type Store struct {
// entire collection (listing and watching). // entire collection (listing and watching).
// //
// KeyRootFunc and KeyFunc must be supplied together or not at all. // KeyRootFunc and KeyFunc must be supplied together or not at all.
KeyRootFunc func(ctx genericapirequest.Context) string KeyRootFunc func(ctx context.Context) string
// KeyFunc returns the key for a specific object in the collection. // KeyFunc returns the key for a specific object in the collection.
// KeyFunc is called for Create/Update/Get/Delete. Note that 'namespace' // KeyFunc is called for Create/Update/Get/Delete. Note that 'namespace'
// can be gotten from ctx. // can be gotten from ctx.
// //
// KeyFunc and KeyRootFunc must be supplied together or not at all. // KeyFunc and KeyRootFunc must be supplied together or not at all.
KeyFunc func(ctx genericapirequest.Context, name string) (string, error) KeyFunc func(ctx context.Context, name string) (string, error)
// ObjectNameFunc returns the name of an object or an error. // ObjectNameFunc returns the name of an object or an error.
ObjectNameFunc func(obj runtime.Object) (string, error) ObjectNameFunc func(obj runtime.Object) (string, error)
...@@ -190,7 +191,7 @@ const ( ...@@ -190,7 +191,7 @@ const (
// NamespaceKeyRootFunc is the default function for constructing storage paths // NamespaceKeyRootFunc is the default function for constructing storage paths
// to resource directories enforcing namespace rules. // to resource directories enforcing namespace rules.
func NamespaceKeyRootFunc(ctx genericapirequest.Context, prefix string) string { func NamespaceKeyRootFunc(ctx context.Context, prefix string) string {
key := prefix key := prefix
ns, ok := genericapirequest.NamespaceFrom(ctx) ns, ok := genericapirequest.NamespaceFrom(ctx)
if ok && len(ns) > 0 { if ok && len(ns) > 0 {
...@@ -202,7 +203,7 @@ func NamespaceKeyRootFunc(ctx genericapirequest.Context, prefix string) string { ...@@ -202,7 +203,7 @@ func NamespaceKeyRootFunc(ctx genericapirequest.Context, prefix string) string {
// NamespaceKeyFunc is the default function for constructing storage paths to // NamespaceKeyFunc is the default function for constructing storage paths to
// a resource relative to the given prefix enforcing namespace rules. If the // a resource relative to the given prefix enforcing namespace rules. If the
// context does not contain a namespace, it errors. // context does not contain a namespace, it errors.
func NamespaceKeyFunc(ctx genericapirequest.Context, prefix string, name string) (string, error) { func NamespaceKeyFunc(ctx context.Context, prefix string, name string) (string, error) {
key := NamespaceKeyRootFunc(ctx, prefix) key := NamespaceKeyRootFunc(ctx, prefix)
ns, ok := genericapirequest.NamespaceFrom(ctx) ns, ok := genericapirequest.NamespaceFrom(ctx)
if !ok || len(ns) == 0 { if !ok || len(ns) == 0 {
...@@ -220,7 +221,7 @@ func NamespaceKeyFunc(ctx genericapirequest.Context, prefix string, name string) ...@@ -220,7 +221,7 @@ func NamespaceKeyFunc(ctx genericapirequest.Context, prefix string, name string)
// NoNamespaceKeyFunc is the default function for constructing storage paths // NoNamespaceKeyFunc is the default function for constructing storage paths
// to a resource relative to the given prefix without a namespace. // to a resource relative to the given prefix without a namespace.
func NoNamespaceKeyFunc(ctx genericapirequest.Context, prefix string, name string) (string, error) { func NoNamespaceKeyFunc(ctx context.Context, prefix string, name string) (string, error) {
if len(name) == 0 { if len(name) == 0 {
return "", kubeerr.NewBadRequest("Name parameter required.") return "", kubeerr.NewBadRequest("Name parameter required.")
} }
...@@ -263,7 +264,7 @@ func (e *Store) GetExportStrategy() rest.RESTExportStrategy { ...@@ -263,7 +264,7 @@ func (e *Store) GetExportStrategy() rest.RESTExportStrategy {
// List returns a list of items matching labels and field according to the // List returns a list of items matching labels and field according to the
// store's PredicateFunc. // store's PredicateFunc.
func (e *Store) List(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (runtime.Object, error) { func (e *Store) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
label := labels.Everything() label := labels.Everything()
if options != nil && options.LabelSelector != nil { if options != nil && options.LabelSelector != nil {
label = options.LabelSelector label = options.LabelSelector
...@@ -286,7 +287,7 @@ func (e *Store) List(ctx genericapirequest.Context, options *metainternalversion ...@@ -286,7 +287,7 @@ func (e *Store) List(ctx genericapirequest.Context, options *metainternalversion
// ListPredicate returns a list of all the items matching the given // ListPredicate returns a list of all the items matching the given
// SelectionPredicate. // SelectionPredicate.
func (e *Store) ListPredicate(ctx genericapirequest.Context, p storage.SelectionPredicate, options *metainternalversion.ListOptions) (runtime.Object, error) { func (e *Store) ListPredicate(ctx context.Context, p storage.SelectionPredicate, options *metainternalversion.ListOptions) (runtime.Object, error) {
if options == nil { if options == nil {
// By default we should serve the request from etcd. // By default we should serve the request from etcd.
options = &metainternalversion.ListOptions{ResourceVersion: ""} options = &metainternalversion.ListOptions{ResourceVersion: ""}
...@@ -309,7 +310,7 @@ func (e *Store) ListPredicate(ctx genericapirequest.Context, p storage.Selection ...@@ -309,7 +310,7 @@ func (e *Store) ListPredicate(ctx genericapirequest.Context, p storage.Selection
} }
// Create inserts a new item according to the unique key from the object. // Create inserts a new item according to the unique key from the object.
func (e *Store) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) { func (e *Store) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
if err := rest.BeforeCreate(e.CreateStrategy, ctx, obj); err != nil { if err := rest.BeforeCreate(e.CreateStrategy, ctx, obj); err != nil {
return nil, err return nil, err
} }
...@@ -372,7 +373,7 @@ func (e *Store) Create(ctx genericapirequest.Context, obj runtime.Object, create ...@@ -372,7 +373,7 @@ func (e *Store) Create(ctx genericapirequest.Context, obj runtime.Object, create
// WaitForInitialized holds until the object is initialized, or returns an error if the default limit expires. // WaitForInitialized holds until the object is initialized, or returns an error if the default limit expires.
// This method is exposed publicly for consumers of generic rest tooling. // This method is exposed publicly for consumers of generic rest tooling.
func (e *Store) WaitForInitialized(ctx genericapirequest.Context, obj runtime.Object) (runtime.Object, error) { func (e *Store) WaitForInitialized(ctx context.Context, obj runtime.Object) (runtime.Object, error) {
// return early if we don't have initializers, or if they've completed already // return early if we don't have initializers, or if they've completed already
accessor, err := meta.Accessor(obj) accessor, err := meta.Accessor(obj)
if err != nil { if err != nil {
...@@ -453,7 +454,7 @@ func (e *Store) WaitForInitialized(ctx genericapirequest.Context, obj runtime.Ob ...@@ -453,7 +454,7 @@ func (e *Store) WaitForInitialized(ctx genericapirequest.Context, obj runtime.Ob
// shouldDeleteDuringUpdate checks if a Update is removing all the object's // shouldDeleteDuringUpdate checks if a Update is removing all the object's
// finalizers. If so, it further checks if the object's // finalizers. If so, it further checks if the object's
// DeletionGracePeriodSeconds is 0. // DeletionGracePeriodSeconds is 0.
func (e *Store) shouldDeleteDuringUpdate(ctx genericapirequest.Context, key string, obj, existing runtime.Object) bool { func (e *Store) shouldDeleteDuringUpdate(ctx context.Context, key string, obj, existing runtime.Object) bool {
newMeta, err := meta.Accessor(obj) newMeta, err := meta.Accessor(obj)
if err != nil { if err != nil {
utilruntime.HandleError(err) utilruntime.HandleError(err)
...@@ -469,7 +470,7 @@ func (e *Store) shouldDeleteDuringUpdate(ctx genericapirequest.Context, key stri ...@@ -469,7 +470,7 @@ func (e *Store) shouldDeleteDuringUpdate(ctx genericapirequest.Context, key stri
// shouldDeleteForFailedInitialization returns true if the provided object is initializing and has // shouldDeleteForFailedInitialization returns true if the provided object is initializing and has
// a failure recorded. // a failure recorded.
func (e *Store) shouldDeleteForFailedInitialization(ctx genericapirequest.Context, obj runtime.Object) bool { func (e *Store) shouldDeleteForFailedInitialization(ctx context.Context, obj runtime.Object) bool {
m, err := meta.Accessor(obj) m, err := meta.Accessor(obj)
if err != nil { if err != nil {
utilruntime.HandleError(err) utilruntime.HandleError(err)
...@@ -483,7 +484,7 @@ func (e *Store) shouldDeleteForFailedInitialization(ctx genericapirequest.Contex ...@@ -483,7 +484,7 @@ func (e *Store) shouldDeleteForFailedInitialization(ctx genericapirequest.Contex
// deleteWithoutFinalizers handles deleting an object ignoring its finalizer list. // deleteWithoutFinalizers handles deleting an object ignoring its finalizer list.
// Used for objects that are either been finalized or have never initialized. // Used for objects that are either been finalized or have never initialized.
func (e *Store) deleteWithoutFinalizers(ctx genericapirequest.Context, name, key string, obj runtime.Object, preconditions *storage.Preconditions) (runtime.Object, bool, error) { func (e *Store) deleteWithoutFinalizers(ctx context.Context, name, key string, obj runtime.Object, preconditions *storage.Preconditions) (runtime.Object, bool, error) {
out := e.NewFunc() out := e.NewFunc()
glog.V(6).Infof("going to delete %s from registry, triggered by update", name) glog.V(6).Infof("going to delete %s from registry, triggered by update", name)
if err := e.Storage.Delete(ctx, key, out, preconditions); err != nil { if err := e.Storage.Delete(ctx, key, out, preconditions); err != nil {
...@@ -509,7 +510,7 @@ func (e *Store) deleteWithoutFinalizers(ctx genericapirequest.Context, name, key ...@@ -509,7 +510,7 @@ func (e *Store) deleteWithoutFinalizers(ctx genericapirequest.Context, name, key
// Update performs an atomic update and set of the object. Returns the result of the update // Update performs an atomic update and set of the object. Returns the result of the update
// or an error. If the registry allows create-on-update, the create flow will be executed. // or an error. If the registry allows create-on-update, the create flow will be executed.
// A bool is returned along with the object and any errors, to indicate object creation. // A bool is returned along with the object and any errors, to indicate object creation.
func (e *Store) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (e *Store) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
key, err := e.KeyFunc(ctx, name) key, err := e.KeyFunc(ctx, name)
if err != nil { if err != nil {
return nil, false, err return nil, false, err
...@@ -666,7 +667,7 @@ func (e *Store) Update(ctx genericapirequest.Context, name string, objInfo rest. ...@@ -666,7 +667,7 @@ func (e *Store) Update(ctx genericapirequest.Context, name string, objInfo rest.
} }
// Get retrieves the item from storage. // Get retrieves the item from storage.
func (e *Store) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (e *Store) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
obj := e.NewFunc() obj := e.NewFunc()
key, err := e.KeyFunc(ctx, name) key, err := e.KeyFunc(ctx, name)
if err != nil { if err != nil {
...@@ -685,7 +686,7 @@ func (e *Store) Get(ctx genericapirequest.Context, name string, options *metav1. ...@@ -685,7 +686,7 @@ func (e *Store) Get(ctx genericapirequest.Context, name string, options *metav1.
// qualifiedResourceFromContext attempts to retrieve a GroupResource from the context's request info. // qualifiedResourceFromContext attempts to retrieve a GroupResource from the context's request info.
// If the context has no request info, DefaultQualifiedResource is used. // If the context has no request info, DefaultQualifiedResource is used.
func (e *Store) qualifiedResourceFromContext(ctx genericapirequest.Context) schema.GroupResource { func (e *Store) qualifiedResourceFromContext(ctx context.Context) schema.GroupResource {
if info, ok := genericapirequest.RequestInfoFrom(ctx); ok { if info, ok := genericapirequest.RequestInfoFrom(ctx); ok {
return schema.GroupResource{Group: info.APIGroup, Resource: info.Resource} return schema.GroupResource{Group: info.APIGroup, Resource: info.Resource}
} }
...@@ -704,7 +705,7 @@ var ( ...@@ -704,7 +705,7 @@ var (
// priority, there are three factors affect whether to add/remove the // priority, there are three factors affect whether to add/remove the
// FinalizerOrphanDependents: options, existing finalizers of the object, // FinalizerOrphanDependents: options, existing finalizers of the object,
// and e.DeleteStrategy.DefaultGarbageCollectionPolicy. // and e.DeleteStrategy.DefaultGarbageCollectionPolicy.
func shouldOrphanDependents(ctx genericapirequest.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) bool { func shouldOrphanDependents(ctx context.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) bool {
// Get default GC policy from this REST object type // Get default GC policy from this REST object type
gcStrategy, ok := e.DeleteStrategy.(rest.GarbageCollectionDeleteStrategy) gcStrategy, ok := e.DeleteStrategy.(rest.GarbageCollectionDeleteStrategy)
var defaultGCPolicy rest.GarbageCollectionPolicy var defaultGCPolicy rest.GarbageCollectionPolicy
...@@ -754,7 +755,7 @@ func shouldOrphanDependents(ctx genericapirequest.Context, e *Store, accessor me ...@@ -754,7 +755,7 @@ func shouldOrphanDependents(ctx genericapirequest.Context, e *Store, accessor me
// priority, there are three factors affect whether to add/remove the // priority, there are three factors affect whether to add/remove the
// FinalizerDeleteDependents: options, existing finalizers of the object, and // FinalizerDeleteDependents: options, existing finalizers of the object, and
// e.DeleteStrategy.DefaultGarbageCollectionPolicy. // e.DeleteStrategy.DefaultGarbageCollectionPolicy.
func shouldDeleteDependents(ctx genericapirequest.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) bool { func shouldDeleteDependents(ctx context.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) bool {
// Get default GC policy from this REST object type // Get default GC policy from this REST object type
if gcStrategy, ok := e.DeleteStrategy.(rest.GarbageCollectionDeleteStrategy); ok && gcStrategy.DefaultGarbageCollectionPolicy(ctx) == rest.Unsupported { if gcStrategy, ok := e.DeleteStrategy.(rest.GarbageCollectionDeleteStrategy); ok && gcStrategy.DefaultGarbageCollectionPolicy(ctx) == rest.Unsupported {
// return false to indicate that we should NOT delete in foreground // return false to indicate that we should NOT delete in foreground
...@@ -797,7 +798,7 @@ func shouldDeleteDependents(ctx genericapirequest.Context, e *Store, accessor me ...@@ -797,7 +798,7 @@ func shouldDeleteDependents(ctx genericapirequest.Context, e *Store, accessor me
// The finalizers returned are intended to be handled by the garbage collector. // The finalizers returned are intended to be handled by the garbage collector.
// If garbage collection is disabled for the store, this function returns false // If garbage collection is disabled for the store, this function returns false
// to ensure finalizers aren't set which will never be cleared. // to ensure finalizers aren't set which will never be cleared.
func deletionFinalizersForGarbageCollection(ctx genericapirequest.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) (bool, []string) { func deletionFinalizersForGarbageCollection(ctx context.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) (bool, []string) {
if !e.EnableGarbageCollection { if !e.EnableGarbageCollection {
return false, []string{} return false, []string{}
} }
...@@ -861,7 +862,7 @@ func markAsDeleting(obj runtime.Object) (err error) { ...@@ -861,7 +862,7 @@ func markAsDeleting(obj runtime.Object) (err error) {
// should be deleted immediately // should be deleted immediately
// 4. a new output object with the state that was updated // 4. a new output object with the state that was updated
// 5. a copy of the last existing state of the object // 5. a copy of the last existing state of the object
func (e *Store) updateForGracefulDeletionAndFinalizers(ctx genericapirequest.Context, name, key string, options *metav1.DeleteOptions, preconditions storage.Preconditions, in runtime.Object) (err error, ignoreNotFound, deleteImmediately bool, out, lastExisting runtime.Object) { func (e *Store) updateForGracefulDeletionAndFinalizers(ctx context.Context, name, key string, options *metav1.DeleteOptions, preconditions storage.Preconditions, in runtime.Object) (err error, ignoreNotFound, deleteImmediately bool, out, lastExisting runtime.Object) {
lastGraceful := int64(0) lastGraceful := int64(0)
var pendingFinalizers bool var pendingFinalizers bool
out = e.NewFunc() out = e.NewFunc()
...@@ -941,7 +942,7 @@ func (e *Store) updateForGracefulDeletionAndFinalizers(ctx genericapirequest.Con ...@@ -941,7 +942,7 @@ func (e *Store) updateForGracefulDeletionAndFinalizers(ctx genericapirequest.Con
} }
// Delete removes the item from storage. // Delete removes the item from storage.
func (e *Store) Delete(ctx genericapirequest.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) { func (e *Store) Delete(ctx context.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
key, err := e.KeyFunc(ctx, name) key, err := e.KeyFunc(ctx, name)
if err != nil { if err != nil {
return nil, false, err return nil, false, err
...@@ -1019,7 +1020,7 @@ func (e *Store) Delete(ctx genericapirequest.Context, name string, options *meta ...@@ -1019,7 +1020,7 @@ func (e *Store) Delete(ctx genericapirequest.Context, name string, options *meta
// are removing all objects of a given type) with the current API (it's technically // are removing all objects of a given type) with the current API (it's technically
// possibly with storage API, but watch is not delivered correctly then). // possibly with storage API, but watch is not delivered correctly then).
// It will be possible to fix it with v3 etcd API. // It will be possible to fix it with v3 etcd API.
func (e *Store) DeleteCollection(ctx genericapirequest.Context, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error) { func (e *Store) DeleteCollection(ctx context.Context, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error) {
if listOptions == nil { if listOptions == nil {
listOptions = &metainternalversion.ListOptions{} listOptions = &metainternalversion.ListOptions{}
} else { } else {
...@@ -1096,7 +1097,7 @@ func (e *Store) DeleteCollection(ctx genericapirequest.Context, options *metav1. ...@@ -1096,7 +1097,7 @@ func (e *Store) DeleteCollection(ctx genericapirequest.Context, options *metav1.
// finalizeDelete runs the Store's AfterDelete hook if runHooks is set and // finalizeDelete runs the Store's AfterDelete hook if runHooks is set and
// returns the decorated deleted object if appropriate. // returns the decorated deleted object if appropriate.
func (e *Store) finalizeDelete(ctx genericapirequest.Context, obj runtime.Object, runHooks bool) (runtime.Object, error) { func (e *Store) finalizeDelete(ctx context.Context, obj runtime.Object, runHooks bool) (runtime.Object, error) {
if runHooks && e.AfterDelete != nil { if runHooks && e.AfterDelete != nil {
if err := e.AfterDelete(obj); err != nil { if err := e.AfterDelete(obj); err != nil {
return nil, err return nil, err
...@@ -1131,7 +1132,7 @@ func (e *Store) finalizeDelete(ctx genericapirequest.Context, obj runtime.Object ...@@ -1131,7 +1132,7 @@ func (e *Store) finalizeDelete(ctx genericapirequest.Context, obj runtime.Object
// WatchPredicate. If possible, you should customize PredicateFunc to produce // WatchPredicate. If possible, you should customize PredicateFunc to produce
// a matcher that matches by key. SelectionPredicate does this for you // a matcher that matches by key. SelectionPredicate does this for you
// automatically. // automatically.
func (e *Store) Watch(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { func (e *Store) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
label := labels.Everything() label := labels.Everything()
if options != nil && options.LabelSelector != nil { if options != nil && options.LabelSelector != nil {
label = options.LabelSelector label = options.LabelSelector
...@@ -1151,7 +1152,7 @@ func (e *Store) Watch(ctx genericapirequest.Context, options *metainternalversio ...@@ -1151,7 +1152,7 @@ func (e *Store) Watch(ctx genericapirequest.Context, options *metainternalversio
} }
// WatchPredicate starts a watch for the items that matches. // WatchPredicate starts a watch for the items that matches.
func (e *Store) WatchPredicate(ctx genericapirequest.Context, p storage.SelectionPredicate, resourceVersion string) (watch.Interface, error) { func (e *Store) WatchPredicate(ctx context.Context, p storage.SelectionPredicate, resourceVersion string) (watch.Interface, error) {
if name, ok := p.MatchesSingle(); ok { if name, ok := p.MatchesSingle(); ok {
if key, err := e.KeyFunc(ctx, name); err == nil { if key, err := e.KeyFunc(ctx, name); err == nil {
w, err := e.Storage.Watch(ctx, key, resourceVersion, p) w, err := e.Storage.Watch(ctx, key, resourceVersion, p)
...@@ -1213,7 +1214,7 @@ func exportObjectMeta(accessor metav1.Object, exact bool) { ...@@ -1213,7 +1214,7 @@ func exportObjectMeta(accessor metav1.Object, exact bool) {
} }
// Export implements the rest.Exporter interface // Export implements the rest.Exporter interface
func (e *Store) Export(ctx genericapirequest.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) { func (e *Store) Export(ctx context.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) {
obj, err := e.Get(ctx, name, &metav1.GetOptions{}) obj, err := e.Get(ctx, name, &metav1.GetOptions{})
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -1303,17 +1304,17 @@ func (e *Store) CompleteWithOptions(options *generic.StoreOptions) error { ...@@ -1303,17 +1304,17 @@ func (e *Store) CompleteWithOptions(options *generic.StoreOptions) error {
// Set the default behavior for storage key generation // Set the default behavior for storage key generation
if e.KeyRootFunc == nil && e.KeyFunc == nil { if e.KeyRootFunc == nil && e.KeyFunc == nil {
if isNamespaced { if isNamespaced {
e.KeyRootFunc = func(ctx genericapirequest.Context) string { e.KeyRootFunc = func(ctx context.Context) string {
return NamespaceKeyRootFunc(ctx, prefix) return NamespaceKeyRootFunc(ctx, prefix)
} }
e.KeyFunc = func(ctx genericapirequest.Context, name string) (string, error) { e.KeyFunc = func(ctx context.Context, name string) (string, error) {
return NamespaceKeyFunc(ctx, prefix, name) return NamespaceKeyFunc(ctx, prefix, name)
} }
} else { } else {
e.KeyRootFunc = func(ctx genericapirequest.Context) string { e.KeyRootFunc = func(ctx context.Context) string {
return prefix return prefix
} }
e.KeyFunc = func(ctx genericapirequest.Context, name string) (string, error) { e.KeyFunc = func(ctx context.Context, name string) (string, error) {
return NoNamespaceKeyFunc(ctx, prefix, name) return NoNamespaceKeyFunc(ctx, prefix, name)
} }
} }
...@@ -1399,7 +1400,7 @@ func (e *Store) startObservingCount(period time.Duration) func() { ...@@ -1399,7 +1400,7 @@ func (e *Store) startObservingCount(period time.Duration) func() {
return func() { close(stopCh) } return func() { close(stopCh) }
} }
func (e *Store) ConvertToTable(ctx genericapirequest.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) { func (e *Store) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
if e.TableConvertor != nil { if e.TableConvertor != nil {
return e.TableConvertor.ConvertToTable(ctx, object, tableOptions) return e.TableConvertor.ConvertToTable(ctx, object, tableOptions)
} }
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package registry package registry
import ( import (
"context"
"fmt" "fmt"
"path" "path"
"reflect" "reflect"
...@@ -72,7 +73,7 @@ type testGracefulStrategy struct { ...@@ -72,7 +73,7 @@ type testGracefulStrategy struct {
testRESTStrategy testRESTStrategy
} }
func (t testGracefulStrategy) CheckGracefulDelete(ctx genericapirequest.Context, obj runtime.Object, options *metav1.DeleteOptions) bool { func (t testGracefulStrategy) CheckGracefulDelete(ctx context.Context, obj runtime.Object, options *metav1.DeleteOptions) bool {
return true return true
} }
...@@ -82,7 +83,7 @@ type testOrphanDeleteStrategy struct { ...@@ -82,7 +83,7 @@ type testOrphanDeleteStrategy struct {
*testRESTStrategy *testRESTStrategy
} }
func (t *testOrphanDeleteStrategy) DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) rest.GarbageCollectionPolicy { func (t *testOrphanDeleteStrategy) DefaultGarbageCollectionPolicy(ctx context.Context) rest.GarbageCollectionPolicy {
return rest.OrphanDependents return rest.OrphanDependents
} }
...@@ -98,7 +99,7 @@ func (t *testRESTStrategy) NamespaceScoped() bool { return t.namespaceS ...@@ -98,7 +99,7 @@ func (t *testRESTStrategy) NamespaceScoped() bool { return t.namespaceS
func (t *testRESTStrategy) AllowCreateOnUpdate() bool { return t.allowCreateOnUpdate } func (t *testRESTStrategy) AllowCreateOnUpdate() bool { return t.allowCreateOnUpdate }
func (t *testRESTStrategy) AllowUnconditionalUpdate() bool { return t.allowUnconditionalUpdate } func (t *testRESTStrategy) AllowUnconditionalUpdate() bool { return t.allowUnconditionalUpdate }
func (t *testRESTStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (t *testRESTStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
metaObj, err := meta.Accessor(obj) metaObj, err := meta.Accessor(obj)
if err != nil { if err != nil {
panic(err.Error()) panic(err.Error())
...@@ -111,11 +112,11 @@ func (t *testRESTStrategy) PrepareForCreate(ctx genericapirequest.Context, obj r ...@@ -111,11 +112,11 @@ func (t *testRESTStrategy) PrepareForCreate(ctx genericapirequest.Context, obj r
metaObj.SetLabels(labels) metaObj.SetLabels(labels)
} }
func (t *testRESTStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) {} func (t *testRESTStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {}
func (t *testRESTStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (t *testRESTStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
return nil return nil
} }
func (t *testRESTStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (t *testRESTStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return nil return nil
} }
func (t *testRESTStrategy) Canonicalize(obj runtime.Object) {} func (t *testRESTStrategy) Canonicalize(obj runtime.Object) {}
...@@ -172,7 +173,7 @@ func TestStoreList(t *testing.T) { ...@@ -172,7 +173,7 @@ func TestStoreList(t *testing.T) {
in *example.PodList in *example.PodList
m storage.SelectionPredicate m storage.SelectionPredicate
out runtime.Object out runtime.Object
context genericapirequest.Context context context.Context
}{ }{
"notFound": { "notFound": {
in: nil, in: nil,
...@@ -579,7 +580,7 @@ func TestStoreCreateInitializedFailed(t *testing.T) { ...@@ -579,7 +580,7 @@ func TestStoreCreateInitializedFailed(t *testing.T) {
} }
} }
func updateAndVerify(t *testing.T, ctx genericapirequest.Context, registry *Store, pod *example.Pod) bool { func updateAndVerify(t *testing.T, ctx context.Context, registry *Store, pod *example.Pod) bool {
obj, _, err := registry.Update(ctx, pod.Name, rest.DefaultUpdatedObjectInfo(pod), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc) obj, _, err := registry.Update(ctx, pod.Name, rest.DefaultUpdatedObjectInfo(pod), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
if err != nil { if err != nil {
t.Errorf("Unexpected error: %v", err) t.Errorf("Unexpected error: %v", err)
...@@ -733,7 +734,7 @@ func TestNoOpUpdates(t *testing.T) { ...@@ -733,7 +734,7 @@ func TestNoOpUpdates(t *testing.T) {
type testPodExport struct{} type testPodExport struct{}
func (t testPodExport) Export(ctx genericapirequest.Context, obj runtime.Object, exact bool) error { func (t testPodExport) Export(ctx context.Context, obj runtime.Object, exact bool) error {
pod := obj.(*example.Pod) pod := obj.(*example.Pod)
if pod.Labels == nil { if pod.Labels == nil {
pod.Labels = map[string]string{} pod.Labels = map[string]string{}
...@@ -1774,7 +1775,7 @@ func TestStoreWatch(t *testing.T) { ...@@ -1774,7 +1775,7 @@ func TestStoreWatch(t *testing.T) {
table := map[string]struct { table := map[string]struct {
selectPred storage.SelectionPredicate selectPred storage.SelectionPredicate
context genericapirequest.Context context context.Context
}{ }{
"single": { "single": {
selectPred: matchPodName("foo"), selectPred: matchPodName("foo"),
...@@ -1865,10 +1866,10 @@ func newTestGenericStoreRegistry(t *testing.T, scheme *runtime.Scheme, hasCacheE ...@@ -1865,10 +1866,10 @@ func newTestGenericStoreRegistry(t *testing.T, scheme *runtime.Scheme, hasCacheE
CreateStrategy: strategy, CreateStrategy: strategy,
UpdateStrategy: strategy, UpdateStrategy: strategy,
DeleteStrategy: strategy, DeleteStrategy: strategy,
KeyRootFunc: func(ctx genericapirequest.Context) string { KeyRootFunc: func(ctx context.Context) string {
return podPrefix return podPrefix
}, },
KeyFunc: func(ctx genericapirequest.Context, id string) (string, error) { KeyFunc: func(ctx context.Context, id string) (string, error) {
if _, ok := genericapirequest.NamespaceFrom(ctx); !ok { if _, ok := genericapirequest.NamespaceFrom(ctx); !ok {
return "", fmt.Errorf("namespace is required") return "", fmt.Errorf("namespace is required")
} }
...@@ -2011,7 +2012,7 @@ type fakeStrategy struct { ...@@ -2011,7 +2012,7 @@ type fakeStrategy struct {
names.NameGenerator names.NameGenerator
} }
func (fakeStrategy) DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) rest.GarbageCollectionPolicy { func (fakeStrategy) DefaultGarbageCollectionPolicy(ctx context.Context) rest.GarbageCollectionPolicy {
appsv1beta1 := schema.GroupVersion{Group: "apps", Version: "v1beta1"} appsv1beta1 := schema.GroupVersion{Group: "apps", Version: "v1beta1"}
appsv1beta2 := schema.GroupVersion{Group: "apps", Version: "v1beta2"} appsv1beta2 := schema.GroupVersion{Group: "apps", Version: "v1beta2"}
extensionsv1beta1 := schema.GroupVersion{Group: "extensions", Version: "v1beta1"} extensionsv1beta1 := schema.GroupVersion{Group: "extensions", Version: "v1beta1"}
......
...@@ -12,7 +12,6 @@ go_library( ...@@ -12,7 +12,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library", "//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest/resttest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest/resttest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/etcd:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/etcd:go_default_library",
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package tester package tester
import ( import (
"context"
"fmt" "fmt"
"testing" "testing"
...@@ -26,7 +27,6 @@ import ( ...@@ -26,7 +27,6 @@ import (
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
"k8s.io/apiserver/pkg/registry/rest/resttest" "k8s.io/apiserver/pkg/registry/rest/resttest"
etcdstorage "k8s.io/apiserver/pkg/storage/etcd" etcdstorage "k8s.io/apiserver/pkg/storage/etcd"
...@@ -142,7 +142,7 @@ func (t *Tester) TestWatch(valid runtime.Object, labelsPass, labelsFail []labels ...@@ -142,7 +142,7 @@ func (t *Tester) TestWatch(valid runtime.Object, labelsPass, labelsFail []labels
// Helper functions // Helper functions
func (t *Tester) getObject(ctx genericapirequest.Context, obj runtime.Object) (runtime.Object, error) { func (t *Tester) getObject(ctx context.Context, obj runtime.Object) (runtime.Object, error) {
accessor, err := meta.Accessor(obj) accessor, err := meta.Accessor(obj)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -155,7 +155,7 @@ func (t *Tester) getObject(ctx genericapirequest.Context, obj runtime.Object) (r ...@@ -155,7 +155,7 @@ func (t *Tester) getObject(ctx genericapirequest.Context, obj runtime.Object) (r
return result, nil return result, nil
} }
func (t *Tester) createObject(ctx genericapirequest.Context, obj runtime.Object) error { func (t *Tester) createObject(ctx context.Context, obj runtime.Object) error {
accessor, err := meta.Accessor(obj) accessor, err := meta.Accessor(obj)
if err != nil { if err != nil {
return err return err
......
...@@ -17,6 +17,8 @@ limitations under the License. ...@@ -17,6 +17,8 @@ limitations under the License.
package rest package rest
import ( import (
"context"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
genericvalidation "k8s.io/apimachinery/pkg/api/validation" genericvalidation "k8s.io/apimachinery/pkg/api/validation"
...@@ -26,7 +28,6 @@ import ( ...@@ -26,7 +28,6 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/features" "k8s.io/apiserver/pkg/features"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
...@@ -52,12 +53,12 @@ type RESTCreateStrategy interface { ...@@ -52,12 +53,12 @@ type RESTCreateStrategy interface {
// status. Clear the status because status changes are internal. External // status. Clear the status because status changes are internal. External
// callers of an api (users) should not be setting an initial status on // callers of an api (users) should not be setting an initial status on
// newly created objects. // newly created objects.
PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) PrepareForCreate(ctx context.Context, obj runtime.Object)
// Validate returns an ErrorList with validation errors or nil. Validate // Validate returns an ErrorList with validation errors or nil. Validate
// is invoked after default fields in the object have been filled in // is invoked after default fields in the object have been filled in
// before the object is persisted. This method should not mutate the // before the object is persisted. This method should not mutate the
// object. // object.
Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList Validate(ctx context.Context, obj runtime.Object) field.ErrorList
// Canonicalize allows an object to be mutated into a canonical form. This // Canonicalize allows an object to be mutated into a canonical form. This
// ensures that code that operates on these objects can rely on the common // ensures that code that operates on these objects can rely on the common
// form for things like comparison. Canonicalize is invoked after // form for things like comparison. Canonicalize is invoked after
...@@ -70,7 +71,7 @@ type RESTCreateStrategy interface { ...@@ -70,7 +71,7 @@ type RESTCreateStrategy interface {
// BeforeCreate ensures that common operations for all resources are performed on creation. It only returns // BeforeCreate ensures that common operations for all resources are performed on creation. It only returns
// errors that can be converted to api.Status. It invokes PrepareForCreate, then GenerateName, then Validate. // errors that can be converted to api.Status. It invokes PrepareForCreate, then GenerateName, then Validate.
// It returns nil if the object should be created. // It returns nil if the object should be created.
func BeforeCreate(strategy RESTCreateStrategy, ctx genericapirequest.Context, obj runtime.Object) error { func BeforeCreate(strategy RESTCreateStrategy, ctx context.Context, obj runtime.Object) error {
objectMeta, kind, kerr := objectMetaAndKind(strategy, obj) objectMeta, kind, kerr := objectMetaAndKind(strategy, obj)
if kerr != nil { if kerr != nil {
return kerr return kerr
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package rest package rest
import ( import (
"context"
"fmt" "fmt"
"time" "time"
...@@ -25,7 +26,6 @@ import ( ...@@ -25,7 +26,6 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/validation" "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
) )
// RESTDeleteStrategy defines deletion behavior on an object that follows Kubernetes // RESTDeleteStrategy defines deletion behavior on an object that follows Kubernetes
...@@ -48,7 +48,7 @@ const ( ...@@ -48,7 +48,7 @@ const (
// orphan dependents by default. // orphan dependents by default.
type GarbageCollectionDeleteStrategy interface { type GarbageCollectionDeleteStrategy interface {
// DefaultGarbageCollectionPolicy returns the default garbage collection behavior. // DefaultGarbageCollectionPolicy returns the default garbage collection behavior.
DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) GarbageCollectionPolicy DefaultGarbageCollectionPolicy(ctx context.Context) GarbageCollectionPolicy
} }
// RESTGracefulDeleteStrategy must be implemented by the registry that supports // RESTGracefulDeleteStrategy must be implemented by the registry that supports
...@@ -56,7 +56,7 @@ type GarbageCollectionDeleteStrategy interface { ...@@ -56,7 +56,7 @@ type GarbageCollectionDeleteStrategy interface {
type RESTGracefulDeleteStrategy interface { type RESTGracefulDeleteStrategy interface {
// CheckGracefulDelete should return true if the object can be gracefully deleted and set // CheckGracefulDelete should return true if the object can be gracefully deleted and set
// any default values on the DeleteOptions. // any default values on the DeleteOptions.
CheckGracefulDelete(ctx genericapirequest.Context, obj runtime.Object, options *metav1.DeleteOptions) bool CheckGracefulDelete(ctx context.Context, obj runtime.Object, options *metav1.DeleteOptions) bool
} }
// BeforeDelete tests whether the object can be gracefully deleted. // BeforeDelete tests whether the object can be gracefully deleted.
...@@ -68,7 +68,7 @@ type RESTGracefulDeleteStrategy interface { ...@@ -68,7 +68,7 @@ type RESTGracefulDeleteStrategy interface {
// where we set deletionTimestamp is pkg/registry/generic/registry/store.go. // where we set deletionTimestamp is pkg/registry/generic/registry/store.go.
// This function is responsible for setting deletionTimestamp during gracefulDeletion, // This function is responsible for setting deletionTimestamp during gracefulDeletion,
// other one for cascading deletions. // other one for cascading deletions.
func BeforeDelete(strategy RESTDeleteStrategy, ctx genericapirequest.Context, obj runtime.Object, options *metav1.DeleteOptions) (graceful, gracefulPending bool, err error) { func BeforeDelete(strategy RESTDeleteStrategy, ctx context.Context, obj runtime.Object, options *metav1.DeleteOptions) (graceful, gracefulPending bool, err error) {
objectMeta, gvk, kerr := objectMetaAndKind(strategy, obj) objectMeta, gvk, kerr := objectMetaAndKind(strategy, obj)
if kerr != nil { if kerr != nil {
return false, false, kerr return false, false, kerr
......
...@@ -17,8 +17,9 @@ limitations under the License. ...@@ -17,8 +17,9 @@ limitations under the License.
package rest package rest
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
) )
// RESTExportStrategy is the interface that defines how to export a Kubernetes // RESTExportStrategy is the interface that defines how to export a Kubernetes
...@@ -29,5 +30,5 @@ import ( ...@@ -29,5 +30,5 @@ import (
type RESTExportStrategy interface { type RESTExportStrategy interface {
// Export strips fields that can not be set by the user. If 'exact' is false // Export strips fields that can not be set by the user. If 'exact' is false
// fields specific to the cluster are also stripped // fields specific to the cluster are also stripped
Export(ctx genericapirequest.Context, obj runtime.Object, exact bool) error Export(ctx context.Context, obj runtime.Object, exact bool) error
} }
...@@ -17,13 +17,15 @@ limitations under the License. ...@@ -17,13 +17,15 @@ limitations under the License.
package rest package rest
import ( import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/util/uuid"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
) )
// FillObjectMetaSystemFields populates fields that are managed by the system on ObjectMeta. // FillObjectMetaSystemFields populates fields that are managed by the system on ObjectMeta.
func FillObjectMetaSystemFields(ctx genericapirequest.Context, meta metav1.Object) { func FillObjectMetaSystemFields(ctx context.Context, meta metav1.Object) {
meta.SetCreationTimestamp(metav1.Now()) meta.SetCreationTimestamp(metav1.Now())
// allows admission controllers to assign a UID earlier in the request processing // allows admission controllers to assign a UID earlier in the request processing
// to support tracking resources pending creation. // to support tracking resources pending creation.
...@@ -38,7 +40,7 @@ func FillObjectMetaSystemFields(ctx genericapirequest.Context, meta metav1.Objec ...@@ -38,7 +40,7 @@ func FillObjectMetaSystemFields(ctx genericapirequest.Context, meta metav1.Objec
// ValidNamespace returns false if the namespace on the context differs from // ValidNamespace returns false if the namespace on the context differs from
// the resource. If the resource has no namespace, it is set to the value in // the resource. If the resource has no namespace, it is set to the value in
// the context. // the context.
func ValidNamespace(ctx genericapirequest.Context, resource metav1.Object) bool { func ValidNamespace(ctx context.Context, resource metav1.Object) bool {
ns, ok := genericapirequest.NamespaceFrom(ctx) ns, ok := genericapirequest.NamespaceFrom(ctx)
if len(resource.GetNamespace()) == 0 { if len(resource.GetNamespace()) == 0 {
resource.SetNamespace(ns) resource.SetNamespace(ns)
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package rest package rest
import ( import (
"context"
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
...@@ -27,7 +28,6 @@ import ( ...@@ -27,7 +28,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
) )
//TODO: //TODO:
...@@ -91,7 +91,7 @@ type Lister interface { ...@@ -91,7 +91,7 @@ type Lister interface {
// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object) // This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
NewList() runtime.Object NewList() runtime.Object
// List selects resources in the storage which match to the selector. 'options' can be nil. // List selects resources in the storage which match to the selector. 'options' can be nil.
List(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (runtime.Object, error) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error)
} }
// Exporter is an object that knows how to strip a RESTful resource for export. A store should implement this interface // Exporter is an object that knows how to strip a RESTful resource for export. A store should implement this interface
...@@ -101,7 +101,7 @@ type Exporter interface { ...@@ -101,7 +101,7 @@ type Exporter interface {
// Export an object. Fields that are not user specified (e.g. Status, ObjectMeta.ResourceVersion) are stripped out // Export an object. Fields that are not user specified (e.g. Status, ObjectMeta.ResourceVersion) are stripped out
// Returns the stripped object. If 'exact' is true, fields that are specific to the cluster (e.g. namespace) are // Returns the stripped object. If 'exact' is true, fields that are specific to the cluster (e.g. namespace) are
// retained, otherwise they are stripped also. // retained, otherwise they are stripped also.
Export(ctx genericapirequest.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) Export(ctx context.Context, name string, opts metav1.ExportOptions) (runtime.Object, error)
} }
// Getter is an object that can retrieve a named RESTful resource. // Getter is an object that can retrieve a named RESTful resource.
...@@ -109,7 +109,7 @@ type Getter interface { ...@@ -109,7 +109,7 @@ type Getter interface {
// Get finds a resource in the storage by name and returns it. // Get finds a resource in the storage by name and returns it.
// Although it can return an arbitrary error value, IsNotFound(err) is true for the // Although it can return an arbitrary error value, IsNotFound(err) is true for the
// returned error value err when the specified resource is not found. // returned error value err when the specified resource is not found.
Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error)
} }
// GetterWithOptions is an object that retrieve a named RESTful resource and takes // GetterWithOptions is an object that retrieve a named RESTful resource and takes
...@@ -122,7 +122,7 @@ type GetterWithOptions interface { ...@@ -122,7 +122,7 @@ type GetterWithOptions interface {
// The options object passed to it is of the same type returned by the NewGetOptions // The options object passed to it is of the same type returned by the NewGetOptions
// method. // method.
// TODO: Pass metav1.GetOptions. // TODO: Pass metav1.GetOptions.
Get(ctx genericapirequest.Context, name string, options runtime.Object) (runtime.Object, error) Get(ctx context.Context, name string, options runtime.Object) (runtime.Object, error)
// NewGetOptions returns an empty options object that will be used to pass // NewGetOptions returns an empty options object that will be used to pass
// options to the Get method. It may return a bool and a string, if true, the // options to the Get method. It may return a bool and a string, if true, the
...@@ -134,7 +134,7 @@ type GetterWithOptions interface { ...@@ -134,7 +134,7 @@ type GetterWithOptions interface {
} }
type TableConvertor interface { type TableConvertor interface {
ConvertToTable(ctx genericapirequest.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error)
} }
// GracefulDeleter knows how to pass deletion options to allow delayed deletion of a // GracefulDeleter knows how to pass deletion options to allow delayed deletion of a
...@@ -149,7 +149,7 @@ type GracefulDeleter interface { ...@@ -149,7 +149,7 @@ type GracefulDeleter interface {
// information about deletion. // information about deletion.
// It also returns a boolean which is set to true if the resource was instantly // It also returns a boolean which is set to true if the resource was instantly
// deleted or false if it will be deleted asynchronously. // deleted or false if it will be deleted asynchronously.
Delete(ctx genericapirequest.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) Delete(ctx context.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error)
} }
// CollectionDeleter is an object that can delete a collection // CollectionDeleter is an object that can delete a collection
...@@ -160,7 +160,7 @@ type CollectionDeleter interface { ...@@ -160,7 +160,7 @@ type CollectionDeleter interface {
// them or return an invalid request error. // them or return an invalid request error.
// DeleteCollection may not be atomic - i.e. it may delete some objects and still // DeleteCollection may not be atomic - i.e. it may delete some objects and still
// return an error after it. On success, returns a list of deleted objects. // return an error after it. On success, returns a list of deleted objects.
DeleteCollection(ctx genericapirequest.Context, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error) DeleteCollection(ctx context.Context, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error)
} }
// Creater is an object that can create an instance of a RESTful object. // Creater is an object that can create an instance of a RESTful object.
...@@ -171,7 +171,7 @@ type Creater interface { ...@@ -171,7 +171,7 @@ type Creater interface {
// Create creates a new version of a resource. If includeUninitialized is set, the object may be returned // Create creates a new version of a resource. If includeUninitialized is set, the object may be returned
// without completing initialization. // without completing initialization.
Create(ctx genericapirequest.Context, obj runtime.Object, createValidation ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) Create(ctx context.Context, obj runtime.Object, createValidation ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error)
} }
// NamedCreater is an object that can create an instance of a RESTful object using a name parameter. // NamedCreater is an object that can create an instance of a RESTful object using a name parameter.
...@@ -184,7 +184,7 @@ type NamedCreater interface { ...@@ -184,7 +184,7 @@ type NamedCreater interface {
// This is needed for create operations on subresources which include the name of the parent // This is needed for create operations on subresources which include the name of the parent
// resource in the path. If includeUninitialized is set, the object may be returned without // resource in the path. If includeUninitialized is set, the object may be returned without
// completing initialization. // completing initialization.
Create(ctx genericapirequest.Context, name string, obj runtime.Object, createValidation ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) Create(ctx context.Context, name string, obj runtime.Object, createValidation ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error)
} }
// UpdatedObjectInfo provides information about an updated object to an Updater. // UpdatedObjectInfo provides information about an updated object to an Updater.
...@@ -197,7 +197,7 @@ type UpdatedObjectInfo interface { ...@@ -197,7 +197,7 @@ type UpdatedObjectInfo interface {
// UpdatedObject returns the updated object, given a context and old object. // UpdatedObject returns the updated object, given a context and old object.
// The only time an empty oldObj should be passed in is if a "create on update" is occurring (there is no oldObj). // The only time an empty oldObj should be passed in is if a "create on update" is occurring (there is no oldObj).
UpdatedObject(ctx genericapirequest.Context, oldObj runtime.Object) (newObj runtime.Object, err error) UpdatedObject(ctx context.Context, oldObj runtime.Object) (newObj runtime.Object, err error)
} }
// ValidateObjectFunc is a function to act on a given object. An error may be returned // ValidateObjectFunc is a function to act on a given object. An error may be returned
...@@ -229,14 +229,14 @@ type Updater interface { ...@@ -229,14 +229,14 @@ type Updater interface {
// Update finds a resource in the storage and updates it. Some implementations // Update finds a resource in the storage and updates it. Some implementations
// may allow updates creates the object - they should set the created boolean // may allow updates creates the object - they should set the created boolean
// to true. // to true.
Update(ctx genericapirequest.Context, name string, objInfo UpdatedObjectInfo, createValidation ValidateObjectFunc, updateValidation ValidateObjectUpdateFunc) (runtime.Object, bool, error) Update(ctx context.Context, name string, objInfo UpdatedObjectInfo, createValidation ValidateObjectFunc, updateValidation ValidateObjectUpdateFunc) (runtime.Object, bool, error)
} }
// CreaterUpdater is a storage object that must support both create and update. // CreaterUpdater is a storage object that must support both create and update.
// Go prevents embedded interfaces that implement the same method. // Go prevents embedded interfaces that implement the same method.
type CreaterUpdater interface { type CreaterUpdater interface {
Creater Creater
Update(ctx genericapirequest.Context, name string, objInfo UpdatedObjectInfo, createValidation ValidateObjectFunc, updateValidation ValidateObjectUpdateFunc) (runtime.Object, bool, error) Update(ctx context.Context, name string, objInfo UpdatedObjectInfo, createValidation ValidateObjectFunc, updateValidation ValidateObjectUpdateFunc) (runtime.Object, bool, error)
} }
// CreaterUpdater must satisfy the Updater interface. // CreaterUpdater must satisfy the Updater interface.
...@@ -255,7 +255,7 @@ type Watcher interface { ...@@ -255,7 +255,7 @@ type Watcher interface {
// are supported; an error should be returned if 'field' tries to select on a field that // are supported; an error should be returned if 'field' tries to select on a field that
// isn't supported. 'resourceVersion' allows for continuing/starting a watch at a // isn't supported. 'resourceVersion' allows for continuing/starting a watch at a
// particular version. // particular version.
Watch(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
} }
// StandardStorage is an interface covering the common verbs. Provided for testing whether a // StandardStorage is an interface covering the common verbs. Provided for testing whether a
...@@ -272,7 +272,7 @@ type StandardStorage interface { ...@@ -272,7 +272,7 @@ type StandardStorage interface {
// Redirector know how to return a remote resource's location. // Redirector know how to return a remote resource's location.
type Redirector interface { type Redirector interface {
// ResourceLocation should return the remote location of the given resource, and an optional transport to use to request it, or an error. // ResourceLocation should return the remote location of the given resource, and an optional transport to use to request it, or an error.
ResourceLocation(ctx genericapirequest.Context, id string) (remoteLocation *url.URL, transport http.RoundTripper, err error) ResourceLocation(ctx context.Context, id string) (remoteLocation *url.URL, transport http.RoundTripper, err error)
} }
// Responder abstracts the normal response behavior for a REST method and is passed to callers that // Responder abstracts the normal response behavior for a REST method and is passed to callers that
...@@ -292,7 +292,7 @@ type Connecter interface { ...@@ -292,7 +292,7 @@ type Connecter interface {
// code and body, so the ServeHTTP method should exit after invoking the responder. The Handler will // code and body, so the ServeHTTP method should exit after invoking the responder. The Handler will
// be used for a single API request and then discarded. The Responder is guaranteed to write to the // be used for a single API request and then discarded. The Responder is guaranteed to write to the
// same http.ResponseWriter passed to ServeHTTP. // same http.ResponseWriter passed to ServeHTTP.
Connect(ctx genericapirequest.Context, id string, options runtime.Object, r Responder) (http.Handler, error) Connect(ctx context.Context, id string, options runtime.Object, r Responder) (http.Handler, error)
// NewConnectOptions returns an empty options object that will be used to pass // NewConnectOptions returns an empty options object that will be used to pass
// options to the Connect method. If nil, then a nil options object is passed to // options to the Connect method. If nil, then a nil options object is passed to
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package resttest package resttest
import ( import (
"context"
"fmt" "fmt"
"reflect" "reflect"
"strings" "strings"
...@@ -99,7 +100,7 @@ func (t *Tester) TestNamespace() string { ...@@ -99,7 +100,7 @@ func (t *Tester) TestNamespace() string {
// TestContext returns a namespaced context that will be used when making storage calls. // TestContext returns a namespaced context that will be used when making storage calls.
// Namespace is determined by TestNamespace() // Namespace is determined by TestNamespace()
func (t *Tester) TestContext() genericapirequest.Context { func (t *Tester) TestContext() context.Context {
if t.clusterScope { if t.clusterScope {
return genericapirequest.NewContext() return genericapirequest.NewContext()
} }
...@@ -128,11 +129,11 @@ func (t *Tester) setObjectMeta(obj runtime.Object, name string) { ...@@ -128,11 +129,11 @@ func (t *Tester) setObjectMeta(obj runtime.Object, name string) {
type AssignFunc func([]runtime.Object) []runtime.Object type AssignFunc func([]runtime.Object) []runtime.Object
type EmitFunc func(runtime.Object, string) error type EmitFunc func(runtime.Object, string) error
type GetFunc func(genericapirequest.Context, runtime.Object) (runtime.Object, error) type GetFunc func(context.Context, runtime.Object) (runtime.Object, error)
type InitWatchFunc func() type InitWatchFunc func()
type InjectErrFunc func(err error) type InjectErrFunc func(err error)
type IsErrorFunc func(err error) bool type IsErrorFunc func(err error) bool
type CreateFunc func(genericapirequest.Context, runtime.Object) error type CreateFunc func(context.Context, runtime.Object) error
type SetRVFunc func(uint64) type SetRVFunc func(uint64)
type UpdateFunc func(runtime.Object) runtime.Object type UpdateFunc func(runtime.Object) runtime.Object
...@@ -219,7 +220,7 @@ func (t *Tester) TestWatch( ...@@ -219,7 +220,7 @@ func (t *Tester) TestWatch(
// ============================================================================= // =============================================================================
// Creation tests. // Creation tests.
func (t *Tester) delete(ctx genericapirequest.Context, obj runtime.Object) error { func (t *Tester) delete(ctx context.Context, obj runtime.Object) error {
objectMeta, err := meta.Accessor(obj) objectMeta, err := meta.Accessor(obj)
if err != nil { if err != nil {
return err return err
...@@ -576,7 +577,7 @@ func (t *Tester) testUpdateRetrievesOldObject(obj runtime.Object, createFn Creat ...@@ -576,7 +577,7 @@ func (t *Tester) testUpdateRetrievesOldObject(obj runtime.Object, createFn Creat
// Make sure a custom transform is called, and sees the expected updatedObject and oldObject // Make sure a custom transform is called, and sees the expected updatedObject and oldObject
// This tests the mechanism used to pass the old and new object to admission // This tests the mechanism used to pass the old and new object to admission
calledUpdatedObject := 0 calledUpdatedObject := 0
noopTransform := func(_ genericapirequest.Context, updatedObject runtime.Object, oldObject runtime.Object) (runtime.Object, error) { noopTransform := func(_ context.Context, updatedObject runtime.Object, oldObject runtime.Object) (runtime.Object, error) {
if !reflect.DeepEqual(storedFoo, oldObject) { if !reflect.DeepEqual(storedFoo, oldObject) {
t.Errorf("Expected\n\t%#v\ngot\n\t%#v", storedFoo, oldObject) t.Errorf("Expected\n\t%#v\ngot\n\t%#v", storedFoo, oldObject)
} }
...@@ -618,7 +619,7 @@ func (t *Tester) testUpdatePropagatesUpdatedObjectError(obj runtime.Object, crea ...@@ -618,7 +619,7 @@ func (t *Tester) testUpdatePropagatesUpdatedObjectError(obj runtime.Object, crea
// Make sure our transform is called, and sees the expected updatedObject and oldObject // Make sure our transform is called, and sees the expected updatedObject and oldObject
propagateErr := fmt.Errorf("custom updated object error for %v", foo) propagateErr := fmt.Errorf("custom updated object error for %v", foo)
noopTransform := func(_ genericapirequest.Context, updatedObject runtime.Object, oldObject runtime.Object) (runtime.Object, error) { noopTransform := func(_ context.Context, updatedObject runtime.Object, oldObject runtime.Object) (runtime.Object, error) {
return nil, propagateErr return nil, propagateErr
} }
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package rest package rest
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"time" "time"
...@@ -26,7 +27,6 @@ import ( ...@@ -26,7 +27,6 @@ import (
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
) )
type defaultTableConvertor struct { type defaultTableConvertor struct {
...@@ -40,7 +40,7 @@ func NewDefaultTableConvertor(resource schema.GroupResource) TableConvertor { ...@@ -40,7 +40,7 @@ func NewDefaultTableConvertor(resource schema.GroupResource) TableConvertor {
var swaggerMetadataDescriptions = metav1.ObjectMeta{}.SwaggerDoc() var swaggerMetadataDescriptions = metav1.ObjectMeta{}.SwaggerDoc()
func (c defaultTableConvertor) ConvertToTable(ctx genericapirequest.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) { func (c defaultTableConvertor) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
var table metav1beta1.Table var table metav1beta1.Table
fn := func(obj runtime.Object) error { fn := func(obj runtime.Object) error {
m, err := meta.Accessor(obj) m, err := meta.Accessor(obj)
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package rest package rest
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
...@@ -27,7 +28,6 @@ import ( ...@@ -27,7 +28,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/features" "k8s.io/apiserver/pkg/features"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
) )
...@@ -46,11 +46,11 @@ type RESTUpdateStrategy interface { ...@@ -46,11 +46,11 @@ type RESTUpdateStrategy interface {
// the object. For example: remove fields that are not to be persisted, // the object. For example: remove fields that are not to be persisted,
// sort order-insensitive list fields, etc. This should not remove fields // sort order-insensitive list fields, etc. This should not remove fields
// whose presence would be considered a validation error. // whose presence would be considered a validation error.
PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
// ValidateUpdate is invoked after default fields in the object have been // ValidateUpdate is invoked after default fields in the object have been
// filled in before the object is persisted. This method should not mutate // filled in before the object is persisted. This method should not mutate
// the object. // the object.
ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList
// Canonicalize allows an object to be mutated into a canonical form. This // Canonicalize allows an object to be mutated into a canonical form. This
// ensures that code that operates on these objects can rely on the common // ensures that code that operates on these objects can rely on the common
// form for things like comparison. Canonicalize is invoked after // form for things like comparison. Canonicalize is invoked after
...@@ -83,7 +83,7 @@ func validateCommonFields(obj, old runtime.Object, strategy RESTUpdateStrategy) ...@@ -83,7 +83,7 @@ func validateCommonFields(obj, old runtime.Object, strategy RESTUpdateStrategy)
// BeforeUpdate ensures that common operations for all resources are performed on update. It only returns // BeforeUpdate ensures that common operations for all resources are performed on update. It only returns
// errors that can be converted to api.Status. It will invoke update validation with the provided existing // errors that can be converted to api.Status. It will invoke update validation with the provided existing
// and updated objects. // and updated objects.
func BeforeUpdate(strategy RESTUpdateStrategy, ctx genericapirequest.Context, obj, old runtime.Object) error { func BeforeUpdate(strategy RESTUpdateStrategy, ctx context.Context, obj, old runtime.Object) error {
objectMeta, kind, kerr := objectMetaAndKind(strategy, obj) objectMeta, kind, kerr := objectMetaAndKind(strategy, obj)
if kerr != nil { if kerr != nil {
return kerr return kerr
...@@ -130,7 +130,7 @@ func BeforeUpdate(strategy RESTUpdateStrategy, ctx genericapirequest.Context, ob ...@@ -130,7 +130,7 @@ func BeforeUpdate(strategy RESTUpdateStrategy, ctx genericapirequest.Context, ob
} }
// TransformFunc is a function to transform and return newObj // TransformFunc is a function to transform and return newObj
type TransformFunc func(ctx genericapirequest.Context, newObj runtime.Object, oldObj runtime.Object) (transformedNewObj runtime.Object, err error) type TransformFunc func(ctx context.Context, newObj runtime.Object, oldObj runtime.Object) (transformedNewObj runtime.Object, err error)
// defaultUpdatedObjectInfo implements UpdatedObjectInfo // defaultUpdatedObjectInfo implements UpdatedObjectInfo
type defaultUpdatedObjectInfo struct { type defaultUpdatedObjectInfo struct {
...@@ -167,7 +167,7 @@ func (i *defaultUpdatedObjectInfo) Preconditions() *metav1.Preconditions { ...@@ -167,7 +167,7 @@ func (i *defaultUpdatedObjectInfo) Preconditions() *metav1.Preconditions {
// UpdatedObject satisfies the UpdatedObjectInfo interface. // UpdatedObject satisfies the UpdatedObjectInfo interface.
// It returns a copy of the held obj, passed through any configured transformers. // It returns a copy of the held obj, passed through any configured transformers.
func (i *defaultUpdatedObjectInfo) UpdatedObject(ctx genericapirequest.Context, oldObj runtime.Object) (runtime.Object, error) { func (i *defaultUpdatedObjectInfo) UpdatedObject(ctx context.Context, oldObj runtime.Object) (runtime.Object, error) {
var err error var err error
// Start with the configured object // Start with the configured object
newObj := i.obj newObj := i.obj
...@@ -214,7 +214,7 @@ func (i *wrappedUpdatedObjectInfo) Preconditions() *metav1.Preconditions { ...@@ -214,7 +214,7 @@ func (i *wrappedUpdatedObjectInfo) Preconditions() *metav1.Preconditions {
// UpdatedObject satisfies the UpdatedObjectInfo interface. // UpdatedObject satisfies the UpdatedObjectInfo interface.
// It delegates to the wrapped objInfo and passes the result through any configured transformers. // It delegates to the wrapped objInfo and passes the result through any configured transformers.
func (i *wrappedUpdatedObjectInfo) UpdatedObject(ctx genericapirequest.Context, oldObj runtime.Object) (runtime.Object, error) { func (i *wrappedUpdatedObjectInfo) UpdatedObject(ctx context.Context, oldObj runtime.Object) (runtime.Object, error) {
newObj, err := i.objInfo.UpdatedObject(ctx, oldObj) newObj, err := i.objInfo.UpdatedObject(ctx, oldObj)
if err != nil { if err != nil {
return newObj, err return newObj, err
......
...@@ -30,7 +30,6 @@ go_test( ...@@ -30,7 +30,6 @@ go_test(
"//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library", "//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/discovery:go_default_library", "//vendor/k8s.io/apiserver/pkg/endpoints/discovery:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/filters:go_default_library", "//vendor/k8s.io/apiserver/pkg/endpoints/filters:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/server/filters:go_default_library", "//vendor/k8s.io/apiserver/pkg/server/filters:go_default_library",
"//vendor/k8s.io/apiserver/pkg/server/healthz:go_default_library", "//vendor/k8s.io/apiserver/pkg/server/healthz:go_default_library",
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package server package server
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
...@@ -47,7 +48,6 @@ import ( ...@@ -47,7 +48,6 @@ import (
"k8s.io/apiserver/pkg/authorization/authorizer" "k8s.io/apiserver/pkg/authorization/authorizer"
"k8s.io/apiserver/pkg/endpoints/discovery" "k8s.io/apiserver/pkg/endpoints/discovery"
genericapifilters "k8s.io/apiserver/pkg/endpoints/filters" genericapifilters "k8s.io/apiserver/pkg/endpoints/filters"
apirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/registry/rest"
genericfilters "k8s.io/apiserver/pkg/server/filters" genericfilters "k8s.io/apiserver/pkg/server/filters"
"k8s.io/client-go/informers" "k8s.io/client-go/informers"
...@@ -468,7 +468,7 @@ func (p *testGetterStorage) New() runtime.Object { ...@@ -468,7 +468,7 @@ func (p *testGetterStorage) New() runtime.Object {
} }
} }
func (p *testGetterStorage) Get(ctx apirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { func (p *testGetterStorage) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
return nil, nil return nil, nil
} }
......
...@@ -14,7 +14,6 @@ go_library( ...@@ -14,7 +14,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
......
...@@ -11,7 +11,6 @@ go_library( ...@@ -11,7 +11,6 @@ go_library(
importpath = "k8s.io/kube-aggregator/pkg/registry/apiservice/etcd", importpath = "k8s.io/kube-aggregator/pkg/registry/apiservice/etcd",
deps = [ deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
......
...@@ -17,8 +17,9 @@ limitations under the License. ...@@ -17,8 +17,9 @@ limitations under the License.
package etcd package etcd
import ( import (
"context"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"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/registry/rest"
...@@ -72,6 +73,6 @@ func (r *StatusREST) New() runtime.Object { ...@@ -72,6 +73,6 @@ func (r *StatusREST) New() runtime.Object {
} }
// Update alters the status subset of an object. // Update alters the status subset of an object.
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
} }
...@@ -17,13 +17,13 @@ limitations under the License. ...@@ -17,13 +17,13 @@ limitations under the License.
package apiservice package apiservice
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
...@@ -45,7 +45,7 @@ func (apiServerStrategy) NamespaceScoped() bool { ...@@ -45,7 +45,7 @@ func (apiServerStrategy) NamespaceScoped() bool {
return false return false
} }
func (apiServerStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (apiServerStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
apiservice := obj.(*apiregistration.APIService) apiservice := obj.(*apiregistration.APIService)
apiservice.Status = apiregistration.APIServiceStatus{} apiservice.Status = apiregistration.APIServiceStatus{}
...@@ -55,13 +55,13 @@ func (apiServerStrategy) PrepareForCreate(ctx genericapirequest.Context, obj run ...@@ -55,13 +55,13 @@ func (apiServerStrategy) PrepareForCreate(ctx genericapirequest.Context, obj run
} }
} }
func (apiServerStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (apiServerStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newAPIService := obj.(*apiregistration.APIService) newAPIService := obj.(*apiregistration.APIService)
oldAPIService := old.(*apiregistration.APIService) oldAPIService := old.(*apiregistration.APIService)
newAPIService.Status = oldAPIService.Status newAPIService.Status = oldAPIService.Status
} }
func (apiServerStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (apiServerStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
return validation.ValidateAPIService(obj.(*apiregistration.APIService)) return validation.ValidateAPIService(obj.(*apiregistration.APIService))
} }
...@@ -76,7 +76,7 @@ func (apiServerStrategy) AllowUnconditionalUpdate() bool { ...@@ -76,7 +76,7 @@ func (apiServerStrategy) AllowUnconditionalUpdate() bool {
func (apiServerStrategy) Canonicalize(obj runtime.Object) { func (apiServerStrategy) Canonicalize(obj runtime.Object) {
} }
func (apiServerStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (apiServerStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateAPIServiceUpdate(obj.(*apiregistration.APIService), old.(*apiregistration.APIService)) return validation.ValidateAPIServiceUpdate(obj.(*apiregistration.APIService), old.(*apiregistration.APIService))
} }
...@@ -93,7 +93,7 @@ func (apiServerStatusStrategy) NamespaceScoped() bool { ...@@ -93,7 +93,7 @@ func (apiServerStatusStrategy) NamespaceScoped() bool {
return false return false
} }
func (apiServerStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (apiServerStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
newAPIService := obj.(*apiregistration.APIService) newAPIService := obj.(*apiregistration.APIService)
oldAPIService := old.(*apiregistration.APIService) oldAPIService := old.(*apiregistration.APIService)
newAPIService.Spec = oldAPIService.Spec newAPIService.Spec = oldAPIService.Spec
...@@ -114,7 +114,7 @@ func (apiServerStatusStrategy) AllowUnconditionalUpdate() bool { ...@@ -114,7 +114,7 @@ func (apiServerStatusStrategy) AllowUnconditionalUpdate() bool {
func (apiServerStatusStrategy) Canonicalize(obj runtime.Object) { func (apiServerStatusStrategy) Canonicalize(obj runtime.Object) {
} }
func (apiServerStatusStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (apiServerStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateAPIServiceStatusUpdate(obj.(*apiregistration.APIService), old.(*apiregistration.APIService)) return validation.ValidateAPIServiceStatusUpdate(obj.(*apiregistration.APIService), old.(*apiregistration.APIService))
} }
......
...@@ -17,7 +17,6 @@ go_library( ...@@ -17,7 +17,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package fischer package fischer
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
...@@ -27,7 +28,6 @@ import ( ...@@ -27,7 +28,6 @@ import (
"k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/sample-apiserver/pkg/apis/wardle" "k8s.io/sample-apiserver/pkg/apis/wardle"
) )
...@@ -70,13 +70,13 @@ func (fischerStrategy) NamespaceScoped() bool { ...@@ -70,13 +70,13 @@ func (fischerStrategy) NamespaceScoped() bool {
return false return false
} }
func (fischerStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (fischerStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
} }
func (fischerStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (fischerStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
} }
func (fischerStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (fischerStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
return field.ErrorList{} return field.ErrorList{}
} }
...@@ -91,6 +91,6 @@ func (fischerStrategy) AllowUnconditionalUpdate() bool { ...@@ -91,6 +91,6 @@ func (fischerStrategy) AllowUnconditionalUpdate() bool {
func (fischerStrategy) Canonicalize(obj runtime.Object) { func (fischerStrategy) Canonicalize(obj runtime.Object) {
} }
func (fischerStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (fischerStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return field.ErrorList{} return field.ErrorList{}
} }
...@@ -17,7 +17,6 @@ go_library( ...@@ -17,7 +17,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package flunder package flunder
import ( import (
"context"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
...@@ -28,7 +29,6 @@ import ( ...@@ -28,7 +29,6 @@ import (
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
"k8s.io/sample-apiserver/pkg/apis/wardle/validation" "k8s.io/sample-apiserver/pkg/apis/wardle/validation"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/sample-apiserver/pkg/apis/wardle" "k8s.io/sample-apiserver/pkg/apis/wardle"
) )
...@@ -71,13 +71,13 @@ func (flunderStrategy) NamespaceScoped() bool { ...@@ -71,13 +71,13 @@ func (flunderStrategy) NamespaceScoped() bool {
return true return true
} }
func (flunderStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { func (flunderStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
} }
func (flunderStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { func (flunderStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
} }
func (flunderStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { func (flunderStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
flunder := obj.(*wardle.Flunder) flunder := obj.(*wardle.Flunder)
return validation.ValidateFlunder(flunder) return validation.ValidateFlunder(flunder)
} }
...@@ -93,6 +93,6 @@ func (flunderStrategy) AllowUnconditionalUpdate() bool { ...@@ -93,6 +93,6 @@ func (flunderStrategy) AllowUnconditionalUpdate() bool {
func (flunderStrategy) Canonicalize(obj runtime.Object) { func (flunderStrategy) Canonicalize(obj runtime.Object) {
} }
func (flunderStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList { func (flunderStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return field.ErrorList{} return field.ErrorList{}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment