Documentation
¶
Index ¶
- Constants
- Variables
- func CreateUser(tx *sqlx.Tx, user *User, password string) (err error)
- func GetColumnNames[T any](obj *T) []string
- func Init(cfg *config.MysqlConfig, t *testing.T) (err error)
- func Instance() *sqlx.DB
- type CustomClaims
- type Image
- func GetImageByFullname(ctx context.Context, fullname string) (*Image, error)
- func GetImageByID(_ context.Context, id int64) (*Image, error)
- func GetPublicImages(_ context.Context) ([]Image, error)
- func QueryImagesByRepoIDs(repoIDs []int64, keyword string, pNum, pSize int) (ans []Image, count int, err error)
- func QueryImagesByUsername(req types.ImagesByUsernameRequest) (ans []Image, count int, err error)
- func QueryPublicImagesByUsername(req types.ImagesByUsernameRequest) (ans []Image, count int, err error)
- type JSONColumn
- type Labels
- type PrivateToken
- type Repository
- func QueryPublicRepoList(user string, pNum, pSize int) (ans []Repository, err error)
- func QueryRepo(ctx context.Context, username, name string) (*Repository, error)
- func QueryRepoByID(ctx context.Context, id int64) (*Repository, error)
- func QueryRepoList(user string, pNum, pSize int) (ans []Repository, err error)
- func (repo *Repository) ColumnNames() string
- func (repo *Repository) Delete(tx *sqlx.Tx) (err error)
- func (repo *Repository) DeleteImage(tx *sqlx.Tx, tag string) (err error)
- func (repo *Repository) Fullname() string
- func (repo *Repository) GetImage(ctx context.Context, tag string) (*Image, error)
- func (repo *Repository) GetImages() ([]Image, error)
- func (repo *Repository) Save(tx *sqlx.Tx) (err error)
- func (repo *Repository) SaveImage(tx *sqlx.Tx, img *Image) (err error)
- func (*Repository) TableName() string
- type User
Constants ¶
View Source
const ( ImageFormatQcow2 = "qcow2" ImageFormatRaw = "raw" ImageFormatRBD = "rbd" )
Variables ¶
View Source
var (
Mock sqlmock.Sqlmock
)
Functions ¶
func GetColumnNames ¶
Types ¶
type CustomClaims ¶
type CustomClaims struct { ID int64 UserName string // AuthorityId uint // 角色认证ID jwt.StandardClaims }
CustomClaims 加解密需要生成的结构
type Image ¶
type Image struct { ID int64 `db:"id" json:"id"` RepoID int64 `db:"repo_id" json:"repoId"` Tag string `db:"tag" json:"tag" description:"image tag, default:latest"` Labels JSONColumn[Labels] `db:"labels" json:"labels"` Size int64 `db:"size" json:"size" description:"actual file size(in bytes)"` VirtualSize int64 `db:"virtual_size" json:"virtualSize" description:"virtual size of image file"` Digest string `db:"digest" json:"digest" description:"image digest"` Format string `db:"format" json:"format" description:"image format"` OS JSONColumn[types.OSInfo] `db:"os" json:"os"` Snapshot string `db:"snapshot" json:"snapshot" description:"RBD Snapshot for this image, eg: eru/ubuntu-18.04@v1"` Description string `db:"description" json:"description" description:"image description"` CreatedAt time.Time `db:"created_at" json:"createdAt" description:"image create time"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt" description:"image update time"` Repo *Repository `db:"-" json:"repo"` }
func GetImageByFullname ¶
func QueryImagesByRepoIDs ¶
func QueryImagesByUsername ¶
func QueryImagesByUsername(req types.ImagesByUsernameRequest) (ans []Image, count int, err error)
func QueryPublicImagesByUsername ¶
func QueryPublicImagesByUsername(req types.ImagesByUsernameRequest) (ans []Image, count int, err error)
func (*Image) ColumnNames ¶
func (*Image) GetRepo ¶
func (img *Image) GetRepo() (*Repository, error)
func (*Image) NormalizeName ¶
type JSONColumn ¶
type JSONColumn[T any] struct { V *T }
func NewJSONColumn ¶
func NewJSONColumn[T any](v *T) JSONColumn[T]
func (*JSONColumn[T]) Get ¶
func (j *JSONColumn[T]) Get() *T
func (*JSONColumn[T]) Scan ¶
func (j *JSONColumn[T]) Scan(src any) error
type PrivateToken ¶
type PrivateToken struct { ID int64 `db:"id" json:"id"` Name string `db:"name" json:"name"` UserID int64 `db:"user_id" json:"userId"` Token string `db:"token" json:"token"` ExpiredAt time.Time `db:"expired_at" json:"expiredAt"` CreatedAt time.Time `db:"created_at" json:"createdAt" description:"user create time"` LastUsed time.Time `db:"last_used" json:"lastUsed"` }
func GetPrivateToken ¶
func GetPrivateToken(token string) (*PrivateToken, error)
func GetPrivateTokenByUserAndName ¶
func GetPrivateTokenByUserAndName(userID int64, name string) (*PrivateToken, error)
func QueryPrivateTokensByUser ¶
func QueryPrivateTokensByUser(ctx context.Context, userID int64) (tokens []*PrivateToken, err error)
func (*PrivateToken) GetUser ¶
func (t *PrivateToken) GetUser() (*User, error)
func (*PrivateToken) UpdateLastUsed ¶
func (t *PrivateToken) UpdateLastUsed() error
type Repository ¶
type Repository struct { ID int64 `db:"id" json:"id"` Username string `db:"username" json:"username" description:"image's username"` Name string `db:"name" json:"name" description:"image name"` Private bool `db:"private" json:"private" description:"image is private"` CreatedAt time.Time `db:"created_at" json:"createdAt" description:"image create time"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt" description:"image update time"` Images []Image `db:"-" json:"-"` }
func QueryPublicRepoList ¶
func QueryPublicRepoList(user string, pNum, pSize int) (ans []Repository, err error)
func QueryRepo ¶
func QueryRepo(ctx context.Context, username, name string) (*Repository, error)
QueryRepo get image info @Param username string false "用户名" @Param name string true "镜像名" @Param tag string true "镜像标签"
func QueryRepoByID ¶
func QueryRepoByID(ctx context.Context, id int64) (*Repository, error)
func QueryRepoList ¶
func QueryRepoList(user string, pNum, pSize int) (ans []Repository, err error)
func (*Repository) ColumnNames ¶
func (repo *Repository) ColumnNames() string
func (*Repository) DeleteImage ¶
func (repo *Repository) DeleteImage(tx *sqlx.Tx, tag string) (err error)
func (*Repository) Fullname ¶
func (repo *Repository) Fullname() string
func (*Repository) GetImages ¶
func (repo *Repository) GetImages() ([]Image, error)
func (*Repository) Save ¶
func (repo *Repository) Save(tx *sqlx.Tx) (err error)
only save image itself, don't save tags
func (*Repository) SaveImage ¶
func (repo *Repository) SaveImage(tx *sqlx.Tx, img *Image) (err error)
func (*Repository) TableName ¶
func (*Repository) TableName() string
type User ¶
type User struct { ID int64 `db:"id" json:"id"` Username string `db:"username" json:"username" description:"Login user name"` Password string `db:"password" json:"password" description:"user login password"` Nickname string `db:"nickname" json:"nickname" description:"user's nickname"` Email string `db:"email" json:"email" description:"user's email"` Admin bool `db:"admin" json:"admin" description:"is a admin"` CreatedAt time.Time `db:"created_at" json:"createdAt" description:"user create time"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt" description:"user update time"` }
func CheckAndGetUser ¶
func (*User) ColumnNames ¶
Click to show internal directories.
Click to hide internal directories.