model

package
v0.0.0-...-fc1dba9 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppNameLabel     = `app`
	AppPateformLabel = `weave.io`
	AppPateformValue = `true`
)
View Source
const (
	RootGroup            = "root"
	AuthenticatedGroup   = "system:authenticated"
	UnAuthenticatedGroup = "system:unauthenticated"
	SystemGroup          = "system"
	CustomGroup          = "custom"
)
View Source
const (
	KubeDeployment  = "deployments"
	KubeStatefulset = "statefulsets"
	KubeDaemonset   = "daemonsets"
	KubePod         = "pods"
	KubeService     = "services"
	KubeIngress     = "ingresses"
)
View Source
const (
	PostAssociation       = "Posts"
	TagAssociation        = "Tags"
	CategoriesAssociation = "Categories"
)
View Source
const (
	ResourceKind = "resource"
	MenuKind     = "menu"
)
View Source
const (
	ContainerResource = "containers"
	PostResource      = "posts"
	UserResource      = "users"
	GroupResource     = "groups"
	RoleResource      = "roles"
	AuthResource      = "auth"
	NamespaceResource = "namespaces"
)
View Source
const (
	UserAssociation         = "Users"
	UserAuthInfoAssociation = "AuthInfos"
	GroupAssociation        = "Groups"
)
View Source
const (
	All = "*"
)

Variables

Functions

func ContainerConfig

func ContainerConfig(con *CreatedContainer) *container.Config

func ContainerHostConfig

func ContainerHostConfig(con *CreatedContainer) *container.HostConfig

Types

type AuthInfo

type AuthInfo struct {
	ID           uint      `json:"id" gorm:"autoIncrement;primaryKey"`
	UserId       uint      `json:"userId" gorm:"size:256"`
	Url          string    `json:"url" gorm:"size:256"`
	AuthType     string    `json:"authType" gorm:"size:256"`
	AuthId       string    `json:"authId" gorm:"size:256"`
	AccessToken  string    `json:"-" gorm:"size:256"`
	RefreshToken string    `json:"-" gorm:"size:256"`
	Expiry       time.Time `json:"-"`

	BaseModel
}

func (*AuthInfo) TableName

func (*AuthInfo) TableName() string

type AuthUser

type AuthUser struct {
	Name      string `json:"name"`
	Password  string `json:"password"`
	SetCookie bool   `json:"setCookie"`
	AuthType  string `json:"authType"`
	AuthCode  string `json:"authCode"`
}

type BaseModel

type BaseModel struct {
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt time.Time      `json:"updatedAt"`
	DeletedAt gorm.DeletedAt `json:"-"` // soft delete
}

type Category

type Category struct {
	ID   uint   `json:"id" gorm:"autoIncrement;primaryKey"`
	Name string `json:"name" gorm:"size:256;not null;unique"`
}

type Comment

type Comment struct {
	ID        uint      `json:"id" gorm:"autoIncrement;primaryKey"`
	ParentID  *uint     `json:"parentId"`
	Parent    *Comment  `json:"parent" gorm:"foreignKey:ParentID"`
	UserID    uint      `json:"userId"`
	User      User      `json:"user" gorm:"foreignKey:UserID"`
	PostID    uint      `json:"postId"`
	Post      Post      `json:"-" gorm:"foreignKey:PostID"`
	Content   string    `json:"content" gorm:"size:1024"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type Container

type Container struct {
	ID      string   `json:"id"`
	Name    string   `json:"name"`
	Image   string   `json:"image"`
	Cmd     []string `json:"cmd"`
	Port    int      `json:"port"`
	Status  string   `json:"status"`
	Address string   `json:"address"`
	StartAt string   `json:"startAt"`
}

func DockerContainerJSONToContainer

func DockerContainerJSONToContainer(container types.ContainerJSON) Container

func DockerContainerToContainer

func DockerContainerToContainer(container types.Container) Container

type CreatedContainer

type CreatedContainer struct {
	Name  string   `json:"name"`
	Image string   `json:"image"`
	Cmd   []string `json:"cmd"`
	Port  int      `json:"port"`
}

func (*CreatedContainer) GetContainer

func (c *CreatedContainer) GetContainer(id string) *Container

type CreatedGroup

type CreatedGroup struct {
	Name      string `json:"name"`
	Describe  string `json:"describe"`
	CreatorId uint   `json:"creatorId"`
}

func (*CreatedGroup) GetGroup

func (g *CreatedGroup) GetGroup(uid uint) *Group

type CreatedUser

type CreatedUser struct {
	Name      string     `json:"name"`
	Password  string     `json:"password"`
	Email     string     `json:"email"`
	Avatar    string     `json:"avatar"`
	AuthInfos []AuthInfo `json:"authInfos"`
}

func (*CreatedUser) GetUser

func (u *CreatedUser) GetUser() *User

type Group

type Group struct {
	ID        uint   `json:"id" gorm:"autoIncrement;primaryKey"`
	Name      string `json:"name" gorm:"size:100;not null;unique"`
	Kind      string `json:"kind" gorm:"size:100"`
	Describe  string `json:"describe" gorm:"size:1024;"`
	CreatorId uint   `json:"creatorId"`
	UpdaterId uint   `json:"updaterId"`
	Users     []User `json:"users" gorm:"many2many:user_groups;"`
	Roles     []Role `json:"roles" gorm:"many2many:group_roles;"`

	BaseModel
}

type JWTToken

type JWTToken struct {
	Token    string `json:"token"`
	Describe string `json:"describe"`
}

type KubeApp

type KubeApp struct {
	KubeBase
	Kind       string             `json:"kind"`
	Replicas   *int32             `json:"replicas"`
	Containers []corev1.Container `json:"containers"`
}

type KubeBase

type KubeBase struct {
	Name        string            `json:"name"`
	Namespace   string            `json:"namespace"`
	Labels      map[string]string `json:"labels,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
}

