Skip to content

Commit 62edc50

Browse files
authored
Introduced UpstreamRegistry and converter functions. (#104)
* introduced ServerRegistry type and converter functions. Signed-off-by: Daniele Martinoli <dmartino@redhat.com> * rebased :( * Using toolhive UpstreamRegistry * renamed test file Signed-off-by: Daniele Martinoli <dmartino@redhat.com> --------- Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
1 parent 347993f commit 62edc50

28 files changed

+681
-389
lines changed

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/onsi/ginkgo/v2 v2.27.2
1414
github.com/onsi/gomega v1.38.2
1515
github.com/spf13/viper v1.21.0
16-
github.com/stacklok/toolhive v0.6.2
16+
github.com/stacklok/toolhive v0.6.6-0.20251117142941-d06cdcbf7cc4
1717
github.com/stretchr/testify v1.11.1
1818
github.com/swaggo/swag/v2 v2.0.0-rc4
1919
github.com/testcontainers/testcontainers-go v0.40.0
@@ -137,19 +137,19 @@ require (
137137
go.uber.org/zap v1.27.0 // indirect
138138
go.yaml.in/yaml/v2 v2.4.2 // indirect
139139
go.yaml.in/yaml/v3 v3.0.4 // indirect
140-
golang.org/x/crypto v0.43.0 // indirect
140+
golang.org/x/crypto v0.44.0 // indirect
141141
golang.org/x/mod v0.30.0 // indirect
142-
golang.org/x/net v0.46.0 // indirect
142+
golang.org/x/net v0.47.0 // indirect
143143
golang.org/x/oauth2 v0.33.0 // indirect
144144
golang.org/x/sync v0.18.0 // indirect
145-
golang.org/x/term v0.36.0 // indirect
146-
golang.org/x/text v0.30.0 // indirect
145+
golang.org/x/term v0.37.0 // indirect
146+
golang.org/x/text v0.31.0 // indirect
147147
golang.org/x/tools v0.38.0 // indirect
148148
google.golang.org/protobuf v1.36.10 // indirect
149149
gopkg.in/inf.v0 v0.9.1 // indirect
150150
gopkg.in/warnings.v0 v0.1.2 // indirect
151151
gopkg.in/yaml.v2 v2.4.0 // indirect
152-
k8s.io/apimachinery v0.34.1 // indirect
152+
k8s.io/apimachinery v0.34.2 // indirect
153153
k8s.io/klog/v2 v2.130.1 // indirect
154154
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect
155155
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect

go.sum

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
287287
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
288288
github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU=
289289
github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY=
290-
github.com/stacklok/toolhive v0.6.2 h1:r47V8z2rv4lTAOOaSMsDVLqHPCuX7jAK5/l9wsY80rs=
291-
github.com/stacklok/toolhive v0.6.2/go.mod h1:TfYC6y/NMiC04GuMe5GdSMp59u7sUZ4ElFz4uSleg3M=
290+
github.com/stacklok/toolhive v0.6.6-0.20251117142941-d06cdcbf7cc4 h1:GYLtT1j/P6B22/TMXSWlrjFB13u4tvirQRG3MGIRCMk=
291+
github.com/stacklok/toolhive v0.6.6-0.20251117142941-d06cdcbf7cc4/go.mod h1:YbBeAB02mDMJkTiQICQTQi7iOC6pqhFivp1IoXWHjn4=
292292
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
293293
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
294294
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
@@ -370,8 +370,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
370370
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
371371
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
372372
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
373-
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
374-
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
373+
golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU=
374+
golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc=
375375
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
376376
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
377377
golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk=
@@ -381,8 +381,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
381381
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
382382
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
383383
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
384-
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
385-
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
384+
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
385+
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
386386
golang.org/x/oauth2 v0.33.0 h1:4Q+qn+E5z8gPRJfmRy7C2gGG3T4jIprK6aSYgTXGRpo=
387387
golang.org/x/oauth2 v0.33.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
388388
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -407,13 +407,13 @@ golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
407407
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
408408
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
409409
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
410-
golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q=
411-
golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss=
410+
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
411+
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
412412
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
413413
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
414414
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
415-
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
416-
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
415+
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
416+
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
417417
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
418418
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
419419
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -451,10 +451,10 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
451451
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
452452
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
453453
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
454-
k8s.io/api v0.34.1 h1:jC+153630BMdlFukegoEL8E/yT7aLyQkIVuwhmwDgJM=
455-
k8s.io/api v0.34.1/go.mod h1:SB80FxFtXn5/gwzCoN6QCtPD7Vbu5w2n1S0J5gFfTYk=
456-
k8s.io/apimachinery v0.34.1 h1:dTlxFls/eikpJxmAC7MVE8oOeP1zryV7iRyIjB0gky4=
457-
k8s.io/apimachinery v0.34.1/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
454+
k8s.io/api v0.34.2 h1:fsSUNZhV+bnL6Aqrp6O7lMTy6o5x2C4XLjnh//8SLYY=
455+
k8s.io/api v0.34.2/go.mod h1:MMBPaWlED2a8w4RSeanD76f7opUoypY8TFYkSM+3XHw=
456+
k8s.io/apimachinery v0.34.2 h1:zQ12Uk3eMHPxrsbUJgNF8bTauTVR2WgqJsTmwTE/NW4=
457+
k8s.io/apimachinery v0.34.2/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
458458
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
459459
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
460460
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzkbzn+gDM4X9T4Ck=

internal/api/v0/routes.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
"github.com/go-chi/chi/v5"
1111
"github.com/stacklok/toolhive/pkg/logger"
12-
"github.com/stacklok/toolhive/pkg/registry"
12+
toolhivetypes "github.com/stacklok/toolhive/pkg/registry/types"
1313
"github.com/stacklok/toolhive/pkg/versions"
1414
"gopkg.in/yaml.v3"
1515

@@ -335,7 +335,7 @@ func (rr *Routes) listDeployedServers(w http.ResponseWriter, r *http.Request) {
335335
}
336336

337337
// newServerSummaryResponse creates a ServerSummaryResponse from server metadata
338-
func newServerSummaryResponse(server registry.ServerMetadata) ServerSummaryResponse {
338+
func newServerSummaryResponse(server toolhivetypes.ServerMetadata) ServerSummaryResponse {
339339
return ServerSummaryResponse{
340340
Name: server.GetName(),
341341
Description: server.GetDescription(),
@@ -347,7 +347,7 @@ func newServerSummaryResponse(server registry.ServerMetadata) ServerSummaryRespo
347347
}
348348

349349
// newServerDetailResponse creates a ServerDetailResponse from server metadata with all available fields
350-
func newServerDetailResponse(server registry.ServerMetadata) ServerDetailResponse {
350+
func newServerDetailResponse(server toolhivetypes.ServerMetadata) ServerDetailResponse {
351351
response := ServerDetailResponse{
352352
Name: server.GetName(),
353353
Description: server.GetDescription(),
@@ -367,7 +367,7 @@ func newServerDetailResponse(server registry.ServerMetadata) ServerDetailRespons
367367
}
368368

369369
// populateEnvVars converts and populates environment variables in the response
370-
func populateEnvVars(response *ServerDetailResponse, server registry.ServerMetadata) {
370+
func populateEnvVars(response *ServerDetailResponse, server toolhivetypes.ServerMetadata) {
371371
envVars := server.GetEnvVars()
372372
if envVars == nil {
373373
return
@@ -388,7 +388,7 @@ func populateEnvVars(response *ServerDetailResponse, server registry.ServerMetad
388388
}
389389

390390
// populateMetadata converts and populates metadata in the response
391-
func populateMetadata(response *ServerDetailResponse, server registry.ServerMetadata) {
391+
func populateMetadata(response *ServerDetailResponse, server toolhivetypes.ServerMetadata) {
392392
// Convert metadata from *Metadata to map[string]interface{}
393393
if metadata := server.GetMetadata(); metadata != nil {
394394
response.Metadata = map[string]interface{}{
@@ -410,7 +410,7 @@ func populateMetadata(response *ServerDetailResponse, server registry.ServerMeta
410410
}
411411

412412
// populateServerTypeSpecificFields populates fields specific to container or remote servers
413-
func populateServerTypeSpecificFields(response *ServerDetailResponse, server registry.ServerMetadata) {
413+
func populateServerTypeSpecificFields(response *ServerDetailResponse, server toolhivetypes.ServerMetadata) {
414414
if !server.IsRemote() {
415415
populateContainerServerFields(response, server)
416416
} else {
@@ -419,12 +419,12 @@ func populateServerTypeSpecificFields(response *ServerDetailResponse, server reg
419419
}
420420

421421
// populateContainerServerFields populates fields specific to container servers (ImageMetadata)
422-
func populateContainerServerFields(response *ServerDetailResponse, server registry.ServerMetadata) {
422+
func populateContainerServerFields(response *ServerDetailResponse, server toolhivetypes.ServerMetadata) {
423423
// The server might be wrapped in a serverWithName struct from the service layer
424424
actualServer := extractEmbeddedServerMetadata(server)
425425

426426
// Type assert to access ImageMetadata-specific fields
427-
imgMetadata, ok := actualServer.(*registry.ImageMetadata)
427+
imgMetadata, ok := actualServer.(*toolhivetypes.ImageMetadata)
428428
if !ok {
429429
return
430430
}
@@ -453,11 +453,11 @@ func populateContainerServerFields(response *ServerDetailResponse, server regist
453453
}
454454

455455
// populateRemoteServerFields populates fields specific to remote servers
456-
func populateRemoteServerFields(response *ServerDetailResponse, server registry.ServerMetadata) {
456+
func populateRemoteServerFields(response *ServerDetailResponse, server toolhivetypes.ServerMetadata) {
457457
// The server might be wrapped in a serverWithName struct from the service layer
458458
actualServer := extractEmbeddedServerMetadata(server)
459459

460-
remoteMetadata, ok := actualServer.(*registry.RemoteServerMetadata)
460+
remoteMetadata, ok := actualServer.(*toolhivetypes.RemoteServerMetadata)
461461
if !ok {
462462
return
463463
}
@@ -474,7 +474,7 @@ func populateRemoteServerFields(response *ServerDetailResponse, server registry.
474474
}
475475

476476
// extractEmbeddedServerMetadata extracts the embedded ServerMetadata from serverWithName wrapper
477-
func extractEmbeddedServerMetadata(server registry.ServerMetadata) registry.ServerMetadata {
477+
func extractEmbeddedServerMetadata(server toolhivetypes.ServerMetadata) toolhivetypes.ServerMetadata {
478478
// Use reflection to check if this is a struct with an embedded ServerMetadata field
479479
v := reflect.ValueOf(server)
480480
if v.Kind() == reflect.Ptr {
@@ -489,7 +489,7 @@ func extractEmbeddedServerMetadata(server registry.ServerMetadata) registry.Serv
489489

490490
// Check if it's an embedded field (Anonymous) that implements ServerMetadata
491491
if fieldType.Anonymous && field.CanInterface() {
492-
if serverMetadata, ok := field.Interface().(registry.ServerMetadata); ok {
492+
if serverMetadata, ok := field.Interface().(toolhivetypes.ServerMetadata); ok {
493493
return serverMetadata
494494
}
495495
}
@@ -671,12 +671,12 @@ func serveOpenAPIYAML(w http.ResponseWriter, _ *http.Request) {
671671

672672
// NewServerSummaryResponseForTesting creates a ServerSummaryResponse for testing
673673
// Deprecated: Use API v0.1 instead
674-
func NewServerSummaryResponseForTesting(server registry.ServerMetadata) ServerSummaryResponse {
674+
func NewServerSummaryResponseForTesting(server toolhivetypes.ServerMetadata) ServerSummaryResponse {
675675
return newServerSummaryResponse(server)
676676
}
677677

678678
// NewServerDetailResponseForTesting creates a ServerDetailResponse for testing
679679
// Deprecated: Use API v0.1 instead
680-
func NewServerDetailResponseForTesting(server registry.ServerMetadata) ServerDetailResponse {
680+
func NewServerDetailResponseForTesting(server toolhivetypes.ServerMetadata) ServerDetailResponse {
681681
return newServerDetailResponse(server)
682682
}

internal/api/v0/routes_test.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"testing"
99
"time"
1010

11-
"github.com/stacklok/toolhive/pkg/registry"
11+
toolhivetypes "github.com/stacklok/toolhive/pkg/registry/types"
1212
"github.com/stretchr/testify/assert"
1313
"github.com/stretchr/testify/require"
1414
"go.uber.org/mock/gomock"
@@ -233,12 +233,12 @@ const testRegistryJSON = `{
233233

234234
// realisticRegistryProvider implements RegistryDataProvider for testing with our realistic test data
235235
type realisticRegistryProvider struct {
236-
data *registry.Registry
236+
data *toolhivetypes.Registry
237237
}
238238

239239
// newRealisticRegistryProvider creates a provider with our representative test data
240240
func newRealisticRegistryProvider() (*realisticRegistryProvider, error) {
241-
var data registry.Registry
241+
var data toolhivetypes.Registry
242242
if err := json.Unmarshal([]byte(testRegistryJSON), &data); err != nil {
243243
return nil, err
244244
}
@@ -249,7 +249,7 @@ func newRealisticRegistryProvider() (*realisticRegistryProvider, error) {
249249
}
250250

251251
// GetRegistryData implements RegistryDataProvider.GetRegistryData
252-
func (p *realisticRegistryProvider) GetRegistryData(_ context.Context) (*registry.Registry, error) {
252+
func (p *realisticRegistryProvider) GetRegistryData(_ context.Context) (*toolhivetypes.Registry, error) {
253253
return p.data, nil
254254
}
255255

@@ -321,14 +321,14 @@ func TestRegistryRouter(t *testing.T) {
321321

322322
mockSvc := mocks.NewMockRegistryService(ctrl)
323323
// Set up expectations for all routes
324-
mockSvc.EXPECT().GetRegistry(gomock.Any()).Return(&registry.Registry{
324+
mockSvc.EXPECT().GetRegistry(gomock.Any()).Return(&toolhivetypes.Registry{
325325
Version: "1.0.0",
326326
LastUpdated: time.Now().Format(time.RFC3339),
327-
Servers: make(map[string]*registry.ImageMetadata),
327+
Servers: make(map[string]*toolhivetypes.ImageMetadata),
328328
}, "test", nil).AnyTimes()
329-
mockSvc.EXPECT().ListServers(gomock.Any()).Return([]registry.ServerMetadata{}, nil).AnyTimes()
330-
mockSvc.EXPECT().GetServer(gomock.Any(), "test-server").Return(&registry.ImageMetadata{
331-
BaseServerMetadata: registry.BaseServerMetadata{
329+
mockSvc.EXPECT().ListServers(gomock.Any()).Return([]toolhivetypes.ServerMetadata{}, nil).AnyTimes()
330+
mockSvc.EXPECT().GetServer(gomock.Any(), "test-server").Return(&toolhivetypes.ImageMetadata{
331+
BaseServerMetadata: toolhivetypes.BaseServerMetadata{
332332
Name: "test-server",
333333
},
334334
}, nil).AnyTimes()
@@ -402,7 +402,7 @@ func TestListServers_FormatParameter(t *testing.T) {
402402

403403
mockSvc := mocks.NewMockRegistryService(ctrl)
404404
// Expect successful calls for toolhive format only
405-
mockSvc.EXPECT().ListServers(gomock.Any()).Return([]registry.ServerMetadata{}, nil).Times(2) // default and explicit toolhive
405+
mockSvc.EXPECT().ListServers(gomock.Any()).Return([]toolhivetypes.ServerMetadata{}, nil).Times(2) // default and explicit toolhive
406406

407407
router := v0.Router(mockSvc)
408408

@@ -481,14 +481,14 @@ func TestNewServer(t *testing.T) {
481481

482482
// Set up expectations for all test routes
483483
mockSvc.EXPECT().CheckReadiness(gomock.Any()).Return(nil).AnyTimes()
484-
mockSvc.EXPECT().GetRegistry(gomock.Any()).Return(&registry.Registry{
484+
mockSvc.EXPECT().GetRegistry(gomock.Any()).Return(&toolhivetypes.Registry{
485485
Version: "1.0.0",
486486
LastUpdated: time.Now().Format(time.RFC3339),
487-
Servers: make(map[string]*registry.ImageMetadata),
487+
Servers: make(map[string]*toolhivetypes.ImageMetadata),
488488
}, "test", nil).AnyTimes()
489-
mockSvc.EXPECT().ListServers(gomock.Any()).Return([]registry.ServerMetadata{}, nil).AnyTimes()
490-
mockSvc.EXPECT().GetServer(gomock.Any(), "test").Return(&registry.ImageMetadata{
491-
BaseServerMetadata: registry.BaseServerMetadata{
489+
mockSvc.EXPECT().ListServers(gomock.Any()).Return([]toolhivetypes.ServerMetadata{}, nil).AnyTimes()
490+
mockSvc.EXPECT().GetServer(gomock.Any(), "test").Return(&toolhivetypes.ImageMetadata{
491+
BaseServerMetadata: toolhivetypes.BaseServerMetadata{
492492
Name: "test",
493493
},
494494
}, nil).AnyTimes()
@@ -588,12 +588,12 @@ func TestNewServer_WithMiddleware(t *testing.T) {
588588

589589
// fileBasedRegistryProvider implements RegistryDataProvider for testing with embedded registry data
590590
type fileBasedRegistryProvider struct {
591-
data *registry.Registry
591+
data *toolhivetypes.Registry
592592
}
593593

594594
// newFileBasedRegistryProvider creates a new provider with embedded registry data
595595
func newFileBasedRegistryProvider() (*fileBasedRegistryProvider, error) {
596-
var data registry.Registry
596+
var data toolhivetypes.Registry
597597
if err := json.Unmarshal([]byte(testRegistryJSON), &data); err != nil {
598598
return nil, err
599599
}
@@ -604,7 +604,7 @@ func newFileBasedRegistryProvider() (*fileBasedRegistryProvider, error) {
604604
}
605605

606606
// GetRegistryData implements RegistryDataProvider.GetRegistryData
607-
func (p *fileBasedRegistryProvider) GetRegistryData(_ context.Context) (*registry.Registry, error) {
607+
func (p *fileBasedRegistryProvider) GetRegistryData(_ context.Context) (*toolhivetypes.Registry, error) {
608608
return p.data, nil
609609
}
610610

@@ -619,11 +619,11 @@ func (*fileBasedRegistryProvider) GetRegistryName() string {
619619
}
620620

621621
// Helper functions for testing the response conversion functions
622-
func newServerSummaryResponseForTesting(server registry.ServerMetadata) v0.ServerSummaryResponse {
622+
func newServerSummaryResponseForTesting(server toolhivetypes.ServerMetadata) v0.ServerSummaryResponse {
623623
return v0.NewServerSummaryResponseForTesting(server)
624624
}
625625

626-
func newServerDetailResponseForTesting(server registry.ServerMetadata) v0.ServerDetailResponse {
626+
func newServerDetailResponseForTesting(server toolhivetypes.ServerMetadata) v0.ServerDetailResponse {
627627
return v0.NewServerDetailResponseForTesting(server)
628628
}
629629

@@ -1396,8 +1396,8 @@ func TestHelperFunctions(t *testing.T) {
13961396
t.Parallel()
13971397

13981398
// Test data setup
1399-
testImageMetadata := &registry.ImageMetadata{
1400-
BaseServerMetadata: registry.BaseServerMetadata{
1399+
testImageMetadata := &toolhivetypes.ImageMetadata{
1400+
BaseServerMetadata: toolhivetypes.BaseServerMetadata{
14011401
Name: "test-server",
14021402
Description: "Test server",
14031403
Tier: "Community",
@@ -1408,8 +1408,8 @@ func TestHelperFunctions(t *testing.T) {
14081408
Image: "test-image:latest",
14091409
}
14101410

1411-
testRemoteMetadata := &registry.RemoteServerMetadata{
1412-
BaseServerMetadata: registry.BaseServerMetadata{
1411+
testRemoteMetadata := &toolhivetypes.RemoteServerMetadata{
1412+
BaseServerMetadata: toolhivetypes.BaseServerMetadata{
14131413
Name: "remote-server",
14141414
Description: "Remote test server",
14151415
Tier: "Official",
@@ -1522,7 +1522,7 @@ func TestErrorScenarios(t *testing.T) {
15221522
t.Parallel()
15231523
// This test needs its own mock since it calls ListServers (chi routes /servers/ to list endpoint)
15241524
emptyNameMockSvc := mocks.NewMockRegistryService(ctrl)
1525-
emptyNameMockSvc.EXPECT().ListServers(gomock.Any()).Return([]registry.ServerMetadata{}, nil)
1525+
emptyNameMockSvc.EXPECT().ListServers(gomock.Any()).Return([]toolhivetypes.ServerMetadata{}, nil)
15261526

15271527
router := v0.Router(emptyNameMockSvc)
15281528

0 commit comments

Comments
 (0)