type FinishFunc … type AfterDeleteFunc … type BeginCreateFunc … type AfterCreateFunc … type BeginUpdateFunc … type AfterUpdateFunc … type GenericStore … type Store … var _ … var _ … var _ … var _ … var _ … const OptimisticLockErrorMsg … const resourceCountPollPeriodJitter … // NamespaceKeyRootFunc is the default function for constructing storage paths // to resource directories enforcing namespace rules. func NamespaceKeyRootFunc(ctx context.Context, prefix string) string { … } // NamespaceKeyFunc is the default function for constructing storage paths to // a resource relative to the given prefix enforcing namespace rules. If the // context does not contain a namespace, it errors. func NamespaceKeyFunc(ctx context.Context, prefix string, name string) (string, error) { … } // NoNamespaceKeyFunc is the default function for constructing storage paths // to a resource relative to the given prefix without a namespace. func NoNamespaceKeyFunc(ctx context.Context, prefix string, name string) (string, error) { … } // New implements RESTStorage.New. func (e *Store) New() runtime.Object { … } // ReadinessCheck checks if the storage is ready for accepting requests. func (e *Store) ReadinessCheck() error { … } // Destroy cleans up its resources on shutdown. func (e *Store) Destroy() { … } // NewList implements rest.Lister. func (e *Store) NewList() runtime.Object { … } // NamespaceScoped indicates whether the resource is namespaced func (e *Store) NamespaceScoped() bool { … } // GetCreateStrategy implements GenericStore. func (e *Store) GetCreateStrategy() rest.RESTCreateStrategy { … } // GetUpdateStrategy implements GenericStore. func (e *Store) GetUpdateStrategy() rest.RESTUpdateStrategy { … } // GetDeleteStrategy implements GenericStore. func (e *Store) GetDeleteStrategy() rest.RESTDeleteStrategy { … } // List returns a list of items matching labels and field according to the // store's PredicateFunc. func (e *Store) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) { … } // ListPredicate returns a list of all the items matching the given // SelectionPredicate. func (e *Store) ListPredicate(ctx context.Context, p storage.SelectionPredicate, options *metainternalversion.ListOptions) (runtime.Object, error) { … } // finishNothing is a do-nothing FinishFunc. func finishNothing(context.Context, bool) { … } const maxNameGenerationCreateAttempts … // Create inserts a new item according to the unique key from the object. // Note that registries may mutate the input object (e.g. in the strategy // hooks). Tests which call this might want to call DeepCopy if they expect to // be able to examine the input and output objects for differences. func (e *Store) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) { … } // needsNameGeneration returns true if the obj has a generateName but no name. func needsNameGeneration(obj runtime.Object) bool { … } // createWithGenerateNameRetry attempts to create obj up to maxNameGenerationCreateAttempts // when create fails due to a name conflict error. Each attempt randomly generates a new // name based on generateName. func (e *Store) createWithGenerateNameRetry(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (resultObj runtime.Object, err error) { … } func (e *Store) create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) { … } // ShouldDeleteDuringUpdate is the default function for // checking if an object should be deleted during an update. // It checks if the new object has no finalizers, // the existing object's deletionTimestamp is set, and // the existing object's deletionGracePeriodSeconds is 0 or nil func ShouldDeleteDuringUpdate(ctx context.Context, key string, obj, existing runtime.Object) bool { … } // deleteWithoutFinalizers handles deleting an object ignoring its finalizer list. // Used for objects that are either been finalized or have never initialized. func (e *Store) deleteWithoutFinalizers(ctx context.Context, name, key string, obj runtime.Object, preconditions *storage.Preconditions, options *metav1.DeleteOptions) (runtime.Object, bool, error) { … } // Update performs an atomic update and set of the object. Returns the result of the update // or an error. If the registry allows create-on-update, the create flow will be executed. // A bool is returned along with the object and any errors, to indicate object creation. func (e *Store) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { … } // This is a helper to convert UpdateOptions to CreateOptions for the // create-on-update path. func newCreateOptionsFromUpdateOptions(in *metav1.UpdateOptions) *metav1.CreateOptions { … } // This is a helper to convert UpdateOptions to DeleteOptions for the // delete-on-update path. func newDeleteOptionsFromUpdateOptions(in *metav1.UpdateOptions) *metav1.DeleteOptions { … } // Get retrieves the item from storage. func (e *Store) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { … } // qualifiedResourceFromContext attempts to retrieve a GroupResource from the context's request info. // If the context has no request info, DefaultQualifiedResource is used. func (e *Store) qualifiedResourceFromContext(ctx context.Context) schema.GroupResource { … } var errAlreadyDeleting … var errDeleteNow … var errEmptiedFinalizers … // shouldOrphanDependents returns true if the finalizer for orphaning should be set // updated for FinalizerOrphanDependents. In the order of highest to lowest // priority, there are three factors affect whether to add/remove the // FinalizerOrphanDependents: options, existing finalizers of the object, // and e.DeleteStrategy.DefaultGarbageCollectionPolicy. func shouldOrphanDependents(ctx context.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) bool { … } // shouldDeleteDependents returns true if the finalizer for foreground deletion should be set // updated for FinalizerDeleteDependents. In the order of highest to lowest // priority, there are three factors affect whether to add/remove the // FinalizerDeleteDependents: options, existing finalizers of the object, and // e.DeleteStrategy.DefaultGarbageCollectionPolicy. func shouldDeleteDependents(ctx context.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) bool { … } // deletionFinalizersForGarbageCollection analyzes the object and delete options // to determine whether the object is in need of finalization by the garbage // collector. If so, returns the set of deletion finalizers to apply and a bool // indicating whether the finalizer list has changed and is in need of updating. // // The finalizers returned are intended to be handled by the garbage collector. // If garbage collection is disabled for the store, this function returns false // to ensure finalizers aren't set which will never be cleared. func deletionFinalizersForGarbageCollection(ctx context.Context, e *Store, accessor metav1.Object, options *metav1.DeleteOptions) (bool, []string) { … } // markAsDeleting sets the obj's DeletionGracePeriodSeconds to 0, and sets the // DeletionTimestamp to "now" if there is no existing deletionTimestamp or if the existing // deletionTimestamp is further in future. Finalizers are watching for such updates and will // finalize the object if their IDs are present in the object's Finalizers list. func markAsDeleting(obj runtime.Object, now time.Time) (err error) { … } // updateForGracefulDeletionAndFinalizers updates the given object for // graceful deletion and finalization by setting the deletion timestamp and // grace period seconds (graceful deletion) and updating the list of // finalizers (finalization); it returns: // // 1. an error // 2. a boolean indicating that the object was not found, but it should be // ignored // 3. a boolean indicating that the object's grace period is exhausted and it // should be deleted immediately // 4. a new output object with the state that was updated // 5. a copy of the last existing state of the object func (e *Store) updateForGracefulDeletionAndFinalizers(ctx context.Context, name, key string, options *metav1.DeleteOptions, preconditions storage.Preconditions, deleteValidation rest.ValidateObjectFunc, in runtime.Object) (err error, ignoreNotFound, deleteImmediately bool, out, lastExisting runtime.Object) { … } // Delete removes the item from storage. // options can be mutated by rest.BeforeDelete due to a graceful deletion strategy. func (e *Store) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error) { … } // DeleteReturnsDeletedObject implements the rest.MayReturnFullObjectDeleter interface func (e *Store) DeleteReturnsDeletedObject() bool { … } var deleteCollectionPageSize … // DeleteCollection removes all items returned by List with a given ListOptions from storage. // // DeleteCollection is currently NOT atomic. It can happen that only subset of objects // will be deleted from storage, and then an error will be returned. // In case of success, the list of deleted objects will be returned. func (e *Store) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error) { … } // finalizeDelete runs the Store's AfterDelete hook if runHooks is set and // returns the decorated deleted object if appropriate. func (e *Store) finalizeDelete(ctx context.Context, obj runtime.Object, runHooks bool, options *metav1.DeleteOptions) (runtime.Object, error) { … } // Watch makes a matcher for the given label and field, and calls // WatchPredicate. If possible, you should customize PredicateFunc to produce // a matcher that matches by key. SelectionPredicate does this for you // automatically. func (e *Store) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { … } // WatchPredicate starts a watch for the items that matches. func (e *Store) WatchPredicate(ctx context.Context, p storage.SelectionPredicate, resourceVersion string, sendInitialEvents *bool) (watch.Interface, error) { … } // calculateTTL is a helper for retrieving the updated TTL for an object or // returning an error if the TTL cannot be calculated. The defaultTTL is // changed to 1 if less than zero. Zero means no TTL, not expire immediately. func (e *Store) calculateTTL(obj runtime.Object, defaultTTL int64, update bool) (ttl uint64, err error) { … } // CompleteWithOptions updates the store with the provided options and // defaults common fields. func (e *Store) CompleteWithOptions(options *generic.StoreOptions) error { … } // startObservingCount starts monitoring given prefix and periodically updating metrics. It returns a function to stop collection. func (e *Store) startObservingCount(period time.Duration, objectCountTracker flowcontrolrequest.StorageObjectCountTracker) func() { … } func (e *Store) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { … } func (e *Store) StorageVersion() runtime.GroupVersioner { … } // GetResetFields implements rest.ResetFieldsStrategy func (e *Store) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { … } func (e *Store) GetSingularName() string { … } // validateIndexers will check the prefix of indexers. func validateIndexers(indexers *cache.Indexers) error { … }