-
Notifications
You must be signed in to change notification settings - Fork 265
Expand file tree
/
Copy pathconfig.go
More file actions
61 lines (52 loc) · 1.2 KB
/
config.go
File metadata and controls
61 lines (52 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package config
import (
"os"
"path/filepath"
"gopkg.in/yaml.v3"
)
type Config struct {
Server ServerConfig `yaml:"server"`
K8s K8sConfig `yaml:"kubernetes"`
Log LogConfig `yaml:"logging"`
}
type ServerConfig struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
Description string `yaml:"description"`
}
type K8sConfig struct {
ConfigPath string `yaml:"configPath"`
Context string `yaml:"context"`
Namespaces []string `yaml:"namespaces"`
}
type LogConfig struct {
Level string `yaml:"level"`
Format string `yaml:"format"`
}
func Load() (*Config, error) {
cfg := &Config{
Server: ServerConfig{
Name: "k8s-mcp-server",
Version: "1.0.0",
Description: "Kubernetes MCP Server for AI-powered cluster management",
},
K8s: K8sConfig{
ConfigPath: filepath.Join(os.Getenv("HOME"), ".kube", "config"),
Namespaces: []string{"default"},
},
Log: LogConfig{
Level: "info",
Format: "json",
},
}
if configFile := os.Getenv("CONFIG_FILE"); configFile != "" {
data, err := os.ReadFile(configFile)
if err != nil {
return nil, err
}
if err := yaml.Unmarshal(data, cfg); err != nil {
return nil, err
}
}
return cfg, nil
}