registry

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type CreateUpdateStrategy

type CreateUpdateStrategy interface {
	// NewObject create an empty object that the strategt applied to
	NewObject() runtime.Object
	// PrepareForCreate mutate a new resource before persistent it
	PrepareForCreate(ctx context.Context, obj runtime.Object)
	// PrepareForUpdate mutate a new resource before it replace the existing on in storage
	PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
	// Validate validates a new resource
	Validate(ctx context.Context, obj runtime.Object) field.ErrorList
	// ValidateUpdate validates an update request for existing resource
	ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList
}

CreateUpdateStrategy is a sub set of the RESTCreateUpdateStrategy interface of kube-apiserver, which abstracts the defaulting and validation logic of each custom resources in the kube-apiserver way but allow using webhook as an alternative implementation. Note that PrepareForCreate/Update method is different with the defaultingFunc of kube-apiserver, the latter one is applied to versioned resource, and PrepareForCreate/Update is applied to resource after conversion. MutatingAdmissionWebhook is also applied to resource after conversion, which allows it to implement the correct semantic of PrepareForCreate/Update as the following figure shows:

         +
      Resource
         |
+--------v---------+
|    Conversion    |
+--------+---------+
         |     MutatingWebhook   +---------------------+
         +---------------------->+   Prepare(Webhook)  |
                                 +----------+----------+
                                            |
         +----------------------------------+
         |
+--------v---------+
|  Prepare(Server) |
+--------+---------+
         |
+--------v---------+
| Validate(Server) |
+--------+---------+
         |    ValidatingWebhook  +---------------------+
         +---------------------->+  Validate(Webhook)  |
                                 +----------+----------+
                                            |
         +----------------------------------+
         |
+--------v---------+
|       ETCD       |
+------------------+

There is a special case for custom resource, if there is only one version specified, the conversion is actually no-op. And if there is multiple versions specified, a storage version could be specified in CustomResourceDefinition which acts the conversion target. So, the strategy is always applied to a certain version of CustomResource instead of an "internal" version.

TODO(aylei): we may place this definition in a more reasonable package

type TikvClusterStrategy

type TikvClusterStrategy struct{}

+k8s:deepcopy-gen=false

func (TikvClusterStrategy) NewObject

func (TikvClusterStrategy) NewObject() runtime.Object

func (TikvClusterStrategy) PrepareForCreate

func (TikvClusterStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object)

func (TikvClusterStrategy) PrepareForUpdate

func (TikvClusterStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)

func (TikvClusterStrategy) Validate

func (TikvClusterStrategy) ValidateUpdate

func (TikvClusterStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL