From ebe34ba1fa1d6cbfdeabb5e5cbac75ced1ddabfd Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Tue, 16 Apr 2019 15:20:45 +0200 Subject: [PATCH] runservice: set default config task working_dir Set default task working_dir to ~/project --- internal/config/config.go | 9 ++++++++- internal/config/config_test.go | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 241c9e1..9742aea 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -33,6 +33,8 @@ const ( maxRunNameLength = 100 maxTaskNameLength = 100 maxStepNameLength = 100 + + defaultWorkingDir = "~/project" ) type ConfigFormat int @@ -760,7 +762,12 @@ func checkConfig(config *Config) error { // Set defaults for _, run := range config.Runs { for _, task := range run.Tasks { - // Set auth type to default if not specified + // set task default working dir + if task.WorkingDir == "" { + task.WorkingDir = defaultWorkingDir + } + + // set auth type to default if not specified runtime := task.Runtime if runtime.Auth != nil { if runtime.Auth.Type == "" { diff --git a/internal/config/config_test.go b/internal/config/config_test.go index d58e25f..968b8be 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -266,7 +266,7 @@ func TestParseOutput(t *testing.T) { "ENV01": Value{Type: ValueTypeString, Value: "ENV01"}, "ENVFROMVARIABLE01": Value{Type: ValueTypeFromVariable, Value: "variable01"}, }, - WorkingDir: "", + WorkingDir: defaultWorkingDir, Shell: "", User: "", Steps: []interface{}{ @@ -374,7 +374,7 @@ func TestParseOutput(t *testing.T) { }, }, }, - WorkingDir: "", + WorkingDir: defaultWorkingDir, Steps: []interface{}{}, Depends: []*Depend{}, }, @@ -389,7 +389,7 @@ func TestParseOutput(t *testing.T) { }, }, }, - WorkingDir: "", + WorkingDir: defaultWorkingDir, Steps: []interface{}{}, Depends: []*Depend{}, }, @@ -404,7 +404,7 @@ func TestParseOutput(t *testing.T) { }, }, }, - WorkingDir: "", + WorkingDir: defaultWorkingDir, Steps: []interface{}{}, Depends: []*Depend{}, },