models

package
v0.0.0-...-dedba89 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NotFoundError error from server
	NotFoundError string = "Not found"
	// ActionNotAllowed error from server
	ActionNotAllowed string = "Action not allowed"
	// WrongLength error from server
	WrongLength string = "Wrong length"
	// ServerError error from server
	ServerError string = "Server Error"
	// WrongInputFormatError wrong user input
	WrongInputFormatError string = "Wrong inputFormat!"
	// InvalidTokenError token is not valid
	InvalidTokenError string = "Token not valid"
	// InvalidCallbackURL token is not valid
	InvalidCallbackURL string = "Callback url is invalid"
	// BatchSizeTooLarge batch is too large
	BatchSizeTooLarge string = "BatchSize soo large!"
	// WrongIntegerFormat integer is probably no integer
	WrongIntegerFormat string = "Number is string"
	// MultipleSourceNameErr err name already exists
	MultipleSourceNameErr string = "You can't have multiple sources with the same name"
	// UserIsInvalidErr err if user is invalid
	UserIsInvalidErr string = "user is invalid"
)
View Source
const (
	// HeaderStatus headername for status in response
	HeaderStatus string = "X-Response-Status"

	// HeaderStatusMessage headername for status in response
	HeaderStatusMessage string = "X-Response-Message"

	// HeaderContentType contenttype of response
	HeaderContentType string = "Content-Type"

	// HeaderContentLength request content length
	HeaderContentLength string = "ContentLength"
)
View Source
const ResInfoFileName = "resInfo"

ResInfoFileName name for resInfo file

View Source
const SessionTokenLength = 64

SessionTokenLength length of session token

Variables

View Source
var (
	// ErrNoManagerDataAvailable if no datamanager data is available but required
	ErrNoManagerDataAvailable = errors.New("No DManager data available")

	// ErrNoVaildUploadMetodPassed if no uploadmethod/data was passed
	ErrNoVaildUploadMetodPassed = errors.New("No vaild upolad method passed")
)
View Source
var (
	// ErrAURNoRepoFound if no repo name was given
	ErrAURNoRepoFound = errors.New("No AUR repo-name found")
)
View Source
var ErrFileEmpty = errors.New("file is empty")

ErrFileEmpty if file is empty

View Source
var ErrInvalidFormat = errors.New("Invalid resInfo format")

ErrInvalidFormat error if resinfo format is invalid

View Source
var ErrJobNotRunning = errors.New("Job not running")

ErrJobNotRunning if job is not running

View Source
var ErrNoLogsFound = errors.New("No logs found")

ErrNoLogsFound if no logs were found

View Source
var ErrorJobCancelled = errors.New("job cancelled")

ErrorJobCancelled error if user exists

View Source
var ErrorNonZeroExit = errors.New("Non zero exit code from container")

ErrorNonZeroExit error if user exists

View Source
var ErrorUserAlreadyExists = errors.New("user already exists")

ErrorUserAlreadyExists error if user exists

Functions

func DirExists

func DirExists(path string) bool

DirExists return true if dir exists

func GetDefaultConfig

func GetDefaultConfig() string

GetDefaultConfig gets the default config path

func GetResInfoPath

func GetResInfoPath(base string) string

GetResInfoPath return path for resinfo file

Types

type ArgParser

type ArgParser struct {
	JobType libremotebuild.JobType
	// contains filtered or unexported fields
}

ArgParser parse job args

func NewArgParser

func NewArgParser(args map[string]string, JobType libremotebuild.JobType) *ArgParser

NewArgParser create new argparser

func (*ArgParser) GetDManagerData

func (argParser *ArgParser) GetDManagerData() *DataManagerArgs

GetDManagerData return Dmanager Data

func (*ArgParser) GetDManagerNamespace

func (argParser *ArgParser) GetDManagerNamespace() string

GetDManagerNamespace return the namespace according to the dmanager args

func (*ArgParser) HasDataManagerArgs

func (argParser *ArgParser) HasDataManagerArgs() bool

