Documentation
¶
Index ¶
- func RelationKey(obj1, obj2 ObjectTypeIface) string
- type BelongToOption
- type Common
- type CommonResourceIfe
- type CommonUser
- type CommonUserIfe
- type Cond
- type ConditionOperator
- type DefaultClient
- func (c *DefaultClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
- func (c *DefaultClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
- func (c *DefaultClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
- func (c *DefaultClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error
- func (c *DefaultClient) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- func (c *DefaultClient) Migrate(ctx context.Context, obj client.Object) error
- func (c *DefaultClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (c *DefaultClient) RESTMapper() meta.RESTMapper
- func (c *DefaultClient) Scheme() *runtime.Scheme
- func (c *DefaultClient) Status() client.StatusWriter
- func (c *DefaultClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
- type HookPhase
- type KubeClientIfe
- type ModelCacheIfe
- type ModelClientIface
- type Object
- type ObjectListIface
- type ObjectTypeIface
- type Option
- type OrderOption
- type PageSizeOption
- type PreloadOption
- type Query
- type Relation
- type RelationCondition
- type RelationKind
- type RelationOption
- type SearchOption
- type SystemRole
- type UserAuthorityIfe
- type WhereOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RelationKey ¶
func RelationKey(obj1, obj2 ObjectTypeIface) string
Types ¶
type BelongToOption ¶
type BelongToOption struct {
// contains filtered or unexported fields
}
type Common ¶
type Common struct {
Name string `gorm:"primaryKey;type:varchar(60);not null"`
Namespace string `gorm:"primaryKey;type:varchar(60);not null"`
UID string `gorm:"uniqueIndex;type:varchar(36)"`
CreationTimestamp time.Time `gorm:"not null"`
DeletionTimestamp time.Time
Labels datatypes.JSON
Annotations datatypes.JSON
OwnerReferences datatypes.JSON
Spec datatypes.JSON
Status datatypes.JSON
}
func (*Common) DecodeInto ¶
func (c *Common) DecodeInto(obj client.Object) error
type CommonResourceIfe ¶
type CommonResourceIfe interface {
GetKind() string
GetID() uint
GetTenantID() uint
GetProjectID() uint
GetEnvironmentID() uint
GetVirtualSpaceID() uint
GetName() string
GetCluster() string
GetNamespace() string
GetOwners() []CommonResourceIfe
}
type CommonUser ¶
type CommonUser struct {
ID uint
Username string
Email string
Phone string
Password string
IsActive *bool
Kind string
Source string
CreatedAt *time.Time
LastLoginAt *time.Time
SystemRole *SystemRole
SystemRoleID uint
}
func (*CommonUser) GetSystemRoleID ¶
func (u *CommonUser) GetSystemRoleID() uint
func (*CommonUser) GetUsername ¶
func (u *CommonUser) GetUsername() string
type CommonUserIfe ¶
type CommonUserIfe interface {
GetID() uint
GetSystemRoleID() uint
GetUsername() string
GetUserKind() string
GetEmail() string
GetSource() string
SetLastLogin(*time.Time)
UnmarshalBinary(data []byte) error
MarshalBinary() (data []byte, err error)
}
type ConditionOperator ¶
type ConditionOperator string
var Eq, Gt, Lt, Neq, Gte, Lte, In, Like ConditionOperator = "=", ">", "<", "<>", ">=", "<=", "in", "like"
type DefaultClient ¶
type DefaultClient struct {
// contains filtered or unexported fields
}
func NewTypedClient ¶
func NewTypedClient(db *gorm.DB) *DefaultClient
func (*DefaultClient) Create ¶
func (c *DefaultClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
Create saves the object obj in the Kubernetes cluster.
func (*DefaultClient) Delete ¶
func (c *DefaultClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
Delete deletes the given obj from Kubernetes cluster.
func (*DefaultClient) DeleteAllOf ¶
func (c *DefaultClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
DeleteAllOf deletes all objects of the given type matching the given options.
func (*DefaultClient) Get ¶
func (c *DefaultClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error
Get retrieves an obj for the given object key from the Kubernetes Cluster. obj must be a struct pointer so that obj can be updated with the response returned by the Server.
func (*DefaultClient) List ¶
func (c *DefaultClient) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
List retrieves list of objects for a given namespace and list options. On a successful call, Items field in the list will be populated with the result returned from the server.
func (*DefaultClient) Migrate ¶
func (c *DefaultClient) Migrate(ctx context.Context, obj client.Object) error
Metadata create/update the table in database
func (*DefaultClient) Patch ¶
func (c *DefaultClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
Patch patches the given obj in the Kubernetes cluster. obj must be a struct pointer so that obj can be updated with the content returned by the Server.
func (*DefaultClient) RESTMapper ¶
func (c *DefaultClient) RESTMapper() meta.RESTMapper
RESTMapper returns the rest this client is using.
type HookPhase ¶
type HookPhase string
var (
BeforeUpdate HookPhase = "BeforeUpdate"
BeforeCreate HookPhase = "BeforeCreate"
BeforeDelete HookPhase = "BeforeDelete"
AfterUpdate HookPhase = "AfterUpdate"
AfterCreate HookPhase = "AfterCreate"
AfterDelete HookPhase = "AfterDelete"
)
type KubeClientIfe ¶
type KubeClientIfe interface {
GetEnvironment(cluster, name string, _ map[string]string) (*v1beta1.Environment, error)
PatchEnvironment(cluster, name string, data *v1beta1.Environment) (*v1beta1.Environment, error)
DeleteEnvironment(clustername, environment string) error
CreateOrUpdateEnvironment(clustername, environment string, spec v1beta1.EnvironmentSpec) error
CreateOrUpdateTenant(clustername, tenantname string, admins, members []string) error
CreateOrUpdateTenantResourceQuota(clustername, tenantname string, content []byte) error
CreateOrUpdateSecret(clustername, namespace, name string, data map[string][]byte) error
DeleteSecretIfExist(clustername, namespace, name string) error
DeleteTenant(clustername, tenantname string) error
ClusterResourceStatistics(cluster string, ret interface{}) error
GetServiceAccount(cluster, namespace, name string, labels map[string]string) (*v1.ServiceAccount, error)
PatchServiceAccount(cluster, namespace, name string, data *v1.ServiceAccount) (*v1.ServiceAccount, error)
}
type ModelCacheIfe ¶
type ModelCacheIfe interface {
// 构建缓存
BuildCache() error
// 资源相关
UpsertTenant(tid uint, name string)
DelTenant(tid uint)
UpsertProject(tid, pid uint, name string) error
DelProject(tid, pid uint) error
UpsertEnvironment(pid, eid uint, name, cluster, namespace string) error
DelEnvironment(pid, eid uint) error
UpsertVirtualSpace(vid uint, name string)
DelVirtualSpace(vid uint)
FindParents(kind string, id uint) []CommonResourceIfe
FindResource(kind string, id uint) CommonResourceIfe
FindEnvironment(cluster, namespace string) CommonResourceIfe
// 普通用户相关
GetUserAuthority(user CommonUserIfe) UserAuthorityIfe
FlushUserAuthority(user CommonUserIfe) UserAuthorityIfe
CacheUserInfo(userinfo CommonUserIfe) error
GetUserInfo(username string, user CommonUserIfe) error
// openapi 相关用户
CacheUserInfoViaToken(token string, user CommonUserIfe, ex time.Duration) error
GetUserInfoViaToken(token string, username string, user CommonUserIfe) error
UserRequestLimitAllow(user CommonUserIfe, d time.Duration, rate int) (bool, error)
}
type ModelClientIface ¶
type ModelClientIface interface {
Create(ctx context.Context, obj Object, opts ...Option) error
Get(ctx context.Context, obj Object, opts ...Option) error
Update(ctx context.Context, obj Object, opts ...Option) error
Delete(ctx context.Context, obj Object, opts ...Option) error
CreateInBatches(ctx context.Context, objs ObjectListIface, opts ...Option) error
List(ctx context.Context, olist ObjectListIface, opts ...Option) error
Count(ctx context.Context, o ObjectTypeIface, t *int64, opts ...Option) error
}
type Object ¶
type Object interface {
ObjectTypeIface
PrimaryKeyValue() interface{}
PreloadFields() *[]string
}
type ObjectListIface ¶
type ObjectListIface interface {
ObjectTypeIface
GetPageSize() (*int64, *int64)
GetTotal() *int64
SetPageSize(int64, int64)
SetTotal(int64)
DataPtr() interface{}
}
type ObjectTypeIface ¶
type ObjectTypeIface interface {
GetKind() *string
PrimaryKeyField() *string
}
type OrderOption ¶
type OrderOption struct {
// contains filtered or unexported fields
}
type PageSizeOption ¶
type PageSizeOption struct {
// contains filtered or unexported fields
}
type PreloadOption ¶
type PreloadOption struct {
// contains filtered or unexported fields
}
type Query ¶
type Query struct {
Page int64
Size int64
Search string
SearchFields []string
Orders []string
Preloads []string
Where []*Cond
Belong []Object
RelationOptions []RelationCondition
}
type Relation ¶
type Relation struct {
Key string
Kind RelationKind
Via ObjectTypeIface
}
func GetRelation ¶
func GetRelation(source, target, via ObjectTypeIface, relkind RelationKind) Relation
type RelationCondition ¶
type RelationCondition struct {
Key string
Value interface{}
Target Object
}
type RelationKind ¶
type RelationKind string
var (
RelationM2M RelationKind = "m2m"
RelationOwn RelationKind = "own"
)
type RelationOption ¶
type RelationOption struct {
// contains filtered or unexported fields
}
func ExistRelation ¶
func ExistRelation(obj Object) *RelationOption
func ExistRelationWithKeyValue ¶
func ExistRelationWithKeyValue(obj Object, key string, value interface{}) *RelationOption
type SearchOption ¶
type SearchOption struct {
// contains filtered or unexported fields
}
type SystemRole ¶
type SystemRole struct {
ID uint
RoleName string
RoleCode string
}
type UserAuthorityIfe ¶
type UserAuthorityIfe interface {
// 资源角色
GetResourceRole(kind string, id uint) string
// 是否是系统管理员
IsSystemAdmin() bool
// 是否是租户管理员
IsTenantAdmin(tenantid uint) bool
// 是否是租户成员
IsTenantMember(tenantid uint) bool
// 是否是项目管理员
IsProjectAdmin(projectid uint) bool
// 是否是项目开发
IsProjectDev(projectid uint) bool
// 是否是项目测试
IsProjectTest(projectid uint) bool
// 是否是项目运维
IsProjectOps(projectid uint) bool
// 是否是环境op
IsEnvironmentOperator(envid uint) bool
// 是否是环境reader
IsEnvironmentReader(envid uint) bool
// 是否是虚拟空间管理员
IsVirtualSpaceAdmin(vsid uint) bool
// 是否是虚拟空间成员
IsVirtualSpaceMember(vsid uint) bool
// 是否是一个租户的管理员
IsAnyTenantAdmin() bool
}
type WhereOption ¶
type WhereOption struct {
// contains filtered or unexported fields
}
func WhereEqual ¶
func WhereEqual(field string, value interface{}) *WhereOption
func WhereNameEqual ¶
func WhereNameEqual(value interface{}) *WhereOption