github.com/Benchkram/bob@v0.0.0-20220321080157-7c8f3876e225/bob/builder.go (about) 1 package bob 2 3 import ( 4 "context" 5 6 "github.com/Benchkram/bob/bob/bobfile" 7 "github.com/Benchkram/bob/pkg/ctl" 8 ) 9 10 var _ ctl.Builder = (*builder)(nil) 11 12 type BuildFunc func(_ context.Context, runname string, aggregate *bobfile.Bobfile) error 13 14 // builder holds all dependencys to build a build task 15 type builder struct { 16 task string 17 aggregate *bobfile.Bobfile 18 f BuildFunc 19 } 20 21 func NewBuilder(b *B, task string, aggregate *bobfile.Bobfile, f BuildFunc) ctl.Builder { 22 builder := &builder{ 23 task: task, 24 aggregate: aggregate, 25 f: f, 26 } 27 return builder 28 } 29 30 func (b *builder) Build(ctx context.Context) error { 31 return b.f(ctx, b.task, b.aggregate) 32 }