Skip to content

Commit

Permalink
Change syntax for task to be used as step of another task
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushjn20 committed May 19, 2019
1 parent 966c4f4 commit 0855885
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .dunner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build:
- PERM=775
- ID=dunner
- DIR=`$HOME`
- name: '@show'
- follow: 'show'
args:
- '/root'
show:
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Task struct {
Commands [][]string `yaml:"commands"`
Envs []string `yaml:"envs"`
Mounts []string `yaml:"mounts"`
Follow string `yaml:"follow"`
Args []string `yaml:"args"`
}

Expand Down
1 change: 1 addition & 0 deletions pkg/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Step struct {
WorkDir string
Volumes map[string]string
ExtMounts []mount.Mount
Follow string
Args []string
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/dunner/dunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func execTask(configs *config.Configs, taskName string, args []string) {
Commands: stepDefinition.Commands,
Env: stepDefinition.Envs,
WorkDir: stepDefinition.SubDir,
Follow: stepDefinition.Follow,
Args: stepDefinition.Args,
}

Expand All @@ -73,16 +74,15 @@ func process(configs *config.Configs, s *docker.Step, wg *sync.WaitGroup, args [
defer wg.Done()
}

if newTask := regexp.MustCompile(`^@\w+$`).FindString(s.Name); newTask != "" {
newTask = strings.Trim(newTask, "@")
if s.Follow != "" {
if async {
wg.Add(1)
go func(wg *sync.WaitGroup) {
execTask(configs, newTask, s.Args)
execTask(configs, s.Follow, s.Args)
wg.Done()
}(wg)
} else {
execTask(configs, newTask, s.Args)
execTask(configs, s.Follow, s.Args)
}
return
}
Expand Down

0 comments on commit 0855885

Please sign in to comment.