Files
ops-assistant/internal/core/module/switches.go
2026-03-19 21:23:28 +08:00

27 lines
423 B
Go

package module
import (
"fmt"
"strings"
"gorm.io/gorm"
"ops-assistant/internal/core/policy"
)
func switchFlag(module string) string {
module = strings.TrimSpace(strings.ToLower(module))
if module == "" {
return ""
}
return fmt.Sprintf("enable_module_%s", module)
}
func IsEnabled(db *gorm.DB, module string) bool {
k := switchFlag(module)
if k == "" {
return false
}
return policy.FlagEnabled(db, k)
}