updated ezconf

This commit is contained in:
2026-02-25 22:47:33 +11:00
parent 2fd5bcf4f5
commit b3428d15e5
14 changed files with 63 additions and 210 deletions

View File

@@ -1,41 +1,11 @@
package rbac
import (
"runtime"
"strings"
"git.haelnorr.com/h/golib/ezconf"
)
// EZConfIntegration provides integration with ezconf for automatic configuration
type EZConfIntegration struct {
configFunc func() (any, error)
name string
}
// PackagePath returns the path to the config package for source parsing
func (e EZConfIntegration) PackagePath() string {
_, filename, _, _ := runtime.Caller(0)
// Return directory of this file
return filename[:len(filename)-len("/ezconf.go")]
}
// ConfigFunc returns the ConfigFromEnv function for ezconf
func (e EZConfIntegration) ConfigFunc() func() (any, error) {
return func() (any, error) {
return e.configFunc()
}
}
// Name returns the name to use when registering with ezconf
func (e EZConfIntegration) Name() string {
return strings.ToLower(e.name)
}
// GroupName returns the display name for grouping environment variables
func (e EZConfIntegration) GroupName() string {
return e.name
}
// NewEZConfIntegration creates a new EZConf integration helper
func NewEZConfIntegration() EZConfIntegration {
return EZConfIntegration{name: "RBAC", configFunc: ConfigFromEnv}
// NewEZConfIntegration creates a new EZConf integration
func NewEZConfIntegration() *ezconf.Integration {
return ezconf.NewIntegration("rbac", "RBAC", &Config{},
func() (any, error) { return ConfigFromEnv() })
}