rbac system first stage
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// Package config provides the environment based configuration for the program
|
||||
package config
|
||||
|
||||
import (
|
||||
@@ -7,6 +8,7 @@ import (
|
||||
"git.haelnorr.com/h/golib/hwsauth"
|
||||
"git.haelnorr.com/h/oslstats/internal/db"
|
||||
"git.haelnorr.com/h/oslstats/internal/discord"
|
||||
"git.haelnorr.com/h/oslstats/internal/rbac"
|
||||
"git.haelnorr.com/h/oslstats/pkg/oauth"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/pkg/errors"
|
||||
@@ -19,10 +21,11 @@ type Config struct {
|
||||
HLOG *hlog.Config
|
||||
Discord *discord.Config
|
||||
OAuth *oauth.Config
|
||||
RBAC *rbac.Config
|
||||
Flags *Flags
|
||||
}
|
||||
|
||||
// Load the application configuration and get a pointer to the Config object
|
||||
// GetConfig loads the application configuration and returns a pointer to the Config object
|
||||
// If doconly is specified, only the loader will be returned
|
||||
func GetConfig(flags *Flags) (*Config, *ezconf.ConfigLoader, error) {
|
||||
err := godotenv.Load(flags.EnvFile)
|
||||
@@ -31,14 +34,18 @@ func GetConfig(flags *Flags) (*Config, *ezconf.ConfigLoader, error) {
|
||||
}
|
||||
|
||||
loader := ezconf.New()
|
||||
loader.RegisterIntegrations(
|
||||
err = loader.RegisterIntegrations(
|
||||
hlog.NewEZConfIntegration(),
|
||||
hws.NewEZConfIntegration(),
|
||||
hwsauth.NewEZConfIntegration(),
|
||||
db.NewEZConfIntegration(),
|
||||
discord.NewEZConfIntegration(),
|
||||
oauth.NewEZConfIntegration(),
|
||||
rbac.NewEZConfIntegration(),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "loader.RegisterIntegrations")
|
||||
}
|
||||
if err := loader.ParseEnvVars(); err != nil {
|
||||
return nil, nil, errors.Wrap(err, "loader.ParseEnvVars")
|
||||
}
|
||||
@@ -81,6 +88,11 @@ func GetConfig(flags *Flags) (*Config, *ezconf.ConfigLoader, error) {
|
||||
return nil, nil, errors.New("OAuth Config not loaded")
|
||||
}
|
||||
|
||||
rbaccfg, ok := loader.GetConfig("rbac")
|
||||
if !ok {
|
||||
return nil, nil, errors.New("RBAC Config not loaded")
|
||||
}
|
||||
|
||||
config := &Config{
|
||||
DB: dbcfg.(*db.Config),
|
||||
HWS: hwscfg.(*hws.Config),
|
||||
@@ -88,6 +100,7 @@ func GetConfig(flags *Flags) (*Config, *ezconf.ConfigLoader, error) {
|
||||
HLOG: hlogcfg.(*hlog.Config),
|
||||
Discord: discordcfg.(*discord.Config),
|
||||
OAuth: oauthcfg.(*oauth.Config),
|
||||
RBAC: rbaccfg.(*rbac.Config),
|
||||
Flags: flags,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user