models

package
v0.0.0-...-0843407 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ImageStatusStart       string = "created"
	ImageStatusDownloading string = "downloading"
	ImageStatusDone        string = "succeed"
	ImageStatusFailed      string = "failed"
)
View Source
const (
	BuildImageFromRelease string = "buildimagefromrelease"
	BuildImageFromISO     string = "buildimagefromiso"
)
View Source
const (

	//job status
	JOB_STATUS_RUNNING = "running"
	JOB_STATUS_SUCCEED = "succeed"
	JOB_STATUS_FAILED  = "failed"
	JOB_STATUS_CREATED = "created"
	JOB_STATUS_STOPPED = "stopped"

	JOB_BUILD_STATUS_SUCCEED = "JobSucceed"
	JOB_BUILD_STATUS_FAILED  = "JobFailed"
	JOB_BUILD_STATUS_CREATED = "JobCreated"
	JOB_BUILD_STATUS_STOPPED = "JobStopped"
	JOB_BUILD_STATUS_RUNNING = "JobRunning"
)
View Source
const (
	JwtString = "omni-manager@98524"
)

Variables

View Source
var AppClient *model.Application
View Source
var AuthingClient *management.Client

Functions

func AddBaseImages

func AddBaseImages(m *BaseImages) (err error)

AddBaseImages insert a new BaseImages into database and returns last inserted Id on success.

func AddImageMeta

func AddImageMeta(m *ImageMeta) (id int64, err error)

AddImageMeta insert a new ImageMeta into database and returns last inserted Id on success.

func AddJobLog

func AddJobLog(m *JobLog) (err error)

AddJobLog insert a new ImageMeta into database and returns last inserted Id on success.

func AddKickStart

func AddKickStart(m *KickStart) (err error)

AddKickStart insert a new ImageMeta into database and returns last inserted Id on success.

func Authorize

func Authorize() gin.HandlerFunc

func CheckAuthorization

func CheckAuthorization(tokenString string) (userInfo map[string]interface{}, err error)

check user token status

func CheckPodStatus

func CheckPodStatus(ns, jobname string) (result map[string]interface{}, job *batchv1.Job, err error)

func CreateRedisJobName

func CreateRedisJobName(jobname string) string

func CreateTables

func CreateTables() (err error)

CreateTables

func DeleteBaseImagesById

func DeleteBaseImagesById(userid, id int) (deleteNum int, err error)

DeleteBaseImagesById

func DeleteImageMeta

func DeleteImageMeta(id int) (err error)

DeleteImageMeta deletes ImageMeta by Id and returns error if the record to be deleted doesn't exist

func DeleteJobLogById

func DeleteJobLogById(jobName string) (err error)

DeleteJobLogById

func DeleteKickStartById

func DeleteKickStartById(userid int, id int) (deleteNum int, err error)

DeleteKickStartById

func DeleteMultiJobLogs

func DeleteMultiJobLogs(names string) (err error)

DeleteMultiJobLogs

func DeleteMultiKickStarts

func DeleteMultiKickStarts(names string) (err error)

DeleteMultiKickStarts

func GetAllImageMeta

func GetAllImageMeta(query map[string]string, fields []string, sortby []string, order []string,
	offset int64, limit int64) (ml []interface{}, err error)

GetAllImageMeta retrieves all ImageMeta matches certain condition. Returns empty list if no records exist

func GetAllJobLog

func GetAllJobLog(query map[string]string, fields []string, sortby []string, order []string,
	offset int64, limit int64) (ml []interface{}, err error)

GetAllJobLog retrieves all ImageMeta matches certain condition. Returns empty list if no records exist

func GetClientSet

func GetClientSet() *kubernetes.Clientset

func GetImagesAndKickStart

func GetImagesAndKickStart(userid int) (result map[string]interface{}, err error)

func GetJwtString

func GetJwtString(expire int, id, name, provider string) (string, error)

GetJwtString GetJwtString

func GetK8sConfig

func GetK8sConfig() *rest.Config

func GetUserInfoByToekn

func GetUserInfoByToekn(token string) error

func InitAuthing

func InitAuthing(userpoolid, secret string)

func InitCustomPkgs

func InitCustomPkgs() error

init custom package rpms list

func InitK8sClient

func InitK8sClient() (err error)

func IsUtf8

func IsUtf8(data []byte) bool

check data is utf8

func MakeConfigMap

func MakeConfigMap(release string, customRpms []string) (cm *v1.ConfigMap)

make ConfigMap

func MakeJob

func MakeJob(cm *v1.ConfigMap, buildtype, release string) (job *batchv1.Job, outputName string, err error)

make job yaml and start job

func ParseAuthingUserInput

func ParseAuthingUserInput(userinput *CreateUserInput) *model.CreateUserRequest

func PersistenceJob

func PersistenceJob(m *JobLog) (err error)

Persistence a Job_log from redis to db

func StartWebSocket

func StartWebSocket()

func SyncJobStatus

func SyncJobStatus()

func UpdateBaseImages

func UpdateBaseImages(m *BaseImages) (err error)

