feat(provider): expose proxy metadata in registry info

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-01 07:08:19 +00:00
parent 1c9e4891e7
commit 71eebc53aa
2 changed files with 28 additions and 1 deletions

View file

@ -120,6 +120,8 @@ type ProviderInfo struct {
BasePath string `json:"basePath"`
Channels []string `json:"channels,omitempty"`
Element *ElementSpec `json:"element,omitempty"`
SpecFile string `json:"specFile,omitempty"`
Upstream string `json:"upstream,omitempty"`
}
// Info returns a summary of all registered providers.
@ -140,6 +142,12 @@ func (r *Registry) Info() []ProviderInfo {
elem := rv.Element()
info.Element = &elem
}
if sf, ok := p.(interface{ SpecFile() string }); ok {
info.SpecFile = sf.SpecFile()
}
if up, ok := p.(interface{ Upstream() string }); ok {
info.Upstream = up.Upstream()
}
infos = append(infos, info)
}
return infos

View file

@ -114,7 +114,7 @@ func TestRegistry_Streamable_Good(t *testing.T) {
func TestRegistry_Describable_Good(t *testing.T) {
reg := provider.NewRegistry()
reg.Add(&stubProvider{}) // not describable
reg.Add(&stubProvider{}) // not describable
reg.Add(&describableProvider{}) // describable
d := reg.Describable()
@ -147,6 +147,25 @@ func TestRegistry_Info_Good(t *testing.T) {
assert.Equal(t, "core-full-panel", info.Element.Tag)
}
func TestRegistry_Info_Good_ProxyMetadata(t *testing.T) {
reg := provider.NewRegistry()
reg.Add(provider.NewProxy(provider.ProxyConfig{
Name: "proxy",
BasePath: "/api/proxy",
Upstream: "http://127.0.0.1:9999",
SpecFile: "/tmp/proxy-openapi.json",
}))
infos := reg.Info()
require.Len(t, infos, 1)
info := infos[0]
assert.Equal(t, "proxy", info.Name)
assert.Equal(t, "/api/proxy", info.BasePath)
assert.Equal(t, "/tmp/proxy-openapi.json", info.SpecFile)
assert.Equal(t, "http://127.0.0.1:9999", info.Upstream)
}
func TestRegistry_Iter_Good(t *testing.T) {
reg := provider.NewRegistry()
reg.Add(&stubProvider{})