model

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// could access everything
	// used to add/remove users
	// to/from projects
	UserType_ADMIN = pb.UserType_ADMIN
	// used to submit job
	// for ordinary students
	UserType_USER = pb.UserType_USER
	// special authorization
	// could read project
	// but can NOT submit job
	UserType_BOT = pb.UserType_BOT
)

Variables

View Source
var (
	ProjectConfigDefaultStages = []string{
		"install",
		"build",
		"test",
	}
)

Functions

This section is empty.

Types

type Job

type Job struct {
	Id        bson.ObjectId  `bson:"_id,omitempty" json:"id"`
	ProjectId bson.ObjectId  `bson:"project_id,omitempty" json:"project_id,omitempty"`
	UserId    bson.ObjectId  `bson:"user_id,omitempty" json:"user_id,omitempty"`
	Progress  pb.JobProgress `bson:"progress,omitempty" json:"progress,omitempty"`
	Score     int32          `bson:"score,omitempty" json:"score,omitempty"`
	Log       string         `bson:"log,omitempty" json:"log,omitempty"`
	Error     *Status        `bson:"error,omitempty" json:"error,omitempty"`
}

func FromPbJob

func FromPbJob(j *pb.Job) *Job

func NewJob

func NewJob(uid bson.ObjectId, pid bson.ObjectId) *Job

func (*Job) ToPbJob

func (j *Job) ToPbJob() (pbJob *pb.Job)

type OrderType

type OrderType int

OrderType is an option type

const (
	OrderTypeUnset OrderType = iota
	OrderTypeAsc
	OrderTypeDesc
)

type Project

type Project struct {
	// Required: project id
	Id bson.ObjectId `bson:"_id,omitempty" json:"id"`
	// Required: project name
	Name string `bson:"name,omitempty" json:"name,omitempty"`
	// Optional: description
	Desc string `bson:"desc,omitempty" json:"desc,omitempty"`

	Config *ProjectConfig `bson:"config,omitempty" json:"config,omitempty"`

	// Meta is NOT in using
	//Meta *structpb.Struct `bson:"meta,omitempty" json:"meta,omitempty"`
	CreateTime  time.Time `bson:"create_time,omitempty" json:"create_time,omitempty"`
	UpdatedTime time.Time `bson:"updated_time,omitempty" json:"updated_time,omitempty"`
	CreatedBy   string    `bson:"created_by,omitempty" json:"created_by"`
}

func FromPbProject

func FromPbProject(p *pb.Project) *Project

func (*Project) ToPbProject

func (p *Project) ToPbProject(rich bool) (pbProject *pb.Project)

type ProjectChecklistElem

type ProjectChecklistElem struct {
	Path       string `bson:"path,omitempty" json:"path" yaml:"check_list"`
	TargetType int    `bson:"target_type,omitempty" json:"target_type" yaml:"target_type"`
}

type ProjectConfig

type ProjectConfig struct {
	Image        string                      `bson:"image,omitempty" json:"image" yaml:"image"`
	Env          []string                    `bson:"env,omitempty" json:"env" yaml:"env"`
	Volume       []string                    `bson:"volume,omitempty" json:"volume" yaml:"volume"`
	Stages       []string                    `bson:"stage,omitempty" json:"stage" yaml:"stage"`
	Jobs         map[string]ProjectJobConfig `bson:"job,omitempty" json:"job" yaml:"job"`
	Checklist    []*pb.ProjectChecklistElem  `bson:"check_list,omitempty" json:"check_list" yaml:"check_list"`
	TimeoutSec   uint64                      `bson:"timeout_sec,omitempty" json:"timeout_sec" yaml:"timeout_sec"`
	MaximumCpu   uint64                      `bson:"maximum_cpu,omitempty" json:"maximum_cpu" yaml:"maximum_cpu"`
	MaximumMemMb uint64                      `bson:"maximum_mem_mb,omitempty" json:"maximum_mem_mb" yaml:"maximum_mem_mb"`
}

func LoadProjectConfig

func LoadProjectConfig(path string) (*ProjectConfig, error)

func (*ProjectConfig) ToBashScriptsExecutor

func (c *ProjectConfig) ToBashScriptsExecutor() *helpers.BashScriptsExecutor

func (*ProjectConfig) ToPbProjectConfig

func (c *ProjectConfig) ToPbProjectConfig(rich bool) (pbConfig *pb.ProjectConfig)

type ProjectJobConfig

type ProjectJobConfig struct {
	Script  string   `bson:"script,omitempty" json:"script" yaml:"script"`
	Scripts []string `bson:"scripts,omitempty" json:"scripts" yaml:"scripts"`
}

type Secret

type Secret struct {
	Id          bson.ObjectId `bson:"_id,omitempty" json:"id"`
	UserId      bson.ObjectId `bson:"user_id,omitempty" json:"user_id"`
	Secret      string        `bson:"secret,omitempty" json:"secret"`
	TempToken   string        `bson:"temp_token,omitempty" json:"temp_token"`
	CreateTime  time.Time     `bson:"create_time,omitempty" json:"create_time,omitempty"`
	UpdatedTime time.Time     `bson:"updated_time,omitempty" json:"updated_time,omitempty"`
}

func FromPbSecret

func FromPbSecret(u *pb.Secret) *Secret

func (*Secret) ToPbSecret

func (u *Secret) ToPbSecret() (pbSecret *pb.Secret)

func (*Secret) UpdateTime

func (u *Secret) UpdateTime() *Secret

type Status

type Status struct {
	Code    errcodes.Code
	Message string
	Details []*any.Any
}

Status is a wrapper to pb-status

func FromPbStatus

func FromPbStatus(st *status.Status) *Status

func (*Status) ToPbStatus

func (st *Status) ToPbStatus() (pbSt *status.Status)

type User

type User struct {
	Id          bson.ObjectId `bson:"_id,omitempty" json:"id"`
	UserType    pb.UserType   `bson:"user_type,omitempty" json:"user_type,omitempty"`
	Name        string        `bson:"name,omitempty" json:"name,omitempty"`
	DisplayName string        `bson:"display_name,omitempty" json:"display_name,omitempty"`
	Email       string        `bson:"email,omitempty" json:"email,omitempty"`
	CreateTime  time.Time     `bson:"create_time,omitempty" json:"create_time,omitempty"`
	UpdatedTime time.Time     `bson:"updated_time,omitempty" json:"updated_time,omitempty"`
	CreatedBy   string        `bson:"created_by,omitempty" json:"created_by"`
}

func FromPbUser

func FromPbUser(u *pb.User) *User

func (*User) ToPbUser

func (u *User) ToPbUser() (pbUser *pb.User)

func (*User) UpdateTime

func (u *User) UpdateTime() *User

type UserServiceFilterOption

type UserServiceFilterOption struct {
	UserType []pb.UserType
	Order    OrderType // 0: ignore, 1: asc, 2: desc
	Name     string    // user name
	Query    string
}

func ParseUserServiceFilterOption

func ParseUserServiceFilterOption(filter string) (opt *UserServiceFilterOption)

type UserType

type UserType pb.UserType

Jump to

Keyboard shortcuts

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