lab

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2019 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLabScenarioFromConfig

func GetLabScenarioFromConfig(students, tasks string) ([]*Student, []*TaskDefinition, error)

Types

type Assignment

type Assignment struct {
	Description string
	Student     *Student
	Tasks       []Task
	Score       int
}

func (*Assignment) GetState

func (a *Assignment) GetState() *AssignmentState

type AssignmentState

type AssignmentState struct {
	Description string       `json:"description"`
	Student     *Student     `json:"student"`
	Tasks       []*TaskState `json:"tasks"`
}

type Lab

type Lab struct {
	Name  string
	Cycle uint

	IsRunning  bool
	IsFinished bool
	// contains filtered or unexported fields
}

func NewLabController

func NewLabController() *Lab

func NewLabFromState

func NewLabFromState(state []byte) (*Lab, error)

func (*Lab) GetState

func (l *Lab) GetState() *LabState

func (*Lab) LabScenarioHandler

func (l *Lab) LabScenarioHandler(w http.ResponseWriter, r *http.Request)

func (*Lab) LabStateHandler

func (l *Lab) LabStateHandler(w http.ResponseWriter, r *http.Request)

func (*Lab) Run

func (l *Lab) Run() error

func (*Lab) SetupScenario

func (l *Lab) SetupScenario(name string, cycle uint, duration time.Duration, students []*Student, defs []*TaskDefinition)

func (*Lab) Stop

func (l *Lab) Stop() error

type LabState

type LabState struct {
	Name        string             `json:"name"`
	Cycle       uint               `json:"cycle"`
	Started     *time.Time         `json:"started"`
	Duration    time.Duration      `json:"duration"`
	Assignments []*AssignmentState `json:"assignments"`
}

type Maker

type Maker interface {
	NewTask(ctx context.Context, def *TaskDefinition, s *Student) (Task, error)
	MakeTaskFromState(ctx context.Context, state *TaskState, s *Student) (Task, error)
}

func NewTaskMaker

func NewTaskMaker() Maker

type Student

type Student struct {
	FirstName         string `yaml:"firstName" json:"firstName"`
	LastName          string `yaml:"lastName" json:"lastName"`
	DockerhubUsername string `yaml:"dockerhubUsername" json:"dockerhubUsername"`
	GithubUsername    string `yaml:"githubUsername" json:"githubUsername"`
	K8sNamespace      string `yaml:"k8sNamespace" json:"k8sNamespace"`
}

type Task

type Task interface {
	Eval() error
	GetKind() string
	GetName() string
	GetUUID() string
	GetScore() int
	IsCompleted() bool
	GetState() *TaskState
}

type TaskDefinition

type TaskDefinition struct {
	Name        string            `yaml:"name" json:"name"`
	Kind        string            `yaml:"kind" json:"kind"`
	Config      map[string]string `yaml:"config" json:"config"`
	Description string            `yaml:"description" json:"description"`
	Score       int               `yaml:"score" json:"score"`
}

type TaskState

type TaskState struct {
	Def       *TaskDefinition `json:"taskDefinition"`
	Completed bool            `json:"completed"`
	UUID      string          `json:"uuid"`
}

Jump to

Keyboard shortcuts

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