forked from siderolabs/kres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroup.go
More file actions
39 lines (30 loc) · 1.18 KB
/
Copy pathgroup.go
File metadata and controls
39 lines (30 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package lefthook
// Group is a container for nested Jobs with its own parallel/piped semantics.
// Used to express "run these in parallel, then those sequentially" without
// touching the hook-level execution model.
type Group struct { //nolint:govet
// Parallel is a pointer so an explicit `parallel: false` can be emitted
// (the bool zero value would otherwise be suppressed by omitempty).
Parallel *bool `yaml:"parallel,omitempty"`
Piped bool `yaml:"piped,omitempty"`
Jobs []*Job `yaml:"jobs,omitempty"`
}
// WithParallel toggles parallel execution of this group's jobs.
func (g *Group) WithParallel(parallel bool) *Group {
g.Parallel = ¶llel
return g
}
// WithPiped enables piped (sequential, fail-fast, stdout-chained) execution.
func (g *Group) WithPiped(piped bool) *Group {
g.Piped = piped
return g
}
// Job appends a new job to the group and returns it for further configuration.
func (g *Group) Job() *Job {
j := &Job{}
g.Jobs = append(g.Jobs, j)
return j
}