Skip to content

Commit

Permalink
Merge pull request #20 from screepers:ags131/issue13
Browse files Browse the repository at this point in the history
[feature] Support docker / docker-compose secrets for steamKey
  • Loading branch information
AlinaNova21 authored Dec 30, 2020
2 parents a276bee + fd4f88c commit 460fc61
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions launcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import (
"io/ioutil"
"log"
"math"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"

"github.com/pkg/errors"
"gopkg.in/yaml.v2"
)

Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 460fc61

Please sign in to comment.