aboutsummaryrefslogtreecommitdiff
path: root/config/game.go
blob: c34c69758b8f82c75a26c34f1be8b26e548904ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package config

import (
	"errors"
	"regexp"
)

var reValidGameName = regexp.MustCompile(`^[\w\._]+$`)

// Game struct containers the configuration for a game
type Game struct {
	// ChrootPath is the chroot path for the game
	ChrootPath string `yaml:"ChrootPath"`
	// FileMode is the file mode to use when copying files
	FileMode string `yaml:"FileMode"`
	// Commands is the command list
	Commands []string `yaml:"Commands"`
	// ScoreFile is relative to the chroot path for the game
	ScoreCommands []string `yaml:"ScoreCommands"`
	// Env is the environment in which to exec the commands
	Env map[string]string `yaml:"Env"`
}

func (g *Game) validate(name string) error {
	// Game name
	if ok := reValidGameName.MatchString(name); !ok {
		return errors.New("Invalid Game name, must match regex `^[\\w\\._]+$` : " + name)
	}
	// ChrootPath  TODO
	// FileMode
	// Commands
	// ScoreFile
	// Env
	return nil
}