HasDataManagerArgs return true if DManager data is available

func (*ArgParser) HasNamespace

func (argParser *ArgParser) HasNamespace() bool

HasNamespace return true if namespace is set

func (*ArgParser) ParseEnvars

func (argParser *ArgParser) ParseEnvars() ([]string, error)

ParseEnvars parse args to envars based on the JobType

type BuildJob

type BuildJob struct {
	*docker.Client `gorm:"-"`
	gorm.Model
	State libremotebuild.JobState // Build state
	Type  libremotebuild.JobType  // Type of job

	Image     string // Dockerimage to run
	UseCcache bool   // use ccahe to improve build speed

	ContainerID string  `gorm:"-"`
	Config      *Config `gorm:"-"`
	// contains filtered or unexported fields
}

BuildJob a job which builds a package

func NewBuildJob

func NewBuildJob(db *gorm.DB, config *Config, buildJob BuildJob, image string, useCcache bool) (*BuildJob, error)

NewBuildJob create new BuildJob

func (*BuildJob) GetLogs

func (buildJob *BuildJob) GetLogs(since int64, w io.Writer, tail string) error

GetLogs of Buildjob

func (*BuildJob) Init

func (buildJob *BuildJob) Init() error

Init buildJob

func (*BuildJob) Pause

func (buildJob *BuildJob) Pause() error

Pause buildjob

func (*BuildJob) Resume

func (buildJob *BuildJob) Resume() error

Resume buildjob

func (*BuildJob) Run

func (buildJob *BuildJob) Run(dataDir string, argParser *ArgParser) (*BuildResult, *time.Duration)

Run a buildjob (start but await)

func (*BuildJob) Save

func (buildJob *BuildJob) Save(db *gorm.DB) error

Save Buildjob

func (*BuildJob) Stop

func (buildJob *BuildJob) Stop()

Stop building

type BuildResult

type BuildResult struct {
	Error error
	// contains filtered or unexported fields
}

BuildResult result of a bulid

type Config

type Config struct {
	Server    configServer
	Webserver webserverConf
}

Config config for the server

func InitConfig

func InitConfig(confFile string, createMode bool) (*Config, bool)

InitConfig inits the config Returns true if system should exit

func (*Config) Check

func (config *Config) Check() bool

Check check the config file of logical errors

func (Config) GetImage

func (config Config) GetImage(buildType libremotebuild.JobType) (string, bool)

GetImage get DockerImage for buildType

func (Config) IsCcacheDirValid

func (config Config) IsCcacheDirValid() bool

IsCcacheDirValid return true if cache is valid

type CountResponse

type CountResponse struct {
	Count uint32 `json:"count"`
}

CountResponse response containing a count of changed items

type DataManagerArgs

type DataManagerArgs struct {
	Username  string
	Host      string
	Token     string
	Namespace string
}

DataManagerArgs data for datamanager

type IDsResponse

type IDsResponse struct {
	IDs []uint `json:"ids"`
}

IDsResponse response containing a list of ids

type Job

type Job struct {
	gorm.Model

	// Buildjob
	BuildJobID uint      `sql:"index"`
	BuildJob   *BuildJob `gorm:"association_autoupdate:false;association_autocreate:false"`

	// UploadJob
	UploadJobID uint       `sql:"index"`
	UploadJob   *UploadJob `gorm:"association_autoupdate:false;association_autocreate:false"`

	DataDir  string // Shared dir containing build files
	Result   string // Message of an exited job
	LastLogs string // Latest logs
	Argdata  string `grom:"type:jsonb"`
	Info     string
	Duration int64

	Args      map[string]string `gorm:"-"` // Envars for Dockerimage
	*gorm.DB  `gorm:"-"`
	Cancelled bool  `gorm:"-"`
	LastSince int64 `gorm:"-"`
	// contains filtered or unexported fields
}

Job a job created by a user

func NewJob

func NewJob(db *gorm.DB, config *Config, image string, buildJob BuildJob, uploadJob UploadJob, args map[string]string, useCcache bool) (*Job, error)