type Like

type Like struct {
	ID     uint `json:"id" gorm:"autoIncrement;primaryKey"`
	UserID uint `json:"userId" gorm:"uniqueIndex:user_post"`
	User   User `json:"-" gorm:"foreignKey:UserID"`
	PostID uint `json:"postId" gorm:"uniqueIndex:user_post"`
	Post   Post `json:"-" gorm:"foreignKey:PostID"`
}

type Operation

type Operation string
const (
	AllOperation  Operation = "*"
	EditOperation Operation = "edit"
	ViewOperation Operation = "view"
)

func (Operation) Contain

func (op Operation) Contain(verb string) bool

type Post

type Post struct {
	ID         uint       `json:"id" gorm:"autoIncrement;primaryKey"`
	Name       string     `json:"name" gorm:"size:256;not null;unique"`
	Content    string     `json:"content" gorm:"type:text;not null"`
	Summary    string     `json:"summary" gorm:"size:512"`
	CreatorID  uint       `json:"creatorId"`
	Creator    User       `json:"creator" gorm:"foreignKey:CreatorID"`
	Tags       []Tag      `json:"tags"  gorm:"many2many:tag_posts"`
	Categories []Category `json:"categories" gorm:"many2many:category_posts"`
	Comments   []Comment  `json:"comments"`

	Views     uint `json:"views" gorm:"type:uint"`
	Likes     uint `json:"likes" gorm:"-"`
	UserLiked bool `json:"userLiked" gorm:"-"`

	BaseModel
}

type Resource

type Resource struct {
	ID    uint   `json:"id" gorm:"autoIncrement;primaryKey"`
	Name  string `json:"name" gorm:"size:256;not null;unique"`
	Scope Scope  `json:"scope"`
	Kind  string `json:"kind"`
}

type Role

type Role struct {
	ID        uint   `json:"id" gorm:"autoIncrement;primaryKey"`
	Name      string `json:"name" gorm:"size:100;not null;unique"`
	Scope     Scope  `json:"scope" gorm:"size:100"`
	Namespace string `json:"namespace"  gorm:"size:100"`
	Rules     Rules  `json:"rules" gorm:"type:json"`
}

type Rule

type Rule struct {
	Resource  string    `json:"resource"`
	Operation Operation `json:"operation"`
}

type Rules

type Rules []Rule

func (*Rules) Scan

func (r *Rules) Scan(value interface{}) error

func (Rules) Value

func (r Rules) Value() (driver.Value, error)

type Scope

type Scope string
const (
	ClusterScope   Scope = "cluster"
	NamespaceScope Scope = "namespace"
)

type Tag

type Tag struct {
	ID   uint   `json:"id" gorm:"autoIncrement;primaryKey"`
	Name string `json:"name" gorm:"size:256;not null;unique"`
}

type UpdatedGroup

type UpdatedGroup struct {
	Name      string `json:"name"`
	Describe  string `json:"describe"`
	UpdaterId uint   `json:"updaterId"`
}

func (*UpdatedGroup) GetGroup

func (g *UpdatedGroup) GetGroup(uid uint) *Group

type UpdatedUser

type UpdatedUser struct {
	Name      string     `json:"name"`
	Password  string     `json:"password"`
	Email     string     `json:"email"`
	AuthInfos []AuthInfo `json:"authInfos"`
}

func (*UpdatedUser) GetUser

func (u *UpdatedUser) GetUser() *User

type User

type User struct {
	ID        uint       `json:"id" gorm:"autoIncrement;primaryKey"`
	Name      string     `json:"name" gorm:"size:100;not null;unique"`
	Password  string     `json:"-" gorm:"size:256;"`
	Email     string     `json:"email" gorm:"size:256;"`
	Avatar    string     `json:"avatar" gorm:"size:256;"`
	AuthInfos []AuthInfo `json:"authInfos" gorm:"foreignKey:UserId;references:ID"`
	Groups    []Group    `json:"groups" gorm:"many2many:user_groups;"`
	Roles     []Role     `json:"roles" gorm:"many2many:user_roles;"`

	BaseModel
}

func (*User) CacheKey

func (u *User) CacheKey() string

func (*User) MarshalBinary

func (u *User) MarshalBinary() ([]byte, error)

func (*User) TableName

func (*User) TableName() string

func (*User) UnmarshalBinary

func (u *User) UnmarshalBinary(data []byte) error

type UserInfo

type UserInfo struct {
	User
	InRoot bool   `json:"inRoot"`
	Role   string `json:"role"`
}

type UserRole

type UserRole struct {
	ID   uint   `json:"id"`
	Name string `json:"name"`
	Role string `json:"role"`
}

func (*UserRole) GetUser

func (u *UserRole) GetUser() *User

type Users

type Users []User

Jump to

Keyboard shortcuts

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