exercise

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DuplicateTagErr = errors.New("Tag already exists")
	MissingTagsErr  = errors.New("No tags, need atleast one tag")
	UnknownTagErr   = errors.New("Unknown tag")
	RegistryLink    = "registry.gitlab.com"

	OvaSuffix = ".ova"
)
View Source
var (
	ErrInvalidFlagFormat = errors.New("Invalid flag format")
)

TODO add comments

View Source
var (
	TagEmptyErr = errors.New("Tag cannot be empty")
)

Functions

func CreateContainer

func CreateContainer(ctx context.Context, conf virtual.ContainerConfig) (*virtual.Container, error)

func NewTag

func NewTag(s string) (string, error)

func ValidateTag

func ValidateTag(t string) error

Types

type ChildExercise

type ChildExercise struct {
	Name  string //challenge name
	Tag   string //challenge tag
	Value string //challenge flag value
}

type ChildrenChalConfig

type ChildrenChalConfig struct {
	Tag        string `json:"tag,omitempty"`
	Name       string `json:"name,omitempty"`
	EnvVar     string `json:"envFlag,omitempty"`
	StaticFlag string `json:"static,omitempty"`
}

type ContainerOptions

type ContainerOptions struct {
	DockerConf     virtual.ContainerConfig
	Records        []RecordConfig
	ChildExercises []ChildExercise
}

type EmptyVarErr

type EmptyVarErr struct {
	Var  string
	Type string
}

func (*EmptyVarErr) Error

func (eve *EmptyVarErr) Error() string

type EnvVarConfig

type EnvVarConfig struct {
	EnvVar string `json:"name,omitempty"`
	Value  string `json:"value,omitempty"`
}

type Exercise

type Exercise struct {
	ContainerOpts []ContainerOptions
	VboxOpts      []ExerciseInstanceConfig

	Tag  string
	Vlib *virtual.VboxLibrary
	Net  *virtual.Network

	DnsAddr    string
	DnsRecords []RecordConfig

	Ips      []int
	Machines []virtual.Instance
}

todo manage exercise status somehow

func NewExercise

func NewExercise(conf ExerciseConfig, vlib *virtual.VboxLibrary, net *virtual.Network, dnsAddr string) *Exercise

TODO add comments

func (*Exercise) Close

func (e *Exercise) Close() error

func (*Exercise) Create

func (e *Exercise) Create(ctx context.Context) error

func (*Exercise) GetChildExercises

func (e *Exercise) GetChildExercises() []ChildExercise

func (*Exercise) InstanceInfo

func (e *Exercise) InstanceInfo() []virtual.InstanceInfo

func (*Exercise) Reset

func (e *Exercise) Reset(ctx context.Context) error

func (*Exercise) Start

func (e *Exercise) Start(ctx context.Context) error

func (*Exercise) Stop

func (e *Exercise) Stop(ctx context.Context) error

TODO: Add multierror or go routine

type ExerciseConfig

type ExerciseConfig struct {
	Tag string `json:"tag,omitempty"`
	// specifies whether challenge will be on docker/vm or none
	// true: none , false: docker/vm
	Static   bool                     `json:"static,omitempty"`
	Instance []ExerciseInstanceConfig `json:"instance,omitempty"`
}

func (ExerciseConfig) CreateContainerOpts

func (e ExerciseConfig) CreateContainerOpts() []ContainerOptions

type ExerciseInstanceConfig

type ExerciseInstanceConfig struct {
	Image    string               `json:"image,omitempty"`
	MemoryMB uint                 `json:"memory,omitempty"`
	CPU      float64              `json:"cpu,omitempty"`
	Envs     []EnvVarConfig       `json:"envs,omitempty"`
	Flags    []ChildrenChalConfig `json:"children,omitempty"`
	Records  []RecordConfig       `json:"records,omitempty"`
}

type Flag

type Flag [flagNumCharsFormat]byte

func NewFlag

func NewFlag() Flag

func (Flag) String

func (f Flag) String() string

type InvalidTagSyntaxErr

type InvalidTagSyntaxErr struct {
	// contains filtered or unexported fields
}

func (*InvalidTagSyntaxErr) Error

func (ite *InvalidTagSyntaxErr) Error() string

type RecordConfig

type RecordConfig struct {
	Type  string `json:"type,omitempty"`
	Name  string `json:"name,omitempty"`
	RData string `json:"data,omitempty"`
}

Jump to

Keyboard shortcuts

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