Skip to content

Commit

Permalink
feat!: Move tags from task to play
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejsika committed Mar 28, 2023
1 parent a5e5e71 commit 4430c67
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions pkg/play/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "github.com/sikalabs/gobble/pkg/task"
type Play struct {
Name string `yaml:"name"`
Sudo bool `yaml:"sudo"`
Tags []string `yaml:"tags"`
Hosts []string `yaml:"hosts"`
Tasks []task.Task `yaml:"tasks"`
}
24 changes: 12 additions & 12 deletions pkg/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ func Run(
}

for _, play := range c.Plays {
if len(onlyTags) > 0 {
skip := true
for _, tag := range onlyTags {
if slices.Contains(play.Tags, tag) {
skip = false
}
}
if skip {
continue
}
}

for _, t := range play.Tasks {
for globalHostName, globalHost := range c.Hosts {
for _, host := range globalHost {
if !slices.Contains(play.Hosts, globalHostName) {
continue
}

if len(onlyTags) > 0 {
skip := true
for _, tag := range onlyTags {
if slices.Contains(t.Tags, tag) {
skip = false
}
}
if skip {
continue
}
}

fmt.Println(`+ play:`, play.Name)
fmt.Println(` host:`, host.SSHTarget)
fmt.Println(` sudo:`, play.Sudo)
Expand Down
1 change: 0 additions & 1 deletion pkg/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

type Task struct {
Name string `yaml:"name"`
Tags []string `yaml:"tags"`
AptInstall apt_install.TaskAptInstall `yaml:"apt_install"`
Cp cp.TaskCp `yaml:"cp"`
Template template.TaskTemplate `yaml:"template"`
Expand Down

0 comments on commit 4430c67

Please # to comment.