NewJob create a new job

func (*Job) Cancel

func (job *Job) Cancel()

Cancel Job

func (*Job) GetInfo

func (job *Job) GetInfo() string

GetInfo for job

func (*Job) GetLogs

func (job *Job) GetLogs(requestTime time.Time, since int64, w io.Writer, checkAmbigious bool) error

GetLogs for job

func (*Job) GetState

func (job *Job) GetState() libremotebuild.JobState

GetState get state of a job

func (*Job) Init

func (job *Job) Init(db *gorm.DB, config *Config) error

Init Job

func (*Job) Run

func (job *Job) Run() error

Run a job

func (*Job) Save

func (job *Job) Save() (err error)

Save job

func (*Job) SetState

func (job *Job) SetState(newState libremotebuild.JobState)

SetState set the state of a job

func (Job) ToJobInfo

func (job Job) ToJobInfo() libremotebuild.JobInfo

ToJobInfo return JobInfo by job

type LoginResponse

type LoginResponse struct {
	Token string `json:"token"`
}

LoginResponse response for login

type LoginSession

type LoginSession struct {
	gorm.Model
	User      *User `gorm:"association_autoupdate:false;association_autocreate:false"`
	UserID    uint
	Token     string
	Requests  int64
	MachineID string
}

LoginSession session for loggedin user

func NewSession

func NewSession(user *User, machineID string) *LoginSession

NewSession create new login session

type Namespaceinfo

type Namespaceinfo struct {
	Name   string   `json:"ns"`
	Groups []string `json:"groups"`
}

Namespaceinfo info for namespace

type ResInfo

type ResInfo struct {
	Name    string
	Version string
	Files   []string
}

ResInfo containing Information about the result of an built package

func ParseResInfo

func ParseResInfo(dataDir, file string) (*ResInfo, error)

ParseResInfo parses result info from file

type ResponseStatus

type ResponseStatus uint8

ResponseStatus the status of response

const (
	//ResponseError if there was an error
	ResponseError ResponseStatus = 0
	//ResponseSuccess if the response is successful
	ResponseSuccess ResponseStatus = 1
)

type StringResponse

type StringResponse struct {
	String string `json:"content"`
}

StringResponse response containing only one string

type StringSliceResponse

type StringSliceResponse struct {
	Slice []string `json:"slice"`
}

StringSliceResponse response containing only one string slice

type UploadJob

type UploadJob struct {
	gorm.Model
	State libremotebuild.JobState // Upload state

	Type libremotebuild.UploadType
	// contains filtered or unexported fields
}

UploadJob a job which uploads a built package

func NewUploadJob

func NewUploadJob(db *gorm.DB, uploadJob UploadJob) (*UploadJob, error)

NewUploadJob create new upload job

func (*UploadJob) Init

func (uploadJob *UploadJob) Init()

Init the uploadJob

func (*UploadJob) Run

func (uploadJob *UploadJob) Run(buildResult BuildResult, argParser *ArgParser) *UploadJobResult

Run an upload job

type UploadJobResult

type UploadJobResult struct {
	Error error
}

UploadJobResult result of uploading a binary

type User

type User struct {
	gorm.Model
	Username string
	Password string
	RoleID   uint `sql:"index"`
}

User user in db

func GetUserFromSession

func GetUserFromSession(db *gorm.DB, token string) (*User, error)

GetUserFromSession return user from session

func (*User) GetUsername

func (user *User) GetUsername() string

GetUsername Gets username of user

func (*User) Has

func (user *User) Has(db *gorm.DB, checkPass bool) (bool, error)

Has return true if user exists

func (*User) Login

func (user *User) Login(db *gorm.DB, machineID string) (*LoginSession, error)

Login login user

func (User) Register

func (user User) Register(db *gorm.DB, config *Config) error

Register register user

type UserAttributeDataResponse

type UserAttributeDataResponse struct {
	Namespace []Namespaceinfo `json:"nsData"`
}

UserAttributeDataResponse response for userattribute data

Jump to

Keyboard shortcuts

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