@@ -3,6 +3,7 @@ package config
33import (
44 "context"
55 "fmt"
6+ "path/filepath"
67
78 "gopkg.in/yaml.v2"
89 corev1 "k8s.io/api/core/v1"
@@ -20,18 +21,20 @@ import (
2021//
2122//nolint:revive
2223type ConfigManager interface {
23- BuildConfig (mcpRegistry * mcpv1alpha1. MCPRegistry ) (* Config , error )
24+ BuildConfig () (* Config , error )
2425 UpsertConfigMap (ctx context.Context ,
2526 mcpRegistry * mcpv1alpha1.MCPRegistry ,
2627 desired * corev1.ConfigMap ,
2728 ) error
29+ GetRegistryServerConfigMapName () string
2830}
2931
3032// NewConfigManager creates a new instance of ConfigManager with required dependencies
3133func NewConfigManager (
3234 k8sClient client.Client ,
3335 scheme * runtime.Scheme ,
3436 checksumManager checksum.RunConfigConfigMapChecksum ,
37+ mcpRegistry * mcpv1alpha1.MCPRegistry ,
3538) (ConfigManager , error ) {
3639 if k8sClient == nil {
3740 return nil , fmt .Errorf ("k8sClient is required and cannot be nil" )
@@ -42,20 +45,33 @@ func NewConfigManager(
4245 if checksumManager == nil {
4346 return nil , fmt .Errorf ("checksumManager is required and cannot be nil" )
4447 }
45- return & configManager {client : k8sClient , scheme : scheme , checksum : checksumManager }, nil
48+
49+ return & configManager {
50+ client : k8sClient ,
51+ scheme : scheme ,
52+ checksum : checksumManager ,
53+ mcpRegistry : mcpRegistry ,
54+ }, nil
4655}
4756
4857// NewConfigManagerForTesting creates a ConfigManager for testing purposes only.
4958// WARNING: This manager will panic if methods requiring dependencies are called.
5059// Only use this for testing BuildConfig or other methods that don't use k8s client.
51- func NewConfigManagerForTesting () ConfigManager {
52- return & configManager {}
60+ func NewConfigManagerForTesting (mcpRegistry * mcpv1alpha1.MCPRegistry ) ConfigManager {
61+ return & configManager {
62+ mcpRegistry : mcpRegistry ,
63+ }
5364}
5465
5566type configManager struct {
56- client client.Client
57- scheme * runtime.Scheme
58- checksum checksum.RunConfigConfigMapChecksum
67+ client client.Client
68+ scheme * runtime.Scheme
69+ checksum checksum.RunConfigConfigMapChecksum
70+ mcpRegistry * mcpv1alpha1.MCPRegistry
71+ }
72+
73+ func (cm * configManager ) GetRegistryServerConfigMapName () string {
74+ return fmt .Sprintf ("%s-registry-server-config" , cm .mcpRegistry .Name )
5975}
6076
6177const (
@@ -69,7 +85,16 @@ const (
6985 SourceTypeFile = "file"
7086
7187 // RegistryJSONFilePath is the file path where the registry JSON file will be mounted
72- RegistryJSONFilePath = "/etc/registry/registry.json"
88+ RegistryJSONFilePath = "/config/registry"
89+
90+ // RegistryJSONFileName is the name of the registry JSON file
91+ RegistryJSONFileName = "registry.json"
92+
93+ // RegistryServerConfigFilePath is the file path where the registry server config file will be mounted
94+ RegistryServerConfigFilePath = "/config"
95+
96+ // RegistryServerConfigFileName is the name of the registry server config file
97+ RegistryServerConfigFileName = "config.yaml"
7398)
7499
75100// Config represents the root configuration structure
@@ -159,22 +184,24 @@ func (c *Config) ToConfigMapWithContentChecksum(mcpRegistry *mcpv1alpha1.MCPRegi
159184
160185 configMap := & corev1.ConfigMap {
161186 ObjectMeta : metav1.ObjectMeta {
162- Name : fmt .Sprintf ("%s-configmap " , c .RegistryName ),
187+ Name : fmt .Sprintf ("%s-registry-server-config " , c .RegistryName ),
163188 Namespace : mcpRegistry .Namespace ,
164189 Annotations : map [string ]string {
165190 checksum .ContentChecksumAnnotation : ctrlutil .CalculateConfigHash (yamlData ),
166191 },
167192 },
168193 Data : map [string ]string {
169- "config.yaml" : string (yamlData ),
194+ RegistryServerConfigFileName : string (yamlData ),
170195 },
171196 }
172197 return configMap , nil
173198}
174199
175- func (* configManager ) BuildConfig (mcpRegistry * mcpv1alpha1. MCPRegistry ) (* Config , error ) {
200+ func (cm * configManager ) BuildConfig () (* Config , error ) {
176201 config := Config {}
177202
203+ mcpRegistry := cm .mcpRegistry
204+
178205 if mcpRegistry .Name == "" {
179206 return nil , fmt .Errorf ("registry name is required" )
180207 }
@@ -254,7 +281,7 @@ func buildSourceConfig(source *mcpv1alpha1.MCPRegistrySource, config *Config) er
254281 // this stops the registry server worrying about configmap sources when all it has to do
255282 // is read the file on startup
256283 sourceConfig .File = & FileConfig {
257- Path : RegistryJSONFilePath ,
284+ Path : filepath . Join ( RegistryJSONFilePath , RegistryJSONFileName ) ,
258285 }
259286 sourceConfig .Type = SourceTypeFile
260287 case mcpv1alpha1 .RegistrySourceTypeGit :
0 commit comments