aboutsummaryrefslogtreecommitdiff
path: root/config/game.go
diff options
context:
space:
mode:
authorJulien Dessaux2020-12-24 15:18:24 +0100
committerJulien Dessaux2020-12-24 15:18:24 +0100
commitb4dc5d6841f7ded5995e5f308509b1a3a034cbed (patch)
tree254466925238c53bd51372a57558ec68fdf78205 /config/game.go
parentImplemented the configuration file format (diff)
downloadshell-game-launcher-b4dc5d6841f7ded5995e5f308509b1a3a034cbed.tar.gz
shell-game-launcher-b4dc5d6841f7ded5995e5f308509b1a3a034cbed.tar.bz2
shell-game-launcher-b4dc5d6841f7ded5995e5f308509b1a3a034cbed.zip
Began implementing config validation
Diffstat (limited to 'config/game.go')
-rw-r--r--config/game.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/config/game.go b/config/game.go
index 0eea917..5520659 100644
--- a/config/game.go
+++ b/config/game.go
@@ -1,5 +1,12 @@
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
@@ -8,4 +15,21 @@ type Game struct {
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 (a *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
}