Skip to content

Commit 1c7015f

Browse files
authored
Merge branch 'main' into worktree-storage-version-controler
2 parents 9b80858 + 5540b3d commit 1c7015f

38 files changed

Lines changed: 1 addition & 1184 deletions

File tree

cmd/thv-operator/pkg/controllerutil/resources.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,6 @@ func CreateProxyServiceName(resourceName string) string {
174174
return fmt.Sprintf("mcp-%s-proxy", resourceName)
175175
}
176176

177-
// CreateProxyServiceURL generates the full cluster-local service URL
178-
// Shared between MCPServer and MCPRemoteProxy
179-
func CreateProxyServiceURL(resourceName, namespace string, port int32) string {
180-
serviceName := CreateProxyServiceName(resourceName)
181-
return fmt.Sprintf("http://%s.%s.svc.cluster.local:%d", serviceName, namespace, port)
182-
}
183-
184177
// ProxyRunnerServiceAccountName generates the service account name for the proxy runner
185178
// Shared between MCPServer and MCPRemoteProxy
186179
func ProxyRunnerServiceAccountName(resourceName string) string {

cmd/thv-operator/pkg/registryapi/podtemplatespec.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ type PodTemplateSpecBuilder struct {
3131
defaultSpec *corev1.PodTemplateSpec
3232
}
3333

34-
// NewPodTemplateSpecBuilder creates a new PodTemplateSpecBuilder with an empty template.
35-
func NewPodTemplateSpecBuilder() *PodTemplateSpecBuilder {
36-
return NewPodTemplateSpecBuilderFrom(nil)
37-
}
38-
3934
// NewPodTemplateSpecBuilderFrom creates a new PodTemplateSpecBuilder with a user-provided template.
4035
// The user template is deep-copied to avoid mutating the original.
4136
// Options applied via Apply() act as defaults - Build() will merge them with user values,

cmd/thv-operator/pkg/registryapi/podtemplatespec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ func TestNewPodTemplateSpecBuilderFrom_MergeOnBuild(t *testing.T) {
717717
assert.Equal(t, "default-value", result.Labels["default-label"])
718718
})
719719