UpdateBaseImages

func UpdateBaseImagesStatus

func UpdateBaseImagesStatus(m *BaseImages) (err error)

UpdateBaseImagesStatus

func UpdateImageMetaById

func UpdateImageMetaById(m *ImageMeta) (err error)

UpdateImageMeta updates ImageMeta by Id and returns error if the record to be updated doesn't exist

func UpdateJobLogStatusById

func UpdateJobLogStatusById(jobname, newStatus string) (err error)

UpdateJobLogStatusById

func UpdateJobStatus

func UpdateJobStatus(m *ImageMeta) (err error)

UpdateJobStatus

func UpdateKickStart

func UpdateKickStart(m *KickStart) (err error)

UpdateKickStart

Types

type AuthingJWKS

type AuthingJWKS struct {
	Keys []AuthingKey
}
var AuthingJWKSItem AuthingJWKS

type AuthingKey

type AuthingKey struct {
	E   string `json:"e"`
	N   string `json:"n"`
	Kty string `json:"kty"`
	Alg string `json:"alg"`
	Use string `json:"use"`
	Kid string `json:"Kid"`
}

type BaseImageConfig

type BaseImageConfig struct {
	Id        string `json:"id"`
	State     string `json:"state"`
	StartTime string `json:"startTime"`
	EndTime   string `json:"endTime"`
}

type BaseImages

type BaseImages struct {
	ID         int       ` description:"id" gorm:"primaryKey"`
	Name       string    ` description:"name"`
	ExtName    string    ` description:"ext name"`
	Desc       string    ` description:"desc"`
	Checksum   string    ` description:"checksum"`
	Url        string    ` description:"url" gorm:"-"`
	Arch       string    ` description:"arch"`
	Status     string    ` description:"status"`
	UserId     int       ` description:"user id"`
	CreateTime time.Time ` description:"create time"`
}

func GetBaseImagesByID

func GetBaseImagesByID(id int) (v *BaseImages, err error)

func GetMyBaseImages

func GetMyBaseImages(userid int, offset int, limit int) (total int64, ml []*BaseImages, err error)

GetMyBaseImages

func (*BaseImages) TableName

func (t *BaseImages) TableName() string

type BaseImagesKickStart

type BaseImagesKickStart struct {
	Label            string ` description:"name"`
	Desc             string ` description:"desc"`
	BaseImageID      string ` description:"BaseImages ID"`
	KickStartID      string ` description:"KickStart ID"`
	KickStartContent string ` description:"KickStart Content"`
	KickStartName    string ` description:"KickStart name"`
}

type BuildParam

type BuildParam struct {
	// Id        int      `gorm:"primaryKey"`
	Arch      string   ` description:"architecture"`
	Release   string   ` description:"release openEuler Version"`
	BuildType string   ` description:"iso , zip ...."`
	CustomPkg []string ` description:"custom"`
	Label     string   ` description:"name"`
	Desc      string   ` description:"description"`
}

post this body to backend

type CreateUserInput

type CreateUserInput struct {
	Username          *string  `json:"username,omitempty"`
	Email             *string  `json:"email,omitempty"`
	EmailVerified     *bool    `json:"emailVerified,omitempty"`
	Phone             *string  `json:"phone,omitempty"`
	PhoneVerified     *bool    `json:"phoneVerified,omitempty"`
	Unionid           *string  `json:"unionid,omitempty"`
	Openid            *string  `json:"openid,omitempty"`
	Nickname          *string  `json:"nickname,omitempty"`
	Photo             *string  `json:"photo,omitempty"`
	Password          *string  `json:"password,omitempty"`
	RegisterSource    []string `json:"registerSource,omitempty"`
	Browser           *string  `json:"browser,omitempty"`
	Oauth             *string  `json:"oauth,omitempty"`
	LoginsCount       *int64   `json:"loginsCount,omitempty"`
	LastLogin         *string  `json:"lastLogin,omitempty"`
	Company           *string  `json:"company,omitempty"`
	LastIP            *string  `json:"lastIP,omitempty"`
	SignedUp          *string  `json:"signedUp,omitempty"`
	Blocked           *bool    `json:"blocked,omitempty"`
	IsDeleted         *bool    `json:"isDeleted,omitempty"`
	Device            *string  `json:"device,omitempty"`
	Name              *string  `json:"name,omitempty"`
	GivenName         *string  `json:"givenName,omitempty"`
	FamilyName        *string  `json:"familyName,omitempty"`
	MiddleName        *string  `json:"middleName,omitempty"`
	Profile           *string  `json:"profile,omitempty"`
	PreferredUsername *string  `json:"preferredUsername,omitempty"`
	Website           *string  `json:"website,omitempty"`
	Gender            *string  `json:"gender,omitempty"`
	Birthdate         *string  `json:"birthdate,omitempty"`
	Zoneinfo          *string  `json:"zoneinfo,omitempty"`
	Locale            *string  `json:"locale,omitempty"`
	Address           *string  `json:"address,omitempty"`
	Formatted         *string  `json:"formatted,omitempty"`
	StreetAddress     *string  `json:"streetAddress,omitempty"`
	Locality          *string  `json:"locality,omitempty"`
	Region            *string  `json:"region,omitempty"`
	PostalCode        *string  `json:"postalCode,omitempty"`
	Country           *string  `json:"country,omitempty"`
	ExternalId        *string  `json:"externalId,omitempty"`
}

