Skip to content

Commit

Permalink
Merge pull request #236 from yohamta/develop
Browse files Browse the repository at this point in the history
Allow DAGs to be loaded without specifying an extension `.yaml`
  • Loading branch information
yottahmd authored Aug 4, 2022
2 parents af8c73f + 46fb89d commit 7cac193
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func Test_startCommand(t *testing.T) {
args: []string{"", "start", "--params=x y", testConfig("cmd_start_with_params_2.yaml")}, errored: false,
output: []string{"params are x and y"},
},
{
args: []string{"", "start", testConfig("cmd_start_success")}, errored: false,
output: []string{"1 finished"},
},
}

for _, v := range tests {
Expand Down
3 changes: 3 additions & 0 deletions examples/calling_subdag_main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
steps:
- name: step1
command: dagu start calling_subdag_sub
3 changes: 3 additions & 0 deletions examples/calling_subdag_sub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
steps:
- name: step1
command: echo hello
3 changes: 3 additions & 0 deletions internal/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ func (cl *Loader) loadConfig(f string, opts *BuildConfigOptions) (*Config, error
if f == "" {
return nil, fmt.Errorf("config file was not specified")
}
if !strings.HasSuffix(f, ".yaml") && !strings.HasSuffix(f, ".yml") {
f = fmt.Sprintf("%s.yaml", f)
}
file, err := filepath.Abs(f)
if err != nil {
return nil, err
Expand Down
5 changes: 5 additions & 0 deletions internal/config/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func TestLoadConfig(t *testing.T) {
}
_, err := l.Load(testConfig, "")
require.NoError(t, err)

// without .yaml
s := path.Join(testDir, "config_load")
_, err = l.Load(s, "")
require.NoError(t, err)
}

func TestLoadGlobalConfig(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions tests/testdata/cmd_start_success.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
steps:
- name: "1"
command: "true"

0 comments on commit 7cac193

Please sign in to comment.