720-
t.Run("nil user template behaves like NewPodTemplateSpecBuilder", func(t *testing.T) {
720+
t.Run("nil user template behaves like an empty builder", func(t *testing.T) {
721721
t.Parallel()
722722

723723
builder := NewPodTemplateSpecBuilderFrom(nil)

cmd/thv-operator/test-integration/mcp-registry/configmap_helpers.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/onsi/gomega"
1313
corev1 "k8s.io/api/core/v1"
1414
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
15-
"k8s.io/apimachinery/pkg/types"
1615
"sigs.k8s.io/controller-runtime/pkg/client"
1716
)
1817

@@ -73,21 +72,6 @@ func (h *ConfigMapTestHelper) NewConfigMapBuilder(name string) *ConfigMapBuilder
7372
}
7473
}
7574

76-
// WithLabel adds a label to the ConfigMap
77-
func (cb *ConfigMapBuilder) WithLabel(key, value string) *ConfigMapBuilder {
78-
if cb.configMap.Labels == nil {
79-
cb.configMap.Labels = make(map[string]string)
80-
}
81-
cb.configMap.Labels[key] = value
82-
return cb
83-
}
84-
85-
// WithData adds arbitrary data to the ConfigMap
86-
func (cb *ConfigMapBuilder) WithData(key, value string) *ConfigMapBuilder {
87-
cb.configMap.Data[key] = value
88-
return cb
89-
}
90-
9175
// WithToolHiveRegistry adds ToolHive format registry data
9276
func (cb *ConfigMapBuilder) WithToolHiveRegistry(key string, servers []RegistryServer) *ConfigMapBuilder {
9377
// Convert slice to map using server names as keys
@@ -151,21 +135,6 @@ func (h *ConfigMapTestHelper) CreateSampleToolHiveRegistry(name string) *corev1.
151135
Create(h)
152136
}
153137

154-
// GetConfigMap retrieves a ConfigMap by name
155-
func (h *ConfigMapTestHelper) GetConfigMap(name string) (*corev1.ConfigMap, error) {
156-
cm := &corev1.ConfigMap{}
157-
err := h.Client.Get(h.Context, types.NamespacedName{
158-
Namespace: h.Namespace,
159-
Name: name,
160-
}, cm)
161-
return cm, err
162-
}
163-
164-
// UpdateConfigMap updates an existing ConfigMap
165-
func (h *ConfigMapTestHelper) UpdateConfigMap(configMap *corev1.ConfigMap) error {
166-
return h.Client.Update(h.Context, configMap)
167-
}
168-
169138
// DeleteConfigMap deletes a ConfigMap by name
170139
func (h *ConfigMapTestHelper) DeleteConfigMap(name string) error {
171140
cm := &corev1.ConfigMap{

cmd/thv-operator/test-integration/mcp-registry/k8s_helpers.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ func (h *K8sResourceTestHelper) GetService(name string) (*corev1.Service, error)
4848
return service, err
4949
}
5050

51-
// GetConfigMap retrieves a configmap by name
52-
func (h *K8sResourceTestHelper) GetConfigMap(name string) (*corev1.ConfigMap, error) {
53-
configMap := &corev1.ConfigMap{}
54-
err := h.k8sClient.Get(h.ctx, types.NamespacedName{
55-
Namespace: h.namespace,
56-
Name: name,
57-
}, configMap)
58-
return configMap, err
59-
}
60-
6151
// DeploymentExists checks if a deployment exists
6252
func (h *K8sResourceTestHelper) DeploymentExists(name string) bool {
6353
_, err := h.GetDeployment(name)
@@ -69,18 +59,3 @@ func (h *K8sResourceTestHelper) ServiceExists(name string) bool {
6959
_, err := h.GetService(name)
7060
return err == nil
7161
}
72-
73-
// IsDeploymentReady checks if a deployment is ready (all replicas available)
74-
func (h *K8sResourceTestHelper) IsDeploymentReady(name string) bool {
75-
deployment, err := h.GetDeployment(name)
76-
if err != nil {
77-
return false
78-
}
79-
80-
// Check if deployment has at least one replica and all are available
81-
if deployment.Spec.Replicas == nil || *deployment.Spec.Replicas == 0 {
82-
return false
83-
}
84-
85-
return deployment.Status.ReadyReplicas == *deployment.Spec.Replicas
86-
}

cmd/thv-operator/test-integration/mcp-registry/registry_helpers.go

Lines changed: 0 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
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
126115
func (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.
174139
func (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
334284
func (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
357299
func (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
416310
func (h *MCPRegistryTestHelper) ListRegistries() (*mcpv1beta1.MCPRegistryList, error) {
417311
registryList := &mcpv1beta1.MCPRegistryList{}

cmd/thv-operator/test-integration/mcp-registry/status_helpers.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/onsi/ginkgo/v2"
1212
"github.com/onsi/gomega"
1313
"k8s.io/apimachinery/pkg/api/errors"
14-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1514
"sigs.k8s.io/controller-runtime/pkg/client"
1615

1716
mcpv1beta1 "github.com/stacklok/toolhive/cmd/thv-operator/api/v1beta1"
@@ -51,44 +50,3 @@ func (h *StatusTestHelper) WaitForPhaseAny(registryName string,
5150
}, timeout, time.Second).Should(gomega.BeElementOf(expectedPhases),
5251
"MCPRegistry %s should reach one of phases %v", registryName, expectedPhases)
5352
}
54-
55-
// WaitForCondition waits for a specific condition to have the expected status
56-
func (h *StatusTestHelper) WaitForCondition(registryName, conditionType string,
57-
expectedStatus metav1.ConditionStatus, timeout time.Duration) {
58-
gomega.Eventually(func() metav1.ConditionStatus {
59-
condition, err := h.registryHelper.GetRegistryCondition(registryName, conditionType)
60-
if err != nil {
61-
return metav1.ConditionUnknown
62-
}
63-
return condition.Status
64-
}, timeout, time.Second).Should(gomega.Equal(expectedStatus),
65-
"MCPRegistry %s should have condition %s with status %s", registryName, conditionType, expectedStatus)
66-
}
67-
68-
// WaitForConditionReason waits for a condition to have a specific reason
69-
func (h *StatusTestHelper) WaitForConditionReason(registryName, conditionType, expectedReason string, timeout time.Duration) {
70-
gomega.Eventually(func() string {
71-
condition, err := h.registryHelper.GetRegistryCondition(registryName, conditionType)
72-
if err != nil {
73-
return ""
74-
}
75-
return condition.Reason
76-
}, timeout, time.Second).Should(gomega.Equal(expectedReason),
77-
"MCPRegistry %s condition %s should have reason %s", registryName, conditionType, expectedReason)
78-
}
79-
80-
// WaitForSyncCompletion waits for a sync operation to complete (either success or failure)
81-
func (h *StatusTestHelper) WaitForSyncCompletion(registryName string, timeout time.Duration) {
82-
gomega.Eventually(func() bool {
83-
registry, err := h.registryHelper.GetRegistry(registryName)
84-
if err != nil {
85-
return false
86-
}
87-
88-
// Check if sync is no longer in progress
89-
phase := registry.Status.Phase
90-
return phase == mcpv1beta1.MCPRegistryPhaseReady ||
91-
phase == mcpv1beta1.MCPRegistryPhaseFailed
92-
}, timeout, time.Second).Should(gomega.BeTrue(),
93-
"MCPRegistry %s sync operation should complete", registryName)
94-
}

0 commit comments

Comments
 (0)