88 "encoding/json"
99 "fmt"
1010 "strings"
11- "time"
1211
1312 "github.com/onsi/ginkgo/v2"
1413 "github.com/onsi/gomega"
@@ -112,16 +111,6 @@ func (rb *RegistryBuilder) WithAPISource(endpoint string) *RegistryBuilder {
112111 return rb
113112}
114113
115- // WithRegistryName sets the name for the source config
116- func (rb * RegistryBuilder ) WithRegistryName (name string ) * RegistryBuilder {
117- rb .config .SourceName = name
118- // Recalculate file path if this is a file source
119- if rb .config .SourceType == sourceTypeFile {
120- rb .config .FilePath = fmt .Sprintf ("/config/registry/%s/registry.json" , name )
121- }
122- return rb
123- }
124-
125114// WithSyncPolicy configures the sync policy interval for the source
126115func (rb * RegistryBuilder ) WithSyncPolicy (interval string ) * RegistryBuilder {
127116 rb .config .SyncInterval = interval
@@ -146,30 +135,6 @@ func (rb *RegistryBuilder) WithLabel(key, value string) *RegistryBuilder {
146135 return rb
147136}
148137
149- // WithNameIncludeFilter sets name include patterns for filtering on the source
150- func (rb * RegistryBuilder ) WithNameIncludeFilter (patterns []string ) * RegistryBuilder {
151- rb .config .NameInclude = patterns
152- return rb
153- }
154-
155- // WithNameExcludeFilter sets name exclude patterns for filtering on the source
156- func (rb * RegistryBuilder ) WithNameExcludeFilter (patterns []string ) * RegistryBuilder {
157- rb .config .NameExclude = patterns
158- return rb
159- }
160-
161- // WithTagIncludeFilter sets tag include patterns for filtering on the source
162- func (rb * RegistryBuilder ) WithTagIncludeFilter (tags []string ) * RegistryBuilder {
163- rb .config .TagInclude = tags
164- return rb
165- }
166-
167- // WithTagExcludeFilter sets tag exclude patterns for filtering on the source
168- func (rb * RegistryBuilder ) WithTagExcludeFilter (tags []string ) * RegistryBuilder {
169- rb .config .TagExclude = tags
170- return rb
171- }
172-
173138// Build returns the constructed MCPRegistry with configYAML generated from the builder config.
174139func (rb * RegistryBuilder ) Build () * mcpv1beta1.MCPRegistry {
175140 configYAML := rb .buildConfigYAML ()
@@ -315,21 +280,6 @@ func writeStringList(b *strings.Builder, label string, items []string) {
315280 }
316281}
317282
318- // CreateBasicConfigMapRegistry creates a simple MCPRegistry with ConfigMap source
319- func (h * MCPRegistryTestHelper ) CreateBasicConfigMapRegistry (name , configMapName string ) * mcpv1beta1.MCPRegistry {
320- return h .NewRegistryBuilder (name ).
321- WithConfigMapSource (configMapName , "registry.json" ).
322- WithSyncPolicy ("1h" ).
323- Create (h )
324- }
325-
326- // CreateManualSyncRegistry creates an MCPRegistry with manual sync only
327- func (h * MCPRegistryTestHelper ) CreateManualSyncRegistry (name , configMapName string ) * mcpv1beta1.MCPRegistry {
328- return h .NewRegistryBuilder (name ).
329- WithConfigMapSource (configMapName , "registry.json" ).
330- Create (h )
331- }
332-
333283// GetRegistry retrieves an MCPRegistry by name
334284func (h * MCPRegistryTestHelper ) GetRegistry (name string ) (* mcpv1beta1.MCPRegistry , error ) {
335285 registry := & mcpv1beta1.MCPRegistry {}
@@ -345,14 +295,6 @@ func (h *MCPRegistryTestHelper) UpdateRegistry(registry *mcpv1beta1.MCPRegistry)
345295 return h .Client .Update (h .Context , registry )
346296}
347297
348- // PatchRegistry patches an MCPRegistry with the given patch
349- func (h * MCPRegistryTestHelper ) PatchRegistry (name string , patch client.Patch ) error {
350- registry := & mcpv1beta1.MCPRegistry {}
351- registry .Name = name
352- registry .Namespace = h .Namespace
353- return h .Client .Patch (h .Context , registry , patch )
354- }
355-
356298// DeleteRegistry deletes an MCPRegistry by name
357299func (h * MCPRegistryTestHelper ) DeleteRegistry (name string ) error {
358300 registry := & mcpv1beta1.MCPRegistry {
@@ -364,54 +306,6 @@ func (h *MCPRegistryTestHelper) DeleteRegistry(name string) error {
364306 return h .Client .Delete (h .Context , registry )
365307}
366308
367- // TriggerManualSync adds the manual sync annotation to trigger a sync
368- func (h * MCPRegistryTestHelper ) TriggerManualSync (name string ) error {
369- registry , err := h .GetRegistry (name )
370- if err != nil {
371- return err
372- }
373-
374- if registry .Annotations == nil {
375- registry .Annotations = make (map [string ]string )
376- }
377- registry .Annotations ["toolhive.stacklok.dev/manual-sync" ] = fmt .Sprintf ("%d" , time .Now ().Unix ())
378-
379- return h .UpdateRegistry (registry )
380- }
381-
382- // GetRegistryStatus returns the current status of an MCPRegistry
383- func (h * MCPRegistryTestHelper ) GetRegistryStatus (name string ) (* mcpv1beta1.MCPRegistryStatus , error ) {
384- registry , err := h .GetRegistry (name )
385- if err != nil {
386- return nil , err
387- }
388- return & registry .Status , nil
389- }
390-
391- // GetRegistryPhase returns the current phase of an MCPRegistry
392- func (h * MCPRegistryTestHelper ) GetRegistryPhase (name string ) (mcpv1beta1.MCPRegistryPhase , error ) {
393- status , err := h .GetRegistryStatus (name )
394- if err != nil {
395- return "" , err
396- }
397- return status .Phase , nil
398- }
399-
400- // GetRegistryCondition returns a specific condition from the registry status
401- func (h * MCPRegistryTestHelper ) GetRegistryCondition (name , conditionType string ) (* metav1.Condition , error ) {
402- status , err := h .GetRegistryStatus (name )
403- if err != nil {
404- return nil , err
405- }
406-
407- for _ , condition := range status .Conditions {
408- if condition .Type == conditionType {
409- return & condition , nil
410- }
411- }
412- return nil , fmt .Errorf ("condition %s not found" , conditionType )
413- }
414-
415309// ListRegistries returns all MCPRegistries in the namespace
416310func (h * MCPRegistryTestHelper ) ListRegistries () (* mcpv1beta1.MCPRegistryList , error ) {
417311 registryList := & mcpv1beta1.MCPRegistryList {}
0 commit comments