Skip to content

Commit

Permalink
feat: adds conditional enabled to fluent API
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszmajsak committed Nov 7, 2023
1 parent e3ce5e5 commit a5e534d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/feature/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ func (fb *featureBuilder) WithResources(resources ...Action) *featureBuilder {
return fb
}

func (fb *featureBuilder) EnabledWhen(enabled func(f *Feature) bool) *featureBuilder {
fb.builders = append(fb.builders, func(f *Feature) error {
f.Enabled = enabled(f)

return nil
})
return fb
}

func (fb *featureBuilder) Load() (*Feature, error) {
feature := &Feature{
Name: fb.name,
Expand Down

0 comments on commit a5e534d

Please sign in to comment.