From fd4f88cb935afc49b820d207e3f3002fb8fffe19 Mon Sep 17 00:00:00 2001 From: ags131 Date: Wed, 30 Dec 2020 19:17:53 +0000 Subject: [PATCH] [feature] Support docker / docker-compose secrets for steamKey Fixes #13 --- launcher/config.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/launcher/config.go b/launcher/config.go index eae5730..b48264c 100644 --- a/launcher/config.go +++ b/launcher/config.go @@ -4,10 +4,13 @@ import ( "io/ioutil" "log" "math" + "os" "path/filepath" "runtime" "strconv" + "strings" + "github.com/pkg/errors" "gopkg.in/yaml.v2" ) @@ -36,6 +39,7 @@ type ConfigCli struct { // Config server config structure type Config struct { SteamKey string `yaml:"steamKey" json:"steamKey"` + SteamKeyFile string `yaml:"steamKeyFile" json:"steamKeyFile"` Cli *ConfigCli `yaml:"cli" json:"cli"` Env *ConfigEnv `yaml:"env" json:"env"` Processors int `yaml:"processors" json:"processors"` @@ -128,6 +132,16 @@ func (c *Config) GetConfig(dir string) (*Config, error) { if c.RunnerThreads > 0 { c.Env.Engine["RUNNER_THREADS"] = strconv.Itoa(c.RunnerThreads) } + if _, err := os.Stat("STEAM_KEY"); c.SteamKeyFile == "" && !os.IsNotExist(err) { + c.SteamKeyFile = "STEAM_KEY" + } + if c.SteamKeyFile != "" { + bytes, err := ioutil.ReadFile(c.SteamKeyFile) + if err != nil { + return c, errors.Wrap(err, "Failed to load steamKeyFile") + } + c.SteamKey = strings.TrimSpace(string(bytes)) + } if c.SteamKey != "" { c.Env.Backend["STEAM_KEY"] = c.SteamKey }