Add script-runner configuration capabilities

This commit is contained in:
Denis Arh
2019-08-23 13:49:36 +02:00
parent 4bbc85e1b4
commit bb7dc471d7
6 changed files with 50 additions and 23 deletions
+11 -5
View File
@@ -1,14 +1,20 @@
package options
import (
"time"
)
type (
StorageOpt struct {
Path string `env:"STORAGE_PATH"`
ScriptRunnerOpt struct {
Addr string `env:"SCRIPT_RUNNER_ADDR"`
MaxBackoffDelay time.Duration `env:"SCRIPT_RUNNER_MAX_BACKOFF_DELAY"`
}
)
func Storage(pfix string) (o *StorageOpt) {
o = &StorageOpt{
Path: "var/store",
func ScriptRunner(pfix string) (o *ScriptRunnerOpt) {
o = &ScriptRunnerOpt{
Addr: "corredor:80",
MaxBackoffDelay: time.Minute,
}
fill(o, pfix)
+2
View File
@@ -50,6 +50,7 @@ type (
ProvisionOpt *options.ProvisionOpt
SentryOpt *options.SentryOpt
StorageOpt *options.StorageOpt
ScriptRunner *options.ScriptRunnerOpt
// DB Connection name, defaults to ServiceName
DatabaseName string
@@ -188,6 +189,7 @@ func (c *Config) Init() {
c.ProvisionOpt = options.Provision(c.ServiceName)
c.SentryOpt = options.Sentry(c.EnvPrefix)
c.StorageOpt = options.Storage(c.EnvPrefix)
c.ScriptRunner = options.ScriptRunner(c.EnvPrefix)
if c.RootCommandDBSetup == nil {
c.RootCommandDBSetup = Runners{func(ctx context.Context, cmd *cobra.Command, c *Config) (err error) {