Go(Gin) + React(Vite + shadcn/ui + Tailwind) 前后端分离,全中文 UI - 集群管理:Kubeconfig / Token 双接入,kubectl + helm 部署 - 主机管理:SSH 密钥 / 密码双认证,CPU/内存/磁盘使用率监控,SSH 错误中文友好提示 - 存储配置、部署管理、系统设置 - Docker 镜像内置 kubectl + helm,开箱即用 - run.sh 一键启停(start/stop/restart/status) Co-Authored-By: Claude <noreply@anthropic.com>
43 lines
810 B
Go
43 lines
810 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"sync"
|
|
)
|
|
|
|
var (
|
|
instance *Config
|
|
once sync.Once
|
|
)
|
|
|
|
type Config struct {
|
|
ServerPort string
|
|
DatabasePath string
|
|
JWTSecret string
|
|
DataDir string
|
|
KubeDir string
|
|
}
|
|
|
|
func GetConfig() *Config {
|
|
once.Do(func() {
|
|
dataDir := getEnv("DATA_DIR", "./data")
|
|
instance = &Config{
|
|
ServerPort: getEnv("SERVER_PORT", "8080"),
|
|
DatabasePath: filepath.Join(dataDir, "lokideploy.json"),
|
|
JWTSecret: getEnv("JWT_SECRET", "lokideploy-secret-key-change-in-production"),
|
|
DataDir: dataDir,
|
|
KubeDir: filepath.Join(dataDir, "kubeconfigs"),
|
|
}
|
|
_ = os.MkdirAll(instance.KubeDir, 0755)
|
|
})
|
|
return instance
|
|
}
|
|
|
|
func getEnv(key, defaultVal string) string {
|
|
if val := os.Getenv(key); val != "" {
|
|
return val
|
|
}
|
|
return defaultVal
|
|
}
|