Skip to content

Commit

Permalink
filter extensions.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Mar 29, 2024
1 parent d919c5a commit fd82115
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions addon/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (h *Task) Application() (r *api.Application, err error) {
}

// Addon returns the addon associated with the task.
// The extensions are filtered to include those specified in the task.
// inject: perform injection.
func (h *Task) Addon(inject bool) (r *api.Addon, err error) {
name := h.task.Addon
Expand All @@ -54,13 +55,28 @@ func (h *Task) Addon(inject bool) (r *api.Addon, err error) {
if err != nil {
return
}
if !inject {
return
// filter
included := map[string]int{}
for _, name := range h.task.Extensions {
included[name] = 0
}
var extensions []api.Extension
for i := range r.Extensions {
extension := &r.Extensions[i]
injector := EnvInjector{}
injector.Inject(extension)
extension := r.Extensions[i]
if _, found := included[extension.Name]; found {
extensions = append(
extensions,
extension)
}
}
r.Extensions = extensions
// inject
if inject {
for i := range r.Extensions {
extension := &r.Extensions[i]
injector := EnvInjector{}
injector.Inject(extension)
}
}
return
}
Expand Down

0 comments on commit fd82115

Please sign in to comment.