Skip to content

Commit efa743a

Browse files
authored
fix(go/internal): discover actions and plugins in parent registry (#3631)
1 parent 8952eda commit efa743a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

go/internal/registry/registry.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,54 @@ func (r *Registry) ListActions() []api.Action {
207207
r.mu.RLock()
208208
defer r.mu.RUnlock()
209209
var actions []api.Action
210+
211+
// recursively check all the registry parents
212+
if r.parent != nil {
213+
parentValues := r.parent.ListActions()
214+
for _, pv := range parentValues {
215+
found := false
216+
for _, cv := range r.actions {
217+
if pv.Name() == cv.Name() {
218+
found = true
219+
break
220+
}
221+
}
222+
if !found {
223+
actions = append(actions, pv)
224+
}
225+
}
226+
}
210227
for _, v := range r.actions {
211228
actions = append(actions, v)
212229
}
213230
return actions
214231
}
215232

216233
// ListPlugins returns a list of all registered plugins.
234+
// This includes plugins from both the current registry and its parent hierarchy.
235+
// Child registry plugins take precedence over parent plugins with the same key.
217236
func (r *Registry) ListPlugins() []api.Plugin {
218237
r.mu.RLock()
219238
defer r.mu.RUnlock()
220239
var plugins []api.Plugin
240+
241+
// recursively check all the registry parents
242+
if r.parent != nil {
243+
parentValues := r.parent.ListPlugins()
244+
for _, pv := range parentValues {
245+
found := false
246+
for _, cv := range r.plugins {
247+
if pv.Name() == cv.Name() {
248+
found = true
249+
break
250+
}
251+
}
252+
if !found {
253+
plugins = append(plugins, pv)
254+
}
255+
}
256+
}
257+
221258
for _, p := range r.plugins {
222259
plugins = append(plugins, p)
223260
}

0 commit comments

Comments
 (0)