replace request.Context with context.Context
Kubernetes-commit: 54fd2aaefd11e12a3ecb6d1a1326f04cdc8ea1a3
This commit is contained in:
parent
53d8e19b68
commit
cd0258b4d7
|
@ -19,6 +19,7 @@ package endpoints
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -410,7 +411,7 @@ type SimpleRESTStorage struct {
|
||||||
injectedFunction func(obj runtime.Object) (returnObj runtime.Object, err error)
|
injectedFunction func(obj runtime.Object) (returnObj runtime.Object, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleRESTStorage) Export(ctx request.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) {
|
func (storage *SimpleRESTStorage) Export(ctx context.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) {
|
||||||
obj, err := storage.Get(ctx, name, &metav1.GetOptions{})
|
obj, err := storage.Get(ctx, name, &metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -425,11 +426,11 @@ func (storage *SimpleRESTStorage) Export(ctx request.Context, name string, opts
|
||||||
return obj, storage.errors["export"]
|
return obj, storage.errors["export"]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleRESTStorage) ConvertToTable(ctx request.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
|
func (storage *SimpleRESTStorage) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
|
||||||
return rest.NewDefaultTableConvertor(schema.GroupResource{Resource: "simple"}).ConvertToTable(ctx, obj, tableOptions)
|
return rest.NewDefaultTableConvertor(schema.GroupResource{Resource: "simple"}).ConvertToTable(ctx, obj, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleRESTStorage) List(ctx request.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
|
func (storage *SimpleRESTStorage) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
|
||||||
storage.checkContext(ctx)
|
storage.checkContext(ctx)
|
||||||
result := &genericapitesting.SimpleList{
|
result := &genericapitesting.SimpleList{
|
||||||
ListMeta: metav1.ListMeta{
|
ListMeta: metav1.ListMeta{
|
||||||
|
@ -484,7 +485,7 @@ func (h *OutputConnect) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
w.Write([]byte(h.response))
|
w.Write([]byte(h.response))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleRESTStorage) Get(ctx request.Context, id string, options *metav1.GetOptions) (runtime.Object, error) {
|
func (storage *SimpleRESTStorage) Get(ctx context.Context, id string, options *metav1.GetOptions) (runtime.Object, error) {
|
||||||
storage.checkContext(ctx)
|
storage.checkContext(ctx)
|
||||||
if id == "binary" {
|
if id == "binary" {
|
||||||
return storage.stream, storage.errors["get"]
|
return storage.stream, storage.errors["get"]
|
||||||
|
@ -492,11 +493,11 @@ func (storage *SimpleRESTStorage) Get(ctx request.Context, id string, options *m
|
||||||
return storage.item.DeepCopy(), storage.errors["get"]
|
return storage.item.DeepCopy(), storage.errors["get"]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleRESTStorage) checkContext(ctx request.Context) {
|
func (storage *SimpleRESTStorage) checkContext(ctx context.Context) {
|
||||||
storage.actualNamespace, storage.namespacePresent = request.NamespaceFrom(ctx)
|
storage.actualNamespace, storage.namespacePresent = request.NamespaceFrom(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleRESTStorage) Delete(ctx request.Context, id string, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
|
func (storage *SimpleRESTStorage) Delete(ctx context.Context, id string, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
|
||||||
storage.checkContext(ctx)
|
storage.checkContext(ctx)
|
||||||
storage.deleted = id
|
storage.deleted = id
|
||||||
storage.deleteOptions = options
|
storage.deleteOptions = options
|
||||||
|
@ -519,7 +520,7 @@ func (storage *SimpleRESTStorage) NewList() runtime.Object {
|
||||||
return &genericapitesting.SimpleList{}
|
return &genericapitesting.SimpleList{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleRESTStorage) Create(ctx request.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
func (storage *SimpleRESTStorage) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||||
storage.checkContext(ctx)
|
storage.checkContext(ctx)
|
||||||
storage.created = obj.(*genericapitesting.Simple)
|
storage.created = obj.(*genericapitesting.Simple)
|
||||||
if err := storage.errors["create"]; err != nil {
|
if err := storage.errors["create"]; err != nil {
|
||||||
|
@ -535,7 +536,7 @@ func (storage *SimpleRESTStorage) Create(ctx request.Context, obj runtime.Object
|
||||||
return obj, err
|
return obj, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleRESTStorage) Update(ctx request.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
func (storage *SimpleRESTStorage) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||||
storage.checkContext(ctx)
|
storage.checkContext(ctx)
|
||||||
obj, err := objInfo.UpdatedObject(ctx, &storage.item)
|
obj, err := objInfo.UpdatedObject(ctx, &storage.item)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -555,7 +556,7 @@ func (storage *SimpleRESTStorage) Update(ctx request.Context, name string, objIn
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement ResourceWatcher.
|
// Implement ResourceWatcher.
|
||||||
func (storage *SimpleRESTStorage) Watch(ctx request.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
|
func (storage *SimpleRESTStorage) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
|
||||||
storage.lock.Lock()
|
storage.lock.Lock()
|
||||||
defer storage.lock.Unlock()
|
defer storage.lock.Unlock()
|
||||||
storage.checkContext(ctx)
|
storage.checkContext(ctx)
|
||||||
|
@ -604,7 +605,7 @@ func (s *ConnecterRESTStorage) New() runtime.Object {
|
||||||
return &genericapitesting.Simple{}
|
return &genericapitesting.Simple{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConnecterRESTStorage) Connect(ctx request.Context, id string, options runtime.Object, responder rest.Responder) (http.Handler, error) {
|
func (s *ConnecterRESTStorage) Connect(ctx context.Context, id string, options runtime.Object, responder rest.Responder) (http.Handler, error) {
|
||||||
s.receivedConnectOptions = options
|
s.receivedConnectOptions = options
|
||||||
s.receivedID = id
|
s.receivedID = id
|
||||||
s.receivedResponder = responder
|
s.receivedResponder = responder
|
||||||
|
@ -629,7 +630,7 @@ type LegacyRESTStorage struct {
|
||||||
*SimpleRESTStorage
|
*SimpleRESTStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage LegacyRESTStorage) Delete(ctx request.Context, id string) (runtime.Object, error) {
|
func (storage LegacyRESTStorage) Delete(ctx context.Context, id string) (runtime.Object, error) {
|
||||||
obj, _, err := storage.SimpleRESTStorage.Delete(ctx, id, nil)
|
obj, _, err := storage.SimpleRESTStorage.Delete(ctx, id, nil)
|
||||||
return obj, err
|
return obj, err
|
||||||
}
|
}
|
||||||
|
@ -655,7 +656,7 @@ type GetWithOptionsRESTStorage struct {
|
||||||
takesPath string
|
takesPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *GetWithOptionsRESTStorage) Get(ctx request.Context, name string, options runtime.Object) (runtime.Object, error) {
|
func (r *GetWithOptionsRESTStorage) Get(ctx context.Context, name string, options runtime.Object) (runtime.Object, error) {
|
||||||
if _, ok := options.(*genericapitesting.SimpleGetOptions); !ok {
|
if _, ok := options.(*genericapitesting.SimpleGetOptions); !ok {
|
||||||
return nil, fmt.Errorf("Unexpected options object: %#v", options)
|
return nil, fmt.Errorf("Unexpected options object: %#v", options)
|
||||||
}
|
}
|
||||||
|
@ -678,7 +679,7 @@ type GetWithOptionsRootRESTStorage struct {
|
||||||
takesPath string
|
takesPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *GetWithOptionsRootRESTStorage) Get(ctx request.Context, name string, options runtime.Object) (runtime.Object, error) {
|
func (r *GetWithOptionsRootRESTStorage) Get(ctx context.Context, name string, options runtime.Object) (runtime.Object, error) {
|
||||||
if _, ok := options.(*genericapitesting.SimpleGetOptions); !ok {
|
if _, ok := options.(*genericapitesting.SimpleGetOptions); !ok {
|
||||||
return nil, fmt.Errorf("Unexpected options object: %#v", options)
|
return nil, fmt.Errorf("Unexpected options object: %#v", options)
|
||||||
}
|
}
|
||||||
|
@ -700,7 +701,7 @@ type NamedCreaterRESTStorage struct {
|
||||||
createdName string
|
createdName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *NamedCreaterRESTStorage) Create(ctx request.Context, name string, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
func (storage *NamedCreaterRESTStorage) Create(ctx context.Context, name string, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||||
storage.checkContext(ctx)
|
storage.checkContext(ctx)
|
||||||
storage.created = obj.(*genericapitesting.Simple)
|
storage.created = obj.(*genericapitesting.Simple)
|
||||||
storage.createdName = name
|
storage.createdName = name
|
||||||
|
@ -730,12 +731,12 @@ func (storage *SimpleTypedStorage) New() runtime.Object {
|
||||||
return storage.baseType
|
return storage.baseType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleTypedStorage) Get(ctx request.Context, id string, options *metav1.GetOptions) (runtime.Object, error) {
|
func (storage *SimpleTypedStorage) Get(ctx context.Context, id string, options *metav1.GetOptions) (runtime.Object, error) {
|
||||||
storage.checkContext(ctx)
|
storage.checkContext(ctx)
|
||||||
return storage.item.DeepCopyObject(), storage.errors["get"]
|
return storage.item.DeepCopyObject(), storage.errors["get"]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleTypedStorage) checkContext(ctx request.Context) {
|
func (storage *SimpleTypedStorage) checkContext(ctx context.Context) {
|
||||||
storage.actualNamespace, storage.namespacePresent = request.NamespaceFrom(ctx)
|
storage.actualNamespace, storage.namespacePresent = request.NamespaceFrom(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3827,7 +3828,7 @@ func (storage *SimpleXGSubresourceRESTStorage) New() runtime.Object {
|
||||||
return &genericapitesting.SimpleXGSubresource{}
|
return &genericapitesting.SimpleXGSubresource{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleXGSubresourceRESTStorage) Get(ctx request.Context, id string, options *metav1.GetOptions) (runtime.Object, error) {
|
func (storage *SimpleXGSubresourceRESTStorage) Get(ctx context.Context, id string, options *metav1.GetOptions) (runtime.Object, error) {
|
||||||
return storage.item.DeepCopyObject(), nil
|
return storage.item.DeepCopyObject(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package filters
|
package filters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ func WithAuthorization(handler http.Handler, a authorizer.Authorizer, s runtime.
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAuthorizerAttributes(ctx request.Context) (authorizer.Attributes, error) {
|
func GetAuthorizerAttributes(ctx context.Context) (authorizer.Attributes, error) {
|
||||||
attribs := authorizer.AttributesRecord{}
|
attribs := authorizer.AttributesRecord{}
|
||||||
|
|
||||||
user, ok := request.UserFrom(ctx)
|
user, ok := request.UserFrom(ctx)
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package filters
|
package filters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
@ -308,7 +309,7 @@ func TestImpersonationFilter(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var ctx request.Context
|
var ctx context.Context
|
||||||
var actualUser user.Info
|
var actualUser user.Info
|
||||||
var lock sync.Mutex
|
var lock sync.Mutex
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -163,6 +164,6 @@ type namedCreaterAdapter struct {
|
||||||
rest.Creater
|
rest.Creater
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *namedCreaterAdapter) Create(ctx request.Context, name string, obj runtime.Object, createValidatingAdmission rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
func (c *namedCreaterAdapter) Create(ctx context.Context, name string, obj runtime.Object, createValidatingAdmission rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||||
return c.Creater.Create(ctx, obj, createValidatingAdmission, includeUninitialized)
|
return c.Creater.Create(ctx, obj, createValidatingAdmission, includeUninitialized)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -40,7 +41,7 @@ import (
|
||||||
|
|
||||||
// getterFunc performs a get request with the given context and object name. The request
|
// getterFunc performs a get request with the given context and object name. The request
|
||||||
// may be used to deserialize an options object to pass to the getter.
|
// may be used to deserialize an options object to pass to the getter.
|
||||||
type getterFunc func(ctx request.Context, name string, req *http.Request, trace *utiltrace.Trace) (runtime.Object, error)
|
type getterFunc func(ctx context.Context, name string, req *http.Request, trace *utiltrace.Trace) (runtime.Object, error)
|
||||||
|
|
||||||
// getResourceHandler is an HTTP handler function for get requests. It delegates to the
|
// getResourceHandler is an HTTP handler function for get requests. It delegates to the
|
||||||
// passed-in getterFunc to perform the actual get.
|
// passed-in getterFunc to perform the actual get.
|
||||||
|
@ -80,7 +81,7 @@ func getResourceHandler(scope RequestScope, getter getterFunc) http.HandlerFunc
|
||||||
// GetResource returns a function that handles retrieving a single resource from a rest.Storage object.
|
// GetResource returns a function that handles retrieving a single resource from a rest.Storage object.
|
||||||
func GetResource(r rest.Getter, e rest.Exporter, scope RequestScope) http.HandlerFunc {
|
func GetResource(r rest.Getter, e rest.Exporter, scope RequestScope) http.HandlerFunc {
|
||||||
return getResourceHandler(scope,
|
return getResourceHandler(scope,
|
||||||
func(ctx request.Context, name string, req *http.Request, trace *utiltrace.Trace) (runtime.Object, error) {
|
func(ctx context.Context, name string, req *http.Request, trace *utiltrace.Trace) (runtime.Object, error) {
|
||||||
// check for export
|
// check for export
|
||||||
options := metav1.GetOptions{}
|
options := metav1.GetOptions{}
|
||||||
if values := req.URL.Query(); len(values) > 0 {
|
if values := req.URL.Query(); len(values) > 0 {
|
||||||
|
@ -110,7 +111,7 @@ func GetResource(r rest.Getter, e rest.Exporter, scope RequestScope) http.Handle
|
||||||
// GetResourceWithOptions returns a function that handles retrieving a single resource from a rest.Storage object.
|
// GetResourceWithOptions returns a function that handles retrieving a single resource from a rest.Storage object.
|
||||||
func GetResourceWithOptions(r rest.GetterWithOptions, scope RequestScope, isSubresource bool) http.HandlerFunc {
|
func GetResourceWithOptions(r rest.GetterWithOptions, scope RequestScope, isSubresource bool) http.HandlerFunc {
|
||||||
return getResourceHandler(scope,
|
return getResourceHandler(scope,
|
||||||
func(ctx request.Context, name string, req *http.Request, trace *utiltrace.Trace) (runtime.Object, error) {
|
func(ctx context.Context, name string, req *http.Request, trace *utiltrace.Trace) (runtime.Object, error) {
|
||||||
opts, subpath, subpathKey := r.NewGetOptions()
|
opts, subpath, subpathKey := r.NewGetOptions()
|
||||||
trace.Step("About to process Get options")
|
trace.Step("About to process Get options")
|
||||||
if err := getRequestOptions(req, scope, opts, subpath, subpathKey, isSubresource); err != nil {
|
if err := getRequestOptions(req, scope, opts, subpath, subpathKey, isSubresource); err != nil {
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -151,7 +152,7 @@ type mutateObjectUpdateFunc func(obj, old runtime.Object) error
|
||||||
|
|
||||||
// patchResource divides PatchResource for easier unit testing
|
// patchResource divides PatchResource for easier unit testing
|
||||||
func patchResource(
|
func patchResource(
|
||||||
ctx request.Context,
|
ctx context.Context,
|
||||||
updateMutation mutateObjectUpdateFunc,
|
updateMutation mutateObjectUpdateFunc,
|
||||||
createValidation rest.ValidateObjectFunc,
|
createValidation rest.ValidateObjectFunc,
|
||||||
updateValidation rest.ValidateObjectUpdateFunc,
|
updateValidation rest.ValidateObjectUpdateFunc,
|
||||||
|
@ -184,7 +185,7 @@ func patchResource(
|
||||||
|
|
||||||
// applyPatch is called every time GuaranteedUpdate asks for the updated object,
|
// applyPatch is called every time GuaranteedUpdate asks for the updated object,
|
||||||
// and is given the currently persisted object as input.
|
// and is given the currently persisted object as input.
|
||||||
applyPatch := func(_ request.Context, _, currentObject runtime.Object) (runtime.Object, error) {
|
applyPatch := func(_ context.Context, _, currentObject runtime.Object) (runtime.Object, error) {
|
||||||
// Make sure we actually have a persisted currentObject
|
// Make sure we actually have a persisted currentObject
|
||||||
trace.Step("About to apply patch")
|
trace.Step("About to apply patch")
|
||||||
if hasUID, err := hasUID(currentObject); err != nil {
|
if hasUID, err := hasUID(currentObject); err != nil {
|
||||||
|
@ -373,7 +374,7 @@ func patchResource(
|
||||||
|
|
||||||
// applyAdmission is called every time GuaranteedUpdate asks for the updated object,
|
// applyAdmission is called every time GuaranteedUpdate asks for the updated object,
|
||||||
// and is given the currently persisted object and the patched object as input.
|
// and is given the currently persisted object and the patched object as input.
|
||||||
applyAdmission := func(ctx request.Context, patchedObject runtime.Object, currentObject runtime.Object) (runtime.Object, error) {
|
applyAdmission := func(ctx context.Context, patchedObject runtime.Object, currentObject runtime.Object) (runtime.Object, error) {
|
||||||
trace.Step("About to check admission control")
|
trace.Step("About to check admission control")
|
||||||
return patchedObject, updateMutation(patchedObject, currentObject)
|
return patchedObject, updateMutation(patchedObject, currentObject)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
@ -28,12 +29,11 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apiserver/pkg/endpoints/handlers/negotiation"
|
"k8s.io/apiserver/pkg/endpoints/handlers/negotiation"
|
||||||
"k8s.io/apiserver/pkg/endpoints/handlers/responsewriters"
|
"k8s.io/apiserver/pkg/endpoints/handlers/responsewriters"
|
||||||
"k8s.io/apiserver/pkg/endpoints/request"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// transformResponseObject takes an object loaded from storage and performs any necessary transformations.
|
// transformResponseObject takes an object loaded from storage and performs any necessary transformations.
|
||||||
// Will write the complete response object.
|
// Will write the complete response object.
|
||||||
func transformResponseObject(ctx request.Context, scope RequestScope, req *http.Request, w http.ResponseWriter, statusCode int, result runtime.Object) {
|
func transformResponseObject(ctx context.Context, scope RequestScope, req *http.Request, w http.ResponseWriter, statusCode int, result runtime.Object) {
|
||||||
// TODO: fetch the media type much earlier in request processing and pass it into this method.
|
// TODO: fetch the media type much earlier in request processing and pass it into this method.
|
||||||
mediaType, _, err := negotiation.NegotiateOutputMediaType(req, scope.Serializer, &scope)
|
mediaType, _, err := negotiation.NegotiateOutputMediaType(req, scope.Serializer, &scope)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package responsewriters
|
package responsewriters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -26,7 +27,6 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||||
"k8s.io/apiserver/pkg/endpoints/request"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Avoid emitting errors that look like valid HTML. Quotes are okay.
|
// Avoid emitting errors that look like valid HTML. Quotes are okay.
|
||||||
|
@ -41,7 +41,7 @@ func BadGatewayError(w http.ResponseWriter, req *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forbidden renders a simple forbidden error
|
// Forbidden renders a simple forbidden error
|
||||||
func Forbidden(ctx request.Context, attributes authorizer.Attributes, w http.ResponseWriter, req *http.Request, reason string, s runtime.NegotiatedSerializer) {
|
func Forbidden(ctx context.Context, attributes authorizer.Attributes, w http.ResponseWriter, req *http.Request, reason string, s runtime.NegotiatedSerializer) {
|
||||||
msg := sanitizer.Replace(forbiddenMessage(attributes))
|
msg := sanitizer.Replace(forbiddenMessage(attributes))
|
||||||
w.Header().Set("X-Content-Type-Options", "nosniff")
|
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -263,7 +264,7 @@ func checkName(obj runtime.Object, name, namespace string, namer ScopeNamer) err
|
||||||
|
|
||||||
// setListSelfLink sets the self link of a list to the base URL, then sets the self links
|
// setListSelfLink sets the self link of a list to the base URL, then sets the self links
|
||||||
// on all child objects returned. Returns the number of items in the list.
|
// on all child objects returned. Returns the number of items in the list.
|
||||||
func setListSelfLink(obj runtime.Object, ctx request.Context, req *http.Request, namer ScopeNamer) (int, error) {
|
func setListSelfLink(obj runtime.Object, ctx context.Context, req *http.Request, namer ScopeNamer) (int, error) {
|
||||||
if !meta.IsListType(obj) {
|
if !meta.IsListType(obj) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -171,7 +172,7 @@ func (p *testPatcher) New() runtime.Object {
|
||||||
return &example.Pod{}
|
return &example.Pod{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *testPatcher) Update(ctx request.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
func (p *testPatcher) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||||
currentPod := p.startingPod
|
currentPod := p.startingPod
|
||||||
if p.numUpdates > 0 {
|
if p.numUpdates > 0 {
|
||||||
currentPod = p.updatePod
|
currentPod = p.updatePod
|
||||||
|
@ -200,7 +201,7 @@ func (p *testPatcher) Update(ctx request.Context, name string, objInfo rest.Upda
|
||||||
return inPod, false, nil
|
return inPod, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *testPatcher) Get(ctx request.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
func (p *testPatcher) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
||||||
p.t.Fatal("Unexpected call to testPatcher.Get")
|
p.t.Fatal("Unexpected call to testPatcher.Get")
|
||||||
return nil, errors.New("Unexpected call to testPatcher.Get")
|
return nil, errors.New("Unexpected call to testPatcher.Get")
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -90,7 +91,7 @@ func UpdateResource(r rest.Updater, scope RequestScope, typer runtime.ObjectType
|
||||||
staticAdmissionAttributes := admission.NewAttributesRecord(nil, nil, scope.Kind, namespace, name, scope.Resource, scope.Subresource, admission.Update, userInfo)
|
staticAdmissionAttributes := admission.NewAttributesRecord(nil, nil, scope.Kind, namespace, name, scope.Resource, scope.Subresource, admission.Update, userInfo)
|
||||||
var transformers []rest.TransformFunc
|
var transformers []rest.TransformFunc
|
||||||
if mutatingAdmission, ok := admit.(admission.MutationInterface); ok && mutatingAdmission.Handles(admission.Update) {
|
if mutatingAdmission, ok := admit.(admission.MutationInterface); ok && mutatingAdmission.Handles(admission.Update) {
|
||||||
transformers = append(transformers, func(ctx request.Context, newObj, oldObj runtime.Object) (runtime.Object, error) {
|
transformers = append(transformers, func(ctx context.Context, newObj, oldObj runtime.Object) (runtime.Object, error) {
|
||||||
return newObj, mutatingAdmission.Admit(admission.NewAttributesRecord(newObj, oldObj, scope.Kind, namespace, name, scope.Resource, scope.Subresource, admission.Update, userInfo))
|
return newObj, mutatingAdmission.Admit(admission.NewAttributesRecord(newObj, oldObj, scope.Kind, namespace, name, scope.Resource, scope.Subresource, admission.Update, userInfo))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ package request
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
@ -27,28 +25,6 @@ import (
|
||||||
"k8s.io/apiserver/pkg/authentication/user"
|
"k8s.io/apiserver/pkg/authentication/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Context carries values across API boundaries.
|
|
||||||
// This context matches the context.Context interface
|
|
||||||
// (https://blog.golang.org/context), for the purposes
|
|
||||||
// of passing the api.Context through to the storage tier.
|
|
||||||
// TODO: Determine the extent that this abstraction+interface
|
|
||||||
// is used by the api, and whether we can remove.
|
|
||||||
type Context interface {
|
|
||||||
// Value returns the value associated with key or nil if none.
|
|
||||||
Value(key interface{}) interface{}
|
|
||||||
|
|
||||||
// Deadline returns the time when this Context will be canceled, if any.
|
|
||||||
Deadline() (deadline time.Time, ok bool)
|
|
||||||
|
|
||||||
// Done returns a channel that is closed when this Context is canceled
|
|
||||||
// or times out.
|
|
||||||
Done() <-chan struct{}
|
|
||||||
|
|
||||||
// Err indicates why this context was canceled, after the Done channel
|
|
||||||
// is closed.
|
|
||||||
Err() error
|
|
||||||
}
|
|
||||||
|
|
||||||
// The key type is unexported to prevent collisions
|
// The key type is unexported to prevent collisions
|
||||||
type key int
|
type key int
|
||||||
|
|
||||||
|
@ -70,43 +46,39 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewContext instantiates a base context object for request flows.
|
// NewContext instantiates a base context object for request flows.
|
||||||
func NewContext() Context {
|
func NewContext() context.Context {
|
||||||
return context.TODO()
|
return context.TODO()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultContext instantiates a base context object for request flows in the default namespace
|
// NewDefaultContext instantiates a base context object for request flows in the default namespace
|
||||||
func NewDefaultContext() Context {
|
func NewDefaultContext() context.Context {
|
||||||
return WithNamespace(NewContext(), metav1.NamespaceDefault)
|
return WithNamespace(NewContext(), metav1.NamespaceDefault)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithValue returns a copy of parent in which the value associated with key is val.
|
// WithValue returns a copy of parent in which the value associated with key is val.
|
||||||
func WithValue(parent Context, key interface{}, val interface{}) Context {
|
func WithValue(parent context.Context, key interface{}, val interface{}) context.Context {
|
||||||
internalCtx, ok := parent.(context.Context)
|
return context.WithValue(parent, key, val)
|
||||||
if !ok {
|
|
||||||
panic(errors.New("Invalid context type"))
|
|
||||||
}
|
|
||||||
return context.WithValue(internalCtx, key, val)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithNamespace returns a copy of parent in which the namespace value is set
|
// WithNamespace returns a copy of parent in which the namespace value is set
|
||||||
func WithNamespace(parent Context, namespace string) Context {
|
func WithNamespace(parent context.Context, namespace string) context.Context {
|
||||||
return WithValue(parent, namespaceKey, namespace)
|
return WithValue(parent, namespaceKey, namespace)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NamespaceFrom returns the value of the namespace key on the ctx
|
// NamespaceFrom returns the value of the namespace key on the ctx
|
||||||
func NamespaceFrom(ctx Context) (string, bool) {
|
func NamespaceFrom(ctx context.Context) (string, bool) {
|
||||||
namespace, ok := ctx.Value(namespaceKey).(string)
|
namespace, ok := ctx.Value(namespaceKey).(string)
|
||||||
return namespace, ok
|
return namespace, ok
|
||||||
}
|
}
|
||||||
|
|
||||||
// NamespaceValue returns the value of the namespace key on the ctx, or the empty string if none
|
// NamespaceValue returns the value of the namespace key on the ctx, or the empty string if none
|
||||||
func NamespaceValue(ctx Context) string {
|
func NamespaceValue(ctx context.Context) string {
|
||||||
namespace, _ := NamespaceFrom(ctx)
|
namespace, _ := NamespaceFrom(ctx)
|
||||||
return namespace
|
return namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithNamespaceDefaultIfNone returns a context whose namespace is the default if and only if the parent context has no namespace value
|
// WithNamespaceDefaultIfNone returns a context whose namespace is the default if and only if the parent context has no namespace value
|
||||||
func WithNamespaceDefaultIfNone(parent Context) Context {
|
func WithNamespaceDefaultIfNone(parent context.Context) context.Context {
|
||||||
namespace, ok := NamespaceFrom(parent)
|
namespace, ok := NamespaceFrom(parent)
|
||||||
if !ok || len(namespace) == 0 {
|
if !ok || len(namespace) == 0 {
|
||||||
return WithNamespace(parent, metav1.NamespaceDefault)
|
return WithNamespace(parent, metav1.NamespaceDefault)
|
||||||
|
@ -115,34 +87,34 @@ func WithNamespaceDefaultIfNone(parent Context) Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithUser returns a copy of parent in which the user value is set
|
// WithUser returns a copy of parent in which the user value is set
|
||||||
func WithUser(parent Context, user user.Info) Context {
|
func WithUser(parent context.Context, user user.Info) context.Context {
|
||||||
return WithValue(parent, userKey, user)
|
return WithValue(parent, userKey, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserFrom returns the value of the user key on the ctx
|
// UserFrom returns the value of the user key on the ctx
|
||||||
func UserFrom(ctx Context) (user.Info, bool) {
|
func UserFrom(ctx context.Context) (user.Info, bool) {
|
||||||
user, ok := ctx.Value(userKey).(user.Info)
|
user, ok := ctx.Value(userKey).(user.Info)
|
||||||
return user, ok
|
return user, ok
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithUID returns a copy of parent in which the uid value is set
|
// WithUID returns a copy of parent in which the uid value is set
|
||||||
func WithUID(parent Context, uid types.UID) Context {
|
func WithUID(parent context.Context, uid types.UID) context.Context {
|
||||||
return WithValue(parent, uidKey, uid)
|
return WithValue(parent, uidKey, uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UIDFrom returns the value of the uid key on the ctx
|
// UIDFrom returns the value of the uid key on the ctx
|
||||||
func UIDFrom(ctx Context) (types.UID, bool) {
|
func UIDFrom(ctx context.Context) (types.UID, bool) {
|
||||||
uid, ok := ctx.Value(uidKey).(types.UID)
|
uid, ok := ctx.Value(uidKey).(types.UID)
|
||||||
return uid, ok
|
return uid, ok
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithAuditEvent returns set audit event struct.
|
// WithAuditEvent returns set audit event struct.
|
||||||
func WithAuditEvent(parent Context, ev *audit.Event) Context {
|
func WithAuditEvent(parent context.Context, ev *audit.Event) context.Context {
|
||||||
return WithValue(parent, auditKey, ev)
|
return WithValue(parent, auditKey, ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuditEventFrom returns the audit event struct on the ctx
|
// AuditEventFrom returns the audit event struct on the ctx
|
||||||
func AuditEventFrom(ctx Context) *audit.Event {
|
func AuditEventFrom(ctx context.Context) *audit.Event {
|
||||||
ev, _ := ctx.Value(auditKey).(*audit.Event)
|
ev, _ := ctx.Value(auditKey).(*audit.Event)
|
||||||
return ev
|
return ev
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package request
|
package request
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -232,12 +233,12 @@ type requestInfoKeyType int
|
||||||
const requestInfoKey requestInfoKeyType = iota
|
const requestInfoKey requestInfoKeyType = iota
|
||||||
|
|
||||||
// WithRequestInfo returns a copy of parent in which the request info value is set
|
// WithRequestInfo returns a copy of parent in which the request info value is set
|
||||||
func WithRequestInfo(parent Context, info *RequestInfo) Context {
|
func WithRequestInfo(parent context.Context, info *RequestInfo) context.Context {
|
||||||
return WithValue(parent, requestInfoKey, info)
|
return WithValue(parent, requestInfoKey, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequestInfoFrom returns the value of the RequestInfo key on the ctx
|
// RequestInfoFrom returns the value of the RequestInfo key on the ctx
|
||||||
func RequestInfoFrom(ctx Context) (*RequestInfo, bool) {
|
func RequestInfoFrom(ctx context.Context) (*RequestInfo, bool) {
|
||||||
info, ok := ctx.Value(requestInfoKey).(*RequestInfo)
|
info, ok := ctx.Value(requestInfoKey).(*RequestInfo)
|
||||||
return info, ok
|
return info, ok
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -99,14 +100,14 @@ type Store struct {
|
||||||
// entire collection (listing and watching).
|
// entire collection (listing and watching).
|
||||||
//
|
//
|
||||||
// KeyRootFunc and KeyFunc must be supplied together or not at all.
|
// KeyRootFunc and KeyFunc must be supplied together or not at all.
|
||||||
KeyRootFunc func(ctx genericapirequest.Context) string
|
KeyRootFunc func(ctx context.Context) string
|
||||||
|
|
||||||
// KeyFunc returns the key for a specific object in the collection.
|
// KeyFunc returns the key for a specific object in the collection.
|
||||||
// KeyFunc is called for Create/Update/Get/Delete. Note that 'namespace'
|
// KeyFunc is called for Create/Update/Get/Delete. Note that 'namespace'
|
||||||
// can be gotten from ctx.
|
// can be gotten from ctx.
|
||||||
//
|
//
|
||||||
// KeyFunc and KeyRootFunc must be supplied together or not at all.
|
// KeyFunc and KeyRootFunc must be supplied together or not at all.
|
||||||
KeyFunc func(ctx genericapirequest.Context, name string) (string, error)
|
KeyFunc func(ctx context.Context, name string) (string, error)
|
||||||
|
|
||||||
// ObjectNameFunc returns the name of an object or an error.
|
// ObjectNameFunc returns the name of an object or an error.
|
||||||
ObjectNameFunc func(obj runtime.Object) (string, error)
|
ObjectNameFunc func(obj runtime.Object) (string, error)
|
||||||
|
@ -190,7 +191,7 @@ const (
|
||||||
|
|
||||||
// NamespaceKeyRootFunc is the default function for constructing storage paths
|
// NamespaceKeyRootFunc is the default function for constructing storage paths
|
||||||
// to resource directories enforcing namespace rules.
|
// to resource directories enforcing namespace rules.
|
||||||
func NamespaceKeyRootFunc(ctx genericapirequest.Context, prefix string) string {
|
func NamespaceKeyRootFunc(ctx context.Context, prefix string) string {
|
||||||
key := prefix
|
key := prefix
|
||||||
ns, ok := genericapirequest.NamespaceFrom(ctx)
|
ns, ok := genericapirequest.NamespaceFrom(ctx)
|
||||||
if ok && len(ns) > 0 {
|
if ok && len(ns) > 0 {
|
||||||
|
@ -202,7 +203,7 @@ func NamespaceKeyRootFunc(ctx genericapirequest.Context, prefix string) string {
|
||||||
// NamespaceKeyFunc is the default function for constructing storage paths to
|
// NamespaceKeyFunc is the default function for constructing storage paths to
|
||||||
// a resource relative to the given prefix enforcing namespace rules. If the
|
// a resource relative to the given prefix enforcing namespace rules. If the
|
||||||
// context does not contain a namespace, it errors.
|
// context does not contain a namespace, it errors.
|
||||||
func NamespaceKeyFunc(ctx genericapirequest.Context, prefix string, name string) (string, error) {
|
func NamespaceKeyFunc(ctx context.Context, prefix string, name string) (string, error) {
|
||||||
key := NamespaceKeyRootFunc(ctx, prefix)
|
key := NamespaceKeyRootFunc(ctx, prefix)
|
||||||
ns, ok := genericapirequest.NamespaceFrom(ctx)
|
ns, ok := genericapirequest.NamespaceFrom(ctx)
|
||||||
if !ok || len(ns) == 0 {
|
if !ok || len(ns) == 0 {
|
||||||
|
@ -220,7 +221,7 @@ func NamespaceKeyFunc(ctx genericapirequest.Context, prefix string, name string)
|
||||||
|
|
||||||
// NoNamespaceKeyFunc is the default function for constructing storage paths
|
// NoNamespaceKeyFunc is the default function for constructing storage paths
|
||||||
// to a resource relative to the given prefix without a namespace.
|
// to a resource relative to the given prefix without a namespace.
|
||||||
func NoNamespaceKeyFunc(ctx genericapirequest.Context, prefix string, name string) (string, error) {
|
func NoNamespaceKeyFunc(ctx context.Context, prefix string, name string) (string, error) {
|
||||||
if len(name) == 0 {
|
if len(name) == 0 {
|
||||||
return "", kubeerr.NewBadRequest("Name parameter required.")
|
return "", kubeerr.NewBadRequest("Name parameter required.")
|
||||||
}
|
}
|
||||||
|
@ -263,7 +264,7 @@ func (e *Store) GetExportStrategy() rest.RESTExportStrategy {
|
||||||
|
|
||||||
// List returns a list of items matching labels and field according to the
|
// List returns a list of items matching labels and field according to the
|
||||||
// store's PredicateFunc.
|
// store's PredicateFunc.
|
||||||
func (e *Store) List(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
|
func (e *Store) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
|
||||||
label := labels.Everything()
|
label := labels.Everything()
|
||||||
if options != nil && options.LabelSelector != nil {
|
if options != nil && options.LabelSelector != nil {
|
||||||
label = options.LabelSelector
|
label = options.LabelSelector
|
||||||
|
@ -286,7 +287,7 @@ func (e *Store) List(ctx genericapirequest.Context, options *metainternalversion
|
||||||
|
|
||||||
// ListPredicate returns a list of all the items matching the given
|
// ListPredicate returns a list of all the items matching the given
|
||||||
// SelectionPredicate.
|
// SelectionPredicate.
|
||||||
func (e *Store) ListPredicate(ctx genericapirequest.Context, p storage.SelectionPredicate, options *metainternalversion.ListOptions) (runtime.Object, error) {
|
func (e *Store) ListPredicate(ctx context.Context, p storage.SelectionPredicate, options *metainternalversion.ListOptions) (runtime.Object, error) {
|
||||||
if options == nil {
|
if options == nil {
|
||||||
// By default we should serve the request from etcd.
|
// By default we should serve the request from etcd.
|
||||||
options = &metainternalversion.ListOptions{ResourceVersion: ""}
|
options = &metainternalversion.ListOptions{ResourceVersion: ""}
|
||||||
|
@ -309,7 +310,7 @@ func (e *Store) ListPredicate(ctx genericapirequest.Context, p storage.Selection
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create inserts a new item according to the unique key from the object.
|
// Create inserts a new item according to the unique key from the object.
|
||||||
func (e *Store) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
func (e *Store) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||||
if err := rest.BeforeCreate(e.CreateStrategy, ctx, obj); err != nil {
|
if err := rest.BeforeCreate(e.CreateStrategy, ctx, obj); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -372,7 +373,7 @@ func (e *Store) Create(ctx genericapirequest.Context, obj runtime.Object, create
|
||||||
|
|
||||||
// WaitForInitialized holds until the object is initialized, or returns an error if the default limit expires.
|
// WaitForInitialized holds until the object is initialized, or returns an error if the default limit expires.
|
||||||
// This method is exposed publicly for consumers of generic rest tooling.
|
// This method is exposed publicly for consumers of generic rest tooling.
|
||||||
func (e *Store) WaitForInitialized(ctx genericapirequest.Context, obj runtime.Object) (runtime.Object, error) {
|
func (e *Store) WaitForInitialized(ctx context.Context, obj runtime.Object) (runtime.Object, error) {
|
||||||
// return early if we don't have initializers, or if they've completed already
|
// return early if we don't have initializers, or if they've completed already
|
||||||
accessor, err := meta.Accessor(obj)
|
accessor, err := meta.Accessor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -453,7 +454,7 @@ func (e *Store) WaitForInitialized(ctx genericapirequest.Context, obj runtime.Ob
|
||||||
// shouldDeleteDuringUpdate checks if a Update is removing all the object's
|
// shouldDeleteDuringUpdate checks if a Update is removing all the object's
|
||||||
// finalizers. If so, it further checks if the object's
|
// finalizers. If so, it further checks if the object's
|
||||||
// DeletionGracePeriodSeconds is 0.
|
// DeletionGracePeriodSeconds is 0.
|
||||||
func (e *Store) shouldDeleteDuringUpdate(ctx genericapirequest.Context, key string, obj, existing runtime.Object) bool {
|
func (e *Store) shouldDeleteDuringUpdate(ctx context.Context, key string, obj, existing runtime.Object) bool {
|
||||||
newMeta, err := meta.Accessor(obj)
|
newMeta, err := meta.Accessor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utilruntime.HandleError(err)
|
utilruntime.HandleError(err)
|
||||||
|
@ -469,7 +470,7 @@ func (e *Store) shouldDeleteDuringUpdate(ctx genericapirequest.Context, key stri
|
||||||
|
|
||||||
// shouldDeleteForFailedInitialization returns true if the provided object is initializing and has
|
// shouldDeleteForFailedInitialization returns true if the provided object is initializing and has
|
||||||
// a failure recorded.
|
// a failure recorded.
|
||||||
func (e *Store) shouldDeleteForFailedInitialization(ctx genericapirequest.Context, obj runtime.Object) bool {
|
func (e *Store) shouldDeleteForFailedInitialization(ctx context.Context, obj runtime.Object) bool {
|
||||||
m, err := meta.Accessor(obj)
|
m, err := meta.Accessor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utilruntime.HandleError(err)
|
utilruntime.HandleError(err)
|
||||||
|
@ -483,7 +484,7 @@ func (e *Store) shouldDeleteForFailedInitialization(ctx genericapirequest.Contex
|
||||||
|
|
||||||
// deleteWithoutFinalizers handles deleting an object ignoring its finalizer list.
|
// deleteWithoutFinalizers handles deleting an object ignoring its finalizer list.
|
||||||
// Used for objects that are either been finalized or have never initialized.
|
// Used for objects that are either been finalized or have never initialized.
|
||||||
func (e *Store) deleteWithoutFinalizers(ctx genericapirequest.Context, name, key string, obj runtime.Object, preconditions *storage.Preconditions) (runtime.Object, bool, error) {
|
func (e *Store) deleteWithoutFinalizers(ctx context.Context, name, key string, obj runtime.Object, preconditions *storage.Preconditions) (runtime.Object, bool, error) {
|
||||||
out := e.NewFunc()
|
out := e.NewFunc()
|
||||||
glog.V(6).Infof("going to delete %s from registry, triggered by update", name)
|
glog.V(6).Infof("going to delete %s from registry, triggered by update", name)
|
||||||
if err := e.Storage.Delete(ctx, key, out, preconditions); err != nil {
|
if err := e.Storage.Delete(ctx, key, out, preconditions); err != nil {
|
||||||
|
@ -509,7 +510,7 @@ func (e *Store) deleteWithoutFinalizers(ctx genericapirequest.Context, name, key
|
||||||
// Update performs an atomic update and set of the object. Returns the result of the update
|
// Update performs an atomic update and set of the object. Returns the result of the update
|
||||||
// or an error. If the registry allows create-on-update, the create flow will be executed.
|
// or an error. If the registry allows create-on-update, the create flow will be executed.
|
||||||
// A bool is returned along with the object and any errors, to indicate object creation.
|
// A bool is returned along with the object and any errors, to indicate object creation.
|
||||||
func (e *Store) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
func (e *Store) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||||
key, err := e.KeyFunc(ctx, name)
|
key, err := e.KeyFunc(ctx, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
|
@ -662,7 +663,7 @@ func (e *Store) Update(ctx genericapirequest.Context, name string, objInfo rest.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get retrieves the item from storage.
|
// Get retrieves the item from storage.
|
||||||
func (e *Store) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
func (e *Store) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
||||||
obj := e.NewFunc()
|
obj := e.NewFunc()
|
||||||
key, err := e.KeyFunc(ctx, name)
|
key, err := e.KeyFunc(ctx, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -681,7 +682,7 @@ func (e *Store) Get(ctx genericapirequest.Context, name string, options *metav1.
|
||||||
|
|
||||||
// qualifiedResourceFromContext attempts to retrieve a GroupResource from the context's request info.
|
// qualifiedResourceFromContext attempts to retrieve a GroupResource from the context's request info.
|
||||||
// If the context has no request info, DefaultQualifiedResource is used.
|
// If the context has no request info, DefaultQualifiedResource is used.
|
||||||
func (e *Store) qualifiedResourceFromContext(ctx genericapirequest.Context) schema.GroupResource {
|
func (e *Store) qualifiedResourceFromContext(ctx context.Context) schema.GroupResource {
|
||||||
if info, ok := genericapirequest.RequestInfoFrom(ctx); ok {
|
if info, ok := genericapirequest.RequestInfoFrom(ctx); ok {
|
||||||
return schema.GroupResource{Group: info.APIGroup, Resource: info.Resource}
|
return schema.GroupResource{Group: info.APIGroup, Resource: info.Resource}
|
||||||
}
|
}
|
||||||
|
@ -700,7 +701,7 @@ var (
|
||||||
// priority, there are three factors affect whether to add/remove the
|
// priority, there are three factors affect whether to add/remove the
|
||||||
// FinalizerOrphanDependents: options, existing finalizers of the object,
|
// FinalizerOrphanDependents: options, existing finalizers of the object,
|
||||||
// and e.DeleteStrategy.DefaultGarbageCollectionPolicy.
|
// and e.DeleteStrategy.DefaultGarbageCollectionPolicy.
|
||||||
func shouldOrphanDependents(ctx genericapirequest.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) bool {
|
func shouldOrphanDependents(ctx context.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) bool {
|
||||||
// Get default GC policy from this REST object type
|
// Get default GC policy from this REST object type
|
||||||
gcStrategy, ok := e.DeleteStrategy.(rest.GarbageCollectionDeleteStrategy)
|
gcStrategy, ok := e.DeleteStrategy.(rest.GarbageCollectionDeleteStrategy)
|
||||||
var defaultGCPolicy rest.GarbageCollectionPolicy
|
var defaultGCPolicy rest.GarbageCollectionPolicy
|
||||||
|
@ -750,7 +751,7 @@ func shouldOrphanDependents(ctx genericapirequest.Context, e *Store, accessor me
|
||||||
// priority, there are three factors affect whether to add/remove the
|
// priority, there are three factors affect whether to add/remove the
|
||||||
// FinalizerDeleteDependents: options, existing finalizers of the object, and
|
// FinalizerDeleteDependents: options, existing finalizers of the object, and
|
||||||
// e.DeleteStrategy.DefaultGarbageCollectionPolicy.
|
// e.DeleteStrategy.DefaultGarbageCollectionPolicy.
|
||||||
func shouldDeleteDependents(ctx genericapirequest.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) bool {
|
func shouldDeleteDependents(ctx context.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) bool {
|
||||||
// Get default GC policy from this REST object type
|
// Get default GC policy from this REST object type
|
||||||
if gcStrategy, ok := e.DeleteStrategy.(rest.GarbageCollectionDeleteStrategy); ok && gcStrategy.DefaultGarbageCollectionPolicy(ctx) == rest.Unsupported {
|
if gcStrategy, ok := e.DeleteStrategy.(rest.GarbageCollectionDeleteStrategy); ok && gcStrategy.DefaultGarbageCollectionPolicy(ctx) == rest.Unsupported {
|
||||||
// return false to indicate that we should NOT delete in foreground
|
// return false to indicate that we should NOT delete in foreground
|
||||||
|
@ -793,7 +794,7 @@ func shouldDeleteDependents(ctx genericapirequest.Context, e *Store, accessor me
|
||||||
// The finalizers returned are intended to be handled by the garbage collector.
|
// The finalizers returned are intended to be handled by the garbage collector.
|
||||||
// If garbage collection is disabled for the store, this function returns false
|
// If garbage collection is disabled for the store, this function returns false
|
||||||
// to ensure finalizers aren't set which will never be cleared.
|
// to ensure finalizers aren't set which will never be cleared.
|
||||||
func deletionFinalizersForGarbageCollection(ctx genericapirequest.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) (bool, []string) {
|
func deletionFinalizersForGarbageCollection(ctx context.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) (bool, []string) {
|
||||||
if !e.EnableGarbageCollection {
|
if !e.EnableGarbageCollection {
|
||||||
return false, []string{}
|
return false, []string{}
|
||||||
}
|
}
|
||||||
|
@ -857,7 +858,7 @@ func markAsDeleting(obj runtime.Object) (err error) {
|
||||||
// should be deleted immediately
|
// should be deleted immediately
|
||||||
// 4. a new output object with the state that was updated
|
// 4. a new output object with the state that was updated
|
||||||
// 5. a copy of the last existing state of the object
|
// 5. a copy of the last existing state of the object
|
||||||
func (e *Store) updateForGracefulDeletionAndFinalizers(ctx genericapirequest.Context, name, key string, options *metav1.DeleteOptions, preconditions storage.Preconditions, in runtime.Object) (err error, ignoreNotFound, deleteImmediately bool, out, lastExisting runtime.Object) {
|
func (e *Store) updateForGracefulDeletionAndFinalizers(ctx context.Context, name, key string, options *metav1.DeleteOptions, preconditions storage.Preconditions, in runtime.Object) (err error, ignoreNotFound, deleteImmediately bool, out, lastExisting runtime.Object) {
|
||||||
lastGraceful := int64(0)
|
lastGraceful := int64(0)
|
||||||
var pendingFinalizers bool
|
var pendingFinalizers bool
|
||||||
out = e.NewFunc()
|
out = e.NewFunc()
|
||||||
|
@ -937,7 +938,7 @@ func (e *Store) updateForGracefulDeletionAndFinalizers(ctx genericapirequest.Con
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete removes the item from storage.
|
// Delete removes the item from storage.
|
||||||
func (e *Store) Delete(ctx genericapirequest.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
|
func (e *Store) Delete(ctx context.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
|
||||||
key, err := e.KeyFunc(ctx, name)
|
key, err := e.KeyFunc(ctx, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
|
@ -1015,7 +1016,7 @@ func (e *Store) Delete(ctx genericapirequest.Context, name string, options *meta
|
||||||
// are removing all objects of a given type) with the current API (it's technically
|
// are removing all objects of a given type) with the current API (it's technically
|
||||||
// possibly with storage API, but watch is not delivered correctly then).
|
// possibly with storage API, but watch is not delivered correctly then).
|
||||||
// It will be possible to fix it with v3 etcd API.
|
// It will be possible to fix it with v3 etcd API.
|
||||||
func (e *Store) DeleteCollection(ctx genericapirequest.Context, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error) {
|
func (e *Store) DeleteCollection(ctx context.Context, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error) {
|
||||||
if listOptions == nil {
|
if listOptions == nil {
|
||||||
listOptions = &metainternalversion.ListOptions{}
|
listOptions = &metainternalversion.ListOptions{}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1092,7 +1093,7 @@ func (e *Store) DeleteCollection(ctx genericapirequest.Context, options *metav1.
|
||||||
|
|
||||||
// finalizeDelete runs the Store's AfterDelete hook if runHooks is set and
|
// finalizeDelete runs the Store's AfterDelete hook if runHooks is set and
|
||||||
// returns the decorated deleted object if appropriate.
|
// returns the decorated deleted object if appropriate.
|
||||||
func (e *Store) finalizeDelete(ctx genericapirequest.Context, obj runtime.Object, runHooks bool) (runtime.Object, error) {
|
func (e *Store) finalizeDelete(ctx context.Context, obj runtime.Object, runHooks bool) (runtime.Object, error) {
|
||||||
if runHooks && e.AfterDelete != nil {
|
if runHooks && e.AfterDelete != nil {
|
||||||
if err := e.AfterDelete(obj); err != nil {
|
if err := e.AfterDelete(obj); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1127,7 +1128,7 @@ func (e *Store) finalizeDelete(ctx genericapirequest.Context, obj runtime.Object
|
||||||
// WatchPredicate. If possible, you should customize PredicateFunc to produce
|
// WatchPredicate. If possible, you should customize PredicateFunc to produce
|
||||||
// a matcher that matches by key. SelectionPredicate does this for you
|
// a matcher that matches by key. SelectionPredicate does this for you
|
||||||
// automatically.
|
// automatically.
|
||||||
func (e *Store) Watch(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
|
func (e *Store) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
|
||||||
label := labels.Everything()
|
label := labels.Everything()
|
||||||
if options != nil && options.LabelSelector != nil {
|
if options != nil && options.LabelSelector != nil {
|
||||||
label = options.LabelSelector
|
label = options.LabelSelector
|
||||||
|
@ -1147,7 +1148,7 @@ func (e *Store) Watch(ctx genericapirequest.Context, options *metainternalversio
|
||||||
}
|
}
|
||||||
|
|
||||||
// WatchPredicate starts a watch for the items that matches.
|
// WatchPredicate starts a watch for the items that matches.
|
||||||
func (e *Store) WatchPredicate(ctx genericapirequest.Context, p storage.SelectionPredicate, resourceVersion string) (watch.Interface, error) {
|
func (e *Store) WatchPredicate(ctx context.Context, p storage.SelectionPredicate, resourceVersion string) (watch.Interface, error) {
|
||||||
if name, ok := p.MatchesSingle(); ok {
|
if name, ok := p.MatchesSingle(); ok {
|
||||||
if key, err := e.KeyFunc(ctx, name); err == nil {
|
if key, err := e.KeyFunc(ctx, name); err == nil {
|
||||||
w, err := e.Storage.Watch(ctx, key, resourceVersion, p)
|
w, err := e.Storage.Watch(ctx, key, resourceVersion, p)
|
||||||
|
@ -1209,7 +1210,7 @@ func exportObjectMeta(accessor metav1.Object, exact bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export implements the rest.Exporter interface
|
// Export implements the rest.Exporter interface
|
||||||
func (e *Store) Export(ctx genericapirequest.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) {
|
func (e *Store) Export(ctx context.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) {
|
||||||
obj, err := e.Get(ctx, name, &metav1.GetOptions{})
|
obj, err := e.Get(ctx, name, &metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1299,17 +1300,17 @@ func (e *Store) CompleteWithOptions(options *generic.StoreOptions) error {
|
||||||
// Set the default behavior for storage key generation
|
// Set the default behavior for storage key generation
|
||||||
if e.KeyRootFunc == nil && e.KeyFunc == nil {
|
if e.KeyRootFunc == nil && e.KeyFunc == nil {
|
||||||
if isNamespaced {
|
if isNamespaced {
|
||||||
e.KeyRootFunc = func(ctx genericapirequest.Context) string {
|
e.KeyRootFunc = func(ctx context.Context) string {
|
||||||
return NamespaceKeyRootFunc(ctx, prefix)
|
return NamespaceKeyRootFunc(ctx, prefix)
|
||||||
}
|
}
|
||||||
e.KeyFunc = func(ctx genericapirequest.Context, name string) (string, error) {
|
e.KeyFunc = func(ctx context.Context, name string) (string, error) {
|
||||||
return NamespaceKeyFunc(ctx, prefix, name)
|
return NamespaceKeyFunc(ctx, prefix, name)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
e.KeyRootFunc = func(ctx genericapirequest.Context) string {
|
e.KeyRootFunc = func(ctx context.Context) string {
|
||||||
return prefix
|
return prefix
|
||||||
}
|
}
|
||||||
e.KeyFunc = func(ctx genericapirequest.Context, name string) (string, error) {
|
e.KeyFunc = func(ctx context.Context, name string) (string, error) {
|
||||||
return NoNamespaceKeyFunc(ctx, prefix, name)
|
return NoNamespaceKeyFunc(ctx, prefix, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1395,7 +1396,7 @@ func (e *Store) startObservingCount(period time.Duration) func() {
|
||||||
return func() { close(stopCh) }
|
return func() { close(stopCh) }
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Store) ConvertToTable(ctx genericapirequest.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
|
func (e *Store) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
|
||||||
if e.TableConvertor != nil {
|
if e.TableConvertor != nil {
|
||||||
return e.TableConvertor.ConvertToTable(ctx, object, tableOptions)
|
return e.TableConvertor.ConvertToTable(ctx, object, tableOptions)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
@ -72,7 +73,7 @@ type testGracefulStrategy struct {
|
||||||
testRESTStrategy
|
testRESTStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t testGracefulStrategy) CheckGracefulDelete(ctx genericapirequest.Context, obj runtime.Object, options *metav1.DeleteOptions) bool {
|
func (t testGracefulStrategy) CheckGracefulDelete(ctx context.Context, obj runtime.Object, options *metav1.DeleteOptions) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ type testOrphanDeleteStrategy struct {
|
||||||
*testRESTStrategy
|
*testRESTStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *testOrphanDeleteStrategy) DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) rest.GarbageCollectionPolicy {
|
func (t *testOrphanDeleteStrategy) DefaultGarbageCollectionPolicy(ctx context.Context) rest.GarbageCollectionPolicy {
|
||||||
return rest.OrphanDependents
|
return rest.OrphanDependents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +99,7 @@ func (t *testRESTStrategy) NamespaceScoped() bool { return t.namespaceS
|
||||||
func (t *testRESTStrategy) AllowCreateOnUpdate() bool { return t.allowCreateOnUpdate }
|
func (t *testRESTStrategy) AllowCreateOnUpdate() bool { return t.allowCreateOnUpdate }
|
||||||
func (t *testRESTStrategy) AllowUnconditionalUpdate() bool { return t.allowUnconditionalUpdate }
|
func (t *testRESTStrategy) AllowUnconditionalUpdate() bool { return t.allowUnconditionalUpdate }
|
||||||
|
|
||||||
func (t *testRESTStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) {
|
func (t *testRESTStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||||
metaObj, err := meta.Accessor(obj)
|
metaObj, err := meta.Accessor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
|
@ -111,11 +112,11 @@ func (t *testRESTStrategy) PrepareForCreate(ctx genericapirequest.Context, obj r
|
||||||
metaObj.SetLabels(labels)
|
metaObj.SetLabels(labels)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *testRESTStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) {}
|
func (t *testRESTStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {}
|
||||||
func (t *testRESTStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList {
|
func (t *testRESTStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (t *testRESTStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList {
|
func (t *testRESTStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (t *testRESTStrategy) Canonicalize(obj runtime.Object) {}
|
func (t *testRESTStrategy) Canonicalize(obj runtime.Object) {}
|
||||||
|
@ -172,7 +173,7 @@ func TestStoreList(t *testing.T) {
|
||||||
in *example.PodList
|
in *example.PodList
|
||||||
m storage.SelectionPredicate
|
m storage.SelectionPredicate
|
||||||
out runtime.Object
|
out runtime.Object
|
||||||
context genericapirequest.Context
|
context context.Context
|
||||||
}{
|
}{
|
||||||
"notFound": {
|
"notFound": {
|
||||||
in: nil,
|
in: nil,
|
||||||
|
@ -579,7 +580,7 @@ func TestStoreCreateInitializedFailed(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateAndVerify(t *testing.T, ctx genericapirequest.Context, registry *Store, pod *example.Pod) bool {
|
func updateAndVerify(t *testing.T, ctx context.Context, registry *Store, pod *example.Pod) bool {
|
||||||
obj, _, err := registry.Update(ctx, pod.Name, rest.DefaultUpdatedObjectInfo(pod), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
obj, _, err := registry.Update(ctx, pod.Name, rest.DefaultUpdatedObjectInfo(pod), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error: %v", err)
|
t.Errorf("Unexpected error: %v", err)
|
||||||
|
@ -733,7 +734,7 @@ func TestNoOpUpdates(t *testing.T) {
|
||||||
|
|
||||||
type testPodExport struct{}
|
type testPodExport struct{}
|
||||||
|
|
||||||
func (t testPodExport) Export(ctx genericapirequest.Context, obj runtime.Object, exact bool) error {
|
func (t testPodExport) Export(ctx context.Context, obj runtime.Object, exact bool) error {
|
||||||
pod := obj.(*example.Pod)
|
pod := obj.(*example.Pod)
|
||||||
if pod.Labels == nil {
|
if pod.Labels == nil {
|
||||||
pod.Labels = map[string]string{}
|
pod.Labels = map[string]string{}
|
||||||
|
@ -1774,7 +1775,7 @@ func TestStoreWatch(t *testing.T) {
|
||||||
|
|
||||||
table := map[string]struct {
|
table := map[string]struct {
|
||||||
selectPred storage.SelectionPredicate
|
selectPred storage.SelectionPredicate
|
||||||
context genericapirequest.Context
|
context context.Context
|
||||||
}{
|
}{
|
||||||
"single": {
|
"single": {
|
||||||
selectPred: matchPodName("foo"),
|
selectPred: matchPodName("foo"),
|
||||||
|
@ -1865,10 +1866,10 @@ func newTestGenericStoreRegistry(t *testing.T, scheme *runtime.Scheme, hasCacheE
|
||||||
CreateStrategy: strategy,
|
CreateStrategy: strategy,
|
||||||
UpdateStrategy: strategy,
|
UpdateStrategy: strategy,
|
||||||
DeleteStrategy: strategy,
|
DeleteStrategy: strategy,
|
||||||
KeyRootFunc: func(ctx genericapirequest.Context) string {
|
KeyRootFunc: func(ctx context.Context) string {
|
||||||
return podPrefix
|
return podPrefix
|
||||||
},
|
},
|
||||||
KeyFunc: func(ctx genericapirequest.Context, id string) (string, error) {
|
KeyFunc: func(ctx context.Context, id string) (string, error) {
|
||||||
if _, ok := genericapirequest.NamespaceFrom(ctx); !ok {
|
if _, ok := genericapirequest.NamespaceFrom(ctx); !ok {
|
||||||
return "", fmt.Errorf("namespace is required")
|
return "", fmt.Errorf("namespace is required")
|
||||||
}
|
}
|
||||||
|
@ -2011,7 +2012,7 @@ type fakeStrategy struct {
|
||||||
names.NameGenerator
|
names.NameGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fakeStrategy) DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) rest.GarbageCollectionPolicy {
|
func (fakeStrategy) DefaultGarbageCollectionPolicy(ctx context.Context) rest.GarbageCollectionPolicy {
|
||||||
appsv1beta1 := schema.GroupVersion{Group: "apps", Version: "v1beta1"}
|
appsv1beta1 := schema.GroupVersion{Group: "apps", Version: "v1beta1"}
|
||||||
appsv1beta2 := schema.GroupVersion{Group: "apps", Version: "v1beta2"}
|
appsv1beta2 := schema.GroupVersion{Group: "apps", Version: "v1beta2"}
|
||||||
extensionsv1beta1 := schema.GroupVersion{Group: "extensions", Version: "v1beta1"}
|
extensionsv1beta1 := schema.GroupVersion{Group: "extensions", Version: "v1beta1"}
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package tester
|
package tester
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -26,7 +27,6 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
"k8s.io/apiserver/pkg/registry/rest/resttest"
|
"k8s.io/apiserver/pkg/registry/rest/resttest"
|
||||||
etcdstorage "k8s.io/apiserver/pkg/storage/etcd"
|
etcdstorage "k8s.io/apiserver/pkg/storage/etcd"
|
||||||
|
@ -142,7 +142,7 @@ func (t *Tester) TestWatch(valid runtime.Object, labelsPass, labelsFail []labels
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|
||||||
func (t *Tester) getObject(ctx genericapirequest.Context, obj runtime.Object) (runtime.Object, error) {
|
func (t *Tester) getObject(ctx context.Context, obj runtime.Object) (runtime.Object, error) {
|
||||||
accessor, err := meta.Accessor(obj)
|
accessor, err := meta.Accessor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -155,7 +155,7 @@ func (t *Tester) getObject(ctx genericapirequest.Context, obj runtime.Object) (r
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tester) createObject(ctx genericapirequest.Context, obj runtime.Object) error {
|
func (t *Tester) createObject(ctx context.Context, obj runtime.Object) error {
|
||||||
accessor, err := meta.Accessor(obj)
|
accessor, err := meta.Accessor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -17,6 +17,8 @@ limitations under the License.
|
||||||
package rest
|
package rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
genericvalidation "k8s.io/apimachinery/pkg/api/validation"
|
genericvalidation "k8s.io/apimachinery/pkg/api/validation"
|
||||||
|
@ -26,7 +28,6 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
"k8s.io/apiserver/pkg/admission"
|
"k8s.io/apiserver/pkg/admission"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
|
||||||
"k8s.io/apiserver/pkg/features"
|
"k8s.io/apiserver/pkg/features"
|
||||||
"k8s.io/apiserver/pkg/storage/names"
|
"k8s.io/apiserver/pkg/storage/names"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
|
@ -52,12 +53,12 @@ type RESTCreateStrategy interface {
|
||||||
// status. Clear the status because status changes are internal. External
|
// status. Clear the status because status changes are internal. External
|
||||||
// callers of an api (users) should not be setting an initial status on
|
// callers of an api (users) should not be setting an initial status on
|
||||||
// newly created objects.
|
// newly created objects.
|
||||||
PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object)
|
PrepareForCreate(ctx context.Context, obj runtime.Object)
|
||||||
// Validate returns an ErrorList with validation errors or nil. Validate
|
// Validate returns an ErrorList with validation errors or nil. Validate
|
||||||
// is invoked after default fields in the object have been filled in
|
// is invoked after default fields in the object have been filled in
|
||||||
// before the object is persisted. This method should not mutate the
|
// before the object is persisted. This method should not mutate the
|
||||||
// object.
|
// object.
|
||||||
Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList
|
Validate(ctx context.Context, obj runtime.Object) field.ErrorList
|
||||||
// Canonicalize allows an object to be mutated into a canonical form. This
|
// Canonicalize allows an object to be mutated into a canonical form. This
|
||||||
// ensures that code that operates on these objects can rely on the common
|
// ensures that code that operates on these objects can rely on the common
|
||||||
// form for things like comparison. Canonicalize is invoked after
|
// form for things like comparison. Canonicalize is invoked after
|
||||||
|
@ -70,7 +71,7 @@ type RESTCreateStrategy interface {
|
||||||
// BeforeCreate ensures that common operations for all resources are performed on creation. It only returns
|
// BeforeCreate ensures that common operations for all resources are performed on creation. It only returns
|
||||||
// errors that can be converted to api.Status. It invokes PrepareForCreate, then GenerateName, then Validate.
|
// errors that can be converted to api.Status. It invokes PrepareForCreate, then GenerateName, then Validate.
|
||||||
// It returns nil if the object should be created.
|
// It returns nil if the object should be created.
|
||||||
func BeforeCreate(strategy RESTCreateStrategy, ctx genericapirequest.Context, obj runtime.Object) error {
|
func BeforeCreate(strategy RESTCreateStrategy, ctx context.Context, obj runtime.Object) error {
|
||||||
objectMeta, kind, kerr := objectMetaAndKind(strategy, obj)
|
objectMeta, kind, kerr := objectMetaAndKind(strategy, obj)
|
||||||
if kerr != nil {
|
if kerr != nil {
|
||||||
return kerr
|
return kerr
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package rest
|
package rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -25,7 +26,6 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/validation"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/validation"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RESTDeleteStrategy defines deletion behavior on an object that follows Kubernetes
|
// RESTDeleteStrategy defines deletion behavior on an object that follows Kubernetes
|
||||||
|
@ -48,7 +48,7 @@ const (
|
||||||
// orphan dependents by default.
|
// orphan dependents by default.
|
||||||
type GarbageCollectionDeleteStrategy interface {
|
type GarbageCollectionDeleteStrategy interface {
|
||||||
// DefaultGarbageCollectionPolicy returns the default garbage collection behavior.
|
// DefaultGarbageCollectionPolicy returns the default garbage collection behavior.
|
||||||
DefaultGarbageCollectionPolicy(ctx genericapirequest.Context) GarbageCollectionPolicy
|
DefaultGarbageCollectionPolicy(ctx context.Context) GarbageCollectionPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
// RESTGracefulDeleteStrategy must be implemented by the registry that supports
|
// RESTGracefulDeleteStrategy must be implemented by the registry that supports
|
||||||
|
@ -56,7 +56,7 @@ type GarbageCollectionDeleteStrategy interface {
|
||||||
type RESTGracefulDeleteStrategy interface {
|
type RESTGracefulDeleteStrategy interface {
|
||||||
// CheckGracefulDelete should return true if the object can be gracefully deleted and set
|
// CheckGracefulDelete should return true if the object can be gracefully deleted and set
|
||||||
// any default values on the DeleteOptions.
|
// any default values on the DeleteOptions.
|
||||||
CheckGracefulDelete(ctx genericapirequest.Context, obj runtime.Object, options *metav1.DeleteOptions) bool
|
CheckGracefulDelete(ctx context.Context, obj runtime.Object, options *metav1.DeleteOptions) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// BeforeDelete tests whether the object can be gracefully deleted.
|
// BeforeDelete tests whether the object can be gracefully deleted.
|
||||||
|
@ -68,7 +68,7 @@ type RESTGracefulDeleteStrategy interface {
|
||||||
// where we set deletionTimestamp is pkg/registry/generic/registry/store.go.
|
// where we set deletionTimestamp is pkg/registry/generic/registry/store.go.
|
||||||
// This function is responsible for setting deletionTimestamp during gracefulDeletion,
|
// This function is responsible for setting deletionTimestamp during gracefulDeletion,
|
||||||
// other one for cascading deletions.
|
// other one for cascading deletions.
|
||||||
func BeforeDelete(strategy RESTDeleteStrategy, ctx genericapirequest.Context, obj runtime.Object, options *metav1.DeleteOptions) (graceful, gracefulPending bool, err error) {
|
func BeforeDelete(strategy RESTDeleteStrategy, ctx context.Context, obj runtime.Object, options *metav1.DeleteOptions) (graceful, gracefulPending bool, err error) {
|
||||||
objectMeta, gvk, kerr := objectMetaAndKind(strategy, obj)
|
objectMeta, gvk, kerr := objectMetaAndKind(strategy, obj)
|
||||||
if kerr != nil {
|
if kerr != nil {
|
||||||
return false, false, kerr
|
return false, false, kerr
|
||||||
|
|
|
@ -17,8 +17,9 @@ limitations under the License.
|
||||||
package rest
|
package rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RESTExportStrategy is the interface that defines how to export a Kubernetes
|
// RESTExportStrategy is the interface that defines how to export a Kubernetes
|
||||||
|
@ -29,5 +30,5 @@ import (
|
||||||
type RESTExportStrategy interface {
|
type RESTExportStrategy interface {
|
||||||
// Export strips fields that can not be set by the user. If 'exact' is false
|
// Export strips fields that can not be set by the user. If 'exact' is false
|
||||||
// fields specific to the cluster are also stripped
|
// fields specific to the cluster are also stripped
|
||||||
Export(ctx genericapirequest.Context, obj runtime.Object, exact bool) error
|
Export(ctx context.Context, obj runtime.Object, exact bool) error
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,15 @@ limitations under the License.
|
||||||
package rest
|
package rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/uuid"
|
"k8s.io/apimachinery/pkg/util/uuid"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FillObjectMetaSystemFields populates fields that are managed by the system on ObjectMeta.
|
// FillObjectMetaSystemFields populates fields that are managed by the system on ObjectMeta.
|
||||||
func FillObjectMetaSystemFields(ctx genericapirequest.Context, meta metav1.Object) {
|
func FillObjectMetaSystemFields(ctx context.Context, meta metav1.Object) {
|
||||||
meta.SetCreationTimestamp(metav1.Now())
|
meta.SetCreationTimestamp(metav1.Now())
|
||||||
// allows admission controllers to assign a UID earlier in the request processing
|
// allows admission controllers to assign a UID earlier in the request processing
|
||||||
// to support tracking resources pending creation.
|
// to support tracking resources pending creation.
|
||||||
|
@ -38,7 +40,7 @@ func FillObjectMetaSystemFields(ctx genericapirequest.Context, meta metav1.Objec
|
||||||
// ValidNamespace returns false if the namespace on the context differs from
|
// ValidNamespace returns false if the namespace on the context differs from
|
||||||
// the resource. If the resource has no namespace, it is set to the value in
|
// the resource. If the resource has no namespace, it is set to the value in
|
||||||
// the context.
|
// the context.
|
||||||
func ValidNamespace(ctx genericapirequest.Context, resource metav1.Object) bool {
|
func ValidNamespace(ctx context.Context, resource metav1.Object) bool {
|
||||||
ns, ok := genericapirequest.NamespaceFrom(ctx)
|
ns, ok := genericapirequest.NamespaceFrom(ctx)
|
||||||
if len(resource.GetNamespace()) == 0 {
|
if len(resource.GetNamespace()) == 0 {
|
||||||
resource.SetNamespace(ns)
|
resource.SetNamespace(ns)
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package rest
|
package rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -27,7 +28,6 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//TODO:
|
//TODO:
|
||||||
|
@ -91,7 +91,7 @@ type Lister interface {
|
||||||
// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
|
// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
|
||||||
NewList() runtime.Object
|
NewList() runtime.Object
|
||||||
// List selects resources in the storage which match to the selector. 'options' can be nil.
|
// List selects resources in the storage which match to the selector. 'options' can be nil.
|
||||||
List(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (runtime.Object, error)
|
List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exporter is an object that knows how to strip a RESTful resource for export. A store should implement this interface
|
// Exporter is an object that knows how to strip a RESTful resource for export. A store should implement this interface
|
||||||
|
@ -101,7 +101,7 @@ type Exporter interface {
|
||||||
// Export an object. Fields that are not user specified (e.g. Status, ObjectMeta.ResourceVersion) are stripped out
|
// Export an object. Fields that are not user specified (e.g. Status, ObjectMeta.ResourceVersion) are stripped out
|
||||||
// Returns the stripped object. If 'exact' is true, fields that are specific to the cluster (e.g. namespace) are
|
// Returns the stripped object. If 'exact' is true, fields that are specific to the cluster (e.g. namespace) are
|
||||||
// retained, otherwise they are stripped also.
|
// retained, otherwise they are stripped also.
|
||||||
Export(ctx genericapirequest.Context, name string, opts metav1.ExportOptions) (runtime.Object, error)
|
Export(ctx context.Context, name string, opts metav1.ExportOptions) (runtime.Object, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getter is an object that can retrieve a named RESTful resource.
|
// Getter is an object that can retrieve a named RESTful resource.
|
||||||
|
@ -109,7 +109,7 @@ type Getter interface {
|
||||||
// Get finds a resource in the storage by name and returns it.
|
// Get finds a resource in the storage by name and returns it.
|
||||||
// Although it can return an arbitrary error value, IsNotFound(err) is true for the
|
// Although it can return an arbitrary error value, IsNotFound(err) is true for the
|
||||||
// returned error value err when the specified resource is not found.
|
// returned error value err when the specified resource is not found.
|
||||||
Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error)
|
Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetterWithOptions is an object that retrieve a named RESTful resource and takes
|
// GetterWithOptions is an object that retrieve a named RESTful resource and takes
|
||||||
|
@ -122,7 +122,7 @@ type GetterWithOptions interface {
|
||||||
// The options object passed to it is of the same type returned by the NewGetOptions
|
// The options object passed to it is of the same type returned by the NewGetOptions
|
||||||
// method.
|
// method.
|
||||||
// TODO: Pass metav1.GetOptions.
|
// TODO: Pass metav1.GetOptions.
|
||||||
Get(ctx genericapirequest.Context, name string, options runtime.Object) (runtime.Object, error)
|
Get(ctx context.Context, name string, options runtime.Object) (runtime.Object, error)
|
||||||
|
|
||||||
// NewGetOptions returns an empty options object that will be used to pass
|
// NewGetOptions returns an empty options object that will be used to pass
|
||||||
// options to the Get method. It may return a bool and a string, if true, the
|
// options to the Get method. It may return a bool and a string, if true, the
|
||||||
|
@ -134,7 +134,7 @@ type GetterWithOptions interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type TableConvertor interface {
|
type TableConvertor interface {
|
||||||
ConvertToTable(ctx genericapirequest.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error)
|
ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GracefulDeleter knows how to pass deletion options to allow delayed deletion of a
|
// GracefulDeleter knows how to pass deletion options to allow delayed deletion of a
|
||||||
|
@ -149,7 +149,7 @@ type GracefulDeleter interface {
|
||||||
// information about deletion.
|
// information about deletion.
|
||||||
// It also returns a boolean which is set to true if the resource was instantly
|
// It also returns a boolean which is set to true if the resource was instantly
|
||||||
// deleted or false if it will be deleted asynchronously.
|
// deleted or false if it will be deleted asynchronously.
|
||||||
Delete(ctx genericapirequest.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error)
|
Delete(ctx context.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CollectionDeleter is an object that can delete a collection
|
// CollectionDeleter is an object that can delete a collection
|
||||||
|
@ -160,7 +160,7 @@ type CollectionDeleter interface {
|
||||||
// them or return an invalid request error.
|
// them or return an invalid request error.
|
||||||
// DeleteCollection may not be atomic - i.e. it may delete some objects and still
|
// DeleteCollection may not be atomic - i.e. it may delete some objects and still
|
||||||
// return an error after it. On success, returns a list of deleted objects.
|
// return an error after it. On success, returns a list of deleted objects.
|
||||||
DeleteCollection(ctx genericapirequest.Context, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error)
|
DeleteCollection(ctx context.Context, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creater is an object that can create an instance of a RESTful object.
|
// Creater is an object that can create an instance of a RESTful object.
|
||||||
|
@ -171,7 +171,7 @@ type Creater interface {
|
||||||
|
|
||||||
// Create creates a new version of a resource. If includeUninitialized is set, the object may be returned
|
// Create creates a new version of a resource. If includeUninitialized is set, the object may be returned
|
||||||
// without completing initialization.
|
// without completing initialization.
|
||||||
Create(ctx genericapirequest.Context, obj runtime.Object, createValidation ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error)
|
Create(ctx context.Context, obj runtime.Object, createValidation ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NamedCreater is an object that can create an instance of a RESTful object using a name parameter.
|
// NamedCreater is an object that can create an instance of a RESTful object using a name parameter.
|
||||||
|
@ -184,7 +184,7 @@ type NamedCreater interface {
|
||||||
// This is needed for create operations on subresources which include the name of the parent
|
// This is needed for create operations on subresources which include the name of the parent
|
||||||
// resource in the path. If includeUninitialized is set, the object may be returned without
|
// resource in the path. If includeUninitialized is set, the object may be returned without
|
||||||
// completing initialization.
|
// completing initialization.
|
||||||
Create(ctx genericapirequest.Context, name string, obj runtime.Object, createValidation ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error)
|
Create(ctx context.Context, name string, obj runtime.Object, createValidation ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatedObjectInfo provides information about an updated object to an Updater.
|
// UpdatedObjectInfo provides information about an updated object to an Updater.
|
||||||
|
@ -197,7 +197,7 @@ type UpdatedObjectInfo interface {
|
||||||
|
|
||||||
// UpdatedObject returns the updated object, given a context and old object.
|
// UpdatedObject returns the updated object, given a context and old object.
|
||||||
// The only time an empty oldObj should be passed in is if a "create on update" is occurring (there is no oldObj).
|
// The only time an empty oldObj should be passed in is if a "create on update" is occurring (there is no oldObj).
|
||||||
UpdatedObject(ctx genericapirequest.Context, oldObj runtime.Object) (newObj runtime.Object, err error)
|
UpdatedObject(ctx context.Context, oldObj runtime.Object) (newObj runtime.Object, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateObjectFunc is a function to act on a given object. An error may be returned
|
// ValidateObjectFunc is a function to act on a given object. An error may be returned
|
||||||
|
@ -229,14 +229,14 @@ type Updater interface {
|
||||||
// Update finds a resource in the storage and updates it. Some implementations
|
// Update finds a resource in the storage and updates it. Some implementations
|
||||||
// may allow updates creates the object - they should set the created boolean
|
// may allow updates creates the object - they should set the created boolean
|
||||||
// to true.
|
// to true.
|
||||||
Update(ctx genericapirequest.Context, name string, objInfo UpdatedObjectInfo, createValidation ValidateObjectFunc, updateValidation ValidateObjectUpdateFunc) (runtime.Object, bool, error)
|
Update(ctx context.Context, name string, objInfo UpdatedObjectInfo, createValidation ValidateObjectFunc, updateValidation ValidateObjectUpdateFunc) (runtime.Object, bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreaterUpdater is a storage object that must support both create and update.
|
// CreaterUpdater is a storage object that must support both create and update.
|
||||||
// Go prevents embedded interfaces that implement the same method.
|
// Go prevents embedded interfaces that implement the same method.
|
||||||
type CreaterUpdater interface {
|
type CreaterUpdater interface {
|
||||||
Creater
|
Creater
|
||||||
Update(ctx genericapirequest.Context, name string, objInfo UpdatedObjectInfo, createValidation ValidateObjectFunc, updateValidation ValidateObjectUpdateFunc) (runtime.Object, bool, error)
|
Update(ctx context.Context, name string, objInfo UpdatedObjectInfo, createValidation ValidateObjectFunc, updateValidation ValidateObjectUpdateFunc) (runtime.Object, bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreaterUpdater must satisfy the Updater interface.
|
// CreaterUpdater must satisfy the Updater interface.
|
||||||
|
@ -255,7 +255,7 @@ type Watcher interface {
|
||||||
// are supported; an error should be returned if 'field' tries to select on a field that
|
// are supported; an error should be returned if 'field' tries to select on a field that
|
||||||
// isn't supported. 'resourceVersion' allows for continuing/starting a watch at a
|
// isn't supported. 'resourceVersion' allows for continuing/starting a watch at a
|
||||||
// particular version.
|
// particular version.
|
||||||
Watch(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StandardStorage is an interface covering the common verbs. Provided for testing whether a
|
// StandardStorage is an interface covering the common verbs. Provided for testing whether a
|
||||||
|
@ -272,7 +272,7 @@ type StandardStorage interface {
|
||||||
// Redirector know how to return a remote resource's location.
|
// Redirector know how to return a remote resource's location.
|
||||||
type Redirector interface {
|
type Redirector interface {
|
||||||
// ResourceLocation should return the remote location of the given resource, and an optional transport to use to request it, or an error.
|
// ResourceLocation should return the remote location of the given resource, and an optional transport to use to request it, or an error.
|
||||||
ResourceLocation(ctx genericapirequest.Context, id string) (remoteLocation *url.URL, transport http.RoundTripper, err error)
|
ResourceLocation(ctx context.Context, id string) (remoteLocation *url.URL, transport http.RoundTripper, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Responder abstracts the normal response behavior for a REST method and is passed to callers that
|
// Responder abstracts the normal response behavior for a REST method and is passed to callers that
|
||||||
|
@ -292,7 +292,7 @@ type Connecter interface {
|
||||||
// code and body, so the ServeHTTP method should exit after invoking the responder. The Handler will
|
// code and body, so the ServeHTTP method should exit after invoking the responder. The Handler will
|
||||||
// be used for a single API request and then discarded. The Responder is guaranteed to write to the
|
// be used for a single API request and then discarded. The Responder is guaranteed to write to the
|
||||||
// same http.ResponseWriter passed to ServeHTTP.
|
// same http.ResponseWriter passed to ServeHTTP.
|
||||||
Connect(ctx genericapirequest.Context, id string, options runtime.Object, r Responder) (http.Handler, error)
|
Connect(ctx context.Context, id string, options runtime.Object, r Responder) (http.Handler, error)
|
||||||
|
|
||||||
// NewConnectOptions returns an empty options object that will be used to pass
|
// NewConnectOptions returns an empty options object that will be used to pass
|
||||||
// options to the Connect method. If nil, then a nil options object is passed to
|
// options to the Connect method. If nil, then a nil options object is passed to
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package resttest
|
package resttest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -99,7 +100,7 @@ func (t *Tester) TestNamespace() string {
|
||||||
|
|
||||||
// TestContext returns a namespaced context that will be used when making storage calls.
|
// TestContext returns a namespaced context that will be used when making storage calls.
|
||||||
// Namespace is determined by TestNamespace()
|
// Namespace is determined by TestNamespace()
|
||||||
func (t *Tester) TestContext() genericapirequest.Context {
|
func (t *Tester) TestContext() context.Context {
|
||||||
if t.clusterScope {
|
if t.clusterScope {
|
||||||
return genericapirequest.NewContext()
|
return genericapirequest.NewContext()
|
||||||
}
|
}
|
||||||
|
@ -128,11 +129,11 @@ func (t *Tester) setObjectMeta(obj runtime.Object, name string) {
|
||||||
|
|
||||||
type AssignFunc func([]runtime.Object) []runtime.Object
|
type AssignFunc func([]runtime.Object) []runtime.Object
|
||||||
type EmitFunc func(runtime.Object, string) error
|
type EmitFunc func(runtime.Object, string) error
|
||||||
type GetFunc func(genericapirequest.Context, runtime.Object) (runtime.Object, error)
|
type GetFunc func(context.Context, runtime.Object) (runtime.Object, error)
|
||||||
type InitWatchFunc func()
|
type InitWatchFunc func()
|
||||||
type InjectErrFunc func(err error)
|
type InjectErrFunc func(err error)
|
||||||
type IsErrorFunc func(err error) bool
|
type IsErrorFunc func(err error) bool
|
||||||
type CreateFunc func(genericapirequest.Context, runtime.Object) error
|
type CreateFunc func(context.Context, runtime.Object) error
|
||||||
type SetRVFunc func(uint64)
|
type SetRVFunc func(uint64)
|
||||||
type UpdateFunc func(runtime.Object) runtime.Object
|
type UpdateFunc func(runtime.Object) runtime.Object
|
||||||
|
|
||||||
|
@ -219,7 +220,7 @@ func (t *Tester) TestWatch(
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Creation tests.
|
// Creation tests.
|
||||||
|
|
||||||
func (t *Tester) delete(ctx genericapirequest.Context, obj runtime.Object) error {
|
func (t *Tester) delete(ctx context.Context, obj runtime.Object) error {
|
||||||
objectMeta, err := meta.Accessor(obj)
|
objectMeta, err := meta.Accessor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -576,7 +577,7 @@ func (t *Tester) testUpdateRetrievesOldObject(obj runtime.Object, createFn Creat
|
||||||
// Make sure a custom transform is called, and sees the expected updatedObject and oldObject
|
// Make sure a custom transform is called, and sees the expected updatedObject and oldObject
|
||||||
// This tests the mechanism used to pass the old and new object to admission
|
// This tests the mechanism used to pass the old and new object to admission
|
||||||
calledUpdatedObject := 0
|
calledUpdatedObject := 0
|
||||||
noopTransform := func(_ genericapirequest.Context, updatedObject runtime.Object, oldObject runtime.Object) (runtime.Object, error) {
|
noopTransform := func(_ context.Context, updatedObject runtime.Object, oldObject runtime.Object) (runtime.Object, error) {
|
||||||
if !reflect.DeepEqual(storedFoo, oldObject) {
|
if !reflect.DeepEqual(storedFoo, oldObject) {
|
||||||
t.Errorf("Expected\n\t%#v\ngot\n\t%#v", storedFoo, oldObject)
|
t.Errorf("Expected\n\t%#v\ngot\n\t%#v", storedFoo, oldObject)
|
||||||
}
|
}
|
||||||
|
@ -618,7 +619,7 @@ func (t *Tester) testUpdatePropagatesUpdatedObjectError(obj runtime.Object, crea
|
||||||
|
|
||||||
// Make sure our transform is called, and sees the expected updatedObject and oldObject
|
// Make sure our transform is called, and sees the expected updatedObject and oldObject
|
||||||
propagateErr := fmt.Errorf("custom updated object error for %v", foo)
|
propagateErr := fmt.Errorf("custom updated object error for %v", foo)
|
||||||
noopTransform := func(_ genericapirequest.Context, updatedObject runtime.Object, oldObject runtime.Object) (runtime.Object, error) {
|
noopTransform := func(_ context.Context, updatedObject runtime.Object, oldObject runtime.Object) (runtime.Object, error) {
|
||||||
return nil, propagateErr
|
return nil, propagateErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package rest
|
package rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -26,7 +27,6 @@ import (
|
||||||
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
|
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type defaultTableConvertor struct {
|
type defaultTableConvertor struct {
|
||||||
|
@ -40,7 +40,7 @@ func NewDefaultTableConvertor(resource schema.GroupResource) TableConvertor {
|
||||||
|
|
||||||
var swaggerMetadataDescriptions = metav1.ObjectMeta{}.SwaggerDoc()
|
var swaggerMetadataDescriptions = metav1.ObjectMeta{}.SwaggerDoc()
|
||||||
|
|
||||||
func (c defaultTableConvertor) ConvertToTable(ctx genericapirequest.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
|
func (c defaultTableConvertor) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
|
||||||
var table metav1beta1.Table
|
var table metav1beta1.Table
|
||||||
fn := func(obj runtime.Object) error {
|
fn := func(obj runtime.Object) error {
|
||||||
m, err := meta.Accessor(obj)
|
m, err := meta.Accessor(obj)
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package rest
|
package rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
@ -27,7 +28,6 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
"k8s.io/apiserver/pkg/admission"
|
"k8s.io/apiserver/pkg/admission"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
|
||||||
"k8s.io/apiserver/pkg/features"
|
"k8s.io/apiserver/pkg/features"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
)
|
)
|
||||||
|
@ -46,11 +46,11 @@ type RESTUpdateStrategy interface {
|
||||||
// the object. For example: remove fields that are not to be persisted,
|
// the object. For example: remove fields that are not to be persisted,
|
||||||
// sort order-insensitive list fields, etc. This should not remove fields
|
// sort order-insensitive list fields, etc. This should not remove fields
|
||||||
// whose presence would be considered a validation error.
|
// whose presence would be considered a validation error.
|
||||||
PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object)
|
PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
|
||||||
// ValidateUpdate is invoked after default fields in the object have been
|
// ValidateUpdate is invoked after default fields in the object have been
|
||||||
// filled in before the object is persisted. This method should not mutate
|
// filled in before the object is persisted. This method should not mutate
|
||||||
// the object.
|
// the object.
|
||||||
ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList
|
ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList
|
||||||
// Canonicalize allows an object to be mutated into a canonical form. This
|
// Canonicalize allows an object to be mutated into a canonical form. This
|
||||||
// ensures that code that operates on these objects can rely on the common
|
// ensures that code that operates on these objects can rely on the common
|
||||||
// form for things like comparison. Canonicalize is invoked after
|
// form for things like comparison. Canonicalize is invoked after
|
||||||
|
@ -83,7 +83,7 @@ func validateCommonFields(obj, old runtime.Object, strategy RESTUpdateStrategy)
|
||||||
// BeforeUpdate ensures that common operations for all resources are performed on update. It only returns
|
// BeforeUpdate ensures that common operations for all resources are performed on update. It only returns
|
||||||
// errors that can be converted to api.Status. It will invoke update validation with the provided existing
|
// errors that can be converted to api.Status. It will invoke update validation with the provided existing
|
||||||
// and updated objects.
|
// and updated objects.
|
||||||
func BeforeUpdate(strategy RESTUpdateStrategy, ctx genericapirequest.Context, obj, old runtime.Object) error {
|
func BeforeUpdate(strategy RESTUpdateStrategy, ctx context.Context, obj, old runtime.Object) error {
|
||||||
objectMeta, kind, kerr := objectMetaAndKind(strategy, obj)
|
objectMeta, kind, kerr := objectMetaAndKind(strategy, obj)
|
||||||
if kerr != nil {
|
if kerr != nil {
|
||||||
return kerr
|
return kerr
|
||||||
|
@ -130,7 +130,7 @@ func BeforeUpdate(strategy RESTUpdateStrategy, ctx genericapirequest.Context, ob
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransformFunc is a function to transform and return newObj
|
// TransformFunc is a function to transform and return newObj
|
||||||
type TransformFunc func(ctx genericapirequest.Context, newObj runtime.Object, oldObj runtime.Object) (transformedNewObj runtime.Object, err error)
|
type TransformFunc func(ctx context.Context, newObj runtime.Object, oldObj runtime.Object) (transformedNewObj runtime.Object, err error)
|
||||||
|
|
||||||
// defaultUpdatedObjectInfo implements UpdatedObjectInfo
|
// defaultUpdatedObjectInfo implements UpdatedObjectInfo
|
||||||
type defaultUpdatedObjectInfo struct {
|
type defaultUpdatedObjectInfo struct {
|
||||||
|
@ -167,7 +167,7 @@ func (i *defaultUpdatedObjectInfo) Preconditions() *metav1.Preconditions {
|
||||||
|
|
||||||
// UpdatedObject satisfies the UpdatedObjectInfo interface.
|
// UpdatedObject satisfies the UpdatedObjectInfo interface.
|
||||||
// It returns a copy of the held obj, passed through any configured transformers.
|
// It returns a copy of the held obj, passed through any configured transformers.
|
||||||
func (i *defaultUpdatedObjectInfo) UpdatedObject(ctx genericapirequest.Context, oldObj runtime.Object) (runtime.Object, error) {
|
func (i *defaultUpdatedObjectInfo) UpdatedObject(ctx context.Context, oldObj runtime.Object) (runtime.Object, error) {
|
||||||
var err error
|
var err error
|
||||||
// Start with the configured object
|
// Start with the configured object
|
||||||
newObj := i.obj
|
newObj := i.obj
|
||||||
|
@ -214,7 +214,7 @@ func (i *wrappedUpdatedObjectInfo) Preconditions() *metav1.Preconditions {
|
||||||
|
|
||||||
// UpdatedObject satisfies the UpdatedObjectInfo interface.
|
// UpdatedObject satisfies the UpdatedObjectInfo interface.
|
||||||
// It delegates to the wrapped objInfo and passes the result through any configured transformers.
|
// It delegates to the wrapped objInfo and passes the result through any configured transformers.
|
||||||
func (i *wrappedUpdatedObjectInfo) UpdatedObject(ctx genericapirequest.Context, oldObj runtime.Object) (runtime.Object, error) {
|
func (i *wrappedUpdatedObjectInfo) UpdatedObject(ctx context.Context, oldObj runtime.Object) (runtime.Object, error) {
|
||||||
newObj, err := i.objInfo.UpdatedObject(ctx, oldObj)
|
newObj, err := i.objInfo.UpdatedObject(ctx, oldObj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return newObj, err
|
return newObj, err
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -47,7 +48,6 @@ import (
|
||||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||||
"k8s.io/apiserver/pkg/endpoints/discovery"
|
"k8s.io/apiserver/pkg/endpoints/discovery"
|
||||||
genericapifilters "k8s.io/apiserver/pkg/endpoints/filters"
|
genericapifilters "k8s.io/apiserver/pkg/endpoints/filters"
|
||||||
apirequest "k8s.io/apiserver/pkg/endpoints/request"
|
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
genericfilters "k8s.io/apiserver/pkg/server/filters"
|
genericfilters "k8s.io/apiserver/pkg/server/filters"
|
||||||
"k8s.io/client-go/informers"
|
"k8s.io/client-go/informers"
|
||||||
|
@ -467,7 +467,7 @@ func (p *testGetterStorage) New() runtime.Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *testGetterStorage) Get(ctx apirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
func (p *testGetterStorage) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue