models

package
v0.0.0-...-7197fd8 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

models/user.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToBufModulePB

func ToBufModulePB(in *Module) *modulev1.Module

func ToCommitPB

func ToCommitPB(in *Commit) *modulev1.Commit

func ToModulePB

func ToModulePB(in *Module) *registrypbv1.Module

func ToUserRegistryPbV1

func ToUserRegistryPbV1(in *User) (*v1.User, error)

Types

type Action

type Action string
const (
	CREATE Action = "create"
	PUSH   Action = "push"
	READ   Action = "read"
)

type CanResponse

type CanResponse struct {
	Allowed bool
}

type Commit

type Commit struct {
	ID               uuid.UUID  `gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
	CommitHash       string     `gorm:"not null;type:varchar(40)"` // TODO should be uniq?
	CreateTime       time.Time  `gorm:"not null" json:"create_time"`
	UpdateTime       time.Time  `gorm:"not null" json:"update_time"`
	OwnerID          uuid.UUID  `gorm:"type:uuid;not null;index"`
	Owner            User       `gorm:"foreignKey:OwnerID"`
	ModuleID         uuid.UUID  `gorm:"type:uuid;not null;index"`
	Module           Module     `gorm:"foreignKey:ModuleID"`
	DigestType       DigestType `gorm:"type:smallint;not null"`
	DigestValue      string     `gorm:"type:varchar(128);not null"` // TODO should be uniq?
	CreatedByUserID  uuid.UUID  `gorm:"type:uuid;index"`
	CreatedByUser    *User      `gorm:"foreignKey:CreatedByUserID"`
	SourceControlURL string     `gorm:"type:text"`
}

func FromCommitPB

func FromCommitPB(in *modulev1.Commit) (*Commit, error)

func (*Commit) BeforeCreate

func (s *Commit) BeforeCreate(tx *gorm.DB) (err error)

type DigestType

type DigestType int32
const (
	DigestType_UNSPECIFIED DigestType = 0
	DigestType_B5          DigestType = 1
)

type DownloadResponse

type DownloadResponse struct {
	Contents []*DownloadResponseContent `json:"contents,omitempty"`
}

type DownloadResponseContent

type DownloadResponseContent struct {
	Commit *Commit `json:"commit,omitempty"`
	Files  []*File `json:"files,omitempty"`
}

type File

type File struct {
	Path    string `json:"path,omitempty"`
	Content []byte `json:"content,omitempty"`
}

type LoginRequest

type LoginRequest struct {
	Username string
	Password string
}

type LoginResponse

type LoginResponse struct {
	Token string
}

type Module

type Module struct {
	ID               uuid.UUID        `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	CreateTime       time.Time        `gorm:"not null" json:"create_time"`
	UpdateTime       time.Time        `gorm:"not null" json:"update_time"`
	Name             string           `gorm:"unique;not null" json:"name"`
	OwnerID          uuid.UUID        `gorm:"type:uuid;not null" json:"owner_id"`
	Owner            User             `gorm:"foreignKey:OwnerID" json:"owner,omitempty"`
	Visibility       ModuleVisibility `gorm:"not null;default:1" json:"visibility"`
	State            ModuleState      `gorm:"not null;default:1" json:"state"`
	Description      string           `gorm:"type:text" json:"description"`
	URL              string           `gorm:"index:url_unique,unique column:url" json:"url"`
	DefaultLabelName string           `gorm:"default:'main'" json:"default_label_name"`
	DefaultBranch    string           `gorm:"default:'main'" json:"default_branch"`

	Commits []Commit `gorm:"foreignKey:ModuleID" json:"commits,omitempty"`
}

func FromBufModulePB

func FromBufModulePB(in *modulev1.Module) (*Module, error)

func FromModulePB

func FromModulePB(in *registrypbv1.Module) (*Module, error)

func (*Module) BeforeCreate

func (s *Module) BeforeCreate(tx *gorm.DB) (err error)

type ModuleRef

type ModuleRef struct {
	Id     string `json:"id"`
	Owner  string `json:"owner,omitempty"`
	Module string `json:"module,omitempty"`
}

type ModuleState

type ModuleState int32
const (
	ModuleState_MODULE_STATE_UNSPECIFIED ModuleState = 0
	ModuleState_MODULE_STATE_ACTIVE      ModuleState = 1
	ModuleState_MODULE_STATE_DEPRECATED  ModuleState = 2
)

type ModuleVisibility

type ModuleVisibility int32
const (
	ModuleVisibility_MODULE_VISIBILITY_UNSPECIFIED ModuleVisibility = 0
	ModuleVisibility_MODULE_VISIBILITY_PUBLIC      ModuleVisibility = 1
	ModuleVisibility_MODULE_VISIBILITY_PRIVATE     ModuleVisibility = 2
)

type Object

type Object string
const (
	REPOSITORY Object = "repository"
)

type Policy

type Policy struct {
	Subject string
	Domain  string
	Object  string
	Action  string
}

type ResourceRefs

type ResourceRefs struct {
	Id        string `json:"id"`
	Owner     string `json:"owner,omitempty"`
	Module    string `json:"module,omitempty"`
	LabelName string `json:"label_name,omitempty"`
	Ref       string `json:"ref,omitempty"`
}

type Role

type Role struct {
	User   string
	Role   string
	Domain string
}

type Session

type Session struct {
	ID         uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	CreateTime time.Time `gorm:"not null" json:"create_time"`
	UpdateTime time.Time `gorm:"not null" json:"update_time"`
	UserID     uuid.UUID `gorm:"type:uuid;not null" json:"user_id"`
	User       User      `gorm:"foreignKey:UserID" json:"user,omitempty"`
	AuthModule string    `gorm:"type:varchar(100);not null" json:"auth_module"`
	ExpiresAt  time.Time `grom:"not null" json:"expires_at"`
}

func (*Session) AfterFind

func (s *Session) AfterFind(tx *gorm.DB) (err error)

func (*Session) BeforeCreate

func (s *Session) BeforeCreate(tx *gorm.DB) (err error)

type SigninRequest

type SigninRequest struct {
	Username    string
	Password    string
	Description string
}

type SigninResponse

type SigninResponse struct {
	User *User
}

type Subject

type Subject string
const (
	OWNER Subject = "owner"
)

type UploadRequest

type UploadRequest struct {
	Contents     []*UploadRequest_Content `json:"contents,omitempty"`
	DepCommitIds []string                 `json:"dep_commit_ids,omitempty"`
}

type UploadRequest_Content

type UploadRequest_Content struct {
	ModuleRef        *ModuleRef `json:"module_ref,omitempty"`
	Files            []*File    `json:"files,omitempty"`
	SourceControlUrl string     `json:"source_control_url,omitempty"`
}

type User

type User struct {
	ID          uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	CreateTime  time.Time `gorm:"not null" json:"create_time"`
	UpdateTime  time.Time `gorm:"not null" json:"update_time"`
	Username    string    `gorm:"uniqueIndex;not null" json:"username"`
	Email       string    `gorm:"uniqueIndex;not null" json:"email"`
	Password    string    `gorm:"column:password;type:varchar(255);not null" json:"password" binding:"required"`
	Type        UserType  `gorm:"not null;default:0" json:"type"`
	State       UserState `gorm:"not null;default:1" json:"state"`
	Description string    `gorm:"type:text" json:"description"`
	URL         string    `gorm:"column:url" json:"url"`
}

func FromUserRegistryPbV1

func FromUserRegistryPbV1(in *v1.User) (*User, error)

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) (err error)

type UserState

type UserState int32
const (
	UserState_USER_STATE_UNSPECIFIED UserState = 0
	UserState_USER_STATE_ACTIVE      UserState = 1
	UserState_USER_STATE_DEACTIVATED UserState = 2
)

type UserType

type UserType int32
const (
	UserType_USER_TYPE_UNSPECIFIED  UserType = 0
	UserType_USER_TYPE_ORGANIZATION UserType = 1
	UserType_USER_TYPE_USER         UserType = 2
)

Jump to

Keyboard shortcuts

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