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
}
func BelongTo ¶
func BelongTo(obj Object) *BelongToOption
func (*BelongToOption) Apply ¶
func (o *BelongToOption) Apply(q *Query)
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 }
type 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) GetEmail ¶
func (u *CommonUser) GetEmail() string
func (*CommonUser) GetID ¶
func (u *CommonUser) GetID() uint
func (*CommonUser) GetKind ¶
func (u *CommonUser) GetKind() string
func (*CommonUser) GetSource ¶
func (u *CommonUser) GetSource() string
func (*CommonUser) GetSystemRoleID ¶
func (u *CommonUser) GetSystemRoleID() uint
func (*CommonUser) GetUsername ¶
func (u *CommonUser) GetUsername() string
type CommonUserIfe ¶
type Cond ¶
type Cond struct { Field string Op ConditionOperator Value interface{} }
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 ¶
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) 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.
func (*DefaultClient) Scheme ¶
func (c *DefaultClient) Scheme() *runtime.Scheme
Scheme returns the scheme this client is using.
func (*DefaultClient) Status ¶
func (c *DefaultClient) Status() client.StatusWriter
func (*DefaultClient) Update ¶
func (c *DefaultClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
Update updates 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.
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 ObjectTypeIface ¶
type OrderOption ¶
type OrderOption struct {
// contains filtered or unexported fields
}
func (*OrderOption) Apply ¶
func (o *OrderOption) Apply(q *Query)
type PageSizeOption ¶
type PageSizeOption struct {
// contains filtered or unexported fields
}
func PageSize ¶
func PageSize(page, size int64) *PageSizeOption
func (*PageSizeOption) Apply ¶
func (p *PageSizeOption) Apply(q *Query)
type PreloadOption ¶
type PreloadOption struct {
// contains filtered or unexported fields
}
func (*PreloadOption) Apply ¶
func (p *PreloadOption) Apply(q *Query)
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 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
func (*RelationOption) Apply ¶
func (o *RelationOption) Apply(q *Query)
type SearchOption ¶
type SearchOption struct {
// contains filtered or unexported fields
}
func (*SearchOption) Apply ¶
func (o *SearchOption) Apply(q *Query)
type SystemRole ¶
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 Where ¶
func Where(field string, op ConditionOperator, value interface{}) *WhereOption
func WhereEqual ¶
func WhereEqual(field string, value interface{}) *WhereOption
func WhereNameEqual ¶
func WhereNameEqual(value interface{}) *WhereOption
func (*WhereOption) Apply ¶
func (w *WhereOption) Apply(q *Query)