type CustomPkg

type CustomPkg struct {
	RPMs []PkgItem `json:"rpms"`
}

func GetCustomePkgList

func GetCustomePkgList(release, arch, sig string) (customPkgList *CustomPkg, err error)

type CustomSigs

type CustomSigs struct {
	Sigs []string
}
var CustomSigList CustomSigs

type ImageInputData

type ImageInputData struct {
	Id        int    `gorm:"primaryKey"`
	Packages  string ` description:"architecture"`
	Version   string ` description:"release openEuler Version"`
	BuildType string ` description:"iso , zip ...."`
	// BasePkg      []pkgData ` description:"default package"`
	CustomPkg []string ` description:"custom"`
}

post this body to backend

type ImageMeta

type ImageMeta struct {
	Id         int       `gorm:"primaryKey"`
	Packages   string    ` description:"architecture"`
	Version    string    ` description:"release openEuler Version"`
	BuildType  string    ` description:"iso , zip ...."`
	BasePkg    string    ` description:"default package"`
	CustomPkg  string    ` description:"custom"`
	UserId     int       ` description:"user id"`
	UserName   string    ` description:"user name"`
	CreateTime time.Time ` description:"create time"`
	Status     string    ` description:"current status :running ,success, failed"`
	JobName    string    ` description:"pod name"`
}

func GetImageMetaById

func GetImageMetaById(id int) (v *ImageMeta, err error)

GetImageMetaById retrieves ImageMeta by Id. Returns error if Id doesn't exist

func (*ImageMeta) TableName

func (t *ImageMeta) TableName() string

func (*ImageMeta) ToString

func (t *ImageMeta) ToString() string

type JobLog

type JobLog struct {
	JobName          string    ` description:"pod name" gorm:"primaryKey"`
	Arch             string    ` description:"architecture"`
	Release          string    ` description:"release openEuler Version"`
	BuildType        string    ` description:"iso , zip ...."`
	BasePkg          string    ` gorm:"size:5055"  description:"default package"`
	CustomPkg        string    ` gorm:"size:5055" description:"custom"`
	UserId           int       ` description:"user id"  gorm:"index:"`
	UserName         string    ` description:"user name"`
	CreateTime       time.Time ` description:"create time"`
	Status           string    ` description:"current status :running ,success, failed" gorm:"index"`
	DownloadUrl      string    ` description:"download the result of build iso file"`
	ConfigMapName    string    ` description:"configMap name"`
	JobLabel         string    ` description:"job label"`
	JobDesc          string    ` description:"job description"`
	StartTime        time.Time ` description:"create time"`
	EndTime          time.Time ` description:"create time"`
	JobType          string    ` description:"job type"`
	KickStartID      string    ` description:"KickStart id"  `
	BaseImageID      string    ` description:"BaseImage id"  `
	KickStartContent string    ` description:"kick_start_content"  `
}

func GetJobLogByJobName

func GetJobLogByJobName(jobname string) (v *JobLog, err error)

func GetMyJobLogs

func GetMyJobLogs(jobitem *JobLog, nameOrDesc string, offset int, limit int) (total int64, ml []*JobLog, err error)

GetMyJobLogs query my build history

func (*JobLog) TableName

func (t *JobLog) TableName() string

func (*JobLog) ToString

func (t *JobLog) ToString() string

type JobStatuItem

type JobStatuItem struct {
	Id        string `json:"id"`
	State     string `json:"state"`
	StartTime string `json:"startTime"`
	EndTime   string `json:"endTime"`
}

type KickStart

type KickStart struct {
	ID         int       ` description:"id" gorm:"primaryKey"`
	Name       string    ` description:"name"`
	Desc       string    ` description:"desc"`
	Content    string    ` description:"content"`
	UserId     int       ` description:"user id"`
	CreateTime time.Time ` description:"create time"`
	UpdateTime time.Time ` description:"update  time"`
}

func GetKickStartByID

func GetKickStartByID(id int) (*KickStart, error)

func GetMyKickStart

func GetMyKickStart(userid int, offset int, limit int) (total int64, ml []*KickStart, err error)

GetMyKickStart

func (*KickStart) TableName

func (t *KickStart) TableName() string

type PkgItem

type PkgItem struct {
	ShortName string `json:"short-name"`
}

type SummaryStatus

type SummaryStatus struct {
	Succeed int `json:"succeed"`
	Running int `json:"running"`
	Failed  int `json:"failed"`
	Created int `json:"created"`
	Stopped int `json:"stopped"`
}

func CountSummaryStatus

func CountSummaryStatus(userid int) (result *SummaryStatus, err error)

CountSummaryStatus

Jump to

Keyboard shortcuts

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