Skip to content

Commit a800f25

Browse files
authored
feat: set TOOLHIVE_SECRETS_PROVIDER=none for K8s proxy runner pods (#684)
1 parent a9a50ef commit a800f25

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

cmd/thv-operator/controllers/mcpserver_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ func (r *MCPServerReconciler) deploymentForMCPServer(m *mcpv1alpha1.MCPServer) *
431431
})
432432
}
433433

434+
// Add TOOLHIVE_SECRETS_PROVIDER=none for Kubernetes deployments
435+
env = append(env, corev1.EnvVar{
436+
Name: "TOOLHIVE_SECRETS_PROVIDER",
437+
Value: "none",
438+
})
439+
434440
// Prepare container volume mounts
435441
volumeMounts := []corev1.VolumeMount{}
436442
volumes := []corev1.Volume{}

cmd/thv-operator/controllers/mcpserver_pod_template_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,48 @@ func TestDeploymentForMCPServerWithPodTemplateSpec(t *testing.T) {
131131
assert.True(t, podTemplatePatchFound, "Pod template patch should be included in the args")
132132
}
133133

134+
func TestDeploymentForMCPServerSecretsProviderEnv(t *testing.T) {
135+
t.Parallel()
136+
// Create a test MCPServer
137+
mcpServer := &mcpv1alpha1.MCPServer{
138+
ObjectMeta: metav1.ObjectMeta{
139+
Name: "test-mcp-server",
140+
Namespace: "default",
141+
},
142+
Spec: mcpv1alpha1.MCPServerSpec{
143+
Image: "test-image:latest",
144+
Transport: "stdio",
145+
Port: 8080,
146+
},
147+
}
148+
149+
// Register the scheme
150+
s := scheme.Scheme
151+
s.AddKnownTypes(mcpv1alpha1.GroupVersion, &mcpv1alpha1.MCPServer{})
152+
s.AddKnownTypes(mcpv1alpha1.GroupVersion, &mcpv1alpha1.MCPServerList{})
153+
154+
// Create a reconciler with the scheme
155+
r := &MCPServerReconciler{
156+
Scheme: s,
157+
}
158+
159+
// Call deploymentForMCPServer
160+
deployment := r.deploymentForMCPServer(mcpServer)
161+
require.NotNil(t, deployment, "Deployment should not be nil")
162+
163+
// Check that the TOOLHIVE_SECRETS_PROVIDER environment variable is set to "none"
164+
container := deployment.Spec.Template.Spec.Containers[0]
165+
secretsProviderEnvFound := false
166+
for _, env := range container.Env {
167+
if env.Name == "TOOLHIVE_SECRETS_PROVIDER" {
168+
secretsProviderEnvFound = true
169+
assert.Equal(t, "none", env.Value, "TOOLHIVE_SECRETS_PROVIDER should be set to 'none'")
170+
break
171+
}
172+
}
173+
assert.True(t, secretsProviderEnvFound, "TOOLHIVE_SECRETS_PROVIDER environment variable should be present")
174+
}
175+
134176
// Helper functions
135177
func boolPtr(b bool) *bool {
136178
return &b

0 commit comments

Comments
 (0)