Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions cmd/thv-operator/api/v1alpha1/virtualmcpserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import (

// VirtualMCPServerSpec defines the desired state of VirtualMCPServer
type VirtualMCPServerSpec struct {
// GroupRef references an existing MCPGroup that defines backend workloads
// The referenced MCPGroup must exist in the same namespace
// TODO(jerm-dro): migrate to the Config field.
// +kubebuilder:validation:Required
GroupRef GroupRef `json:"groupRef"`
Comment thread
jerm-dro marked this conversation as resolved.

// IncomingAuth configures authentication for clients connecting to the Virtual MCP server
// Must be explicitly set - use "anonymous" type when no authentication is required
// TODO(jerm-dro): migrate to the Config field.
Expand Down Expand Up @@ -85,13 +79,6 @@ type VirtualMCPServerSpec struct {
Config config.Config `json:"config,omitempty"`
}

// GroupRef references an MCPGroup resource
type GroupRef struct {
// Name is the name of the MCPGroup resource in the same namespace
// +kubebuilder:validation:Required
Name string `json:"name"`
}

// IncomingAuthConfig configures authentication for clients connecting to the Virtual MCP server
type IncomingAuthConfig struct {
// Type defines the authentication type: anonymous or oidc
Expand Down
26 changes: 11 additions & 15 deletions cmd/thv-operator/api/v1alpha1/virtualmcpserver_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (

"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/stacklok/toolhive/pkg/vmcp/config"
)

func TestVirtualMCPServerPhaseTransitions(t *testing.T) {
Expand Down Expand Up @@ -138,9 +140,7 @@ func TestVirtualMCPServerDefaultValues(t *testing.T) {
Namespace: "default",
},
Spec: VirtualMCPServerSpec{
GroupRef: GroupRef{
Name: "test-group",
},
Config: config.Config{Group: "test-group"},
OutgoingAuth: &OutgoingAuthConfig{
Source: "", // Should default to "discovered"
},
Expand All @@ -166,9 +166,7 @@ func TestVirtualMCPServerNamespaceIsolation(t *testing.T) {
Namespace: "team-a",
},
Spec: VirtualMCPServerSpec{
GroupRef: GroupRef{
Name: "backend-group", // Must be in team-a namespace
},
Config: config.Config{Group: "backend-group"}, // Must be in team-a namespace
},
}

Expand All @@ -179,9 +177,7 @@ func TestVirtualMCPServerNamespaceIsolation(t *testing.T) {
Namespace: "team-b",
},
Spec: VirtualMCPServerSpec{
GroupRef: GroupRef{
Name: "backend-group", // Different group in team-b namespace
},
Config: config.Config{Group: "backend-group"}, // Different group in team-b namespace
},
}

Expand All @@ -190,9 +186,9 @@ func TestVirtualMCPServerNamespaceIsolation(t *testing.T) {
assert.Equal(t, "vmcp", vmcpTeamB.Name)
assert.NotEqual(t, vmcpTeamA.Namespace, vmcpTeamB.Namespace)

// GroupRef names can be the same but refer to different groups in different namespaces
assert.Equal(t, "backend-group", vmcpTeamA.Spec.GroupRef.Name)
assert.Equal(t, "backend-group", vmcpTeamB.Spec.GroupRef.Name)
// Group names can be the same but refer to different groups in different namespaces
assert.Equal(t, "backend-group", vmcpTeamA.Spec.Config.Group)
assert.Equal(t, "backend-group", vmcpTeamB.Spec.Config.Group)
}

func TestConflictResolutionStrategies(t *testing.T) {
Expand Down Expand Up @@ -234,7 +230,7 @@ func TestConflictResolutionStrategies(t *testing.T) {

vmcp := &VirtualMCPServer{
Spec: VirtualMCPServerSpec{
GroupRef: GroupRef{Name: "test-group"},
Config: config.Config{Group: "test-group"},
Aggregation: &AggregationConfig{
ConflictResolution: tt.strategy,
ConflictResolutionConfig: tt.config,
Expand Down Expand Up @@ -287,7 +283,7 @@ func TestBackendAuthConfigTypes(t *testing.T) {

vmcp := &VirtualMCPServer{
Spec: VirtualMCPServerSpec{
GroupRef: GroupRef{Name: "test-group"},
Config: config.Config{Group: "test-group"},
OutgoingAuth: &OutgoingAuthConfig{
Backends: map[string]BackendAuthConfig{
"test-backend": tt.authConfig,
Expand Down Expand Up @@ -352,7 +348,7 @@ func TestCompositeToolStepDependencies(t *testing.T) {

vmcp := &VirtualMCPServer{
Spec: VirtualMCPServerSpec{
GroupRef: GroupRef{Name: "test-group"},
Config: config.Config{Group: "test-group"},
CompositeTools: []CompositeToolSpec{
{
Name: "test-workflow",
Expand Down
6 changes: 3 additions & 3 deletions cmd/thv-operator/api/v1alpha1/virtualmcpserver_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func (*VirtualMCPServer) ValidateDelete(_ context.Context, _ runtime.Object) (ad
// Validate performs validation for VirtualMCPServer
// This method can be called by the controller during reconciliation or by the webhook
func (r *VirtualMCPServer) Validate() error {
// Validate GroupRef is set (required field)
if r.Spec.GroupRef.Name == "" {
return fmt.Errorf("spec.groupRef.name is required")
// Validate Group is set (required field)
if r.Spec.Config.Group == "" {
return fmt.Errorf("spec.config.groupRef is required")
Comment thread
jhrozek marked this conversation as resolved.
}

// Validate IncomingAuth configuration
Expand Down
Loading
Loading