Skip to content

Commit

Permalink
bt: Add retries to stack component config
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGamba committed Oct 2, 2024
1 parent 12c9852 commit 85fdd31
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions bt/stack/config/schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package bt_stacks
depends_on: [...#Component.id]
variables: [...#Variable]
workspaces: [...string]
retries: int | *0
}

#Stack: {
Expand Down
3 changes: 2 additions & 1 deletion bt/stack/config/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Component struct {
DependsOn []string `json:"depends_on"`
Variables []Variable `json:"variables"`
Workspaces []string `json:"workspaces"`
Retries int `json:"retries"`
}

type ID string
Expand All @@ -30,7 +31,7 @@ type Stack struct {
}

func (c Component) String() string {
return fmt.Sprintf("id: %s, path: %s, depends_on: %v, variables: %v, workspaces: %v", c.ID, c.Path, c.DependsOn, c.Variables, c.Workspaces)
return fmt.Sprintf("id: %s, path: %s, depends_on: %v, variables: %v, workspaces: %v, retries: %d", c.ID, c.Path, c.DependsOn, c.Variables, c.Workspaces, c.Retries)
}

func (s Stack) String() string {
Expand Down
6 changes: 6 additions & 0 deletions bt/stack/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,18 @@ func generateDAG(opt *getoptions.GetOpt, id string, cfg *sconfig.Config, normal
} else {
g.TaskDependsOn(tm.Get(wID), tm.Get(cID))
}
if c.Retries > 0 {
g.TaskRetries(tm.Get(wID), c.Retries)
}
}
} else {
// normal mode
tm.Add(cID, wsFn(cID, c.Path, "", variables))
Logger.Printf("adding task %s on %s vars: %v\n", cID, c.Path, variables)
g.AddTask(tm.Get(cID))
if c.Retries > 0 {
g.TaskRetries(tm.Get(cID), c.Retries)
}
}
}

Expand Down

0 comments on commit 85fdd31

Please sign in to comment.