provision: Dynamically find components to provision

This commit is contained in:
Tom Wiesing 2022-09-20 19:45:32 +02:00
parent 33cd18e9d9
commit a5d9b1a386
No known key found for this signature in database
5 changed files with 46 additions and 22 deletions

View file

@ -67,7 +67,7 @@ func makeComponent[C component.Component](dis *Distillery, field *lazy.Lazy[C],
})
}
func (dis *Distillery) ComponentsX() []component.Component {
func (dis *Distillery) Components() []component.Component {
return []component.Component{
dis.Web(),
dis.Control(),
@ -93,8 +93,13 @@ func (dis *Distillery) Updateable() []component.Updatable {
return getComponents[component.Updatable](dis)
}
// Provisionable returns all components which can be provisioned
func (dis *Distillery) Provisionable() []component.Provisionable {
return getComponents[component.Provisionable](dis)
}
func getComponents[C component.Component](dis *Distillery) (result []C) {
all := dis.ComponentsX()
all := dis.Components()
result = make([]C, 0, len(all))
for _, c := range all {