From 54fd2aaefd11e12a3ecb6d1a1326f04cdc8ea1a3 Mon Sep 17 00:00:00 2001 From: Mike Danese Date: Tue, 24 Apr 2018 08:10:34 -0700 Subject: [PATCH] replace request.Context with context.Context --- pkg/printers/storage/BUILD | 1 - pkg/printers/storage/storage.go | 5 +- .../initializerconfiguration/BUILD | 1 - .../initializerconfiguration/strategy.go | 10 +-- .../mutatingwebhookconfiguration/BUILD | 1 - .../mutatingwebhookconfiguration/strategy.go | 10 +-- .../validatingwebhookconfiguration/BUILD | 1 - .../strategy.go | 10 +-- pkg/registry/apps/controllerrevision/BUILD | 1 - .../apps/controllerrevision/strategy.go | 11 ++-- pkg/registry/apps/daemonset/storage/BUILD | 1 - .../apps/daemonset/storage/storage.go | 7 ++- pkg/registry/apps/daemonset/strategy.go | 16 ++--- pkg/registry/apps/deployment/registry.go | 22 +++---- pkg/registry/apps/deployment/storage/BUILD | 1 - .../apps/deployment/storage/storage.go | 16 ++--- pkg/registry/apps/deployment/strategy.go | 16 ++--- pkg/registry/apps/replicaset/registry.go | 26 ++++---- pkg/registry/apps/replicaset/storage/BUILD | 1 - .../apps/replicaset/storage/storage.go | 10 +-- pkg/registry/apps/replicaset/strategy.go | 15 ++--- pkg/registry/apps/statefulset/registry.go | 26 ++++---- pkg/registry/apps/statefulset/storage/BUILD | 1 - .../apps/statefulset/storage/storage.go | 10 +-- pkg/registry/apps/statefulset/strategy.go | 16 ++--- .../authentication/tokenreview/storage.go | 3 +- .../localsubjectaccessreview/rest.go | 3 +- .../selfsubjectaccessreview/rest.go | 3 +- .../selfsubjectrulesreview/rest.go | 3 +- .../authorization/subjectaccessreview/BUILD | 1 - .../authorization/subjectaccessreview/rest.go | 4 +- .../autoscaling/horizontalpodautoscaler/BUILD | 1 - .../horizontalpodautoscaler/storage/BUILD | 1 - .../storage/storage.go | 7 ++- .../horizontalpodautoscaler/strategy.go | 15 ++--- pkg/registry/batch/cronjob/BUILD | 1 - pkg/registry/batch/cronjob/storage/BUILD | 1 - pkg/registry/batch/cronjob/storage/storage.go | 7 ++- pkg/registry/batch/cronjob/strategy.go | 17 +++--- pkg/registry/batch/job/BUILD | 1 - pkg/registry/batch/job/storage/BUILD | 1 - pkg/registry/batch/job/storage/storage.go | 7 ++- pkg/registry/batch/job/strategy.go | 16 ++--- .../certificates/certificates/registry.go | 27 ++++---- .../certificates/certificates/storage/BUILD | 1 - .../certificates/storage/storage.go | 7 ++- .../certificates/certificates/strategy.go | 19 +++--- .../certificates/strategy_test.go | 3 +- pkg/registry/core/componentstatus/BUILD | 1 - pkg/registry/core/componentstatus/rest.go | 6 +- pkg/registry/core/configmap/BUILD | 1 - pkg/registry/core/configmap/registry.go | 27 ++++---- pkg/registry/core/configmap/strategy.go | 11 ++-- pkg/registry/core/endpoint/BUILD | 1 - pkg/registry/core/endpoint/registry.go | 23 +++---- pkg/registry/core/endpoint/strategy.go | 11 ++-- pkg/registry/core/event/BUILD | 1 - pkg/registry/core/event/strategy.go | 12 ++-- pkg/registry/core/limitrange/BUILD | 1 - pkg/registry/core/limitrange/strategy.go | 13 ++-- pkg/registry/core/namespace/BUILD | 1 - pkg/registry/core/namespace/registry.go | 27 ++++---- pkg/registry/core/namespace/storage/BUILD | 1 - .../core/namespace/storage/storage.go | 24 ++++---- pkg/registry/core/namespace/strategy.go | 18 +++--- pkg/registry/core/node/BUILD | 1 - pkg/registry/core/node/registry.go | 27 ++++---- pkg/registry/core/node/rest/BUILD | 1 - pkg/registry/core/node/rest/proxy.go | 4 +- pkg/registry/core/node/storage/storage.go | 7 ++- pkg/registry/core/node/strategy.go | 22 +++---- pkg/registry/core/persistentvolume/BUILD | 1 - .../core/persistentvolume/storage/BUILD | 1 - .../core/persistentvolume/storage/storage.go | 7 ++- .../core/persistentvolume/strategy.go | 14 ++--- pkg/registry/core/persistentvolumeclaim/BUILD | 1 - .../core/persistentvolumeclaim/storage/BUILD | 1 - .../persistentvolumeclaim/storage/storage.go | 7 ++- .../core/persistentvolumeclaim/strategy.go | 14 ++--- pkg/registry/core/pod/BUILD | 1 - pkg/registry/core/pod/rest/BUILD | 1 - pkg/registry/core/pod/rest/log.go | 4 +- pkg/registry/core/pod/rest/subresources.go | 10 +-- pkg/registry/core/pod/storage/BUILD | 1 - pkg/registry/core/pod/storage/eviction.go | 6 +- pkg/registry/core/pod/storage/storage.go | 14 ++--- pkg/registry/core/pod/strategy.go | 34 +++++------ pkg/registry/core/pod/strategy_test.go | 3 +- pkg/registry/core/podtemplate/BUILD | 1 - pkg/registry/core/podtemplate/strategy.go | 13 ++-- pkg/registry/core/replicationcontroller/BUILD | 1 - .../core/replicationcontroller/registry.go | 26 ++++---- .../core/replicationcontroller/storage/BUILD | 1 - .../replicationcontroller/storage/storage.go | 10 +-- .../core/replicationcontroller/strategy.go | 16 ++--- pkg/registry/core/resourcequota/BUILD | 1 - pkg/registry/core/resourcequota/storage/BUILD | 1 - .../core/resourcequota/storage/storage.go | 7 ++- pkg/registry/core/resourcequota/strategy.go | 15 ++--- pkg/registry/core/secret/BUILD | 1 - pkg/registry/core/secret/strategy.go | 12 ++-- pkg/registry/core/service/BUILD | 1 - pkg/registry/core/service/proxy.go | 4 +- pkg/registry/core/service/registry.go | 30 ++++----- pkg/registry/core/service/storage/rest.go | 21 ++++--- .../core/service/storage/rest_test.go | 23 +++---- pkg/registry/core/service/storage/storage.go | 7 ++- pkg/registry/core/service/strategy.go | 16 ++--- pkg/registry/core/serviceaccount/BUILD | 1 - .../core/serviceaccount/storage/token.go | 7 ++- pkg/registry/core/serviceaccount/strategy.go | 11 ++-- pkg/registry/events/event/BUILD | 1 - pkg/registry/events/event/strategy.go | 10 +-- .../extensions/controller/storage/BUILD | 1 - .../extensions/controller/storage/storage.go | 6 +- pkg/registry/extensions/ingress/BUILD | 1 - pkg/registry/extensions/ingress/storage/BUILD | 1 - .../extensions/ingress/storage/storage.go | 7 ++- pkg/registry/extensions/ingress/strategy.go | 15 ++--- pkg/registry/networking/networkpolicy/BUILD | 1 - .../networking/networkpolicy/registry.go | 27 ++++---- .../networking/networkpolicy/strategy.go | 10 +-- pkg/registry/policy/poddisruptionbudget/BUILD | 1 - .../policy/poddisruptionbudget/storage/BUILD | 1 - .../poddisruptionbudget/storage/storage.go | 7 ++- .../policy/poddisruptionbudget/strategy.go | 15 ++--- pkg/registry/policy/podsecuritypolicy/BUILD | 1 - .../policy/podsecuritypolicy/strategy.go | 11 ++-- .../rbac/clusterrole/policybased/BUILD | 1 - .../rbac/clusterrole/policybased/storage.go | 8 +-- pkg/registry/rbac/clusterrole/registry.go | 26 ++++---- pkg/registry/rbac/clusterrole/strategy.go | 11 ++-- .../rbac/clusterrolebinding/policybased/BUILD | 1 - .../clusterrolebinding/policybased/storage.go | 9 +-- .../rbac/clusterrolebinding/registry.go | 26 ++++---- .../rbac/clusterrolebinding/strategy.go | 11 ++-- pkg/registry/rbac/escalation_check.go | 5 +- pkg/registry/rbac/role/policybased/BUILD | 1 - pkg/registry/rbac/role/policybased/storage.go | 9 +-- pkg/registry/rbac/role/registry.go | 26 ++++---- pkg/registry/rbac/role/strategy.go | 11 ++-- .../rbac/rolebinding/policybased/storage.go | 8 ++- pkg/registry/rbac/rolebinding/registry.go | 26 ++++---- pkg/registry/rbac/rolebinding/strategy.go | 11 ++-- pkg/registry/rbac/validation/rule.go | 3 +- pkg/registry/registrytest/endpoint.go | 12 ++-- pkg/registry/registrytest/node.go | 14 ++--- pkg/registry/registrytest/service.go | 15 ++--- pkg/registry/scheduling/priorityclass/BUILD | 1 - .../scheduling/priorityclass/registry.go | 27 ++++---- .../scheduling/priorityclass/storage/BUILD | 1 - .../priorityclass/storage/storage.go | 4 +- .../scheduling/priorityclass/strategy.go | 11 ++-- pkg/registry/settings/podpreset/BUILD | 1 - pkg/registry/settings/podpreset/registry.go | 27 ++++---- pkg/registry/settings/podpreset/strategy.go | 11 ++-- pkg/registry/storage/storageclass/BUILD | 1 - pkg/registry/storage/storageclass/strategy.go | 11 ++-- pkg/registry/storage/volumeattachment/BUILD | 1 - .../storage/volumeattachment/strategy.go | 11 ++-- .../pkg/registry/customresource/BUILD | 1 - .../pkg/registry/customresource/etcd.go | 10 +-- .../pkg/registry/customresource/registry.go | 26 ++++---- .../customresource/status_strategy.go | 7 ++- .../pkg/registry/customresource/strategy.go | 11 ++-- .../customresource/tableconvertor/BUILD | 1 - .../tableconvertor/tableconvertor.go | 4 +- .../pkg/registry/customresource/validator.go | 8 +-- .../registry/customresourcedefinition/BUILD | 1 - .../registry/customresourcedefinition/etcd.go | 6 +- .../customresourcedefinition/strategy.go | 14 ++--- .../apiserver/pkg/endpoints/apiserver_test.go | 35 +++++------ .../pkg/endpoints/filters/authorization.go | 3 +- .../endpoints/filters/impersonation_test.go | 3 +- .../pkg/endpoints/handlers/create.go | 3 +- .../apiserver/pkg/endpoints/handlers/get.go | 7 ++- .../apiserver/pkg/endpoints/handlers/patch.go | 7 ++- .../pkg/endpoints/handlers/response.go | 4 +- .../handlers/responsewriters/errors.go | 4 +- .../apiserver/pkg/endpoints/handlers/rest.go | 3 +- .../pkg/endpoints/handlers/rest_test.go | 5 +- .../pkg/endpoints/handlers/update.go | 3 +- .../pkg/endpoints/request/context.go | 56 +++++------------ .../pkg/endpoints/request/requestinfo.go | 5 +- .../pkg/registry/generic/registry/store.go | 61 ++++++++++--------- .../registry/generic/registry/store_test.go | 27 ++++---- .../pkg/registry/generic/testing/BUILD | 1 - .../pkg/registry/generic/testing/tester.go | 6 +- .../apiserver/pkg/registry/rest/create.go | 9 +-- .../apiserver/pkg/registry/rest/delete.go | 8 +-- .../apiserver/pkg/registry/rest/export.go | 5 +- .../apiserver/pkg/registry/rest/meta.go | 6 +- .../apiserver/pkg/registry/rest/rest.go | 32 +++++----- .../pkg/registry/rest/resttest/resttest.go | 13 ++-- .../apiserver/pkg/registry/rest/table.go | 4 +- .../apiserver/pkg/registry/rest/update.go | 14 ++--- staging/src/k8s.io/apiserver/pkg/server/BUILD | 1 - .../pkg/server/genericapiserver_test.go | 4 +- .../pkg/registry/apiservice/BUILD | 1 - .../pkg/registry/apiservice/etcd/BUILD | 1 - .../pkg/registry/apiservice/etcd/etcd.go | 5 +- .../pkg/registry/apiservice/strategy.go | 14 ++--- .../pkg/registry/wardle/fischer/BUILD | 1 - .../pkg/registry/wardle/fischer/strategy.go | 10 +-- .../pkg/registry/wardle/flunder/BUILD | 1 - .../pkg/registry/wardle/flunder/strategy.go | 10 +-- 206 files changed, 944 insertions(+), 945 deletions(-) diff --git a/pkg/printers/storage/BUILD b/pkg/printers/storage/BUILD index a560d725aa5..afb74a8a930 100644 --- a/pkg/printers/storage/BUILD +++ b/pkg/printers/storage/BUILD @@ -13,7 +13,6 @@ go_library( "//pkg/printers: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/apiserver/pkg/endpoints/request:go_default_library", ], ) diff --git a/pkg/printers/storage/storage.go b/pkg/printers/storage/storage.go index 3eee73825a0..f2b732974fe 100644 --- a/pkg/printers/storage/storage.go +++ b/pkg/printers/storage/storage.go @@ -17,9 +17,10 @@ limitations under the License. package storage import ( + "context" + metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/kubernetes/pkg/printers" ) @@ -27,6 +28,6 @@ type TableConvertor struct { 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}) } diff --git a/pkg/registry/admissionregistration/initializerconfiguration/BUILD b/pkg/registry/admissionregistration/initializerconfiguration/BUILD index 29c56e75b65..76fe73c8818 100644 --- a/pkg/registry/admissionregistration/initializerconfiguration/BUILD +++ b/pkg/registry/admissionregistration/initializerconfiguration/BUILD @@ -18,7 +18,6 @@ go_library( "//pkg/apis/admissionregistration/validation: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", ], ) diff --git a/pkg/registry/admissionregistration/initializerconfiguration/strategy.go b/pkg/registry/admissionregistration/initializerconfiguration/strategy.go index f32e4ea9dcb..70b2be0cc7c 100644 --- a/pkg/registry/admissionregistration/initializerconfiguration/strategy.go +++ b/pkg/registry/admissionregistration/initializerconfiguration/strategy.go @@ -17,11 +17,11 @@ limitations under the License. package initializerconfiguration import ( + "context" "reflect" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/apis/admissionregistration" @@ -43,13 +43,13 @@ func (initializerConfigurationStrategy) NamespaceScoped() bool { } // 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.Generation = 1 } // 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) oldIC := old.(*admissionregistration.InitializerConfiguration) @@ -62,7 +62,7 @@ func (initializerConfigurationStrategy) PrepareForUpdate(ctx genericapirequest.C } // 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) return validation.ValidateInitializerConfiguration(ic) } @@ -77,7 +77,7 @@ func (initializerConfigurationStrategy) AllowCreateOnUpdate() bool { } // 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)) updateErrorList := validation.ValidateInitializerConfigurationUpdate(obj.(*admissionregistration.InitializerConfiguration), old.(*admissionregistration.InitializerConfiguration)) return append(validationErrorList, updateErrorList...) diff --git a/pkg/registry/admissionregistration/mutatingwebhookconfiguration/BUILD b/pkg/registry/admissionregistration/mutatingwebhookconfiguration/BUILD index 92ae7b566fc..c16824304ea 100644 --- a/pkg/registry/admissionregistration/mutatingwebhookconfiguration/BUILD +++ b/pkg/registry/admissionregistration/mutatingwebhookconfiguration/BUILD @@ -18,7 +18,6 @@ go_library( "//pkg/apis/admissionregistration/validation: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", ], ) diff --git a/pkg/registry/admissionregistration/mutatingwebhookconfiguration/strategy.go b/pkg/registry/admissionregistration/mutatingwebhookconfiguration/strategy.go index 735980ac42f..ae0f8b7f961 100644 --- a/pkg/registry/admissionregistration/mutatingwebhookconfiguration/strategy.go +++ b/pkg/registry/admissionregistration/mutatingwebhookconfiguration/strategy.go @@ -17,11 +17,11 @@ limitations under the License. package mutatingwebhookconfiguration import ( + "context" "reflect" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/apis/admissionregistration" @@ -43,13 +43,13 @@ func (mutatingWebhookConfigurationStrategy) NamespaceScoped() bool { } // 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.Generation = 1 } // 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) oldIC := old.(*admissionregistration.MutatingWebhookConfiguration) @@ -62,7 +62,7 @@ func (mutatingWebhookConfigurationStrategy) PrepareForUpdate(ctx genericapireque } // 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) return validation.ValidateMutatingWebhookConfiguration(ic) } @@ -77,7 +77,7 @@ func (mutatingWebhookConfigurationStrategy) AllowCreateOnUpdate() bool { } // 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)) updateErrorList := validation.ValidateMutatingWebhookConfigurationUpdate(obj.(*admissionregistration.MutatingWebhookConfiguration), old.(*admissionregistration.MutatingWebhookConfiguration)) return append(validationErrorList, updateErrorList...) diff --git a/pkg/registry/admissionregistration/validatingwebhookconfiguration/BUILD b/pkg/registry/admissionregistration/validatingwebhookconfiguration/BUILD index 0b07d302867..363e6531c27 100644 --- a/pkg/registry/admissionregistration/validatingwebhookconfiguration/BUILD +++ b/pkg/registry/admissionregistration/validatingwebhookconfiguration/BUILD @@ -18,7 +18,6 @@ go_library( "//pkg/apis/admissionregistration/validation: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", ], ) diff --git a/pkg/registry/admissionregistration/validatingwebhookconfiguration/strategy.go b/pkg/registry/admissionregistration/validatingwebhookconfiguration/strategy.go index e59ecc98950..ee696717bfd 100644 --- a/pkg/registry/admissionregistration/validatingwebhookconfiguration/strategy.go +++ b/pkg/registry/admissionregistration/validatingwebhookconfiguration/strategy.go @@ -17,11 +17,11 @@ limitations under the License. package validatingwebhookconfiguration import ( + "context" "reflect" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/apis/admissionregistration" @@ -43,13 +43,13 @@ func (validatingWebhookConfigurationStrategy) NamespaceScoped() bool { } // 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.Generation = 1 } // 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) oldIC := old.(*admissionregistration.ValidatingWebhookConfiguration) @@ -62,7 +62,7 @@ func (validatingWebhookConfigurationStrategy) PrepareForUpdate(ctx genericapireq } // 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) return validation.ValidateValidatingWebhookConfiguration(ic) } @@ -77,7 +77,7 @@ func (validatingWebhookConfigurationStrategy) AllowCreateOnUpdate() bool { } // 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)) updateErrorList := validation.ValidateValidatingWebhookConfigurationUpdate(obj.(*admissionregistration.ValidatingWebhookConfiguration), old.(*admissionregistration.ValidatingWebhookConfiguration)) return append(validationErrorList, updateErrorList...) diff --git a/pkg/registry/apps/controllerrevision/BUILD b/pkg/registry/apps/controllerrevision/BUILD index 474d6bb1b46..1b45798f1be 100644 --- a/pkg/registry/apps/controllerrevision/BUILD +++ b/pkg/registry/apps/controllerrevision/BUILD @@ -32,7 +32,6 @@ go_library( "//pkg/apis/apps/validation: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", ], diff --git a/pkg/registry/apps/controllerrevision/strategy.go b/pkg/registry/apps/controllerrevision/strategy.go index 08161d718ad..a47f8587caa 100644 --- a/pkg/registry/apps/controllerrevision/strategy.go +++ b/pkg/registry/apps/controllerrevision/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package controllerrevision import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" @@ -54,17 +55,17 @@ func (strategy) AllowCreateOnUpdate() bool { return false } -func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { +func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { _ = 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) 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) _ = newObj.(*apps.ControllerRevision) } @@ -73,7 +74,7 @@ func (strategy) AllowUnconditionalUpdate() bool { 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) return validation.ValidateControllerRevisionUpdate(newRevision, oldRevision) } diff --git a/pkg/registry/apps/daemonset/storage/BUILD b/pkg/registry/apps/daemonset/storage/BUILD index dc992ae1e98..88d5df242f8 100644 --- a/pkg/registry/apps/daemonset/storage/BUILD +++ b/pkg/registry/apps/daemonset/storage/BUILD @@ -36,7 +36,6 @@ go_library( "//pkg/registry/apps/daemonset: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/apiserver/pkg/endpoints/request: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/rest:go_default_library", diff --git a/pkg/registry/apps/daemonset/storage/storage.go b/pkg/registry/apps/daemonset/storage/storage.go index 8a961399df8..aeb09657d06 100644 --- a/pkg/registry/apps/daemonset/storage/storage.go +++ b/pkg/registry/apps/daemonset/storage/storage.go @@ -17,9 +17,10 @@ limitations under the License. package storage import ( + "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -90,11 +91,11 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } diff --git a/pkg/registry/apps/daemonset/strategy.go b/pkg/registry/apps/daemonset/strategy.go index 04723fdcf25..cdc70a600fc 100644 --- a/pkg/registry/apps/daemonset/strategy.go +++ b/pkg/registry/apps/daemonset/strategy.go @@ -17,6 +17,8 @@ limitations under the License. package daemonset import ( + "context" + appsv1beta2 "k8s.io/api/apps/v1beta2" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" apiequality "k8s.io/apimachinery/pkg/api/equality" @@ -43,7 +45,7 @@ type daemonSetStrategy struct { var Strategy = daemonSetStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} // 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 { groupVersion := schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion} switch groupVersion { @@ -63,7 +65,7 @@ func (daemonSetStrategy) NamespaceScoped() bool { } // 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.Status = extensions.DaemonSetStatus{} @@ -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. -func (daemonSetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (daemonSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newDaemonSet := obj.(*extensions.DaemonSet) oldDaemonSet := old.(*extensions.DaemonSet) @@ -111,7 +113,7 @@ func (daemonSetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol } // 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) return validation.ValidateDaemonSet(daemonSet) } @@ -127,7 +129,7 @@ func (daemonSetStrategy) AllowCreateOnUpdate() bool { } // 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) oldDaemonSet := old.(*extensions.DaemonSet) allErrs := validation.ValidateDaemonSet(obj.(*extensions.DaemonSet)) @@ -162,12 +164,12 @@ type daemonSetStatusStrategy struct { 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) oldDaemonSet := old.(*extensions.DaemonSet) 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)) } diff --git a/pkg/registry/apps/deployment/registry.go b/pkg/registry/apps/deployment/registry.go index 951e86863fb..cf09bda5867 100644 --- a/pkg/registry/apps/deployment/registry.go +++ b/pkg/registry/apps/deployment/registry.go @@ -17,22 +17,22 @@ limitations under the License. package deployment import ( + "context" "fmt" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/kubernetes/pkg/apis/extensions" ) // Registry is an interface for things that know how to store Deployments. type Registry interface { - ListDeployments(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*extensions.DeploymentList, error) - GetDeployment(ctx genericapirequest.Context, deploymentID string, options *metav1.GetOptions) (*extensions.Deployment, error) - CreateDeployment(ctx genericapirequest.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) - DeleteDeployment(ctx genericapirequest.Context, deploymentID string) error + ListDeployments(ctx context.Context, options *metainternalversion.ListOptions) (*extensions.DeploymentList, error) + GetDeployment(ctx context.Context, deploymentID string, options *metav1.GetOptions) (*extensions.Deployment, error) + CreateDeployment(ctx context.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc) (*extensions.Deployment, error) + UpdateDeployment(ctx context.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.Deployment, error) + DeleteDeployment(ctx context.Context, deploymentID string) error } // storage puts strong typing around storage calls @@ -45,7 +45,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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() { return nil, fmt.Errorf("field selector not supported yet") } @@ -56,7 +56,7 @@ func (s *storage) ListDeployments(ctx genericapirequest.Context, options *metain 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) if err != nil { return nil, err @@ -64,7 +64,7 @@ func (s *storage) GetDeployment(ctx genericapirequest.Context, deploymentID stri 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) if err != nil { return nil, err @@ -72,7 +72,7 @@ func (s *storage) CreateDeployment(ctx genericapirequest.Context, deployment *ex 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) if err != nil { return nil, err @@ -80,7 +80,7 @@ func (s *storage) UpdateDeployment(ctx genericapirequest.Context, deployment *ex 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) return err } diff --git a/pkg/registry/apps/deployment/storage/BUILD b/pkg/registry/apps/deployment/storage/BUILD index 488a9f08b14..600ff2032d2 100644 --- a/pkg/registry/apps/deployment/storage/BUILD +++ b/pkg/registry/apps/deployment/storage/BUILD @@ -53,7 +53,6 @@ go_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/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/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", diff --git a/pkg/registry/apps/deployment/storage/storage.go b/pkg/registry/apps/deployment/storage/storage.go index 2fa85ea97df..c8b469ec45d 100644 --- a/pkg/registry/apps/deployment/storage/storage.go +++ b/pkg/registry/apps/deployment/storage/storage.go @@ -17,6 +17,7 @@ limitations under the License. package storage import ( + "context" "fmt" "net/http" @@ -24,7 +25,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -123,12 +123,12 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } @@ -144,7 +144,7 @@ func (r *RollbackREST) New() runtime.Object { 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) if !ok { 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, }, 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 { err = storeerr.InterpretGetError(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 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) if err != nil { return nil, err @@ -228,7 +228,7 @@ func (r *ScaleREST) New() runtime.Object { 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) if err != nil { return nil, errors.NewNotFound(extensions.Resource("deployments/scale"), name) @@ -240,7 +240,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met 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{}) if err != nil { return nil, false, errors.NewNotFound(extensions.Resource("deployments/scale"), name) diff --git a/pkg/registry/apps/deployment/strategy.go b/pkg/registry/apps/deployment/strategy.go index 29fcd750aac..139d6df6aff 100644 --- a/pkg/registry/apps/deployment/strategy.go +++ b/pkg/registry/apps/deployment/strategy.go @@ -17,6 +17,8 @@ limitations under the License. package deployment import ( + "context" + appsv1beta1 "k8s.io/api/apps/v1beta1" appsv1beta2 "k8s.io/api/apps/v1beta2" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" @@ -45,7 +47,7 @@ type deploymentStrategy struct { var Strategy = deploymentStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} // 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 { groupVersion := schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion} switch groupVersion { @@ -65,7 +67,7 @@ func (deploymentStrategy) NamespaceScoped() bool { } // 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.Status = extensions.DeploymentStatus{} deployment.Generation = 1 @@ -74,7 +76,7 @@ func (deploymentStrategy) PrepareForCreate(ctx genericapirequest.Context, obj ru } // 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) return validation.ValidateDeployment(deployment) } @@ -89,7 +91,7 @@ func (deploymentStrategy) AllowCreateOnUpdate() bool { } // 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) oldDeployment := old.(*extensions.Deployment) newDeployment.Status = oldDeployment.Status @@ -107,7 +109,7 @@ func (deploymentStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, o } // 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) oldDeployment := old.(*extensions.Deployment) allErrs := validation.ValidateDeploymentUpdate(newDeployment, oldDeployment) @@ -142,7 +144,7 @@ type deploymentStatusStrategy struct { var StatusStrategy = deploymentStatusStrategy{Strategy} // 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) oldDeployment := old.(*extensions.Deployment) newDeployment.Spec = oldDeployment.Spec @@ -150,6 +152,6 @@ func (deploymentStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, } // 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)) } diff --git a/pkg/registry/apps/replicaset/registry.go b/pkg/registry/apps/replicaset/registry.go index 029631eb68e..83dd85f4ab1 100644 --- a/pkg/registry/apps/replicaset/registry.go +++ b/pkg/registry/apps/replicaset/registry.go @@ -19,24 +19,24 @@ limitations under the License. package replicaset import ( + "context" "fmt" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/kubernetes/pkg/apis/extensions" ) // Registry is an interface for things that know how to store ReplicaSets. type Registry interface { - ListReplicaSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*extensions.ReplicaSetList, error) - WatchReplicaSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) - GetReplicaSet(ctx genericapirequest.Context, replicaSetID string, options *metav1.GetOptions) (*extensions.ReplicaSet, error) - CreateReplicaSet(ctx genericapirequest.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) - DeleteReplicaSet(ctx genericapirequest.Context, replicaSetID string) error + ListReplicaSets(ctx context.Context, options *metainternalversion.ListOptions) (*extensions.ReplicaSetList, error) + WatchReplicaSets(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + GetReplicaSet(ctx context.Context, replicaSetID string, options *metav1.GetOptions) (*extensions.ReplicaSet, error) + CreateReplicaSet(ctx context.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc) (*extensions.ReplicaSet, error) + UpdateReplicaSet(ctx context.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.ReplicaSet, error) + DeleteReplicaSet(ctx context.Context, replicaSetID string) error } // storage puts strong typing around storage calls @@ -50,7 +50,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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() { return nil, fmt.Errorf("field selector not supported yet") } @@ -61,11 +61,11 @@ func (s *storage) ListReplicaSets(ctx genericapirequest.Context, options *metain 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) } -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) if err != nil { return nil, err @@ -73,7 +73,7 @@ func (s *storage) GetReplicaSet(ctx genericapirequest.Context, replicaSetID stri 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) if err != nil { return nil, err @@ -81,7 +81,7 @@ func (s *storage) CreateReplicaSet(ctx genericapirequest.Context, replicaSet *ex 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) if err != nil { return nil, err @@ -89,7 +89,7 @@ func (s *storage) UpdateReplicaSet(ctx genericapirequest.Context, replicaSet *ex 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) return err } diff --git a/pkg/registry/apps/replicaset/storage/BUILD b/pkg/registry/apps/replicaset/storage/BUILD index 917b635c46e..20785a44d57 100644 --- a/pkg/registry/apps/replicaset/storage/BUILD +++ b/pkg/registry/apps/replicaset/storage/BUILD @@ -50,7 +50,6 @@ go_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/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/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", diff --git a/pkg/registry/apps/replicaset/storage/storage.go b/pkg/registry/apps/replicaset/storage/storage.go index d181b35c972..aa8ee4e1754 100644 --- a/pkg/registry/apps/replicaset/storage/storage.go +++ b/pkg/registry/apps/replicaset/storage/storage.go @@ -19,13 +19,13 @@ limitations under the License. package storage import ( + "context" "fmt" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -121,12 +121,12 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } @@ -156,7 +156,7 @@ func (r *ScaleREST) New() runtime.Object { 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) if err != nil { return nil, errors.NewNotFound(extensions.Resource("replicasets/scale"), name) @@ -168,7 +168,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met 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{}) if err != nil { return nil, false, errors.NewNotFound(extensions.Resource("replicasets/scale"), name) diff --git a/pkg/registry/apps/replicaset/strategy.go b/pkg/registry/apps/replicaset/strategy.go index fac1f2a5a0b..decb062c623 100644 --- a/pkg/registry/apps/replicaset/strategy.go +++ b/pkg/registry/apps/replicaset/strategy.go @@ -19,6 +19,7 @@ limitations under the License. package replicaset import ( + "context" "fmt" "strconv" @@ -52,7 +53,7 @@ type rsStrategy struct { var Strategy = rsStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} // 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 { groupVersion := schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion} switch groupVersion { @@ -72,7 +73,7 @@ func (rsStrategy) NamespaceScoped() bool { } // 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.Status = extensions.ReplicaSetStatus{} @@ -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. -func (rsStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (rsStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newRS := obj.(*extensions.ReplicaSet) oldRS := old.(*extensions.ReplicaSet) // update is not allowed to set status @@ -105,7 +106,7 @@ func (rsStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runti } // 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) return validation.ValidateReplicaSet(rs) } @@ -121,7 +122,7 @@ func (rsStrategy) AllowCreateOnUpdate() bool { } // 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) oldReplicaSet := old.(*extensions.ReplicaSet) allErrs := validation.ValidateReplicaSet(obj.(*extensions.ReplicaSet)) @@ -184,13 +185,13 @@ type rsStatusStrategy struct { 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) oldRS := old.(*extensions.ReplicaSet) // update is not allowed to set 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)) } diff --git a/pkg/registry/apps/statefulset/registry.go b/pkg/registry/apps/statefulset/registry.go index eb33b6e1ced..b9d49647831 100644 --- a/pkg/registry/apps/statefulset/registry.go +++ b/pkg/registry/apps/statefulset/registry.go @@ -17,25 +17,25 @@ limitations under the License. package statefulset import ( + "context" "fmt" "k8s.io/apimachinery/pkg/api/errors" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/kubernetes/pkg/apis/apps" ) // Registry is an interface for things that know how to store StatefulSets. type Registry interface { - ListStatefulSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*apps.StatefulSetList, error) - WatchStatefulSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) - GetStatefulSet(ctx genericapirequest.Context, statefulSetID string, options *metav1.GetOptions) (*apps.StatefulSet, error) - CreateStatefulSet(ctx genericapirequest.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) - DeleteStatefulSet(ctx genericapirequest.Context, statefulSetID string) error + ListStatefulSets(ctx context.Context, options *metainternalversion.ListOptions) (*apps.StatefulSetList, error) + WatchStatefulSets(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + GetStatefulSet(ctx context.Context, statefulSetID string, options *metav1.GetOptions) (*apps.StatefulSet, error) + CreateStatefulSet(ctx context.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc) (*apps.StatefulSet, error) + UpdateStatefulSet(ctx context.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*apps.StatefulSet, error) + DeleteStatefulSet(ctx context.Context, statefulSetID string) error } // storage puts strong typing around storage calls @@ -49,7 +49,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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() { return nil, fmt.Errorf("field selector not supported yet") } @@ -60,11 +60,11 @@ func (s *storage) ListStatefulSets(ctx genericapirequest.Context, options *metai 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) } -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) if err != nil { return nil, errors.NewNotFound(apps.Resource("statefulsets/scale"), statefulSetID) @@ -72,7 +72,7 @@ func (s *storage) GetStatefulSet(ctx genericapirequest.Context, statefulSetID st 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) if err != nil { return nil, err @@ -80,7 +80,7 @@ func (s *storage) CreateStatefulSet(ctx genericapirequest.Context, statefulSet * 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) if err != nil { return nil, err @@ -88,7 +88,7 @@ func (s *storage) UpdateStatefulSet(ctx genericapirequest.Context, statefulSet * 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) return err } diff --git a/pkg/registry/apps/statefulset/storage/BUILD b/pkg/registry/apps/statefulset/storage/BUILD index b67e2fea55b..3708a705fec 100644 --- a/pkg/registry/apps/statefulset/storage/BUILD +++ b/pkg/registry/apps/statefulset/storage/BUILD @@ -49,7 +49,6 @@ go_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/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/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", diff --git a/pkg/registry/apps/statefulset/storage/storage.go b/pkg/registry/apps/statefulset/storage/storage.go index d97f17270e5..5ec3dfb2a20 100644 --- a/pkg/registry/apps/statefulset/storage/storage.go +++ b/pkg/registry/apps/statefulset/storage/storage.go @@ -17,13 +17,13 @@ limitations under the License. package storage import ( + "context" "fmt" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -104,12 +104,12 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } @@ -145,7 +145,7 @@ func (r *ScaleREST) New() runtime.Object { 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) if err != nil { return nil, err @@ -157,7 +157,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met 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{}) if err != nil { return nil, false, err diff --git a/pkg/registry/apps/statefulset/strategy.go b/pkg/registry/apps/statefulset/strategy.go index 08ff765a34d..cbf584933e3 100644 --- a/pkg/registry/apps/statefulset/strategy.go +++ b/pkg/registry/apps/statefulset/strategy.go @@ -17,6 +17,8 @@ limitations under the License. package statefulset import ( + "context" + appsv1beta1 "k8s.io/api/apps/v1beta1" appsv1beta2 "k8s.io/api/apps/v1beta2" apiequality "k8s.io/apimachinery/pkg/api/equality" @@ -42,7 +44,7 @@ type statefulSetStrategy struct { var Strategy = statefulSetStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} // 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 { groupVersion := schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion} switch groupVersion { @@ -62,7 +64,7 @@ func (statefulSetStrategy) NamespaceScoped() bool { } // 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) // create cannot set status statefulSet.Status = apps.StatefulSetStatus{} @@ -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. -func (statefulSetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (statefulSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newStatefulSet := obj.(*apps.StatefulSet) oldStatefulSet := old.(*apps.StatefulSet) // Update is not allowed to set status @@ -92,7 +94,7 @@ func (statefulSetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, } // 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) return validation.ValidateStatefulSet(statefulSet) } @@ -107,7 +109,7 @@ func (statefulSetStrategy) AllowCreateOnUpdate() bool { } // 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)) updateErrorList := validation.ValidateStatefulSetUpdate(obj.(*apps.StatefulSet), old.(*apps.StatefulSet)) return append(validationErrorList, updateErrorList...) @@ -125,7 +127,7 @@ type statefulSetStatusStrategy struct { var StatusStrategy = statefulSetStatusStrategy{Strategy} // 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) oldStatefulSet := old.(*apps.StatefulSet) // status changes are not allowed to update spec @@ -133,7 +135,7 @@ func (statefulSetStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, } // 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. return validation.ValidateStatefulSetStatusUpdate(obj.(*apps.StatefulSet), old.(*apps.StatefulSet)) } diff --git a/pkg/registry/authentication/tokenreview/storage.go b/pkg/registry/authentication/tokenreview/storage.go index 28c1da7c8d9..71217ac60bb 100644 --- a/pkg/registry/authentication/tokenreview/storage.go +++ b/pkg/registry/authentication/tokenreview/storage.go @@ -17,6 +17,7 @@ limitations under the License. package tokenreview import ( + "context" "fmt" "net/http" @@ -40,7 +41,7 @@ func (r *REST) New() runtime.Object { 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) if !ok { return nil, apierrors.NewBadRequest(fmt.Sprintf("not a TokenReview: %#v", obj)) diff --git a/pkg/registry/authorization/localsubjectaccessreview/rest.go b/pkg/registry/authorization/localsubjectaccessreview/rest.go index af49b6bd4d9..e49fe4674ce 100644 --- a/pkg/registry/authorization/localsubjectaccessreview/rest.go +++ b/pkg/registry/authorization/localsubjectaccessreview/rest.go @@ -17,6 +17,7 @@ limitations under the License. package localsubjectaccessreview import ( + "context" "fmt" kapierrors "k8s.io/apimachinery/pkg/api/errors" @@ -41,7 +42,7 @@ func (r *REST) New() runtime.Object { 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) if !ok { return nil, kapierrors.NewBadRequest(fmt.Sprintf("not a LocaLocalSubjectAccessReview: %#v", obj)) diff --git a/pkg/registry/authorization/selfsubjectaccessreview/rest.go b/pkg/registry/authorization/selfsubjectaccessreview/rest.go index 38900a877f4..a67b8753ac0 100644 --- a/pkg/registry/authorization/selfsubjectaccessreview/rest.go +++ b/pkg/registry/authorization/selfsubjectaccessreview/rest.go @@ -17,6 +17,7 @@ limitations under the License. package selfsubjectaccessreview import ( + "context" "fmt" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -41,7 +42,7 @@ func (r *REST) New() runtime.Object { 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) if !ok { return nil, apierrors.NewBadRequest(fmt.Sprintf("not a SelfSubjectAccessReview: %#v", obj)) diff --git a/pkg/registry/authorization/selfsubjectrulesreview/rest.go b/pkg/registry/authorization/selfsubjectrulesreview/rest.go index 2093f324ede..63131d818d1 100644 --- a/pkg/registry/authorization/selfsubjectrulesreview/rest.go +++ b/pkg/registry/authorization/selfsubjectrulesreview/rest.go @@ -17,6 +17,7 @@ limitations under the License. package selfsubjectrulesreview import ( + "context" "fmt" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -43,7 +44,7 @@ func (r *REST) New() runtime.Object { } // 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) if !ok { return nil, apierrors.NewBadRequest(fmt.Sprintf("not a SelfSubjectRulesReview: %#v", obj)) diff --git a/pkg/registry/authorization/subjectaccessreview/BUILD b/pkg/registry/authorization/subjectaccessreview/BUILD index 09d797c1f7d..d15e51e6d68 100644 --- a/pkg/registry/authorization/subjectaccessreview/BUILD +++ b/pkg/registry/authorization/subjectaccessreview/BUILD @@ -17,7 +17,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/api/errors: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/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", ], ) diff --git a/pkg/registry/authorization/subjectaccessreview/rest.go b/pkg/registry/authorization/subjectaccessreview/rest.go index 92da3d34244..aeb7da2198e 100644 --- a/pkg/registry/authorization/subjectaccessreview/rest.go +++ b/pkg/registry/authorization/subjectaccessreview/rest.go @@ -17,12 +17,12 @@ limitations under the License. package subjectaccessreview import ( + "context" "fmt" kapierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apiserver/pkg/authorization/authorizer" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" authorizationapi "k8s.io/kubernetes/pkg/apis/authorization" authorizationvalidation "k8s.io/kubernetes/pkg/apis/authorization/validation" @@ -41,7 +41,7 @@ func (r *REST) New() runtime.Object { 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) if !ok { return nil, kapierrors.NewBadRequest(fmt.Sprintf("not a SubjectAccessReview: %#v", obj)) diff --git a/pkg/registry/autoscaling/horizontalpodautoscaler/BUILD b/pkg/registry/autoscaling/horizontalpodautoscaler/BUILD index e5fef0856af..0e2901c7661 100644 --- a/pkg/registry/autoscaling/horizontalpodautoscaler/BUILD +++ b/pkg/registry/autoscaling/horizontalpodautoscaler/BUILD @@ -18,7 +18,6 @@ go_library( "//pkg/apis/autoscaling/validation: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", ], ) diff --git a/pkg/registry/autoscaling/horizontalpodautoscaler/storage/BUILD b/pkg/registry/autoscaling/horizontalpodautoscaler/storage/BUILD index f5fde8df423..f180e2d2e3e 100644 --- a/pkg/registry/autoscaling/horizontalpodautoscaler/storage/BUILD +++ b/pkg/registry/autoscaling/horizontalpodautoscaler/storage/BUILD @@ -41,7 +41,6 @@ go_library( "//pkg/registry/autoscaling/horizontalpodautoscaler: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/apiserver/pkg/endpoints/request: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/rest:go_default_library", diff --git a/pkg/registry/autoscaling/horizontalpodautoscaler/storage/storage.go b/pkg/registry/autoscaling/horizontalpodautoscaler/storage/storage.go index 4e5ccca0664..f6a6dc5cf4e 100644 --- a/pkg/registry/autoscaling/horizontalpodautoscaler/storage/storage.go +++ b/pkg/registry/autoscaling/horizontalpodautoscaler/storage/storage.go @@ -17,9 +17,10 @@ limitations under the License. package storage import ( + "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -83,11 +84,11 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } diff --git a/pkg/registry/autoscaling/horizontalpodautoscaler/strategy.go b/pkg/registry/autoscaling/horizontalpodautoscaler/strategy.go index 3100a96982f..12dbad2dd08 100644 --- a/pkg/registry/autoscaling/horizontalpodautoscaler/strategy.go +++ b/pkg/registry/autoscaling/horizontalpodautoscaler/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package horizontalpodautoscaler import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/apis/autoscaling" @@ -42,7 +43,7 @@ func (autoscalerStrategy) NamespaceScoped() bool { } // 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) // create cannot set status @@ -50,7 +51,7 @@ func (autoscalerStrategy) PrepareForCreate(ctx genericapirequest.Context, obj ru } // 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) return validation.ValidateHorizontalPodAutoscaler(autoscaler) } @@ -65,7 +66,7 @@ func (autoscalerStrategy) AllowCreateOnUpdate() bool { } // 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) oldHPA := old.(*autoscaling.HorizontalPodAutoscaler) // Update is not allowed to set status @@ -73,7 +74,7 @@ func (autoscalerStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, o } // 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)) } @@ -87,13 +88,13 @@ type autoscalerStatusStrategy struct { 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) oldAutoscaler := old.(*autoscaling.HorizontalPodAutoscaler) // status changes are not allowed to update 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)) } diff --git a/pkg/registry/batch/cronjob/BUILD b/pkg/registry/batch/cronjob/BUILD index ac61eca1d7d..c71f3fb083b 100644 --- a/pkg/registry/batch/cronjob/BUILD +++ b/pkg/registry/batch/cronjob/BUILD @@ -20,7 +20,6 @@ go_library( "//pkg/apis/batch/validation: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", ], diff --git a/pkg/registry/batch/cronjob/storage/BUILD b/pkg/registry/batch/cronjob/storage/BUILD index ab8de0a52bb..674818aa120 100644 --- a/pkg/registry/batch/cronjob/storage/BUILD +++ b/pkg/registry/batch/cronjob/storage/BUILD @@ -38,7 +38,6 @@ go_library( "//pkg/registry/batch/cronjob: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/apiserver/pkg/endpoints/request: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/rest:go_default_library", diff --git a/pkg/registry/batch/cronjob/storage/storage.go b/pkg/registry/batch/cronjob/storage/storage.go index 7826ea5a1e7..dcb151f76b1 100644 --- a/pkg/registry/batch/cronjob/storage/storage.go +++ b/pkg/registry/batch/cronjob/storage/storage.go @@ -17,9 +17,10 @@ limitations under the License. package storage import ( + "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -82,11 +83,11 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } diff --git a/pkg/registry/batch/cronjob/strategy.go b/pkg/registry/batch/cronjob/strategy.go index 3544ca10b13..1e756d6b15f 100644 --- a/pkg/registry/batch/cronjob/strategy.go +++ b/pkg/registry/batch/cronjob/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package cronjob import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" @@ -39,7 +40,7 @@ var Strategy = cronJobStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} // DefaultGarbageCollectionPolicy returns Orphan because that was the default // 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 } @@ -49,7 +50,7 @@ func (cronJobStrategy) NamespaceScoped() bool { } // 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.Status = batch.CronJobStatus{} @@ -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. -func (cronJobStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (cronJobStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newCronJob := obj.(*batch.CronJob) oldCronJob := old.(*batch.CronJob) newCronJob.Status = oldCronJob.Status @@ -67,7 +68,7 @@ func (cronJobStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old } // 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) return validation.ValidateCronJob(cronJob) } @@ -86,7 +87,7 @@ func (cronJobStrategy) AllowCreateOnUpdate() bool { } // 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)) } @@ -96,12 +97,12 @@ type cronJobStatusStrategy struct { 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) oldJob := old.(*batch.CronJob) 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{} } diff --git a/pkg/registry/batch/job/BUILD b/pkg/registry/batch/job/BUILD index 1c3e57aed4b..31f9eea1adb 100644 --- a/pkg/registry/batch/job/BUILD +++ b/pkg/registry/batch/job/BUILD @@ -23,7 +23,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/labels: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/apiserver/pkg/endpoints/request: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/storage:go_default_library", diff --git a/pkg/registry/batch/job/storage/BUILD b/pkg/registry/batch/job/storage/BUILD index e53918f074e..86b5dd8de7a 100644 --- a/pkg/registry/batch/job/storage/BUILD +++ b/pkg/registry/batch/job/storage/BUILD @@ -36,7 +36,6 @@ go_library( "//pkg/registry/batch/job: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/apiserver/pkg/endpoints/request: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/rest:go_default_library", diff --git a/pkg/registry/batch/job/storage/storage.go b/pkg/registry/batch/job/storage/storage.go index 580cc5a7531..7162f61dd9f 100644 --- a/pkg/registry/batch/job/storage/storage.go +++ b/pkg/registry/batch/job/storage/storage.go @@ -17,9 +17,10 @@ limitations under the License. package storage import ( + "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -93,11 +94,11 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } diff --git a/pkg/registry/batch/job/strategy.go b/pkg/registry/batch/job/strategy.go index aecf38a36d9..c0eb2be5f53 100644 --- a/pkg/registry/batch/job/strategy.go +++ b/pkg/registry/batch/job/strategy.go @@ -17,6 +17,7 @@ limitations under the License. package job import ( + "context" "fmt" "strconv" @@ -25,7 +26,6 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "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/rest" "k8s.io/apiserver/pkg/storage" @@ -47,7 +47,7 @@ var Strategy = jobStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} // DefaultGarbageCollectionPolicy returns Orphan because that was the default // 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 } @@ -57,7 +57,7 @@ func (jobStrategy) NamespaceScoped() bool { } // 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.Status = batch.JobStatus{} @@ -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. -func (jobStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (jobStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newJob := obj.(*batch.Job) oldJob := old.(*batch.Job) newJob.Status = oldJob.Status @@ -75,7 +75,7 @@ func (jobStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runt } // 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) // TODO: move UID generation earlier and do this in defaulting logic? if job.Spec.ManualSelector == nil || *job.Spec.ManualSelector == false { @@ -148,7 +148,7 @@ func (jobStrategy) AllowCreateOnUpdate() bool { } // 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)) updateErrorList := validation.ValidateJobUpdate(obj.(*batch.Job), old.(*batch.Job)) return append(validationErrorList, updateErrorList...) @@ -160,13 +160,13 @@ type jobStatusStrategy struct { 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) oldJob := old.(*batch.Job) 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)) } diff --git a/pkg/registry/certificates/certificates/registry.go b/pkg/registry/certificates/certificates/registry.go index d3eea018bce..e48a6382b14 100644 --- a/pkg/registry/certificates/certificates/registry.go +++ b/pkg/registry/certificates/certificates/registry.go @@ -17,22 +17,23 @@ limitations under the License. package certificates import ( + "context" + metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/kubernetes/pkg/apis/certificates" ) // Registry is an interface for things that know how to store CSRs. type Registry interface { - ListCSRs(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*certificates.CertificateSigningRequestList, error) - CreateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc) error - UpdateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error - GetCSR(ctx genericapirequest.Context, csrID string, options *metav1.GetOptions) (*certificates.CertificateSigningRequest, error) - DeleteCSR(ctx genericapirequest.Context, csrID string) error - WatchCSRs(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + ListCSRs(ctx context.Context, options *metainternalversion.ListOptions) (*certificates.CertificateSigningRequestList, error) + CreateCSR(ctx context.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc) error + UpdateCSR(ctx context.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error + GetCSR(ctx context.Context, csrID string, options *metav1.GetOptions) (*certificates.CertificateSigningRequest, error) + DeleteCSR(ctx context.Context, csrID string) error + WatchCSRs(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) } // storage puts strong typing around storage calls @@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -55,21 +56,21 @@ func (s *storage) ListCSRs(ctx genericapirequest.Context, options *metainternalv 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) 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) 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) } -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) if err != nil { return nil, err @@ -77,7 +78,7 @@ func (s *storage) GetCSR(ctx genericapirequest.Context, name string, options *me 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) return err } diff --git a/pkg/registry/certificates/certificates/storage/BUILD b/pkg/registry/certificates/certificates/storage/BUILD index 23a23392025..7889ede2652 100644 --- a/pkg/registry/certificates/certificates/storage/BUILD +++ b/pkg/registry/certificates/certificates/storage/BUILD @@ -16,7 +16,6 @@ go_library( "//pkg/printers/storage:go_default_library", "//pkg/registry/certificates/certificates: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/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", diff --git a/pkg/registry/certificates/certificates/storage/storage.go b/pkg/registry/certificates/certificates/storage/storage.go index 77ab436fce8..507269a72ba 100644 --- a/pkg/registry/certificates/certificates/storage/storage.go +++ b/pkg/registry/certificates/certificates/storage/storage.go @@ -17,8 +17,9 @@ limitations under the License. package storage import ( + "context" + "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -83,7 +84,7 @@ func (r *StatusREST) New() runtime.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) } @@ -97,6 +98,6 @@ func (r *ApprovalREST) New() runtime.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) } diff --git a/pkg/registry/certificates/certificates/strategy.go b/pkg/registry/certificates/certificates/strategy.go index eff6a8965ea..82830ea6ee3 100644 --- a/pkg/registry/certificates/certificates/strategy.go +++ b/pkg/registry/certificates/certificates/strategy.go @@ -17,6 +17,7 @@ limitations under the License. package certificates import ( + "context" "fmt" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -51,7 +52,7 @@ func (csrStrategy) AllowCreateOnUpdate() bool { // PrepareForCreate clears fields that are not allowed to be set by end users // on creation. -func (csrStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { +func (csrStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { csr := obj.(*certificates.CertificateSigningRequest) // Clear any user-specified info @@ -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 // 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) oldCSR := old.(*certificates.CertificateSigningRequest) @@ -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. -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) return validation.ValidateCertificateSigningRequest(csr) } @@ -97,7 +98,7 @@ func (csrStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) f func (csrStrategy) Canonicalize(obj runtime.Object) {} // 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) newCSR := obj.(*certificates.CertificateSigningRequest) return validation.ValidateCertificateSigningRequestUpdate(newCSR, oldCSR) @@ -112,7 +113,7 @@ func (csrStrategy) AllowUnconditionalUpdate() bool { 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) if !ok { // unexpected programmer error @@ -134,7 +135,7 @@ type csrStatusStrategy struct { 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) oldCSR := old.(*certificates.CertificateSigningRequest) @@ -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)) } @@ -168,7 +169,7 @@ var ApprovalStrategy = csrApprovalStrategy{Strategy} // PrepareForUpdate prepares the new certificate signing request by limiting // 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. -func (csrApprovalStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (csrApprovalStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newCSR := obj.(*certificates.CertificateSigningRequest) oldCSR := old.(*certificates.CertificateSigningRequest) @@ -186,6 +187,6 @@ func (csrApprovalStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, 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)) } diff --git a/pkg/registry/certificates/certificates/strategy_test.go b/pkg/registry/certificates/certificates/strategy_test.go index d6d2b2c01cb..b1b660ba068 100644 --- a/pkg/registry/certificates/certificates/strategy_test.go +++ b/pkg/registry/certificates/certificates/strategy_test.go @@ -17,6 +17,7 @@ limitations under the License. package certificates import ( + "context" "reflect" "testing" @@ -29,7 +30,7 @@ import ( func TestStrategyCreate(t *testing.T) { tests := map[string]struct { - ctx genericapirequest.Context + ctx context.Context obj runtime.Object expectedObj runtime.Object }{ diff --git a/pkg/registry/core/componentstatus/BUILD b/pkg/registry/core/componentstatus/BUILD index d58dd84b1db..453aa812823 100644 --- a/pkg/registry/core/componentstatus/BUILD +++ b/pkg/registry/core/componentstatus/BUILD @@ -22,7 +22,6 @@ go_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/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", ], ) diff --git a/pkg/registry/core/componentstatus/rest.go b/pkg/registry/core/componentstatus/rest.go index c67b42ead71..6312c30442e 100644 --- a/pkg/registry/core/componentstatus/rest.go +++ b/pkg/registry/core/componentstatus/rest.go @@ -17,13 +17,13 @@ limitations under the License. package componentstatus import ( + "context" "fmt" "sync" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" api "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/probe" @@ -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. // 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() wait := sync.WaitGroup{} @@ -73,7 +73,7 @@ func (rs *REST) List(ctx genericapirequest.Context, options *metainternalversion 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() if server, ok := servers[name]; !ok { diff --git a/pkg/registry/core/configmap/BUILD b/pkg/registry/core/configmap/BUILD index b9f7c6398dc..d14a2eb298d 100644 --- a/pkg/registry/core/configmap/BUILD +++ b/pkg/registry/core/configmap/BUILD @@ -23,7 +23,6 @@ go_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/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/storage/names:go_default_library", ], diff --git a/pkg/registry/core/configmap/registry.go b/pkg/registry/core/configmap/registry.go index 440300f2dcf..33784fe5e81 100644 --- a/pkg/registry/core/configmap/registry.go +++ b/pkg/registry/core/configmap/registry.go @@ -17,22 +17,23 @@ limitations under the License. package configmap import ( + "context" + metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" api "k8s.io/kubernetes/pkg/apis/core" ) // Registry is an interface for things that know how to store ConfigMaps. type Registry interface { - ListConfigMaps(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ConfigMapList, error) - WatchConfigMaps(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) - GetConfigMap(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.ConfigMap, error) - CreateConfigMap(ctx genericapirequest.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) - DeleteConfigMap(ctx genericapirequest.Context, name string) error + ListConfigMaps(ctx context.Context, options *metainternalversion.ListOptions) (*api.ConfigMapList, error) + WatchConfigMaps(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + GetConfigMap(ctx context.Context, name string, options *metav1.GetOptions) (*api.ConfigMap, error) + CreateConfigMap(ctx context.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc) (*api.ConfigMap, error) + UpdateConfigMap(ctx context.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ConfigMap, error) + DeleteConfigMap(ctx context.Context, name string) error } // storage puts strong typing around storage calls @@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -55,11 +56,11 @@ func (s *storage) ListConfigMaps(ctx genericapirequest.Context, options *metaint 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) } -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) if err != nil { return nil, err @@ -68,7 +69,7 @@ func (s *storage) GetConfigMap(ctx genericapirequest.Context, name string, optio 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) if err != nil { return nil, err @@ -77,7 +78,7 @@ func (s *storage) CreateConfigMap(ctx genericapirequest.Context, cfg *api.Config 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) if err != nil { return nil, err @@ -86,7 +87,7 @@ func (s *storage) UpdateConfigMap(ctx genericapirequest.Context, cfg *api.Config 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) return err } diff --git a/pkg/registry/core/configmap/strategy.go b/pkg/registry/core/configmap/strategy.go index 58f57f4f9cb..6cf9a6172a3 100644 --- a/pkg/registry/core/configmap/strategy.go +++ b/pkg/registry/core/configmap/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package configmap import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" @@ -47,11 +48,11 @@ func (strategy) NamespaceScoped() bool { return true } -func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { +func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { _ = 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) return validation.ValidateConfigMap(cfg) @@ -65,7 +66,7 @@ func (strategy) AllowCreateOnUpdate() bool { 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) _ = newObj.(*api.ConfigMap) } @@ -74,7 +75,7 @@ func (strategy) AllowUnconditionalUpdate() bool { 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) return validation.ValidateConfigMapUpdate(newCfg, oldCfg) diff --git a/pkg/registry/core/endpoint/BUILD b/pkg/registry/core/endpoint/BUILD index 775b1958394..d87f6793265 100644 --- a/pkg/registry/core/endpoint/BUILD +++ b/pkg/registry/core/endpoint/BUILD @@ -23,7 +23,6 @@ go_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/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/storage/names:go_default_library", ], diff --git a/pkg/registry/core/endpoint/registry.go b/pkg/registry/core/endpoint/registry.go index 3cb03c4f9c7..fec4e517de4 100644 --- a/pkg/registry/core/endpoint/registry.go +++ b/pkg/registry/core/endpoint/registry.go @@ -17,21 +17,22 @@ limitations under the License. package endpoint import ( + "context" + metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" api "k8s.io/kubernetes/pkg/apis/core" ) // Registry is an interface for things that know how to store endpoints. type Registry interface { - ListEndpoints(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.EndpointsList, error) - GetEndpoints(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.Endpoints, error) - WatchEndpoints(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) - UpdateEndpoints(ctx genericapirequest.Context, e *api.Endpoints, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error - DeleteEndpoints(ctx genericapirequest.Context, name string) error + ListEndpoints(ctx context.Context, options *metainternalversion.ListOptions) (*api.EndpointsList, error) + GetEndpoints(ctx context.Context, name string, options *metav1.GetOptions) (*api.Endpoints, error) + WatchEndpoints(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + UpdateEndpoints(ctx context.Context, e *api.Endpoints, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error + DeleteEndpoints(ctx context.Context, name string) error } // storage puts strong typing around storage calls @@ -45,7 +46,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -53,11 +54,11 @@ func (s *storage) ListEndpoints(ctx genericapirequest.Context, options *metainte 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) } -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) if err != nil { return nil, err @@ -65,12 +66,12 @@ func (s *storage) GetEndpoints(ctx genericapirequest.Context, name string, optio 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) 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) return err } diff --git a/pkg/registry/core/endpoint/strategy.go b/pkg/registry/core/endpoint/strategy.go index 93204e6ca62..bd6ede7cd87 100644 --- a/pkg/registry/core/endpoint/strategy.go +++ b/pkg/registry/core/endpoint/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package endpoint import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" endptspkg "k8s.io/kubernetes/pkg/api/endpoints" "k8s.io/kubernetes/pkg/api/legacyscheme" @@ -43,15 +44,15 @@ func (endpointsStrategy) NamespaceScoped() bool { } // 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. -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. -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)) } @@ -67,7 +68,7 @@ func (endpointsStrategy) AllowCreateOnUpdate() bool { } // 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)) return append(errorList, validation.ValidateEndpointsUpdate(obj.(*api.Endpoints), old.(*api.Endpoints))...) } diff --git a/pkg/registry/core/event/BUILD b/pkg/registry/core/event/BUILD index 53fa733b797..de4c168bd3b 100644 --- a/pkg/registry/core/event/BUILD +++ b/pkg/registry/core/event/BUILD @@ -21,7 +21,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/labels: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/apiserver/pkg/endpoints/request: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/storage:go_default_library", diff --git a/pkg/registry/core/event/strategy.go b/pkg/registry/core/event/strategy.go index 0ca15dfa684..bfe3c9d597b 100644 --- a/pkg/registry/core/event/strategy.go +++ b/pkg/registry/core/event/strategy.go @@ -17,13 +17,13 @@ limitations under the License. package event import ( + "context" "fmt" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "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/rest" "k8s.io/apiserver/pkg/storage" @@ -42,7 +42,7 @@ type eventStrategy struct { // Event objects via the REST API. 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 } @@ -50,13 +50,13 @@ func (eventStrategy) NamespaceScoped() bool { 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) return validation.ValidateEvent(event) } @@ -69,7 +69,7 @@ func (eventStrategy) AllowCreateOnUpdate() bool { 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) return validation.ValidateEvent(event) } diff --git a/pkg/registry/core/limitrange/BUILD b/pkg/registry/core/limitrange/BUILD index 303471f795f..e4daeb3693d 100644 --- a/pkg/registry/core/limitrange/BUILD +++ b/pkg/registry/core/limitrange/BUILD @@ -19,7 +19,6 @@ go_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/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", ], ) diff --git a/pkg/registry/core/limitrange/strategy.go b/pkg/registry/core/limitrange/strategy.go index b4a55075b98..17e506e46d3 100644 --- a/pkg/registry/core/limitrange/strategy.go +++ b/pkg/registry/core/limitrange/strategy.go @@ -17,10 +17,11 @@ limitations under the License. package limitrange import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" api "k8s.io/kubernetes/pkg/apis/core" @@ -40,17 +41,17 @@ func (limitrangeStrategy) NamespaceScoped() bool { return true } -func (limitrangeStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { +func (limitrangeStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { limitRange := obj.(*api.LimitRange) if len(limitRange.Name) == 0 { 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) return validation.ValidateLimitRange(limitRange) } @@ -63,7 +64,7 @@ func (limitrangeStrategy) AllowCreateOnUpdate() bool { 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) return validation.ValidateLimitRange(limitRange) } @@ -72,7 +73,7 @@ func (limitrangeStrategy) AllowUnconditionalUpdate() bool { return true } -func (limitrangeStrategy) Export(genericapirequest.Context, runtime.Object, bool) error { +func (limitrangeStrategy) Export(context.Context, runtime.Object, bool) error { // Copied from OpenShift exporter // TODO: this needs to be fixed // limitrange.Strategy.PrepareForCreate(ctx, obj) diff --git a/pkg/registry/core/namespace/BUILD b/pkg/registry/core/namespace/BUILD index 675e7db80c6..37143246a9f 100644 --- a/pkg/registry/core/namespace/BUILD +++ b/pkg/registry/core/namespace/BUILD @@ -25,7 +25,6 @@ go_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/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/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library", diff --git a/pkg/registry/core/namespace/registry.go b/pkg/registry/core/namespace/registry.go index cbd470d1519..ec5cf674980 100644 --- a/pkg/registry/core/namespace/registry.go +++ b/pkg/registry/core/namespace/registry.go @@ -17,22 +17,23 @@ limitations under the License. package namespace import ( + "context" + metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" api "k8s.io/kubernetes/pkg/apis/core" ) // Registry is an interface implemented by things that know how to store Namespace objects. type Registry interface { - ListNamespaces(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.NamespaceList, error) - WatchNamespaces(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) - GetNamespace(ctx genericapirequest.Context, namespaceID string, options *metav1.GetOptions) (*api.Namespace, error) - CreateNamespace(ctx genericapirequest.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc) error - UpdateNamespace(ctx genericapirequest.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error - DeleteNamespace(ctx genericapirequest.Context, namespaceID string) error + ListNamespaces(ctx context.Context, options *metainternalversion.ListOptions) (*api.NamespaceList, error) + WatchNamespaces(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + GetNamespace(ctx context.Context, namespaceID string, options *metav1.GetOptions) (*api.Namespace, error) + CreateNamespace(ctx context.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc) error + UpdateNamespace(ctx context.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error + DeleteNamespace(ctx context.Context, namespaceID string) error } // storage puts strong typing around storage calls @@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -54,11 +55,11 @@ func (s *storage) ListNamespaces(ctx genericapirequest.Context, options *metaint 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) } -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) if err != nil { return nil, err @@ -66,17 +67,17 @@ func (s *storage) GetNamespace(ctx genericapirequest.Context, namespaceName stri 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) 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) 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) return err } diff --git a/pkg/registry/core/namespace/storage/BUILD b/pkg/registry/core/namespace/storage/BUILD index ff853936af7..9834572dfbb 100644 --- a/pkg/registry/core/namespace/storage/BUILD +++ b/pkg/registry/core/namespace/storage/BUILD @@ -40,7 +40,6 @@ go_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/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/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", diff --git a/pkg/registry/core/namespace/storage/storage.go b/pkg/registry/core/namespace/storage/storage.go index 77f8747b50b..2be85e1b805 100644 --- a/pkg/registry/core/namespace/storage/storage.go +++ b/pkg/registry/core/namespace/storage/storage.go @@ -17,6 +17,7 @@ limitations under the License. package storage import ( + "context" "fmt" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -25,7 +26,6 @@ import ( metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -92,32 +92,32 @@ func (r *REST) NewList() runtime.Object { 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) } -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) } -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) } -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) } -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) } -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) } // 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{}) if err != nil { return nil, false, err @@ -208,7 +208,7 @@ func (r *REST) Delete(ctx genericapirequest.Context, name string, options *metav 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) } @@ -225,12 +225,12 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } @@ -239,6 +239,6 @@ func (r *FinalizeREST) New() runtime.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) } diff --git a/pkg/registry/core/namespace/strategy.go b/pkg/registry/core/namespace/strategy.go index 53a139e5223..be15c1b9636 100644 --- a/pkg/registry/core/namespace/strategy.go +++ b/pkg/registry/core/namespace/strategy.go @@ -17,13 +17,13 @@ limitations under the License. package namespace import ( + "context" "fmt" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" apistorage "k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage/names" @@ -48,7 +48,7 @@ func (namespaceStrategy) NamespaceScoped() bool { } // 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 namespace := obj.(*api.Namespace) namespace.Status = api.NamespaceStatus{ @@ -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. -func (namespaceStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (namespaceStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newNamespace := obj.(*api.Namespace) oldNamespace := old.(*api.Namespace) newNamespace.Spec.Finalizers = oldNamespace.Spec.Finalizers @@ -81,7 +81,7 @@ func (namespaceStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol } // 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) return validation.ValidateNamespace(namespace) } @@ -96,7 +96,7 @@ func (namespaceStrategy) AllowCreateOnUpdate() bool { } // 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)) return append(errorList, validation.ValidateNamespaceUpdate(obj.(*api.Namespace), old.(*api.Namespace))...) } @@ -111,13 +111,13 @@ type namespaceStatusStrategy struct { 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) oldNamespace := old.(*api.Namespace) 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)) } @@ -127,12 +127,12 @@ type namespaceFinalizeStrategy struct { 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)) } // 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) oldNamespace := old.(*api.Namespace) newNamespace.Status = oldNamespace.Status diff --git a/pkg/registry/core/node/BUILD b/pkg/registry/core/node/BUILD index 32a872cb43b..d9499581f1a 100644 --- a/pkg/registry/core/node/BUILD +++ b/pkg/registry/core/node/BUILD @@ -30,7 +30,6 @@ go_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/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/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library", diff --git a/pkg/registry/core/node/registry.go b/pkg/registry/core/node/registry.go index e4476ded4b9..71752425ab4 100644 --- a/pkg/registry/core/node/registry.go +++ b/pkg/registry/core/node/registry.go @@ -17,22 +17,23 @@ limitations under the License. package node import ( + "context" + metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" api "k8s.io/kubernetes/pkg/apis/core" ) // Registry is an interface for things that know how to store node. type Registry interface { - ListNodes(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.NodeList, error) - CreateNode(ctx genericapirequest.Context, node *api.Node, createValidation rest.ValidateObjectFunc) error - UpdateNode(ctx genericapirequest.Context, node *api.Node, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error - GetNode(ctx genericapirequest.Context, nodeID string, options *metav1.GetOptions) (*api.Node, error) - DeleteNode(ctx genericapirequest.Context, nodeID string) error - WatchNodes(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + ListNodes(ctx context.Context, options *metainternalversion.ListOptions) (*api.NodeList, error) + CreateNode(ctx context.Context, node *api.Node, createValidation rest.ValidateObjectFunc) error + UpdateNode(ctx context.Context, node *api.Node, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error + GetNode(ctx context.Context, nodeID string, options *metav1.GetOptions) (*api.Node, error) + DeleteNode(ctx context.Context, nodeID string) error + WatchNodes(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) } // storage puts strong typing around storage calls @@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -55,21 +56,21 @@ func (s *storage) ListNodes(ctx genericapirequest.Context, options *metainternal 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) 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) 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) } -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) if err != nil { return nil, err @@ -77,7 +78,7 @@ func (s *storage) GetNode(ctx genericapirequest.Context, name string, options *m 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) return err } diff --git a/pkg/registry/core/node/rest/BUILD b/pkg/registry/core/node/rest/BUILD index 1425ee92026..b0dcb27da92 100644 --- a/pkg/registry/core/node/rest/BUILD +++ b/pkg/registry/core/node/rest/BUILD @@ -17,7 +17,6 @@ go_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/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/rest:go_default_library", ], diff --git a/pkg/registry/core/node/rest/proxy.go b/pkg/registry/core/node/rest/proxy.go index b314617f42e..2701d3c0457 100644 --- a/pkg/registry/core/node/rest/proxy.go +++ b/pkg/registry/core/node/rest/proxy.go @@ -17,6 +17,7 @@ limitations under the License. package node import ( + "context" "fmt" "net/http" "net/url" @@ -24,7 +25,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/proxy" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" api "k8s.io/kubernetes/pkg/apis/core" @@ -61,7 +61,7 @@ func (r *ProxyREST) NewConnectOptions() (runtime.Object, bool, string) { } // 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) if !ok { return nil, fmt.Errorf("Invalid options object: %#v", opts) diff --git a/pkg/registry/core/node/storage/storage.go b/pkg/registry/core/node/storage/storage.go index a61e575885b..ee3927d40a8 100644 --- a/pkg/registry/core/node/storage/storage.go +++ b/pkg/registry/core/node/storage/storage.go @@ -17,6 +17,7 @@ limitations under the License. package storage import ( + "context" "fmt" "net/http" "net/url" @@ -63,12 +64,12 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } @@ -137,7 +138,7 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, kubeletClientConfig client var _ = rest.Redirector(&REST{}) // 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) } diff --git a/pkg/registry/core/node/strategy.go b/pkg/registry/core/node/strategy.go index b5f432a4936..6d391801a3f 100644 --- a/pkg/registry/core/node/strategy.go +++ b/pkg/registry/core/node/strategy.go @@ -17,6 +17,7 @@ limitations under the License. package node import ( + "context" "fmt" "net" "net/http" @@ -30,7 +31,6 @@ import ( "k8s.io/apimachinery/pkg/types" utilnet "k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" pkgstorage "k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage/names" @@ -63,7 +63,7 @@ func (nodeStrategy) AllowCreateOnUpdate() bool { } // 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) // Nodes allow *all* fields, including status, to be set on create. @@ -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. -func (nodeStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (nodeStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newNode := obj.(*api.Node) oldNode := old.(*api.Node) newNode.Status = oldNode.Status @@ -85,7 +85,7 @@ func (nodeStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old run } // 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) return validation.ValidateNode(node) } @@ -95,7 +95,7 @@ func (nodeStrategy) Canonicalize(obj runtime.Object) { } // 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)) return append(errorList, validation.ValidateNodeUpdate(obj.(*api.Node), old.(*api.Node))...) } @@ -104,7 +104,7 @@ func (nodeStrategy) AllowUnconditionalUpdate() bool { 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) if !ok { // unexpected programmer error @@ -126,18 +126,18 @@ type nodeStatusStrategy struct { 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) // 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) oldNode := old.(*api.Node) 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)) } @@ -147,7 +147,7 @@ func (nodeStatusStrategy) Canonicalize(obj runtime.Object) { // ResourceGetter is an interface for retrieving resources by ResourceLocation. 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. @@ -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. -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) if !valid { return nil, nil, errors.NewBadRequest(fmt.Sprintf("invalid node request %q", id)) diff --git a/pkg/registry/core/persistentvolume/BUILD b/pkg/registry/core/persistentvolume/BUILD index 8cf27c1c97c..9cb65fecfaf 100644 --- a/pkg/registry/core/persistentvolume/BUILD +++ b/pkg/registry/core/persistentvolume/BUILD @@ -23,7 +23,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/labels: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/apiserver/pkg/endpoints/request: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/names:go_default_library", diff --git a/pkg/registry/core/persistentvolume/storage/BUILD b/pkg/registry/core/persistentvolume/storage/BUILD index 25c758afda3..602854b4410 100644 --- a/pkg/registry/core/persistentvolume/storage/BUILD +++ b/pkg/registry/core/persistentvolume/storage/BUILD @@ -40,7 +40,6 @@ go_library( "//pkg/registry/core/persistentvolume: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/apiserver/pkg/endpoints/request: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/rest:go_default_library", diff --git a/pkg/registry/core/persistentvolume/storage/storage.go b/pkg/registry/core/persistentvolume/storage/storage.go index 519b7cb9c84..c272364ef6b 100644 --- a/pkg/registry/core/persistentvolume/storage/storage.go +++ b/pkg/registry/core/persistentvolume/storage/storage.go @@ -17,9 +17,10 @@ limitations under the License. package storage import ( + "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -78,11 +79,11 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } diff --git a/pkg/registry/core/persistentvolume/strategy.go b/pkg/registry/core/persistentvolume/strategy.go index 477bca2bad5..eb172251a8d 100644 --- a/pkg/registry/core/persistentvolume/strategy.go +++ b/pkg/registry/core/persistentvolume/strategy.go @@ -17,13 +17,13 @@ limitations under the License. package persistentvolume import ( + "context" "fmt" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage/names" @@ -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. -func (persistentvolumeStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { +func (persistentvolumeStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { pv := obj.(*api.PersistentVolume) pv.Status = api.PersistentVolumeStatus{} 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) errorList := validation.ValidatePersistentVolume(persistentvolume) return append(errorList, volumevalidation.ValidatePersistentVolume(persistentvolume)...) @@ -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 -func (persistentvolumeStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (persistentvolumeStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newPv := obj.(*api.PersistentVolume) oldPv := old.(*api.PersistentVolume) newPv.Status = oldPv.Status @@ -80,7 +80,7 @@ func (persistentvolumeStrategy) PrepareForUpdate(ctx genericapirequest.Context, 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) errorList := validation.ValidatePersistentVolume(newPv) errorList = append(errorList, volumevalidation.ValidatePersistentVolume(newPv)...) @@ -98,13 +98,13 @@ type persistentvolumeStatusStrategy struct { var StatusStrategy = persistentvolumeStatusStrategy{Strategy} // 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) oldPv := old.(*api.PersistentVolume) 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)) } diff --git a/pkg/registry/core/persistentvolumeclaim/BUILD b/pkg/registry/core/persistentvolumeclaim/BUILD index dcf84be0849..61d90f4acae 100644 --- a/pkg/registry/core/persistentvolumeclaim/BUILD +++ b/pkg/registry/core/persistentvolumeclaim/BUILD @@ -22,7 +22,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/labels: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/apiserver/pkg/endpoints/request: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/names:go_default_library", diff --git a/pkg/registry/core/persistentvolumeclaim/storage/BUILD b/pkg/registry/core/persistentvolumeclaim/storage/BUILD index c927ef5b3c7..277f1155694 100644 --- a/pkg/registry/core/persistentvolumeclaim/storage/BUILD +++ b/pkg/registry/core/persistentvolumeclaim/storage/BUILD @@ -40,7 +40,6 @@ go_library( "//pkg/registry/core/persistentvolumeclaim: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/apiserver/pkg/endpoints/request: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/rest:go_default_library", diff --git a/pkg/registry/core/persistentvolumeclaim/storage/storage.go b/pkg/registry/core/persistentvolumeclaim/storage/storage.go index 2720c2d5812..3d4a0d2698a 100644 --- a/pkg/registry/core/persistentvolumeclaim/storage/storage.go +++ b/pkg/registry/core/persistentvolumeclaim/storage/storage.go @@ -17,9 +17,10 @@ limitations under the License. package storage import ( + "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -78,11 +79,11 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } diff --git a/pkg/registry/core/persistentvolumeclaim/strategy.go b/pkg/registry/core/persistentvolumeclaim/strategy.go index 1a63e1faea8..abefe0de111 100644 --- a/pkg/registry/core/persistentvolumeclaim/strategy.go +++ b/pkg/registry/core/persistentvolumeclaim/strategy.go @@ -17,13 +17,13 @@ limitations under the License. package persistentvolumeclaim import ( + "context" "fmt" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage/names" @@ -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. -func (persistentvolumeclaimStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { +func (persistentvolumeclaimStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { pvc := obj.(*api.PersistentVolumeClaim) pvc.Status = api.PersistentVolumeClaimStatus{} 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) return validation.ValidatePersistentVolumeClaim(pvc) } @@ -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 -func (persistentvolumeclaimStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (persistentvolumeclaimStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newPvc := obj.(*api.PersistentVolumeClaim) oldPvc := old.(*api.PersistentVolumeClaim) newPvc.Status = oldPvc.Status @@ -78,7 +78,7 @@ func (persistentvolumeclaimStrategy) PrepareForUpdate(ctx genericapirequest.Cont 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)) return append(errorList, validation.ValidatePersistentVolumeClaimUpdate(obj.(*api.PersistentVolumeClaim), old.(*api.PersistentVolumeClaim))...) } @@ -94,13 +94,13 @@ type persistentvolumeclaimStatusStrategy struct { var StatusStrategy = persistentvolumeclaimStatusStrategy{Strategy} // 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) oldPv := old.(*api.PersistentVolumeClaim) 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)) } diff --git a/pkg/registry/core/pod/BUILD b/pkg/registry/core/pod/BUILD index 34e64e3514d..59f0e2fad40 100644 --- a/pkg/registry/core/pod/BUILD +++ b/pkg/registry/core/pod/BUILD @@ -30,7 +30,6 @@ go_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/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/registry/generic:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library", diff --git a/pkg/registry/core/pod/rest/BUILD b/pkg/registry/core/pod/rest/BUILD index 114159cdedf..ee4116277f0 100644 --- a/pkg/registry/core/pod/rest/BUILD +++ b/pkg/registry/core/pod/rest/BUILD @@ -23,7 +23,6 @@ go_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/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/registry/generic/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/generic/rest:go_default_library", diff --git a/pkg/registry/core/pod/rest/log.go b/pkg/registry/core/pod/rest/log.go index e33f2a7fe93..ea74dff5c02 100644 --- a/pkg/registry/core/pod/rest/log.go +++ b/pkg/registry/core/pod/rest/log.go @@ -17,11 +17,11 @@ limitations under the License. package rest import ( + "context" "fmt" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" genericrest "k8s.io/apiserver/pkg/registry/generic/rest" "k8s.io/apiserver/pkg/registry/rest" @@ -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 -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) if !ok { return nil, fmt.Errorf("invalid options object: %#v", opts) diff --git a/pkg/registry/core/pod/rest/subresources.go b/pkg/registry/core/pod/rest/subresources.go index 2df82797683..641237367a7 100644 --- a/pkg/registry/core/pod/rest/subresources.go +++ b/pkg/registry/core/pod/rest/subresources.go @@ -17,6 +17,7 @@ limitations under the License. package rest import ( + "context" "fmt" "net/http" "net/url" @@ -24,7 +25,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/proxy" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericfeatures "k8s.io/apiserver/pkg/features" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -62,7 +62,7 @@ func (r *ProxyREST) NewConnectOptions() (runtime.Object, bool, string) { } // 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) if !ok { return nil, fmt.Errorf("Invalid options object: %#v", opts) @@ -94,7 +94,7 @@ func (r *AttachREST) New() runtime.Object { } // 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) if !ok { return nil, fmt.Errorf("Invalid options object: %#v", opts) @@ -131,7 +131,7 @@ func (r *ExecREST) New() runtime.Object { } // 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) if !ok { return nil, fmt.Errorf("invalid options object: %#v", opts) @@ -179,7 +179,7 @@ func (r *PortForwardREST) ConnectMethods() []string { } // 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) if !ok { return nil, fmt.Errorf("invalid options object: %#v", opts) diff --git a/pkg/registry/core/pod/storage/BUILD b/pkg/registry/core/pod/storage/BUILD index 7df41837149..f830237c29c 100644 --- a/pkg/registry/core/pod/storage/BUILD +++ b/pkg/registry/core/pod/storage/BUILD @@ -61,7 +61,6 @@ go_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/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/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", diff --git a/pkg/registry/core/pod/storage/eviction.go b/pkg/registry/core/pod/storage/eviction.go index e98a93211af..5eb66cb6e76 100644 --- a/pkg/registry/core/pod/storage/eviction.go +++ b/pkg/registry/core/pod/storage/eviction.go @@ -17,6 +17,7 @@ limitations under the License. package storage import ( + "context" "fmt" "time" @@ -26,7 +27,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/wait" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/client-go/util/retry" @@ -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. -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) obj, err := r.store.Get(ctx, eviction.Name, &metav1.GetOptions{}) @@ -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. -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 { return nil, nil } diff --git a/pkg/registry/core/pod/storage/storage.go b/pkg/registry/core/pod/storage/storage.go index 129fd1a43d0..cc22f943677 100644 --- a/pkg/registry/core/pod/storage/storage.go +++ b/pkg/registry/core/pod/storage/storage.go @@ -17,6 +17,7 @@ limitations under the License. package storage import ( + "context" "fmt" "net/http" "net/url" @@ -24,7 +25,6 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -102,7 +102,7 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, k client.ConnectionInfoGet var _ = rest.Redirector(&REST{}) // 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) } @@ -135,7 +135,7 @@ func (r *BindingREST) New() runtime.Object { var _ = rest.Creater(&BindingREST{}) // 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) // TODO: move me to a binding strategy @@ -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 // previously 'oldMachine' and merges the provided annotations with those of the pod. // 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) if err != nil { return nil, err @@ -185,7 +185,7 @@ func (r *BindingREST) setPodHostAndAnnotations(ctx genericapirequest.Context, po } // 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 { err = storeerr.InterpretGetError(err, api.Resource("pods"), podID) err = storeerr.InterpretUpdateError(err, api.Resource("pods"), podID) @@ -207,11 +207,11 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } diff --git a/pkg/registry/core/pod/strategy.go b/pkg/registry/core/pod/strategy.go index 90118016cdb..a3658911120 100644 --- a/pkg/registry/core/pod/strategy.go +++ b/pkg/registry/core/pod/strategy.go @@ -17,6 +17,7 @@ limitations under the License. package pod import ( + "context" "fmt" "net" "net/http" @@ -35,7 +36,6 @@ import ( "k8s.io/apimachinery/pkg/types" utilnet "k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/features" "k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/storage" @@ -65,7 +65,7 @@ func (podStrategy) NamespaceScoped() bool { } // 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.Status = api.PodStatus{ Phase: api.PodPending, @@ -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. -func (podStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (podStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newPod := obj.(*api.Pod) oldPod := old.(*api.Pod) newPod.Status = oldPod.Status @@ -86,7 +86,7 @@ func (podStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runt } // 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) return validation.ValidatePod(pod) } @@ -116,7 +116,7 @@ func isUpdatingUninitializedPod(old runtime.Object) (bool, error) { } // 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)) uninitializedUpdate, err := isUpdatingUninitializedPod(old) if err != nil { @@ -135,7 +135,7 @@ func (podStrategy) AllowUnconditionalUpdate() bool { // CheckGracefulDelete allows a pod to be gracefully deleted. It updates the DeleteOptions to // 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 { return false } @@ -168,7 +168,7 @@ type podStrategyWithoutGraceful struct { } // 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 } @@ -181,7 +181,7 @@ type podStatusStrategy struct { 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) oldPod := old.(*api.Pod) newPod.Spec = oldPod.Spec @@ -192,7 +192,7 @@ func (podStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol 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 uninitializedUpdate, err := isUpdatingUninitializedPod(old) if err != nil { @@ -249,10 +249,10 @@ func PodToSelectableFields(pod *api.Pod) fields.Set { // ResourceGetter is an interface for retrieving resources by ResourceLocation. 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{}) if err != nil { return nil, err @@ -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. -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". // If port is not specified, try to use the first defined port on the pod. scheme, name, port, valid := utilnet.SplitSchemeNamePort(id) @@ -314,7 +314,7 @@ func getContainerNames(containers []api.Container) string { func LogLocation( getter ResourceGetter, connInfo client.ConnectionInfoGetter, - ctx genericapirequest.Context, + ctx context.Context, name string, opts *api.PodLogOptions, ) (*url.URL, http.RoundTripper, error) { @@ -450,7 +450,7 @@ func streamParams(params url.Values, opts runtime.Object) error { func AttachLocation( getter ResourceGetter, connInfo client.ConnectionInfoGetter, - ctx genericapirequest.Context, + ctx context.Context, name string, opts *api.PodAttachOptions, ) (*url.URL, http.RoundTripper, error) { @@ -462,7 +462,7 @@ func AttachLocation( func ExecLocation( getter ResourceGetter, connInfo client.ConnectionInfoGetter, - ctx genericapirequest.Context, + ctx context.Context, name string, opts *api.PodExecOptions, ) (*url.URL, http.RoundTripper, error) { @@ -472,7 +472,7 @@ func ExecLocation( func streamLocation( getter ResourceGetter, connInfo client.ConnectionInfoGetter, - ctx genericapirequest.Context, + ctx context.Context, name string, opts runtime.Object, container, @@ -531,7 +531,7 @@ func streamLocation( func PortForwardLocation( getter ResourceGetter, connInfo client.ConnectionInfoGetter, - ctx genericapirequest.Context, + ctx context.Context, name string, opts *api.PodPortForwardOptions, ) (*url.URL, http.RoundTripper, error) { diff --git a/pkg/registry/core/pod/strategy_test.go b/pkg/registry/core/pod/strategy_test.go index 2601083420f..ff4f24fcad4 100644 --- a/pkg/registry/core/pod/strategy_test.go +++ b/pkg/registry/core/pod/strategy_test.go @@ -17,6 +17,7 @@ limitations under the License. package pod import ( + "context" "net/url" "reflect" "testing" @@ -268,7 +269,7 @@ type mockPodGetter struct { 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 } diff --git a/pkg/registry/core/podtemplate/BUILD b/pkg/registry/core/podtemplate/BUILD index 5841503ea28..9caae700da4 100644 --- a/pkg/registry/core/podtemplate/BUILD +++ b/pkg/registry/core/podtemplate/BUILD @@ -19,7 +19,6 @@ go_library( "//pkg/apis/core/validation: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", ], ) diff --git a/pkg/registry/core/podtemplate/strategy.go b/pkg/registry/core/podtemplate/strategy.go index 0f19250d97f..83c516fc886 100644 --- a/pkg/registry/core/podtemplate/strategy.go +++ b/pkg/registry/core/podtemplate/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package podtemplate import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/pod" @@ -43,14 +44,14 @@ func (podTemplateStrategy) NamespaceScoped() bool { } // 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) pod.DropDisabledAlphaFields(&template.Template.Spec) } // 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) return validation.ValidatePodTemplate(pod) } @@ -65,7 +66,7 @@ func (podTemplateStrategy) AllowCreateOnUpdate() bool { } // 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) oldTemplate := old.(*api.PodTemplate) @@ -74,7 +75,7 @@ func (podTemplateStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, } // 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)) } @@ -82,7 +83,7 @@ func (podTemplateStrategy) AllowUnconditionalUpdate() bool { 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 return nil } diff --git a/pkg/registry/core/replicationcontroller/BUILD b/pkg/registry/core/replicationcontroller/BUILD index a55314ed708..94badf99a3e 100644 --- a/pkg/registry/core/replicationcontroller/BUILD +++ b/pkg/registry/core/replicationcontroller/BUILD @@ -28,7 +28,6 @@ go_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/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/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage:go_default_library", diff --git a/pkg/registry/core/replicationcontroller/registry.go b/pkg/registry/core/replicationcontroller/registry.go index 199981db097..caf5d78fc45 100644 --- a/pkg/registry/core/replicationcontroller/registry.go +++ b/pkg/registry/core/replicationcontroller/registry.go @@ -19,24 +19,24 @@ limitations under the License. package replicationcontroller import ( + "context" "fmt" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" api "k8s.io/kubernetes/pkg/apis/core" ) // Registry is an interface for things that know how to store ReplicationControllers. type Registry interface { - ListControllers(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ReplicationControllerList, error) - WatchControllers(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) - GetController(ctx genericapirequest.Context, controllerID string, options *metav1.GetOptions) (*api.ReplicationController, error) - CreateController(ctx genericapirequest.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) - DeleteController(ctx genericapirequest.Context, controllerID string) error + ListControllers(ctx context.Context, options *metainternalversion.ListOptions) (*api.ReplicationControllerList, error) + WatchControllers(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + GetController(ctx context.Context, controllerID string, options *metav1.GetOptions) (*api.ReplicationController, error) + CreateController(ctx context.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc) (*api.ReplicationController, error) + UpdateController(ctx context.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ReplicationController, error) + DeleteController(ctx context.Context, controllerID string) error } // storage puts strong typing around storage calls @@ -50,7 +50,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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() { return nil, fmt.Errorf("field selector not supported yet") } @@ -61,11 +61,11 @@ func (s *storage) ListControllers(ctx genericapirequest.Context, options *metain 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) } -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) if err != nil { return nil, err @@ -73,7 +73,7 @@ func (s *storage) GetController(ctx genericapirequest.Context, controllerID stri 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) if err != nil { return nil, err @@ -81,7 +81,7 @@ func (s *storage) CreateController(ctx genericapirequest.Context, controller *ap 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) if err != nil { return nil, err @@ -89,7 +89,7 @@ func (s *storage) UpdateController(ctx genericapirequest.Context, controller *ap 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) return err } diff --git a/pkg/registry/core/replicationcontroller/storage/BUILD b/pkg/registry/core/replicationcontroller/storage/BUILD index 0ccf4bf1907..ef5a16ef8f5 100644 --- a/pkg/registry/core/replicationcontroller/storage/BUILD +++ b/pkg/registry/core/replicationcontroller/storage/BUILD @@ -48,7 +48,6 @@ go_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/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/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", diff --git a/pkg/registry/core/replicationcontroller/storage/storage.go b/pkg/registry/core/replicationcontroller/storage/storage.go index ead95842d96..0c5217f37c5 100644 --- a/pkg/registry/core/replicationcontroller/storage/storage.go +++ b/pkg/registry/core/replicationcontroller/storage/storage.go @@ -19,6 +19,7 @@ limitations under the License. package storage import ( + "context" "fmt" "k8s.io/apimachinery/pkg/api/errors" @@ -26,7 +27,6 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -114,12 +114,12 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } @@ -145,7 +145,7 @@ func (r *ScaleREST) New() runtime.Object { 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) if err != nil { return nil, errors.NewNotFound(autoscaling.Resource("replicationcontrollers/scale"), name) @@ -153,7 +153,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met 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{}) if err != nil { return nil, false, errors.NewNotFound(autoscaling.Resource("replicationcontrollers/scale"), name) diff --git a/pkg/registry/core/replicationcontroller/strategy.go b/pkg/registry/core/replicationcontroller/strategy.go index ede6e672481..0cc784bc9fd 100644 --- a/pkg/registry/core/replicationcontroller/strategy.go +++ b/pkg/registry/core/replicationcontroller/strategy.go @@ -19,6 +19,7 @@ limitations under the License. package replicationcontroller import ( + "context" "fmt" "strconv" "strings" @@ -28,7 +29,6 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "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/rest" apistorage "k8s.io/apiserver/pkg/storage" @@ -51,7 +51,7 @@ var Strategy = rcStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} // DefaultGarbageCollectionPolicy returns Orphan because that was the default // 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 } @@ -61,7 +61,7 @@ func (rcStrategy) NamespaceScoped() bool { } // 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.Status = api.ReplicationControllerStatus{} @@ -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. -func (rcStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (rcStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newController := obj.(*api.ReplicationController) oldController := old.(*api.ReplicationController) // update is not allowed to set status @@ -100,7 +100,7 @@ func (rcStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runti } // 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) return validation.ValidateReplicationController(controller) } @@ -116,7 +116,7 @@ func (rcStrategy) AllowCreateOnUpdate() bool { } // 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) newRc := obj.(*api.ReplicationController) @@ -183,13 +183,13 @@ type rcStatusStrategy struct { 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) oldRc := old.(*api.ReplicationController) // update is not allowed to set 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)) } diff --git a/pkg/registry/core/resourcequota/BUILD b/pkg/registry/core/resourcequota/BUILD index a2458fa3684..699f8dda402 100644 --- a/pkg/registry/core/resourcequota/BUILD +++ b/pkg/registry/core/resourcequota/BUILD @@ -19,7 +19,6 @@ go_library( "//pkg/apis/core/validation: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", ], ) diff --git a/pkg/registry/core/resourcequota/storage/BUILD b/pkg/registry/core/resourcequota/storage/BUILD index fb088527b7a..773c5ea9af0 100644 --- a/pkg/registry/core/resourcequota/storage/BUILD +++ b/pkg/registry/core/resourcequota/storage/BUILD @@ -36,7 +36,6 @@ go_library( "//pkg/registry/core/resourcequota: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/apiserver/pkg/endpoints/request: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/rest:go_default_library", diff --git a/pkg/registry/core/resourcequota/storage/storage.go b/pkg/registry/core/resourcequota/storage/storage.go index 391cb17f067..8e9ea953301 100644 --- a/pkg/registry/core/resourcequota/storage/storage.go +++ b/pkg/registry/core/resourcequota/storage/storage.go @@ -17,9 +17,10 @@ limitations under the License. package storage import ( + "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -72,11 +73,11 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } diff --git a/pkg/registry/core/resourcequota/strategy.go b/pkg/registry/core/resourcequota/strategy.go index eecfc59d936..dc313ac9bf0 100644 --- a/pkg/registry/core/resourcequota/strategy.go +++ b/pkg/registry/core/resourcequota/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package resourcequota import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" api "k8s.io/kubernetes/pkg/apis/core" @@ -42,20 +43,20 @@ func (resourcequotaStrategy) NamespaceScoped() bool { } // 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.Status = api.ResourceQuotaStatus{} } // 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) oldResourcequota := old.(*api.ResourceQuota) newResourcequota.Status = oldResourcequota.Status } // 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) return validation.ValidateResourceQuota(resourcequota) } @@ -70,7 +71,7 @@ func (resourcequotaStrategy) AllowCreateOnUpdate() bool { } // 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)) return append(errorList, validation.ValidateResourceQuotaUpdate(obj.(*api.ResourceQuota), old.(*api.ResourceQuota))...) } @@ -85,12 +86,12 @@ type resourcequotaStatusStrategy struct { 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) oldResourcequota := old.(*api.ResourceQuota) 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)) } diff --git a/pkg/registry/core/secret/BUILD b/pkg/registry/core/secret/BUILD index 2626c3cec83..65b6a515460 100644 --- a/pkg/registry/core/secret/BUILD +++ b/pkg/registry/core/secret/BUILD @@ -22,7 +22,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/labels: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/apiserver/pkg/endpoints/request: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/storage:go_default_library", diff --git a/pkg/registry/core/secret/strategy.go b/pkg/registry/core/secret/strategy.go index fbdb05572de..c0725f33f68 100644 --- a/pkg/registry/core/secret/strategy.go +++ b/pkg/registry/core/secret/strategy.go @@ -17,6 +17,7 @@ limitations under the License. package secret import ( + "context" "fmt" "k8s.io/apimachinery/pkg/api/errors" @@ -24,7 +25,6 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "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/rest" apistorage "k8s.io/apiserver/pkg/storage" @@ -52,10 +52,10 @@ func (strategy) NamespaceScoped() bool { 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)) } @@ -66,10 +66,10 @@ func (strategy) AllowCreateOnUpdate() bool { 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)) } @@ -77,7 +77,7 @@ func (strategy) AllowUnconditionalUpdate() bool { 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) if !ok { // unexpected programmer error diff --git a/pkg/registry/core/service/BUILD b/pkg/registry/core/service/BUILD index fd277aa7c93..87bf4184175 100644 --- a/pkg/registry/core/service/BUILD +++ b/pkg/registry/core/service/BUILD @@ -27,7 +27,6 @@ go_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/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/storage/names:go_default_library", ], diff --git a/pkg/registry/core/service/proxy.go b/pkg/registry/core/service/proxy.go index 23e016b07af..2ddf87df9ea 100644 --- a/pkg/registry/core/service/proxy.go +++ b/pkg/registry/core/service/proxy.go @@ -17,6 +17,7 @@ limitations under the License. package service import ( + "context" "fmt" "net/http" "net/url" @@ -24,7 +25,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/proxy" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" api "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/capabilities" @@ -57,7 +57,7 @@ func (r *ProxyREST) NewConnectOptions() (runtime.Object, bool, string) { } // 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) if !ok { return nil, fmt.Errorf("Invalid options object: %#v", opts) diff --git a/pkg/registry/core/service/registry.go b/pkg/registry/core/service/registry.go index 332d651e7dd..cbb738489e0 100644 --- a/pkg/registry/core/service/registry.go +++ b/pkg/registry/core/service/registry.go @@ -17,25 +17,25 @@ limitations under the License. package service import ( + "context" "fmt" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" api "k8s.io/kubernetes/pkg/apis/core" ) // Registry is an interface for things that know how to store services. type Registry interface { - ListServices(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ServiceList, error) - CreateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc) (*api.Service, error) - GetService(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.Service, error) - DeleteService(ctx genericapirequest.Context, name string) error - UpdateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.Service, error) - WatchServices(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) - ExportService(ctx genericapirequest.Context, name string, options metav1.ExportOptions) (*api.Service, error) + ListServices(ctx context.Context, options *metainternalversion.ListOptions) (*api.ServiceList, error) + CreateService(ctx context.Context, svc *api.Service, createValidation rest.ValidateObjectFunc) (*api.Service, error) + GetService(ctx context.Context, name string, options *metav1.GetOptions) (*api.Service, error) + DeleteService(ctx context.Context, name string) error + UpdateService(ctx context.Context, svc *api.Service, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.Service, error) + WatchServices(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + ExportService(ctx context.Context, name string, options metav1.ExportOptions) (*api.Service, error) } // storage puts strong typing around storage calls @@ -49,7 +49,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -57,7 +57,7 @@ func (s *storage) ListServices(ctx genericapirequest.Context, options *metainter 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) if err != nil { return nil, err @@ -65,7 +65,7 @@ func (s *storage) CreateService(ctx genericapirequest.Context, svc *api.Service, 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) if err != nil { return nil, err @@ -73,12 +73,12 @@ func (s *storage) GetService(ctx genericapirequest.Context, name string, options 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) 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) if err != nil { return nil, err @@ -86,13 +86,13 @@ func (s *storage) UpdateService(ctx genericapirequest.Context, svc *api.Service, 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) } // If StandardStorage implements rest.Exporter, returns exported service. // 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) if !isExporter { return nil, fmt.Errorf("export is not supported") diff --git a/pkg/registry/core/service/storage/rest.go b/pkg/registry/core/service/storage/rest.go index 6dea373d189..0190a8b84da 100644 --- a/pkg/registry/core/service/storage/rest.go +++ b/pkg/registry/core/service/storage/rest.go @@ -17,6 +17,7 @@ limitations under the License. package storage import ( + "context" "fmt" "math/rand" "net" @@ -130,23 +131,23 @@ func (rs *REST) NewList() runtime.Object { 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) } -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) } -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) } -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) } -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) 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 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 obj, _, err := rs.services.Delete(ctx, id, options) if err != nil { @@ -320,7 +321,7 @@ func (rs *REST) healthCheckNodePortUpdate(oldService, service *api.Service, node 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{}) if err != nil { return nil, false, err @@ -413,7 +414,7 @@ func (rs *REST) Update(ctx genericapirequest.Context, name string, objInfo rest. var _ = rest.Redirector(&REST{}) // 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". svcScheme, svcName, portStr, valid := utilnet.SplitSchemeNamePort(id) if !valid { @@ -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)) } -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) } -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 { return fmt.Errorf("Address has no target ref, skipping: %v", addr) } diff --git a/pkg/registry/core/service/storage/rest_test.go b/pkg/registry/core/service/storage/rest_test.go index 9fbb7f26fcb..163e5edb411 100644 --- a/pkg/registry/core/service/storage/rest_test.go +++ b/pkg/registry/core/service/storage/rest_test.go @@ -17,6 +17,7 @@ limitations under the License. package storage import ( + "context" "net" "reflect" "strings" @@ -64,12 +65,12 @@ type serviceStorage struct { 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 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 } @@ -77,7 +78,7 @@ func (s *serviceStorage) NewList() runtime.Object { 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) // Copy metadata from internal list into result @@ -102,7 +103,7 @@ func (s *serviceStorage) New() runtime.Object { 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) s.CreatedID = obj.(metav1.Object).GetName() s.Service = svc.DeepCopy() @@ -115,7 +116,7 @@ func (s *serviceStorage) Create(ctx genericapirequest.Context, obj runtime.Objec 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 obj, err := objInfo.UpdatedObject(ctx, s.OldService) if err != nil { @@ -125,24 +126,24 @@ func (s *serviceStorage) Update(ctx genericapirequest.Context, name string, objI 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 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") } -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") } -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") } -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") } @@ -207,7 +208,7 @@ func makeIPNet(t *testing.T) *net.IPNet { 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{}) if err != nil { t.Errorf("Unexpected error: %v", err) diff --git a/pkg/registry/core/service/storage/storage.go b/pkg/registry/core/service/storage/storage.go index 131c7c2ba1d..aa983c8e526 100644 --- a/pkg/registry/core/service/storage/storage.go +++ b/pkg/registry/core/service/storage/storage.go @@ -17,9 +17,10 @@ limitations under the License. package storage import ( + "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -84,11 +85,11 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } diff --git a/pkg/registry/core/service/strategy.go b/pkg/registry/core/service/strategy.go index 278da88ed6b..71cdda7f1c5 100644 --- a/pkg/registry/core/service/strategy.go +++ b/pkg/registry/core/service/strategy.go @@ -17,11 +17,11 @@ limitations under the License. package service import ( + "context" "fmt" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" api "k8s.io/kubernetes/pkg/apis/core" @@ -44,20 +44,20 @@ func (svcStrategy) NamespaceScoped() bool { } // 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.Status = api.ServiceStatus{} } // 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) oldService := old.(*api.Service) newService.Status = oldService.Status } // 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) return validation.ValidateService(service) } @@ -70,7 +70,7 @@ func (svcStrategy) AllowCreateOnUpdate() bool { 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)) } @@ -78,7 +78,7 @@ func (svcStrategy) AllowUnconditionalUpdate() bool { 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) if !ok { // unexpected programmer error @@ -108,7 +108,7 @@ type serviceStatusStrategy struct { var StatusStrategy = serviceStatusStrategy{Strategy} // 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) oldService := old.(*api.Service) // status changes are not allowed to update spec @@ -116,6 +116,6 @@ func (serviceStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj } // 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)) } diff --git a/pkg/registry/core/serviceaccount/BUILD b/pkg/registry/core/serviceaccount/BUILD index 076f7f734f4..a1327e3e070 100644 --- a/pkg/registry/core/serviceaccount/BUILD +++ b/pkg/registry/core/serviceaccount/BUILD @@ -18,7 +18,6 @@ go_library( "//pkg/apis/core/validation: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", ], ) diff --git a/pkg/registry/core/serviceaccount/storage/token.go b/pkg/registry/core/serviceaccount/storage/token.go index c0ee5e9a02b..2194f6da4db 100644 --- a/pkg/registry/core/serviceaccount/storage/token.go +++ b/pkg/registry/core/serviceaccount/storage/token.go @@ -17,6 +17,7 @@ limitations under the License. package storage import ( + "context" "fmt" authenticationapiv1 "k8s.io/api/authentication/v1" @@ -46,7 +47,7 @@ type TokenREST struct { 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 { return nil, err } @@ -120,11 +121,11 @@ func (r *TokenREST) GroupVersionKind(containingGV schema.GroupVersion) schema.Gr } 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 -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) if !found { return ctx diff --git a/pkg/registry/core/serviceaccount/strategy.go b/pkg/registry/core/serviceaccount/strategy.go index 8a6a372070e..a37826dd89b 100644 --- a/pkg/registry/core/serviceaccount/strategy.go +++ b/pkg/registry/core/serviceaccount/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package serviceaccount import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" api "k8s.io/kubernetes/pkg/apis/core" @@ -40,11 +41,11 @@ func (strategy) NamespaceScoped() bool { return true } -func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { +func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { 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)) } @@ -56,7 +57,7 @@ func (strategy) AllowCreateOnUpdate() bool { 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)) } @@ -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)) } diff --git a/pkg/registry/events/event/BUILD b/pkg/registry/events/event/BUILD index 6f69eb73996..8c5f488f587 100644 --- a/pkg/registry/events/event/BUILD +++ b/pkg/registry/events/event/BUILD @@ -16,7 +16,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/labels: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/apiserver/pkg/endpoints/request: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/names:go_default_library", diff --git a/pkg/registry/events/event/strategy.go b/pkg/registry/events/event/strategy.go index f2958c4b17f..a043384ad9c 100644 --- a/pkg/registry/events/event/strategy.go +++ b/pkg/registry/events/event/strategy.go @@ -17,13 +17,13 @@ limitations under the License. package event import ( + "context" "fmt" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" apistorage "k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage/names" @@ -47,15 +47,15 @@ func (eventStrategy) NamespaceScoped() bool { } // 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. -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. -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) return validation.ValidateEvent(event) } @@ -69,7 +69,7 @@ func (eventStrategy) AllowCreateOnUpdate() bool { func (eventStrategy) Canonicalize(obj runtime.Object) {} // 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) return validation.ValidateEvent(event) } diff --git a/pkg/registry/extensions/controller/storage/BUILD b/pkg/registry/extensions/controller/storage/BUILD index 26a1fd9f401..63b97e27259 100644 --- a/pkg/registry/extensions/controller/storage/BUILD +++ b/pkg/registry/extensions/controller/storage/BUILD @@ -39,7 +39,6 @@ go_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/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/rest:go_default_library", ], diff --git a/pkg/registry/extensions/controller/storage/storage.go b/pkg/registry/extensions/controller/storage/storage.go index 774a78911f0..18d9946a7bf 100644 --- a/pkg/registry/extensions/controller/storage/storage.go +++ b/pkg/registry/extensions/controller/storage/storage.go @@ -17,13 +17,13 @@ limitations under the License. package storage import ( + "context" "fmt" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/kubernetes/pkg/apis/autoscaling" @@ -63,7 +63,7 @@ func (r *ScaleREST) New() runtime.Object { 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) if err != nil { return nil, errors.NewNotFound(extensions.Resource("replicationcontrollers/scale"), name) @@ -71,7 +71,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met 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{}) if err != nil { return nil, false, errors.NewNotFound(extensions.Resource("replicationcontrollers/scale"), name) diff --git a/pkg/registry/extensions/ingress/BUILD b/pkg/registry/extensions/ingress/BUILD index 63b888a3282..3c98c6bf104 100644 --- a/pkg/registry/extensions/ingress/BUILD +++ b/pkg/registry/extensions/ingress/BUILD @@ -20,7 +20,6 @@ go_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/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", ], ) diff --git a/pkg/registry/extensions/ingress/storage/BUILD b/pkg/registry/extensions/ingress/storage/BUILD index bffa12adb3e..b4c59e0c770 100644 --- a/pkg/registry/extensions/ingress/storage/BUILD +++ b/pkg/registry/extensions/ingress/storage/BUILD @@ -37,7 +37,6 @@ go_library( "//pkg/registry/extensions/ingress: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/apiserver/pkg/endpoints/request: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/rest:go_default_library", diff --git a/pkg/registry/extensions/ingress/storage/storage.go b/pkg/registry/extensions/ingress/storage/storage.go index 0c7273d8578..26fa74c108c 100644 --- a/pkg/registry/extensions/ingress/storage/storage.go +++ b/pkg/registry/extensions/ingress/storage/storage.go @@ -17,9 +17,10 @@ limitations under the License. package storage import ( + "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -76,11 +77,11 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } diff --git a/pkg/registry/extensions/ingress/strategy.go b/pkg/registry/extensions/ingress/strategy.go index e970d105c2f..1dc2efbd47e 100644 --- a/pkg/registry/extensions/ingress/strategy.go +++ b/pkg/registry/extensions/ingress/strategy.go @@ -17,10 +17,11 @@ limitations under the License. package ingress import ( + "context" + apiequality "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/apis/extensions" @@ -42,7 +43,7 @@ func (ingressStrategy) NamespaceScoped() bool { } // 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) // create cannot set status ingress.Status = extensions.IngressStatus{} @@ -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. -func (ingressStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (ingressStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newIngress := obj.(*extensions.Ingress) oldIngress := old.(*extensions.Ingress) // Update is not allowed to set status @@ -67,7 +68,7 @@ func (ingressStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old } // 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) err := validation.ValidateIngress(ingress) return err @@ -83,7 +84,7 @@ func (ingressStrategy) AllowCreateOnUpdate() bool { } // 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)) updateErrorList := validation.ValidateIngressUpdate(obj.(*extensions.Ingress), old.(*extensions.Ingress)) return append(validationErrorList, updateErrorList...) @@ -101,7 +102,7 @@ type ingressStatusStrategy struct { var StatusStrategy = ingressStatusStrategy{Strategy} // 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) oldIngress := old.(*extensions.Ingress) // status changes are not allowed to update spec @@ -109,6 +110,6 @@ func (ingressStatusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj } // 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)) } diff --git a/pkg/registry/networking/networkpolicy/BUILD b/pkg/registry/networking/networkpolicy/BUILD index f5e83616620..816dbf69aa4 100644 --- a/pkg/registry/networking/networkpolicy/BUILD +++ b/pkg/registry/networking/networkpolicy/BUILD @@ -22,7 +22,6 @@ go_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/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/storage/names:go_default_library", ], diff --git a/pkg/registry/networking/networkpolicy/registry.go b/pkg/registry/networking/networkpolicy/registry.go index 1ddcd2139f2..46566730302 100644 --- a/pkg/registry/networking/networkpolicy/registry.go +++ b/pkg/registry/networking/networkpolicy/registry.go @@ -17,22 +17,23 @@ limitations under the License. package networkpolicy import ( + "context" + metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/kubernetes/pkg/apis/networking" ) // Registry is an interface for things that know how to store NetworkPolicies. type Registry interface { - ListNetworkPolicies(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*networking.NetworkPolicyList, error) - CreateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc) error - UpdateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error - GetNetworkPolicy(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*networking.NetworkPolicy, error) - DeleteNetworkPolicy(ctx genericapirequest.Context, name string) error - WatchNetworkPolicies(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + ListNetworkPolicies(ctx context.Context, options *metainternalversion.ListOptions) (*networking.NetworkPolicyList, error) + CreateNetworkPolicy(ctx context.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc) error + UpdateNetworkPolicy(ctx context.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error + GetNetworkPolicy(ctx context.Context, name string, options *metav1.GetOptions) (*networking.NetworkPolicy, error) + DeleteNetworkPolicy(ctx context.Context, name string) error + WatchNetworkPolicies(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) } // storage puts strong typing around storage calls @@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -55,21 +56,21 @@ func (s *storage) ListNetworkPolicies(ctx genericapirequest.Context, options *me 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) 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) 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) } -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) if err != nil { return nil, err @@ -77,7 +78,7 @@ func (s *storage) GetNetworkPolicy(ctx genericapirequest.Context, name string, o 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) return err } diff --git a/pkg/registry/networking/networkpolicy/strategy.go b/pkg/registry/networking/networkpolicy/strategy.go index 16e0b54a623..8dc3ea7edea 100644 --- a/pkg/registry/networking/networkpolicy/strategy.go +++ b/pkg/registry/networking/networkpolicy/strategy.go @@ -17,11 +17,11 @@ limitations under the License. package networkpolicy import ( + "context" "reflect" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/apis/networking" @@ -43,13 +43,13 @@ func (networkPolicyStrategy) NamespaceScoped() bool { } // 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.Generation = 1 } // 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) oldNetworkPolicy := old.(*networking.NetworkPolicy) @@ -62,7 +62,7 @@ func (networkPolicyStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj } // 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) return validation.ValidateNetworkPolicy(networkPolicy) } @@ -76,7 +76,7 @@ func (networkPolicyStrategy) AllowCreateOnUpdate() bool { } // 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)) updateErrorList := validation.ValidateNetworkPolicyUpdate(obj.(*networking.NetworkPolicy), old.(*networking.NetworkPolicy)) return append(validationErrorList, updateErrorList...) diff --git a/pkg/registry/policy/poddisruptionbudget/BUILD b/pkg/registry/policy/poddisruptionbudget/BUILD index bc8ab60b6d8..804d7a2c979 100644 --- a/pkg/registry/policy/poddisruptionbudget/BUILD +++ b/pkg/registry/policy/poddisruptionbudget/BUILD @@ -20,7 +20,6 @@ go_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/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", ], ) diff --git a/pkg/registry/policy/poddisruptionbudget/storage/BUILD b/pkg/registry/policy/poddisruptionbudget/storage/BUILD index 7c1ad4c6012..c291e29a83b 100644 --- a/pkg/registry/policy/poddisruptionbudget/storage/BUILD +++ b/pkg/registry/policy/poddisruptionbudget/storage/BUILD @@ -37,7 +37,6 @@ go_library( "//pkg/registry/policy/poddisruptionbudget: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/apiserver/pkg/endpoints/request: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/rest:go_default_library", diff --git a/pkg/registry/policy/poddisruptionbudget/storage/storage.go b/pkg/registry/policy/poddisruptionbudget/storage/storage.go index 40aff589d1d..b6915740148 100644 --- a/pkg/registry/policy/poddisruptionbudget/storage/storage.go +++ b/pkg/registry/policy/poddisruptionbudget/storage/storage.go @@ -17,9 +17,10 @@ limitations under the License. package storage import ( + "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -73,11 +74,11 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } diff --git a/pkg/registry/policy/poddisruptionbudget/strategy.go b/pkg/registry/policy/poddisruptionbudget/strategy.go index 382dc92ab2c..36e940b6acb 100644 --- a/pkg/registry/policy/poddisruptionbudget/strategy.go +++ b/pkg/registry/policy/poddisruptionbudget/strategy.go @@ -17,10 +17,11 @@ limitations under the License. package poddisruptionbudget import ( + "context" + apiequality "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/apis/policy" @@ -42,7 +43,7 @@ func (podDisruptionBudgetStrategy) NamespaceScoped() bool { } // 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) // create cannot set status podDisruptionBudget.Status = policy.PodDisruptionBudgetStatus{} @@ -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. -func (podDisruptionBudgetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (podDisruptionBudgetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newPodDisruptionBudget := obj.(*policy.PodDisruptionBudget) oldPodDisruptionBudget := old.(*policy.PodDisruptionBudget) // Update is not allowed to set status @@ -66,7 +67,7 @@ func (podDisruptionBudgetStrategy) PrepareForUpdate(ctx genericapirequest.Contex } // 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) return validation.ValidatePodDisruptionBudget(podDisruptionBudget) } @@ -81,7 +82,7 @@ func (podDisruptionBudgetStrategy) AllowCreateOnUpdate() bool { } // 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)) updateErrorList := validation.ValidatePodDisruptionBudgetUpdate(obj.(*policy.PodDisruptionBudget), old.(*policy.PodDisruptionBudget)) return append(validationErrorList, updateErrorList...) @@ -100,7 +101,7 @@ type podDisruptionBudgetStatusStrategy struct { var StatusStrategy = podDisruptionBudgetStatusStrategy{Strategy} // 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) oldPodDisruptionBudget := old.(*policy.PodDisruptionBudget) // status changes are not allowed to update spec @@ -108,7 +109,7 @@ func (podDisruptionBudgetStatusStrategy) PrepareForUpdate(ctx genericapirequest. } // 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. return field.ErrorList{} // return validation.ValidatePodDisruptionBudgetStatusUpdate(obj.(*policy.PodDisruptionBudget), old.(*policy.PodDisruptionBudget)) diff --git a/pkg/registry/policy/podsecuritypolicy/BUILD b/pkg/registry/policy/podsecuritypolicy/BUILD index 28d528e8b24..659c7ec19fc 100644 --- a/pkg/registry/policy/podsecuritypolicy/BUILD +++ b/pkg/registry/policy/podsecuritypolicy/BUILD @@ -18,7 +18,6 @@ go_library( "//pkg/apis/policy/validation: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", ], diff --git a/pkg/registry/policy/podsecuritypolicy/strategy.go b/pkg/registry/policy/podsecuritypolicy/strategy.go index 06d48e3a797..668bafa3319 100644 --- a/pkg/registry/policy/podsecuritypolicy/strategy.go +++ b/pkg/registry/policy/podsecuritypolicy/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package podsecuritypolicy import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" @@ -53,19 +54,19 @@ func (strategy) AllowUnconditionalUpdate() bool { 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) 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)) } -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)) } diff --git a/pkg/registry/rbac/clusterrole/policybased/BUILD b/pkg/registry/rbac/clusterrole/policybased/BUILD index e58b32eac07..77afcb6cff6 100644 --- a/pkg/registry/rbac/clusterrole/policybased/BUILD +++ b/pkg/registry/rbac/clusterrole/policybased/BUILD @@ -16,7 +16,6 @@ go_library( "//pkg/registry/rbac/validation: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", ], ) diff --git a/pkg/registry/rbac/clusterrole/policybased/storage.go b/pkg/registry/rbac/clusterrole/policybased/storage.go index 0b32fdebf1c..6d1f461d15f 100644 --- a/pkg/registry/rbac/clusterrole/policybased/storage.go +++ b/pkg/registry/rbac/clusterrole/policybased/storage.go @@ -18,11 +18,11 @@ limitations under the License. package policybased import ( + "context" "errors" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" kapihelper "k8s.io/kubernetes/pkg/apis/core/helper" "k8s.io/kubernetes/pkg/apis/rbac" @@ -47,7 +47,7 @@ var fullAuthority = []rbac.PolicyRule{ 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) { return s.StandardStorage.Create(ctx, obj, createValidatingAdmission, includeUninitialized) } @@ -67,12 +67,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, crea 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) { 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) oldClusterRole := oldObj.(*rbac.ClusterRole) diff --git a/pkg/registry/rbac/clusterrole/registry.go b/pkg/registry/rbac/clusterrole/registry.go index b8b1a21b54a..a6244ac087a 100644 --- a/pkg/registry/rbac/clusterrole/registry.go +++ b/pkg/registry/rbac/clusterrole/registry.go @@ -17,6 +17,8 @@ limitations under the License. package clusterrole import ( + "context" + metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" @@ -27,12 +29,12 @@ import ( // Registry is an interface for things that know how to store ClusterRoles. type Registry interface { - ListClusterRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleList, error) - CreateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc) error - UpdateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error - GetClusterRole(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRole, error) - DeleteClusterRole(ctx genericapirequest.Context, name string) error - WatchClusterRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + ListClusterRoles(ctx context.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleList, error) + CreateClusterRole(ctx context.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc) error + UpdateClusterRole(ctx context.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error + GetClusterRole(ctx context.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRole, error) + DeleteClusterRole(ctx context.Context, name string) error + WatchClusterRoles(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) } // storage puts strong typing around storage calls @@ -46,7 +48,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -55,21 +57,21 @@ func (s *storage) ListClusterRoles(ctx genericapirequest.Context, options *metai 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) 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) 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) } -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) if err != nil { return nil, err @@ -77,7 +79,7 @@ func (s *storage) GetClusterRole(ctx genericapirequest.Context, name string, opt 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) return err } diff --git a/pkg/registry/rbac/clusterrole/strategy.go b/pkg/registry/rbac/clusterrole/strategy.go index e1be1f06cfd..eb547579359 100644 --- a/pkg/registry/rbac/clusterrole/strategy.go +++ b/pkg/registry/rbac/clusterrole/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package clusterrole import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" @@ -55,12 +56,12 @@ func (strategy) AllowCreateOnUpdate() bool { // PrepareForCreate clears fields that are not allowed to be set by end users // on creation. -func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { +func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { _ = obj.(*rbac.ClusterRole) } // 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) oldClusterRole := old.(*rbac.ClusterRole) @@ -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. -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) return validation.ValidateClusterRole(clusterRole) } @@ -79,7 +80,7 @@ func (strategy) Canonicalize(obj runtime.Object) { } // 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) errorList := validation.ValidateClusterRole(newObj) return append(errorList, validation.ValidateClusterRoleUpdate(newObj, old.(*rbac.ClusterRole))...) diff --git a/pkg/registry/rbac/clusterrolebinding/policybased/BUILD b/pkg/registry/rbac/clusterrolebinding/policybased/BUILD index 2141978eec9..66d61e93d13 100644 --- a/pkg/registry/rbac/clusterrolebinding/policybased/BUILD +++ b/pkg/registry/rbac/clusterrolebinding/policybased/BUILD @@ -18,7 +18,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1: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/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", ], ) diff --git a/pkg/registry/rbac/clusterrolebinding/policybased/storage.go b/pkg/registry/rbac/clusterrolebinding/policybased/storage.go index 12264dba462..6ff8a883851 100644 --- a/pkg/registry/rbac/clusterrolebinding/policybased/storage.go +++ b/pkg/registry/rbac/clusterrolebinding/policybased/storage.go @@ -18,11 +18,12 @@ limitations under the License. package policybased import ( + "context" + "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apiserver/pkg/authorization/authorizer" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" kapihelper "k8s.io/kubernetes/pkg/apis/core/helper" "k8s.io/kubernetes/pkg/apis/rbac" @@ -44,7 +45,7 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe 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) { return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized) } @@ -64,12 +65,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, crea 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) { 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) // if we're only mutating fields needed for the GC to eventually delete this obj, return diff --git a/pkg/registry/rbac/clusterrolebinding/registry.go b/pkg/registry/rbac/clusterrolebinding/registry.go index 2a3524e6ed3..02ba53bf8c8 100644 --- a/pkg/registry/rbac/clusterrolebinding/registry.go +++ b/pkg/registry/rbac/clusterrolebinding/registry.go @@ -17,6 +17,8 @@ limitations under the License. package clusterrolebinding import ( + "context" + metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" @@ -27,12 +29,12 @@ import ( // Registry is an interface for things that know how to store ClusterRoleBindings. type Registry interface { - ListClusterRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleBindingList, error) - CreateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc) error - UpdateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error - GetClusterRoleBinding(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRoleBinding, error) - DeleteClusterRoleBinding(ctx genericapirequest.Context, name string) error - WatchClusterRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + ListClusterRoleBindings(ctx context.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleBindingList, error) + CreateClusterRoleBinding(ctx context.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc) error + UpdateClusterRoleBinding(ctx context.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error + GetClusterRoleBinding(ctx context.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRoleBinding, error) + DeleteClusterRoleBinding(ctx context.Context, name string) error + WatchClusterRoleBindings(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) } // storage puts strong typing around storage calls @@ -46,7 +48,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -55,21 +57,21 @@ func (s *storage) ListClusterRoleBindings(ctx genericapirequest.Context, options 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) 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) 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) } -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) if err != nil { return nil, err @@ -77,7 +79,7 @@ func (s *storage) GetClusterRoleBinding(ctx genericapirequest.Context, name stri 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) return err } diff --git a/pkg/registry/rbac/clusterrolebinding/strategy.go b/pkg/registry/rbac/clusterrolebinding/strategy.go index 1b2e33772d4..e7be7a634ab 100644 --- a/pkg/registry/rbac/clusterrolebinding/strategy.go +++ b/pkg/registry/rbac/clusterrolebinding/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package clusterrolebinding import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" @@ -55,12 +56,12 @@ func (strategy) AllowCreateOnUpdate() bool { // PrepareForCreate clears fields that are not allowed to be set by end users // on creation. -func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { +func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { _ = obj.(*rbac.ClusterRoleBinding) } // 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) oldClusterRoleBinding := old.(*rbac.ClusterRoleBinding) @@ -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. -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) return validation.ValidateClusterRoleBinding(clusterRoleBinding) } @@ -79,7 +80,7 @@ func (strategy) Canonicalize(obj runtime.Object) { } // 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) errorList := validation.ValidateClusterRoleBinding(newObj) return append(errorList, validation.ValidateClusterRoleBindingUpdate(newObj, old.(*rbac.ClusterRoleBinding))...) diff --git a/pkg/registry/rbac/escalation_check.go b/pkg/registry/rbac/escalation_check.go index 4ac1392fbbd..74d6aff7cda 100644 --- a/pkg/registry/rbac/escalation_check.go +++ b/pkg/registry/rbac/escalation_check.go @@ -17,6 +17,7 @@ limitations under the License. package rbac import ( + "context" "fmt" utilruntime "k8s.io/apimachinery/pkg/util/runtime" @@ -26,7 +27,7 @@ import ( "k8s.io/kubernetes/pkg/apis/rbac" ) -func EscalationAllowed(ctx genericapirequest.Context) bool { +func EscalationAllowed(ctx context.Context) bool { u, ok := genericapirequest.UserFrom(ctx) if !ok { return false @@ -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 -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 { return false } diff --git a/pkg/registry/rbac/role/policybased/BUILD b/pkg/registry/rbac/role/policybased/BUILD index 65fa12025f0..0c1e560666b 100644 --- a/pkg/registry/rbac/role/policybased/BUILD +++ b/pkg/registry/rbac/role/policybased/BUILD @@ -16,7 +16,6 @@ go_library( "//pkg/registry/rbac/validation: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", ], ) diff --git a/pkg/registry/rbac/role/policybased/storage.go b/pkg/registry/rbac/role/policybased/storage.go index d67e3777fe0..65579d9eacb 100644 --- a/pkg/registry/rbac/role/policybased/storage.go +++ b/pkg/registry/rbac/role/policybased/storage.go @@ -18,9 +18,10 @@ limitations under the License. package policybased import ( + "context" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" kapihelper "k8s.io/kubernetes/pkg/apis/core/helper" "k8s.io/kubernetes/pkg/apis/rbac" @@ -40,7 +41,7 @@ func NewStorage(s rest.StandardStorage, ruleResolver rbacregistryvalidation.Auth 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) { return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized) } @@ -53,12 +54,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, crea 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) { 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) // if we're only mutating fields needed for the GC to eventually delete this obj, return diff --git a/pkg/registry/rbac/role/registry.go b/pkg/registry/rbac/role/registry.go index bbf26b5e23d..6f026b01642 100644 --- a/pkg/registry/rbac/role/registry.go +++ b/pkg/registry/rbac/role/registry.go @@ -17,6 +17,8 @@ limitations under the License. package role import ( + "context" + metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" @@ -27,12 +29,12 @@ import ( // Registry is an interface for things that know how to store Roles. type Registry interface { - ListRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.RoleList, error) - CreateRole(ctx genericapirequest.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc) error - UpdateRole(ctx genericapirequest.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error - GetRole(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.Role, error) - DeleteRole(ctx genericapirequest.Context, name string) error - WatchRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + ListRoles(ctx context.Context, options *metainternalversion.ListOptions) (*rbac.RoleList, error) + CreateRole(ctx context.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc) error + UpdateRole(ctx context.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error + GetRole(ctx context.Context, name string, options *metav1.GetOptions) (*rbac.Role, error) + DeleteRole(ctx context.Context, name string) error + WatchRoles(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) } // storage puts strong typing around storage calls @@ -46,7 +48,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -55,22 +57,22 @@ func (s *storage) ListRoles(ctx genericapirequest.Context, options *metainternal 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) 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? _, _, err := s.Update(ctx, role.Name, rest.DefaultUpdatedObjectInfo(role), createValidation, updateValidation) 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) } -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) if err != nil { return nil, err @@ -78,7 +80,7 @@ func (s *storage) GetRole(ctx genericapirequest.Context, name string, options *m 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) return err } diff --git a/pkg/registry/rbac/role/strategy.go b/pkg/registry/rbac/role/strategy.go index b815f98db40..b6358b3bfd7 100644 --- a/pkg/registry/rbac/role/strategy.go +++ b/pkg/registry/rbac/role/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package role import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" @@ -55,12 +56,12 @@ func (strategy) AllowCreateOnUpdate() bool { // PrepareForCreate clears fields that are not allowed to be set by end users // on creation. -func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { +func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { _ = obj.(*rbac.Role) } // 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) oldRole := old.(*rbac.Role) @@ -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. -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) return validation.ValidateRole(role) } @@ -79,7 +80,7 @@ func (strategy) Canonicalize(obj runtime.Object) { } // 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) errorList := validation.ValidateRole(newObj) return append(errorList, validation.ValidateRoleUpdate(newObj, old.(*rbac.Role))...) diff --git a/pkg/registry/rbac/rolebinding/policybased/storage.go b/pkg/registry/rbac/rolebinding/policybased/storage.go index 9e539a77aca..4c32e354ae0 100644 --- a/pkg/registry/rbac/rolebinding/policybased/storage.go +++ b/pkg/registry/rbac/rolebinding/policybased/storage.go @@ -18,6 +18,8 @@ limitations under the License. package policybased import ( + "context" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apiserver/pkg/authorization/authorizer" @@ -43,7 +45,7 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe 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) { return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized) } @@ -70,12 +72,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, crea 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) { 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). // The namespace in the object can be empty until StandardStorage.Update()->BeforeUpdate() populates it from the context. namespace, ok := genericapirequest.NamespaceFrom(ctx) diff --git a/pkg/registry/rbac/rolebinding/registry.go b/pkg/registry/rbac/rolebinding/registry.go index c708d088bb0..cd0fc2c746d 100644 --- a/pkg/registry/rbac/rolebinding/registry.go +++ b/pkg/registry/rbac/rolebinding/registry.go @@ -17,6 +17,8 @@ limitations under the License. package rolebinding import ( + "context" + metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" @@ -27,12 +29,12 @@ import ( // Registry is an interface for things that know how to store RoleBindings. type Registry interface { - ListRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.RoleBindingList, error) - CreateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc) error - UpdateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error - GetRoleBinding(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.RoleBinding, error) - DeleteRoleBinding(ctx genericapirequest.Context, name string) error - WatchRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + ListRoleBindings(ctx context.Context, options *metainternalversion.ListOptions) (*rbac.RoleBindingList, error) + CreateRoleBinding(ctx context.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc) error + UpdateRoleBinding(ctx context.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error + GetRoleBinding(ctx context.Context, name string, options *metav1.GetOptions) (*rbac.RoleBinding, error) + DeleteRoleBinding(ctx context.Context, name string) error + WatchRoleBindings(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) } // storage puts strong typing around storage calls @@ -46,7 +48,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -55,22 +57,22 @@ func (s *storage) ListRoleBindings(ctx genericapirequest.Context, options *metai 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 _, err := s.Create(ctx, roleBinding, createValidation, false) 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) 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) } -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) if err != nil { return nil, err @@ -78,7 +80,7 @@ func (s *storage) GetRoleBinding(ctx genericapirequest.Context, name string, opt 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) return err } diff --git a/pkg/registry/rbac/rolebinding/strategy.go b/pkg/registry/rbac/rolebinding/strategy.go index 136cffd34b9..2715b235324 100644 --- a/pkg/registry/rbac/rolebinding/strategy.go +++ b/pkg/registry/rbac/rolebinding/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package rolebinding import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" @@ -55,12 +56,12 @@ func (strategy) AllowCreateOnUpdate() bool { // PrepareForCreate clears fields that are not allowed to be set by end users // on creation. -func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { +func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { _ = obj.(*rbac.RoleBinding) } // 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) oldRoleBinding := old.(*rbac.RoleBinding) @@ -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. -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) return validation.ValidateRoleBinding(roleBinding) } @@ -79,7 +80,7 @@ func (strategy) Canonicalize(obj runtime.Object) { } // 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) errorList := validation.ValidateRoleBinding(newObj) return append(errorList, validation.ValidateRoleBindingUpdate(newObj, old.(*rbac.RoleBinding))...) diff --git a/pkg/registry/rbac/validation/rule.go b/pkg/registry/rbac/validation/rule.go index 5c8a2406f4b..e101470ce43 100644 --- a/pkg/registry/rbac/validation/rule.go +++ b/pkg/registry/rbac/validation/rule.go @@ -17,6 +17,7 @@ limitations under the License. package validation import ( + "context" "errors" "fmt" @@ -46,7 +47,7 @@ type AuthorizationRuleResolver interface { } // 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{} user, ok := genericapirequest.UserFrom(ctx) diff --git a/pkg/registry/registrytest/endpoint.go b/pkg/registry/registrytest/endpoint.go index 170b9595542..cc22b478e1e 100644 --- a/pkg/registry/registrytest/endpoint.go +++ b/pkg/registry/registrytest/endpoint.go @@ -17,6 +17,7 @@ limitations under the License. package registrytest import ( + "context" "fmt" "sync" @@ -24,7 +25,6 @@ import ( metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" api "k8s.io/kubernetes/pkg/apis/core" ) @@ -38,7 +38,7 @@ type EndpointRegistry struct { 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 e.lock.Lock() defer e.lock.Unlock() @@ -46,7 +46,7 @@ func (e *EndpointRegistry) ListEndpoints(ctx genericapirequest.Context, options 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 e.lock.Lock() defer e.lock.Unlock() @@ -63,11 +63,11 @@ func (e *EndpointRegistry) GetEndpoints(ctx genericapirequest.Context, name stri 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!") } -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 e.lock.Lock() defer e.lock.Unlock() @@ -94,7 +94,7 @@ func (e *EndpointRegistry) UpdateEndpoints(ctx genericapirequest.Context, endpoi 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 e.lock.Lock() defer e.lock.Unlock() diff --git a/pkg/registry/registrytest/node.go b/pkg/registry/registrytest/node.go index e4d813dfe92..9186006a2fc 100644 --- a/pkg/registry/registrytest/node.go +++ b/pkg/registry/registrytest/node.go @@ -17,13 +17,13 @@ limitations under the License. package registrytest import ( + "context" "sync" "k8s.io/apimachinery/pkg/api/errors" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" api "k8s.io/kubernetes/pkg/apis/core" ) @@ -60,13 +60,13 @@ func (r *NodeRegistry) SetError(err error) { 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() defer r.Unlock() 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() defer r.Unlock() r.Node = node.Name @@ -74,7 +74,7 @@ func (r *NodeRegistry) CreateNode(ctx genericapirequest.Context, node *api.Node) 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() defer r.Unlock() for i, item := range r.Nodes.Items { @@ -86,7 +86,7 @@ func (r *NodeRegistry) UpdateNode(ctx genericapirequest.Context, node *api.Node) 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() defer r.Unlock() if r.Err != nil { @@ -100,7 +100,7 @@ func (r *NodeRegistry) GetNode(ctx genericapirequest.Context, nodeID string, opt 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() defer r.Unlock() var newList []api.Node @@ -113,6 +113,6 @@ func (r *NodeRegistry) DeleteNode(ctx genericapirequest.Context, nodeID string) 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 } diff --git a/pkg/registry/registrytest/service.go b/pkg/registry/registrytest/service.go index 136d34153bd..490bc0e37e5 100644 --- a/pkg/registry/registrytest/service.go +++ b/pkg/registry/registrytest/service.go @@ -17,6 +17,7 @@ limitations under the License. package registrytest import ( + "context" "sync" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" @@ -49,7 +50,7 @@ func (r *ServiceRegistry) SetError(err error) { 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() defer r.mu.Unlock() @@ -73,7 +74,7 @@ func (r *ServiceRegistry) ListServices(ctx genericapirequest.Context, options *m 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() defer r.mu.Unlock() @@ -83,7 +84,7 @@ func (r *ServiceRegistry) CreateService(ctx genericapirequest.Context, svc *api. 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() defer r.mu.Unlock() @@ -91,7 +92,7 @@ func (r *ServiceRegistry) GetService(ctx genericapirequest.Context, id string, o 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() defer r.mu.Unlock() @@ -100,7 +101,7 @@ func (r *ServiceRegistry) DeleteService(ctx genericapirequest.Context, id string 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() defer r.mu.Unlock() @@ -110,14 +111,14 @@ func (r *ServiceRegistry) UpdateService(ctx genericapirequest.Context, svc *api. 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() defer r.mu.Unlock() 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() defer r.mu.Unlock() diff --git a/pkg/registry/scheduling/priorityclass/BUILD b/pkg/registry/scheduling/priorityclass/BUILD index 498ccb32c02..579329ebb80 100644 --- a/pkg/registry/scheduling/priorityclass/BUILD +++ b/pkg/registry/scheduling/priorityclass/BUILD @@ -34,7 +34,6 @@ go_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/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/storage/names:go_default_library", ], diff --git a/pkg/registry/scheduling/priorityclass/registry.go b/pkg/registry/scheduling/priorityclass/registry.go index 5e4c44dc161..c9c36989e63 100644 --- a/pkg/registry/scheduling/priorityclass/registry.go +++ b/pkg/registry/scheduling/priorityclass/registry.go @@ -17,22 +17,23 @@ limitations under the License. package priorityclass import ( + "context" + metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/kubernetes/pkg/apis/scheduling" ) // Registry is an interface for things that know how to store PriorityClass. type Registry interface { - ListPriorityClasses(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*scheduling.PriorityClassList, error) - CreatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc) error - UpdatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error - GetPriorityClass(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*scheduling.PriorityClass, error) - DeletePriorityClass(ctx genericapirequest.Context, name string) error - WatchPriorityClasses(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + ListPriorityClasses(ctx context.Context, options *metainternalversion.ListOptions) (*scheduling.PriorityClassList, error) + CreatePriorityClass(ctx context.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc) error + UpdatePriorityClass(ctx context.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error + GetPriorityClass(ctx context.Context, name string, options *metav1.GetOptions) (*scheduling.PriorityClass, error) + DeletePriorityClass(ctx context.Context, name string) error + WatchPriorityClasses(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) } // storage puts strong typing around storage calls @@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -55,21 +56,21 @@ func (s *storage) ListPriorityClasses(ctx genericapirequest.Context, options *me 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) 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) 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) } -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) if err != nil { return nil, err @@ -77,7 +78,7 @@ func (s *storage) GetPriorityClass(ctx genericapirequest.Context, name string, o 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) return err } diff --git a/pkg/registry/scheduling/priorityclass/storage/BUILD b/pkg/registry/scheduling/priorityclass/storage/BUILD index 472ea8dee94..6cff8319683 100644 --- a/pkg/registry/scheduling/priorityclass/storage/BUILD +++ b/pkg/registry/scheduling/priorityclass/storage/BUILD @@ -34,7 +34,6 @@ go_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/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/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", diff --git a/pkg/registry/scheduling/priorityclass/storage/storage.go b/pkg/registry/scheduling/priorityclass/storage/storage.go index da78b01e1eb..e0594bb16cc 100644 --- a/pkg/registry/scheduling/priorityclass/storage/storage.go +++ b/pkg/registry/scheduling/priorityclass/storage/storage.go @@ -17,12 +17,12 @@ limitations under the License. package storage import ( + "context" "errors" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -63,7 +63,7 @@ func (r *REST) ShortNames() []string { } // 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() { 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")) diff --git a/pkg/registry/scheduling/priorityclass/strategy.go b/pkg/registry/scheduling/priorityclass/strategy.go index 45fb3eacb0b..0a5b87a55ac 100644 --- a/pkg/registry/scheduling/priorityclass/strategy.go +++ b/pkg/registry/scheduling/priorityclass/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package priorityclass import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/apis/scheduling" @@ -41,19 +42,19 @@ func (priorityClassStrategy) NamespaceScoped() bool { } // 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.Generation = 1 } // 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) _ = old.(*scheduling.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) return validation.ValidatePriorityClass(pc) } @@ -67,7 +68,7 @@ func (priorityClassStrategy) AllowCreateOnUpdate() bool { } // 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)) } diff --git a/pkg/registry/settings/podpreset/BUILD b/pkg/registry/settings/podpreset/BUILD index 5d58bda6a7d..e495b532954 100644 --- a/pkg/registry/settings/podpreset/BUILD +++ b/pkg/registry/settings/podpreset/BUILD @@ -23,7 +23,6 @@ go_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/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/storage/names:go_default_library", ], diff --git a/pkg/registry/settings/podpreset/registry.go b/pkg/registry/settings/podpreset/registry.go index 74b056d0e67..e90032b9863 100644 --- a/pkg/registry/settings/podpreset/registry.go +++ b/pkg/registry/settings/podpreset/registry.go @@ -17,22 +17,23 @@ limitations under the License. package podpreset import ( + "context" + metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/kubernetes/pkg/apis/settings" ) // Registry is an interface for things that know how to store PodPresets. type Registry interface { - ListPodPresets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*settings.PodPresetList, error) - CreatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc) error - UpdatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error - GetPodPreset(ctx genericapirequest.Context, ppID string, options *metav1.GetOptions) (*settings.PodPreset, error) - DeletePodPreset(ctx genericapirequest.Context, ppID string) error - WatchPodPresets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + ListPodPresets(ctx context.Context, options *metainternalversion.ListOptions) (*settings.PodPresetList, error) + CreatePodPreset(ctx context.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc) error + UpdatePodPreset(ctx context.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error + GetPodPreset(ctx context.Context, ppID string, options *metav1.GetOptions) (*settings.PodPreset, error) + DeletePodPreset(ctx context.Context, ppID string) error + WatchPodPresets(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) } // storage puts strong typing around storage calls @@ -46,7 +47,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -55,21 +56,21 @@ func (s *storage) ListPodPresets(ctx genericapirequest.Context, options *metaint 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) 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) 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) } -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) if err != nil { return nil, err @@ -77,7 +78,7 @@ func (s *storage) GetPodPreset(ctx genericapirequest.Context, name string, optio 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) return err } diff --git a/pkg/registry/settings/podpreset/strategy.go b/pkg/registry/settings/podpreset/strategy.go index eaeb927926b..b6e2f2c7b3e 100644 --- a/pkg/registry/settings/podpreset/strategy.go +++ b/pkg/registry/settings/podpreset/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package podpreset import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/pod" @@ -42,7 +43,7 @@ func (podPresetStrategy) NamespaceScoped() bool { } // 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.Generation = 1 @@ -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. -func (podPresetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (podPresetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newPodPreset := obj.(*settings.PodPreset) oldPodPreset := old.(*settings.PodPreset) @@ -62,7 +63,7 @@ func (podPresetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol } // 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) return validation.ValidatePodPreset(pip) } @@ -76,7 +77,7 @@ func (podPresetStrategy) AllowCreateOnUpdate() bool { } // 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)) updateErrorList := validation.ValidatePodPresetUpdate(obj.(*settings.PodPreset), old.(*settings.PodPreset)) return append(validationErrorList, updateErrorList...) diff --git a/pkg/registry/storage/storageclass/BUILD b/pkg/registry/storage/storageclass/BUILD index d0a99123f0a..d251687bcb0 100644 --- a/pkg/registry/storage/storageclass/BUILD +++ b/pkg/registry/storage/storageclass/BUILD @@ -21,7 +21,6 @@ go_library( "//pkg/features: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", "//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library", ], diff --git a/pkg/registry/storage/storageclass/strategy.go b/pkg/registry/storage/storageclass/strategy.go index b1cbf49ebcf..b570d39e239 100644 --- a/pkg/registry/storage/storageclass/strategy.go +++ b/pkg/registry/storage/storageclass/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package storageclass import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/kubernetes/pkg/api/legacyscheme" @@ -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. -func (storageClassStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { +func (storageClassStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { class := obj.(*storage.StorageClass) if !utilfeature.DefaultFeatureGate.Enabled(features.ExpandPersistentVolumes) { @@ -54,7 +55,7 @@ func (storageClassStrategy) PrepareForCreate(ctx genericapirequest.Context, obj 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) return validation.ValidateStorageClass(storageClass) } @@ -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 -func (storageClassStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (storageClassStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newClass := obj.(*storage.StorageClass) oldClass := old.(*storage.StorageClass) @@ -80,7 +81,7 @@ func (storageClassStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, 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)) return append(errorList, validation.ValidateStorageClassUpdate(obj.(*storage.StorageClass), old.(*storage.StorageClass))...) } diff --git a/pkg/registry/storage/volumeattachment/BUILD b/pkg/registry/storage/volumeattachment/BUILD index 582dd553311..40f3de8bcb2 100644 --- a/pkg/registry/storage/volumeattachment/BUILD +++ b/pkg/registry/storage/volumeattachment/BUILD @@ -14,7 +14,6 @@ go_library( "//pkg/apis/storage/validation: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/apiserver/pkg/endpoints/request:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", ], ) diff --git a/pkg/registry/storage/volumeattachment/strategy.go b/pkg/registry/storage/volumeattachment/strategy.go index e319a0d878e..9ee76f1874a 100644 --- a/pkg/registry/storage/volumeattachment/strategy.go +++ b/pkg/registry/storage/volumeattachment/strategy.go @@ -17,9 +17,10 @@ limitations under the License. package volumeattachment import ( + "context" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/storage/names" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/apis/storage" @@ -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. -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) return validation.ValidateVolumeAttachment(volumeAttachment) } @@ -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 -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) oldVolumeAttachmentObj := old.(*storage.VolumeAttachment) errorList := validation.ValidateVolumeAttachment(newVolumeAttachmentObj) diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/BUILD b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/BUILD index 1650919915b..98184ae6b78 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/BUILD +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/BUILD @@ -35,7 +35,6 @@ go_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/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/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd.go index bf54fe33b9a..f0cb5fda8f8 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd.go @@ -17,6 +17,7 @@ limitations under the License. package customresource import ( + "context" "fmt" "strings" @@ -26,7 +27,6 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -121,12 +121,12 @@ func (r *StatusREST) New() runtime.Object { } // 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) } // 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) } @@ -150,7 +150,7 @@ func (r *ScaleREST) New() runtime.Object { 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) if err != nil { return nil, err @@ -166,7 +166,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met 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{}) if err != nil { return nil, false, err diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/registry.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/registry.go index a0fd086d0ac..e3d46803653 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/registry.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/registry.go @@ -17,6 +17,7 @@ limitations under the License. package customresource import ( + "context" "fmt" "strings" @@ -26,18 +27,17 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" ) // Registry is an interface for things that know how to store CustomResources. type Registry interface { - ListCustomResources(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*unstructured.UnstructuredList, error) - WatchCustomResources(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) - GetCustomResource(ctx genericapirequest.Context, customResourceID string, options *metav1.GetOptions) (*unstructured.Unstructured, error) - CreateCustomResource(ctx genericapirequest.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) - DeleteCustomResource(ctx genericapirequest.Context, customResourceID string) error + ListCustomResources(ctx context.Context, options *metainternalversion.ListOptions) (*unstructured.UnstructuredList, error) + WatchCustomResources(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) + GetCustomResource(ctx context.Context, customResourceID string, options *metav1.GetOptions) (*unstructured.Unstructured, error) + CreateCustomResource(ctx context.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc) (*unstructured.Unstructured, error) + UpdateCustomResource(ctx context.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*unstructured.Unstructured, error) + DeleteCustomResource(ctx context.Context, customResourceID string) error } // storage puts strong typing around storage calls @@ -51,7 +51,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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() { return nil, fmt.Errorf("field selector not supported yet") } @@ -62,11 +62,11 @@ func (s *storage) ListCustomResources(ctx genericapirequest.Context, options *me 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) } -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) customResource, ok := obj.(*unstructured.Unstructured) if !ok { @@ -82,7 +82,7 @@ func (s *storage) GetCustomResource(ctx genericapirequest.Context, customResourc 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) if err != nil { return nil, err @@ -90,7 +90,7 @@ func (s *storage) CreateCustomResource(ctx genericapirequest.Context, customReso 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) if err != nil { return nil, err @@ -98,7 +98,7 @@ func (s *storage) UpdateCustomResource(ctx genericapirequest.Context, customReso 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) return err } diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go index dab6bf47a3f..c98b06c4b32 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go @@ -17,10 +17,11 @@ limitations under the License. package customresource import ( + "context" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" ) type statusStrategy struct { @@ -31,7 +32,7 @@ func NewStatusStrategy(strategy customResourceStrategy) statusStrategy { 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) oldCustomResourceObject := old.(*unstructured.Unstructured) @@ -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. -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) } diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/strategy.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/strategy.go index 092bfc89c4e..4895e287af1 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/strategy.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/strategy.go @@ -17,6 +17,8 @@ limitations under the License. package customresource import ( + "context" + "github.com/go-openapi/validate" apiequality "k8s.io/apimachinery/pkg/api/equality" @@ -28,7 +30,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" apiserverstorage "k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage/names" utilfeature "k8s.io/apiserver/pkg/util/feature" @@ -69,7 +70,7 @@ func (a customResourceStrategy) NamespaceScoped() bool { } // 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 { customResourceObject := obj.(*unstructured.Unstructured) customResource := customResourceObject.UnstructuredContent() @@ -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. -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 { return } @@ -126,7 +127,7 @@ func (a customResourceStrategy) PrepareForUpdate(ctx genericapirequest.Context, } // 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) } @@ -146,7 +147,7 @@ func (customResourceStrategy) AllowUnconditionalUpdate() bool { } // 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) } diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/BUILD b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/BUILD index e6150d20368..c9c5e70b772 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/BUILD +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/BUILD @@ -12,7 +12,6 @@ go_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/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/client-go/util/jsonpath:go_default_library", ], diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor.go index 4eb62da6b7c..d4ea111fa59 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor.go @@ -18,6 +18,7 @@ package tableconvertor import ( "bytes" + "context" "fmt" "strings" @@ -28,7 +29,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/client-go/util/jsonpath" ) @@ -85,7 +85,7 @@ type convertor struct { 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{ ColumnDefinitions: c.headers, } diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/validator.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/validator.go index ef5023dc63a..fefbecb3c60 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/validator.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource/validator.go @@ -17,6 +17,7 @@ limitations under the License. package customresource import ( + "context" "fmt" "math" "strings" @@ -29,7 +30,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" apiservervalidation "k8s.io/apiextensions-apiserver/pkg/apiserver/validation" @@ -42,7 +42,7 @@ type customResourceValidator struct { 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) if err != nil { return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())} @@ -109,7 +109,7 @@ func (a customResourceValidator) Validate(ctx genericapirequest.Context, obj run 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) if err != nil { return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())} @@ -180,7 +180,7 @@ func (a customResourceValidator) ValidateUpdate(ctx genericapirequest.Context, o 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) if err != nil { return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())} diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/BUILD b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/BUILD index 2a77d83b325..f2088ab887a 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/BUILD +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/BUILD @@ -23,7 +23,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/labels: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/apiserver/pkg/endpoints/request: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/rest:go_default_library", diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go index c501c6a0867..e46b42217c2 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go @@ -17,13 +17,13 @@ limitations under the License. package customresourcedefinition import ( + "context" "fmt" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -66,7 +66,7 @@ func (r *REST) ShortNames() []string { } // 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{}) if err != nil { return nil, false, err @@ -167,6 +167,6 @@ func (r *StatusREST) New() runtime.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) } diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go index 7e44fa4c2bb..839833e636f 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go @@ -17,6 +17,7 @@ limitations under the License. package customresourcedefinition import ( + "context" "fmt" apiequality "k8s.io/apimachinery/pkg/api/equality" @@ -24,7 +25,6 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage/names" @@ -50,7 +50,7 @@ func (strategy) NamespaceScoped() bool { } // 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.Status = apiextensions.CustomResourceDefinitionStatus{} crd.Generation = 1 @@ -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. -func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { +func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { newCRD := obj.(*apiextensions.CustomResourceDefinition) oldCRD := old.(*apiextensions.CustomResourceDefinition) newCRD.Status = oldCRD.Status @@ -93,7 +93,7 @@ func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime } // 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)) } @@ -113,7 +113,7 @@ func (strategy) Canonicalize(obj runtime.Object) { } // 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)) } @@ -130,7 +130,7 @@ func (statusStrategy) NamespaceScoped() bool { 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) oldObj := old.(*apiextensions.CustomResourceDefinition) newObj.Spec = oldObj.Spec @@ -155,7 +155,7 @@ func (statusStrategy) AllowUnconditionalUpdate() bool { 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)) } diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go index 9b8378800ff..14c8ab09504 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go @@ -19,6 +19,7 @@ package endpoints import ( "bytes" "compress/gzip" + "context" "encoding/json" "errors" "fmt" @@ -414,7 +415,7 @@ type SimpleRESTStorage struct { 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{}) if err != nil { return nil, err @@ -429,11 +430,11 @@ func (storage *SimpleRESTStorage) Export(ctx request.Context, name string, opts 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) } -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) result := &genericapitesting.SimpleList{ ListMeta: metav1.ListMeta{ @@ -488,7 +489,7 @@ func (h *OutputConnect) ServeHTTP(w http.ResponseWriter, req *http.Request) { 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) if id == "binary" { return storage.stream, storage.errors["get"] @@ -496,11 +497,11 @@ func (storage *SimpleRESTStorage) Get(ctx request.Context, id string, options *m 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) } -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.deleted = id storage.deleteOptions = options @@ -523,7 +524,7 @@ func (storage *SimpleRESTStorage) NewList() runtime.Object { 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.created = obj.(*genericapitesting.Simple) if err := storage.errors["create"]; err != nil { @@ -539,7 +540,7 @@ func (storage *SimpleRESTStorage) Create(ctx request.Context, obj runtime.Object 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) obj, err := objInfo.UpdatedObject(ctx, &storage.item) if err != nil { @@ -559,7 +560,7 @@ func (storage *SimpleRESTStorage) Update(ctx request.Context, name string, objIn } // 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() defer storage.lock.Unlock() storage.checkContext(ctx) @@ -608,7 +609,7 @@ func (s *ConnecterRESTStorage) New() runtime.Object { 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.receivedID = id s.receivedResponder = responder @@ -633,7 +634,7 @@ type LegacyRESTStorage struct { *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) return obj, err } @@ -659,7 +660,7 @@ type GetWithOptionsRESTStorage struct { 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 { return nil, fmt.Errorf("Unexpected options object: %#v", options) } @@ -682,7 +683,7 @@ type GetWithOptionsRootRESTStorage struct { 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 { return nil, fmt.Errorf("Unexpected options object: %#v", options) } @@ -704,7 +705,7 @@ type NamedCreaterRESTStorage struct { 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.created = obj.(*genericapitesting.Simple) storage.createdName = name @@ -734,12 +735,12 @@ func (storage *SimpleTypedStorage) New() runtime.Object { 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) 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) } @@ -3831,7 +3832,7 @@ func (storage *SimpleXGSubresourceRESTStorage) New() runtime.Object { 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 } diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/authorization.go b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/authorization.go index 66a641e41ab..4c9f140ca30 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/authorization.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/authorization.go @@ -17,6 +17,7 @@ limitations under the License. package filters import ( + "context" "errors" "net/http" @@ -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{} user, ok := request.UserFrom(ctx) diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/impersonation_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/impersonation_test.go index 2a2245e57d3..3357e038db1 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/impersonation_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/impersonation_test.go @@ -17,6 +17,7 @@ limitations under the License. package filters import ( + "context" "fmt" "net/http" "net/http/httptest" @@ -308,7 +309,7 @@ func TestImpersonationFilter(t *testing.T) { }, } - var ctx request.Context + var ctx context.Context var actualUser user.Info var lock sync.Mutex diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/create.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/create.go index b369bafec96..f64aa2bf2e4 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/create.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/create.go @@ -17,6 +17,7 @@ limitations under the License. package handlers import ( + "context" "fmt" "net/http" "time" @@ -163,6 +164,6 @@ type namedCreaterAdapter struct { 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) } diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/get.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/get.go index 3b891dd5ae7..8e5e4d76367 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/get.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/get.go @@ -17,6 +17,7 @@ limitations under the License. package handlers import ( + "context" "fmt" "math/rand" "net/http" @@ -40,7 +41,7 @@ import ( // 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. -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 // passed-in getterFunc to perform the actual get. @@ -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. func GetResource(r rest.Getter, e rest.Exporter, scope RequestScope) http.HandlerFunc { 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 options := metav1.GetOptions{} if values := req.URL.Query(); len(values) > 0 { @@ -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. func GetResourceWithOptions(r rest.GetterWithOptions, scope RequestScope, isSubresource bool) http.HandlerFunc { 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() trace.Step("About to process Get options") if err := getRequestOptions(req, scope, opts, subpath, subpathKey, isSubresource); err != nil { diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/patch.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/patch.go index 3ac6c3b3d71..db9f325a43b 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/patch.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/patch.go @@ -17,6 +17,7 @@ limitations under the License. package handlers import ( + "context" "fmt" "net/http" "strings" @@ -151,7 +152,7 @@ type mutateObjectUpdateFunc func(obj, old runtime.Object) error // patchResource divides PatchResource for easier unit testing func patchResource( - ctx request.Context, + ctx context.Context, updateMutation mutateObjectUpdateFunc, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, @@ -184,7 +185,7 @@ func patchResource( // applyPatch is called every time GuaranteedUpdate asks for the updated object, // 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 trace.Step("About to apply patch") if hasUID, err := hasUID(currentObject); err != nil { @@ -373,7 +374,7 @@ func patchResource( // applyAdmission is called every time GuaranteedUpdate asks for the updated object, // 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") return patchedObject, updateMutation(patchedObject, currentObject) } diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/response.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/response.go index 949fd16c8fe..8cee470a51e 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/response.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/response.go @@ -17,6 +17,7 @@ limitations under the License. package handlers import ( + "context" "fmt" "net/http" @@ -28,12 +29,11 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apiserver/pkg/endpoints/handlers/negotiation" "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. // 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. mediaType, _, err := negotiation.NegotiateOutputMediaType(req, scope.Serializer, &scope) if err != nil { diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors.go index 0e9eeff2b60..007efe9d884 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors.go @@ -17,6 +17,7 @@ limitations under the License. package responsewriters import ( + "context" "fmt" "net/http" "strings" @@ -26,7 +27,6 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apiserver/pkg/authorization/authorizer" - "k8s.io/apiserver/pkg/endpoints/request" ) // Avoid emitting errors that look like valid HTML. Quotes are okay. @@ -41,7 +41,7 @@ func BadGatewayError(w http.ResponseWriter, req *http.Request) { } // 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)) w.Header().Set("X-Content-Type-Options", "nosniff") diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest.go index c700d3a19a9..7ebd9579292 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest.go @@ -17,6 +17,7 @@ limitations under the License. package handlers import ( + "context" "encoding/hex" "fmt" "io/ioutil" @@ -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 // 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) { return 0, nil } diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go index d87d7700689..1db9b740480 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest_test.go @@ -17,6 +17,7 @@ limitations under the License. package handlers import ( + "context" "errors" "fmt" "net/http" @@ -171,7 +172,7 @@ func (p *testPatcher) New() runtime.Object { 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 if p.numUpdates > 0 { currentPod = p.updatePod @@ -200,7 +201,7 @@ func (p *testPatcher) Update(ctx request.Context, name string, objInfo rest.Upda 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") return nil, errors.New("Unexpected call to testPatcher.Get") } diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/update.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/update.go index feb01a6863f..30527712cf6 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/update.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/update.go @@ -17,6 +17,7 @@ limitations under the License. package handlers import ( + "context" "fmt" "net/http" "time" @@ -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) var transformers []rest.TransformFunc 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)) }) } diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/request/context.go b/staging/src/k8s.io/apiserver/pkg/endpoints/request/context.go index 42f59ab46c7..03f78fe1786 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/request/context.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/request/context.go @@ -18,8 +18,6 @@ package request import ( "context" - "errors" - "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -27,28 +25,6 @@ import ( "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 type key int @@ -70,43 +46,39 @@ const ( ) // NewContext instantiates a base context object for request flows. -func NewContext() Context { +func NewContext() context.Context { return context.TODO() } // 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) } // WithValue returns a copy of parent in which the value associated with key is val. -func WithValue(parent Context, key interface{}, val interface{}) Context { - internalCtx, ok := parent.(context.Context) - if !ok { - panic(errors.New("Invalid context type")) - } - return context.WithValue(internalCtx, key, val) +func WithValue(parent context.Context, key interface{}, val interface{}) context.Context { + return context.WithValue(parent, key, val) } // 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) } // 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) return namespace, ok } // 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) return namespace } // 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) if !ok || len(namespace) == 0 { return WithNamespace(parent, metav1.NamespaceDefault) @@ -115,34 +87,34 @@ func WithNamespaceDefaultIfNone(parent Context) Context { } // 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) } // 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) return user, ok } // 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) } // 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) return uid, ok } // 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) } // 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) return ev } diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/request/requestinfo.go b/staging/src/k8s.io/apiserver/pkg/endpoints/request/requestinfo.go index e73ad658b18..057d1956584 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/request/requestinfo.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/request/requestinfo.go @@ -17,6 +17,7 @@ limitations under the License. package request import ( + "context" "fmt" "net/http" "strings" @@ -232,12 +233,12 @@ type requestInfoKeyType int const requestInfoKey requestInfoKeyType = iota // 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) } // 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) return info, ok } diff --git a/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go b/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go index 9901f320f0e..3eab41e6c38 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go @@ -17,6 +17,7 @@ limitations under the License. package registry import ( + "context" "fmt" "reflect" "strings" @@ -99,14 +100,14 @@ type Store struct { // entire collection (listing and watching). // // 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 is called for Create/Update/Get/Delete. Note that 'namespace' // can be gotten from ctx. // // 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 func(obj runtime.Object) (string, error) @@ -190,7 +191,7 @@ const ( // NamespaceKeyRootFunc is the default function for constructing storage paths // to resource directories enforcing namespace rules. -func NamespaceKeyRootFunc(ctx genericapirequest.Context, prefix string) string { +func NamespaceKeyRootFunc(ctx context.Context, prefix string) string { key := prefix ns, ok := genericapirequest.NamespaceFrom(ctx) if ok && len(ns) > 0 { @@ -202,7 +203,7 @@ func NamespaceKeyRootFunc(ctx genericapirequest.Context, prefix string) string { // NamespaceKeyFunc is the default function for constructing storage paths to // a resource relative to the given prefix enforcing namespace rules. If the // 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) ns, ok := genericapirequest.NamespaceFrom(ctx) if !ok || len(ns) == 0 { @@ -220,7 +221,7 @@ func NamespaceKeyFunc(ctx genericapirequest.Context, prefix string, name string) // NoNamespaceKeyFunc is the default function for constructing storage paths // 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 { return "", kubeerr.NewBadRequest("Name parameter required.") } @@ -263,7 +264,7 @@ func (e *Store) GetExportStrategy() rest.RESTExportStrategy { // List returns a list of items matching labels and field according to the // 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() if options != nil && options.LabelSelector != nil { label = options.LabelSelector @@ -286,7 +287,7 @@ func (e *Store) List(ctx genericapirequest.Context, options *metainternalversion // ListPredicate returns a list of all the items matching the given // 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 { // By default we should serve the request from etcd. options = &metainternalversion.ListOptions{ResourceVersion: ""} @@ -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. -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 { return nil, err } @@ -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. // 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 accessor, err := meta.Accessor(obj) if err != nil { @@ -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 // finalizers. If so, it further checks if the object's // 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) if err != nil { utilruntime.HandleError(err) @@ -469,7 +470,7 @@ func (e *Store) shouldDeleteDuringUpdate(ctx genericapirequest.Context, key stri // shouldDeleteForFailedInitialization returns true if the provided object is initializing and has // 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) if err != nil { utilruntime.HandleError(err) @@ -483,7 +484,7 @@ func (e *Store) shouldDeleteForFailedInitialization(ctx genericapirequest.Contex // deleteWithoutFinalizers handles deleting an object ignoring its finalizer list. // 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() 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 { @@ -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 // 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. -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) if err != nil { return nil, false, err @@ -666,7 +667,7 @@ func (e *Store) Update(ctx genericapirequest.Context, name string, objInfo rest. } // 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() key, err := e.KeyFunc(ctx, name) if err != nil { @@ -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. // 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 { return schema.GroupResource{Group: info.APIGroup, Resource: info.Resource} } @@ -704,7 +705,7 @@ var ( // priority, there are three factors affect whether to add/remove the // FinalizerOrphanDependents: options, existing finalizers of the object, // 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 gcStrategy, ok := e.DeleteStrategy.(rest.GarbageCollectionDeleteStrategy) var defaultGCPolicy rest.GarbageCollectionPolicy @@ -754,7 +755,7 @@ func shouldOrphanDependents(ctx genericapirequest.Context, e *Store, accessor me // priority, there are three factors affect whether to add/remove the // FinalizerDeleteDependents: options, existing finalizers of the object, and // 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 if gcStrategy, ok := e.DeleteStrategy.(rest.GarbageCollectionDeleteStrategy); ok && gcStrategy.DefaultGarbageCollectionPolicy(ctx) == rest.Unsupported { // return false to indicate that we should NOT delete in foreground @@ -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. // If garbage collection is disabled for the store, this function returns false // 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 { return false, []string{} } @@ -861,7 +862,7 @@ func markAsDeleting(obj runtime.Object) (err error) { // should be deleted immediately // 4. a new output object with the state that was updated // 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) var pendingFinalizers bool out = e.NewFunc() @@ -941,7 +942,7 @@ func (e *Store) updateForGracefulDeletionAndFinalizers(ctx genericapirequest.Con } // 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) if err != nil { return nil, false, err @@ -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 // possibly with storage API, but watch is not delivered correctly then). // 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 { listOptions = &metainternalversion.ListOptions{} } else { @@ -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 // 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 err := e.AfterDelete(obj); err != nil { return nil, err @@ -1131,7 +1132,7 @@ func (e *Store) finalizeDelete(ctx genericapirequest.Context, obj runtime.Object // WatchPredicate. If possible, you should customize PredicateFunc to produce // a matcher that matches by key. SelectionPredicate does this for you // 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() if options != nil && options.LabelSelector != nil { label = options.LabelSelector @@ -1151,7 +1152,7 @@ func (e *Store) Watch(ctx genericapirequest.Context, options *metainternalversio } // 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 key, err := e.KeyFunc(ctx, name); err == nil { w, err := e.Storage.Watch(ctx, key, resourceVersion, p) @@ -1213,7 +1214,7 @@ func exportObjectMeta(accessor metav1.Object, exact bool) { } // 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{}) if err != nil { return nil, err @@ -1303,17 +1304,17 @@ func (e *Store) CompleteWithOptions(options *generic.StoreOptions) error { // Set the default behavior for storage key generation if e.KeyRootFunc == nil && e.KeyFunc == nil { if isNamespaced { - e.KeyRootFunc = func(ctx genericapirequest.Context) string { + e.KeyRootFunc = func(ctx context.Context) string { 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) } } else { - e.KeyRootFunc = func(ctx genericapirequest.Context) string { + e.KeyRootFunc = func(ctx context.Context) string { 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) } } @@ -1399,7 +1400,7 @@ func (e *Store) startObservingCount(period time.Duration) func() { 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 { return e.TableConvertor.ConvertToTable(ctx, object, tableOptions) } diff --git a/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store_test.go b/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store_test.go index 1e0a96b55f6..76ed138af81 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store_test.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store_test.go @@ -17,6 +17,7 @@ limitations under the License. package registry import ( + "context" "fmt" "path" "reflect" @@ -72,7 +73,7 @@ type testGracefulStrategy struct { 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 } @@ -82,7 +83,7 @@ type testOrphanDeleteStrategy struct { *testRESTStrategy } -func (t *testOrphanDeleteStrategy) DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) rest.GarbageCollectionPolicy { +func (t *testOrphanDeleteStrategy) DefaultGarbageCollectionPolicy(ctx context.Context) rest.GarbageCollectionPolicy { return rest.OrphanDependents } @@ -98,7 +99,7 @@ func (t *testRESTStrategy) NamespaceScoped() bool { return t.namespaceS func (t *testRESTStrategy) AllowCreateOnUpdate() bool { return t.allowCreateOnUpdate } 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) if err != nil { panic(err.Error()) @@ -111,11 +112,11 @@ func (t *testRESTStrategy) PrepareForCreate(ctx genericapirequest.Context, obj r metaObj.SetLabels(labels) } -func (t *testRESTStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) {} -func (t *testRESTStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList { +func (t *testRESTStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {} +func (t *testRESTStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { 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 } func (t *testRESTStrategy) Canonicalize(obj runtime.Object) {} @@ -172,7 +173,7 @@ func TestStoreList(t *testing.T) { in *example.PodList m storage.SelectionPredicate out runtime.Object - context genericapirequest.Context + context context.Context }{ "notFound": { in: nil, @@ -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) if err != nil { t.Errorf("Unexpected error: %v", err) @@ -733,7 +734,7 @@ func TestNoOpUpdates(t *testing.T) { 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) if pod.Labels == nil { pod.Labels = map[string]string{} @@ -1774,7 +1775,7 @@ func TestStoreWatch(t *testing.T) { table := map[string]struct { selectPred storage.SelectionPredicate - context genericapirequest.Context + context context.Context }{ "single": { selectPred: matchPodName("foo"), @@ -1865,10 +1866,10 @@ func newTestGenericStoreRegistry(t *testing.T, scheme *runtime.Scheme, hasCacheE CreateStrategy: strategy, UpdateStrategy: strategy, DeleteStrategy: strategy, - KeyRootFunc: func(ctx genericapirequest.Context) string { + KeyRootFunc: func(ctx context.Context) string { 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 { return "", fmt.Errorf("namespace is required") } @@ -2011,7 +2012,7 @@ type fakeStrategy struct { 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"} appsv1beta2 := schema.GroupVersion{Group: "apps", Version: "v1beta2"} extensionsv1beta1 := schema.GroupVersion{Group: "extensions", Version: "v1beta1"} diff --git a/staging/src/k8s.io/apiserver/pkg/registry/generic/testing/BUILD b/staging/src/k8s.io/apiserver/pkg/registry/generic/testing/BUILD index 088c78d678c..68f55a69113 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/generic/testing/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/registry/generic/testing/BUILD @@ -12,7 +12,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/fields:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels: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/rest/resttest:go_default_library", "//vendor/k8s.io/apiserver/pkg/storage/etcd:go_default_library", diff --git a/staging/src/k8s.io/apiserver/pkg/registry/generic/testing/tester.go b/staging/src/k8s.io/apiserver/pkg/registry/generic/testing/tester.go index 25f096149ef..e1ac7c1357c 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/generic/testing/tester.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/generic/testing/tester.go @@ -17,6 +17,7 @@ limitations under the License. package tester import ( + "context" "fmt" "testing" @@ -26,7 +27,6 @@ import ( "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest/resttest" etcdstorage "k8s.io/apiserver/pkg/storage/etcd" @@ -142,7 +142,7 @@ func (t *Tester) TestWatch(valid runtime.Object, labelsPass, labelsFail []labels // 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) if err != nil { return nil, err @@ -155,7 +155,7 @@ func (t *Tester) getObject(ctx genericapirequest.Context, obj runtime.Object) (r 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) if err != nil { return err diff --git a/staging/src/k8s.io/apiserver/pkg/registry/rest/create.go b/staging/src/k8s.io/apiserver/pkg/registry/rest/create.go index 1f998332e9c..a52c673ccf8 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/create.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/create.go @@ -17,6 +17,8 @@ limitations under the License. package rest import ( + "context" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" genericvalidation "k8s.io/apimachinery/pkg/api/validation" @@ -26,7 +28,6 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apiserver/pkg/admission" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/features" "k8s.io/apiserver/pkg/storage/names" utilfeature "k8s.io/apiserver/pkg/util/feature" @@ -52,12 +53,12 @@ type RESTCreateStrategy interface { // status. Clear the status because status changes are internal. External // callers of an api (users) should not be setting an initial status on // 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 // is invoked after default fields in the object have been filled in // before the object is persisted. This method should not mutate the // 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 // ensures that code that operates on these objects can rely on the common // form for things like comparison. Canonicalize is invoked after @@ -70,7 +71,7 @@ type RESTCreateStrategy interface { // 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. // 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) if kerr != nil { return kerr diff --git a/staging/src/k8s.io/apiserver/pkg/registry/rest/delete.go b/staging/src/k8s.io/apiserver/pkg/registry/rest/delete.go index 94c29592c97..7c39f6be10f 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/delete.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/delete.go @@ -17,6 +17,7 @@ limitations under the License. package rest import ( + "context" "fmt" "time" @@ -25,7 +26,6 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/validation" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" ) // RESTDeleteStrategy defines deletion behavior on an object that follows Kubernetes @@ -48,7 +48,7 @@ const ( // orphan dependents by default. type GarbageCollectionDeleteStrategy interface { // 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 @@ -56,7 +56,7 @@ type GarbageCollectionDeleteStrategy interface { type RESTGracefulDeleteStrategy interface { // CheckGracefulDelete should return true if the object can be gracefully deleted and set // 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. @@ -68,7 +68,7 @@ type RESTGracefulDeleteStrategy interface { // where we set deletionTimestamp is pkg/registry/generic/registry/store.go. // This function is responsible for setting deletionTimestamp during gracefulDeletion, // 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) if kerr != nil { return false, false, kerr diff --git a/staging/src/k8s.io/apiserver/pkg/registry/rest/export.go b/staging/src/k8s.io/apiserver/pkg/registry/rest/export.go index b0fc292e2e7..b3fd8af3001 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/export.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/export.go @@ -17,8 +17,9 @@ limitations under the License. package rest import ( + "context" + "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" ) // RESTExportStrategy is the interface that defines how to export a Kubernetes @@ -29,5 +30,5 @@ import ( type RESTExportStrategy interface { // Export strips fields that can not be set by the user. If 'exact' is false // 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 } diff --git a/staging/src/k8s.io/apiserver/pkg/registry/rest/meta.go b/staging/src/k8s.io/apiserver/pkg/registry/rest/meta.go index b79527b476b..86f184d0c18 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/meta.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/meta.go @@ -17,13 +17,15 @@ limitations under the License. package rest import ( + "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/uuid" genericapirequest "k8s.io/apiserver/pkg/endpoints/request" ) // 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()) // allows admission controllers to assign a UID earlier in the request processing // to support tracking resources pending creation. @@ -38,7 +40,7 @@ func FillObjectMetaSystemFields(ctx genericapirequest.Context, meta metav1.Objec // 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 context. -func ValidNamespace(ctx genericapirequest.Context, resource metav1.Object) bool { +func ValidNamespace(ctx context.Context, resource metav1.Object) bool { ns, ok := genericapirequest.NamespaceFrom(ctx) if len(resource.GetNamespace()) == 0 { resource.SetNamespace(ns) diff --git a/staging/src/k8s.io/apiserver/pkg/registry/rest/rest.go b/staging/src/k8s.io/apiserver/pkg/registry/rest/rest.go index a2b0930f38a..19564b18164 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/rest.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/rest.go @@ -17,6 +17,7 @@ limitations under the License. package rest import ( + "context" "io" "net/http" "net/url" @@ -27,7 +28,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/watch" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" ) //TODO: @@ -91,7 +91,7 @@ type Lister interface { // This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object) NewList() runtime.Object // 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 @@ -101,7 +101,7 @@ type Exporter interface { // 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 // 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. @@ -109,7 +109,7 @@ type Getter interface { // 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 // 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 @@ -122,7 +122,7 @@ type GetterWithOptions interface { // The options object passed to it is of the same type returned by the NewGetOptions // method. // 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 // options to the Get method. It may return a bool and a string, if true, the @@ -134,7 +134,7 @@ type GetterWithOptions 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 @@ -149,7 +149,7 @@ type GracefulDeleter interface { // information about deletion. // It also returns a boolean which is set to true if the resource was instantly // 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 @@ -160,7 +160,7 @@ type CollectionDeleter interface { // them or return an invalid request error. // 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. - 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. @@ -171,7 +171,7 @@ type Creater interface { // Create creates a new version of a resource. If includeUninitialized is set, the object may be returned // 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. @@ -184,7 +184,7 @@ type NamedCreater interface { // 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 // 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. @@ -197,7 +197,7 @@ type UpdatedObjectInfo interface { // 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). - 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 @@ -229,14 +229,14 @@ type Updater interface { // Update finds a resource in the storage and updates it. Some implementations // may allow updates creates the object - they should set the created boolean // 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. // Go prevents embedded interfaces that implement the same method. type CreaterUpdater interface { 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. @@ -255,7 +255,7 @@ type Watcher interface { // 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 // 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 @@ -272,7 +272,7 @@ type StandardStorage interface { // Redirector know how to return a remote resource's location. 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(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 @@ -292,7 +292,7 @@ type Connecter interface { // 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 // 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 // options to the Connect method. If nil, then a nil options object is passed to diff --git a/staging/src/k8s.io/apiserver/pkg/registry/rest/resttest/resttest.go b/staging/src/k8s.io/apiserver/pkg/registry/rest/resttest/resttest.go index f7244e2b707..64d792a607a 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/resttest/resttest.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/resttest/resttest.go @@ -17,6 +17,7 @@ limitations under the License. package resttest import ( + "context" "fmt" "reflect" "strings" @@ -99,7 +100,7 @@ func (t *Tester) TestNamespace() string { // TestContext returns a namespaced context that will be used when making storage calls. // Namespace is determined by TestNamespace() -func (t *Tester) TestContext() genericapirequest.Context { +func (t *Tester) TestContext() context.Context { if t.clusterScope { return genericapirequest.NewContext() } @@ -128,11 +129,11 @@ func (t *Tester) setObjectMeta(obj runtime.Object, name string) { type AssignFunc func([]runtime.Object) []runtime.Object 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 InjectErrFunc func(err error) 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 UpdateFunc func(runtime.Object) runtime.Object @@ -219,7 +220,7 @@ func (t *Tester) TestWatch( // ============================================================================= // 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) if err != nil { return err @@ -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 // This tests the mechanism used to pass the old and new object to admission 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) { t.Errorf("Expected\n\t%#v\ngot\n\t%#v", storedFoo, oldObject) } @@ -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 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 } diff --git a/staging/src/k8s.io/apiserver/pkg/registry/rest/table.go b/staging/src/k8s.io/apiserver/pkg/registry/rest/table.go index 2f0d1df3b6c..bfcdcf58b13 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/table.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/table.go @@ -17,6 +17,7 @@ limitations under the License. package rest import ( + "context" "fmt" "net/http" "time" @@ -26,7 +27,6 @@ import ( metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" ) type defaultTableConvertor struct { @@ -40,7 +40,7 @@ func NewDefaultTableConvertor(resource schema.GroupResource) TableConvertor { 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 fn := func(obj runtime.Object) error { m, err := meta.Accessor(obj) diff --git a/staging/src/k8s.io/apiserver/pkg/registry/rest/update.go b/staging/src/k8s.io/apiserver/pkg/registry/rest/update.go index aaee5800c29..aa3e452c4ce 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/update.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/update.go @@ -17,6 +17,7 @@ limitations under the License. package rest import ( + "context" "fmt" "k8s.io/apimachinery/pkg/api/errors" @@ -27,7 +28,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apiserver/pkg/admission" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/features" utilfeature "k8s.io/apiserver/pkg/util/feature" ) @@ -46,11 +46,11 @@ type RESTUpdateStrategy interface { // the object. For example: remove fields that are not to be persisted, // sort order-insensitive list fields, etc. This should not remove fields // 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 // filled in before the object is persisted. This method should not mutate // 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 // ensures that code that operates on these objects can rely on the common // form for things like comparison. Canonicalize is invoked after @@ -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 // errors that can be converted to api.Status. It will invoke update validation with the provided existing // 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) if kerr != nil { return kerr @@ -130,7 +130,7 @@ func BeforeUpdate(strategy RESTUpdateStrategy, ctx genericapirequest.Context, ob } // 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 type defaultUpdatedObjectInfo struct { @@ -167,7 +167,7 @@ func (i *defaultUpdatedObjectInfo) Preconditions() *metav1.Preconditions { // UpdatedObject satisfies the UpdatedObjectInfo interface. // 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 // Start with the configured object newObj := i.obj @@ -214,7 +214,7 @@ func (i *wrappedUpdatedObjectInfo) Preconditions() *metav1.Preconditions { // UpdatedObject satisfies the UpdatedObjectInfo interface. // 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) if err != nil { return newObj, err diff --git a/staging/src/k8s.io/apiserver/pkg/server/BUILD b/staging/src/k8s.io/apiserver/pkg/server/BUILD index c1073fc1d56..8073cdc59b9 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/server/BUILD @@ -30,7 +30,6 @@ go_test( "//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/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/server/filters:go_default_library", "//vendor/k8s.io/apiserver/pkg/server/healthz:go_default_library", diff --git a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver_test.go b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver_test.go index 0bb94f09b50..4cf8c868d42 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver_test.go +++ b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver_test.go @@ -17,6 +17,7 @@ limitations under the License. package server import ( + "context" "encoding/json" "fmt" "io" @@ -47,7 +48,6 @@ import ( "k8s.io/apiserver/pkg/authorization/authorizer" "k8s.io/apiserver/pkg/endpoints/discovery" genericapifilters "k8s.io/apiserver/pkg/endpoints/filters" - apirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" genericfilters "k8s.io/apiserver/pkg/server/filters" "k8s.io/client-go/informers" @@ -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 } diff --git a/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/BUILD b/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/BUILD index 751de834adb..9c5b70c7e82 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/BUILD +++ b/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/BUILD @@ -14,7 +14,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/labels: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/apiserver/pkg/endpoints/request: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/names:go_default_library", diff --git a/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd/BUILD b/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd/BUILD index 0fb9c4f5ea9..ea90ecbf0e5 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd/BUILD +++ b/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd/BUILD @@ -11,7 +11,6 @@ go_library( importpath = "k8s.io/kube-aggregator/pkg/registry/apiservice/etcd", deps = [ "//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/registry:go_default_library", "//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library", diff --git a/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd/etcd.go b/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd/etcd.go index b69f1a39d56..8eca6be0a25 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd/etcd.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd/etcd.go @@ -17,8 +17,9 @@ limitations under the License. package etcd import ( + "context" + "k8s.io/apimachinery/pkg/runtime" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/registry/rest" @@ -72,6 +73,6 @@ func (r *StatusREST) New() runtime.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) } diff --git a/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/strategy.go b/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/strategy.go index 51887d71937..96c40fd33f5 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/strategy.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/strategy.go @@ -17,13 +17,13 @@ limitations under the License. package apiservice import ( + "context" "fmt" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage/names" @@ -45,7 +45,7 @@ func (apiServerStrategy) NamespaceScoped() bool { 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.Status = apiregistration.APIServiceStatus{} @@ -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) oldAPIService := old.(*apiregistration.APIService) 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)) } @@ -76,7 +76,7 @@ func (apiServerStrategy) AllowUnconditionalUpdate() bool { 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)) } @@ -93,7 +93,7 @@ func (apiServerStatusStrategy) NamespaceScoped() bool { 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) oldAPIService := old.(*apiregistration.APIService) newAPIService.Spec = oldAPIService.Spec @@ -114,7 +114,7 @@ func (apiServerStatusStrategy) AllowUnconditionalUpdate() bool { 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)) } diff --git a/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer/BUILD b/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer/BUILD index e4d17123559..433a49f764b 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer/BUILD +++ b/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer/BUILD @@ -17,7 +17,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/labels: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/apiserver/pkg/endpoints/request: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/storage:go_default_library", diff --git a/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer/strategy.go b/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer/strategy.go index 3f739c3dab4..a0e9af28c0b 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer/strategy.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer/strategy.go @@ -17,6 +17,7 @@ limitations under the License. package fischer import ( + "context" "fmt" "k8s.io/apimachinery/pkg/fields" @@ -27,7 +28,6 @@ import ( "k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage/names" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/sample-apiserver/pkg/apis/wardle" ) @@ -70,13 +70,13 @@ func (fischerStrategy) NamespaceScoped() bool { 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{} } @@ -91,6 +91,6 @@ func (fischerStrategy) AllowUnconditionalUpdate() bool { 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{} } diff --git a/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder/BUILD b/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder/BUILD index 3dfce9befa9..2e2bcb7624e 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder/BUILD +++ b/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder/BUILD @@ -17,7 +17,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/labels: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/apiserver/pkg/endpoints/request: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/storage:go_default_library", diff --git a/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder/strategy.go b/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder/strategy.go index e94879acb10..8f6fdccf0f3 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder/strategy.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder/strategy.go @@ -17,6 +17,7 @@ limitations under the License. package flunder import ( + "context" "fmt" "k8s.io/apimachinery/pkg/fields" @@ -28,7 +29,6 @@ import ( "k8s.io/apiserver/pkg/storage/names" "k8s.io/sample-apiserver/pkg/apis/wardle/validation" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/sample-apiserver/pkg/apis/wardle" ) @@ -71,13 +71,13 @@ func (flunderStrategy) NamespaceScoped() bool { 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) return validation.ValidateFlunder(flunder) } @@ -93,6 +93,6 @@ func (flunderStrategy) AllowUnconditionalUpdate() bool { 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{} }