66 "fmt"
77
88 toolhiveRegistry "github.com/stacklok/toolhive/pkg/registry"
9+
910 "github.com/stacklok/toolhive-registry/pkg/types"
1011)
1112
@@ -40,7 +41,7 @@ func (v *SchemaValidator) ValidateEntry(entry *types.RegistryEntry, name string)
4041}
4142
4243// ValidateRegistry validates a complete registry using the toolhive schema
43- func (v * SchemaValidator ) ValidateRegistry (registry * toolhiveRegistry.Registry ) error {
44+ func (* SchemaValidator ) ValidateRegistry (registry * toolhiveRegistry.Registry ) error {
4445 // Serialize to JSON for schema validation
4546 registryJSON , err := json .Marshal (registry )
4647 if err != nil {
@@ -56,11 +57,11 @@ func (v *SchemaValidator) ValidateRegistry(registry *toolhiveRegistry.Registry)
5657}
5758
5859// convertToToolhiveRegistry converts our RegistryEntry to a minimal toolhive Registry for validation
59- func (v * SchemaValidator ) convertToToolhiveRegistry (entry * types.RegistryEntry , name string ) (* toolhiveRegistry.Registry , error ) {
60+ func (* SchemaValidator ) convertToToolhiveRegistry (entry * types.RegistryEntry , name string ) (* toolhiveRegistry.Registry , error ) {
6061 registry := & toolhiveRegistry.Registry {
61- Version : "1.0.0" ,
62- LastUpdated : "2024-01-01T00:00:00Z" , // Placeholder for validation
63- Servers : make (map [string ]* toolhiveRegistry.ImageMetadata ),
62+ Version : "1.0.0" ,
63+ LastUpdated : "2024-01-01T00:00:00Z" , // Placeholder for validation
64+ Servers : make (map [string ]* toolhiveRegistry.ImageMetadata ),
6465 RemoteServers : make (map [string ]* toolhiveRegistry.RemoteServerMetadata ),
6566 }
6667
@@ -84,7 +85,7 @@ func (v *SchemaValidator) convertToToolhiveRegistry(entry *types.RegistryEntry,
8485}
8586
8687// ValidateEntryFields performs additional field-level validation beyond schema validation
87- func (v * SchemaValidator ) ValidateEntryFields (entry * types.RegistryEntry , name string ) error {
88+ func (* SchemaValidator ) ValidateEntryFields (entry * types.RegistryEntry , name string ) error {
8889 // Basic type validation
8990 if entry .ImageMetadata == nil && entry .RemoteServerMetadata == nil {
9091 return fmt .Errorf ("entry '%s' must be either an image or remote server" , name )
@@ -106,7 +107,7 @@ func (v *SchemaValidator) ValidateEntryFields(entry *types.RegistryEntry, name s
106107 if entry .URL == "" {
107108 return fmt .Errorf ("entry '%s': url field is required for remote servers" , name )
108109 }
109-
110+
110111 // Remote servers cannot use stdio transport
111112 if entry .GetTransport () == "stdio" {
112113 return fmt .Errorf ("entry '%s': remote servers cannot use stdio transport (use sse or streamable-http)" , name )
@@ -137,9 +138,5 @@ func (v *SchemaValidator) ValidateComplete(entry *types.RegistryEntry, name stri
137138 }
138139
139140 // Then perform schema validation
140- if err := v .ValidateEntry (entry , name ); err != nil {
141- return err
142- }
143-
144- return nil
145- }
141+ return v .ValidateEntry (entry , name )
142+ }
0 commit comments