Documentation ¶
Index ¶
- func MigrateNamespacedObjects()
- func MigrateStorageVersion()
- func RegisterStorageRegistry(registry ApiObjectRegistry) error
- func RegisterStorageVersion(gk core.GK, apiVersion string) error
- func SetConvertByBytesFunc(f core.ConvertByBytesFunc)
- func SetNewByGVKFunc(f core.NewByGVKFunc)
- type ApiObjectRegistry
- type HookFunc
- type Registry
- func (r Registry) Create(ctx context.Context, obj core.ApiObject, opts ...core.OpOpt) (core.ApiObject, error)
- func (r Registry) Delete(ctx context.Context, namespace string, name string, opts ...core.OpOpt) (core.ApiObject, error)
- func (r Registry) GVK() core.GVK
- func (r Registry) Get(ctx context.Context, namespace string, name string, opts ...core.OpOpt) (core.ApiObject, error)
- func (r Registry) GetWatch(ctx context.Context, namespace string, name string) <-chan core.ApiObjectAction
- func (r Registry) List(ctx context.Context, namespace string, opts ...core.OpOpt) (core.ApiObjectList, error)
- func (r Registry) ListWatch(ctx context.Context, namespace string) <-chan core.ApiObjectAction
- func (r Registry) MigrateObjects() error
- func (r Registry) Namespaced() bool
- func (r *Registry) SetDecorateHook(hook HookFunc)
- func (r *Registry) SetDefaultFinalizers(finalizers []string)
- func (r *Registry) SetMutateHook(hook HookFunc)
- func (r *Registry) SetPostCreateHook(hook HookFunc)
- func (r *Registry) SetPostDeleteHook(hook HookFunc)
- func (r *Registry) SetPostUpdateHook(hook HookFunc)
- func (r *Registry) SetPreCreateHook(hook HookFunc)
- func (r *Registry) SetPreDeleteHook(hook HookFunc)
- func (r *Registry) SetPreUpdateHook(hook HookFunc)
- func (r *Registry) SetRevisioner(revisioner Revisioner)
- func (r *Registry) SetValidateHook(hook HookFunc)
- func (r Registry) Update(ctx context.Context, obj core.ApiObject, opts ...core.OpOpt) (core.ApiObject, error)
- func (r Registry) UpdateStatus(namespace string, name string, status core.Status) (core.ApiObject, error)
- func (r Registry) UpdateStatusPhase(namespace string, name string, phase string) (core.ApiObject, error)
- func (r Registry) Watch(ctx context.Context, namespace string, name string) <-chan core.ApiObjectAction
- type Revisioner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateNamespacedObjects ¶
func MigrateNamespacedObjects()
MigrateNamespacedObjects 将归属于命名空间下的资源存储路径进行迁移,从/registry/namespaces/<namespace>/<kind>/<name>迁移至/registry/<kind>/<namespace>/<name>
func RegisterStorageRegistry ¶
func RegisterStorageRegistry(registry ApiObjectRegistry) error
RegisterStorageRegistry 注册可用于数据迁移的存储器
func RegisterStorageVersion ¶
RegisterStorageVersion 注册数据库中实际存储的对象版本
func SetConvertByBytesFunc ¶
func SetConvertByBytesFunc(f core.ConvertByBytesFunc)
SetConverByBytesFunc 设置将字节转换为资源结构的方法实现,该方法在存储器中使用,将未知的序列化数据反序列化为明确类型的资源对象,并转换为指定版本结构的资源对象
func SetNewByGVKFunc ¶
func SetNewByGVKFunc(f core.NewByGVKFunc)
SetNewByGVKFunc 设置根据GVK生成明确类型资源对象的方法,该方法在数据迁移时使用,根据Group,ApiVersion和Kind信息实例化对应的资源对象
Types ¶
type ApiObjectRegistry ¶
type ApiObjectRegistry interface { // 写入一条新记录 Create(ctx context.Context, obj core.ApiObject, opts ...core.OpOpt) (core.ApiObject, error) // 更新一条已存在的记录 Update(ctx context.Context, obj core.ApiObject, opts ...core.OpOpt) (core.ApiObject, error) // 删除一条已存在的记录 Delete(ctx context.Context, namespace string, name string, opts ...core.OpOpt) (core.ApiObject, error) // 获取一条已存在的记录 Get(ctx context.Context, namespace, name string, opts ...core.OpOpt) (core.ApiObject, error) // 获取所有记录 List(ctx context.Context, namespace string, opts ...core.OpOpt) (core.ApiObjectList, error) // 获取并监听所有记录的变更 ListWatch(ctx context.Context, namespace string) <-chan core.ApiObjectAction // 将其他结构版本的记录转换成当前版本的结构并写入数据库 MigrateObjects() error // 返回当前存储器对应的资源是否属于命名空间资源 Namespaced() bool // 获取当前存储器所对应资源的分类,结构版本和类别 GVK() core.GVK }
ApiObjectRegistry 资源对象存储器接口,实现了该接口的对象可对资源对象进行数据库读写
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry 通用资源对象存储器,实现了通用的对象CRUD接口
func NewRegistry ¶
NewRegistry 创建一个通用资源对象存储器
func (Registry) Create ¶
func (r Registry) Create(ctx context.Context, obj core.ApiObject, opts ...core.OpOpt) (core.ApiObject, error)
Create 创建单个资源对象
func (Registry) Delete ¶
func (r Registry) Delete(ctx context.Context, namespace string, name string, opts ...core.OpOpt) (core.ApiObject, error)
Delete 删除单个资源对象
func (Registry) Get ¶
func (r Registry) Get(ctx context.Context, namespace string, name string, opts ...core.OpOpt) (core.ApiObject, error)
Get 获取单个资源对象
func (Registry) GetWatch ¶
func (r Registry) GetWatch(ctx context.Context, namespace string, name string) <-chan core.ApiObjectAction
GetWatch 侦听单个资源对象的变动
func (Registry) List ¶
func (r Registry) List(ctx context.Context, namespace string, opts ...core.OpOpt) (core.ApiObjectList, error)
List 列举单个命名空间下的所有资源对象
func (Registry) MigrateObjects ¶
MigrateObjects 将所有资源对象转换为当前存储器所指定的版本
func (*Registry) SetDecorateHook ¶
SetDecorateHook 注入获取对象后的内容填充钩子,该钩子会在Get和Watch获取到对象后执行
func (*Registry) SetDefaultFinalizers ¶
SetDefaultFinalizers 设置默认finalizers
func (*Registry) SetMutateHook ¶
SetMutateHook 注入自定义数据填充钩子,该钩子会在Create和Update前执行
func (*Registry) SetPostCreateHook ¶
SetPostCreateHook 注入后置创建钩子
func (*Registry) SetPostDeleteHook ¶
SetPostCreateHook 注入后置删除钩子
func (*Registry) SetPostUpdateHook ¶
SetPostUpdateHook 注入后置更新钩子
func (*Registry) SetPreCreateHook ¶
SetPreCreateHook 注入前置创建钩子
func (*Registry) SetPreDeleteHook ¶
SetPreCreateHook 注入前置删除钩子
func (*Registry) SetPreUpdateHook ¶
SetPreUpdateHook 注入前置更新钩子
func (*Registry) SetRevisioner ¶
func (r *Registry) SetRevisioner(revisioner Revisioner)
SetRevisioner 设置修订历史记录器
func (*Registry) SetValidateHook ¶
SetValidateHook 注入用于自定义校验钩子,该钩子会在Create和Update前执行
func (Registry) Update ¶
func (r Registry) Update(ctx context.Context, obj core.ApiObject, opts ...core.OpOpt) (core.ApiObject, error)
Update 更新单个资源对象
func (Registry) UpdateStatus ¶
func (r Registry) UpdateStatus(namespace string, name string, status core.Status) (core.ApiObject, error)
UpdateStatus 更新单个资源对象的Status
type Revisioner ¶
type Revisioner interface { // 列举目标资源的所有的修订版本 ListRevisions(ctx context.Context, namespace string, name string) (core.ApiObjectList, error) // 为目标资源添加一条修订版本 SetRevision(ctx context.Context, obj core.ApiObject) error // 获取最新的修订版本 GetLastRevision(ctx context.Context, namespace string, name string) (core.ApiObject, error) // 获取指定编号的修订版本 GetRevision(ctx context.Context, namespace string, name string, revision int) (core.ApiObject, error) // 将目标资源回退到指定的修订版本 RevertRevision(ctx context.Context, namespace string, name string, revision int) (core.ApiObject, error) // 删除目标资源的修订版本 DeleteRevision(ctx context.Context, namespace string, name string, revision int) (core.ApiObject, error) // 删除目标资源的所有修订版本 DeleteAllRevisions(ctx context.Context, namespace string, name string) error }
Revisioner 修订版本记录器接口,实现了该接口的对象可被注入到被存储器中,使存储器支持版本记录和回退