updated ezconf
This commit is contained in:
8
go.mod
8
go.mod
@@ -4,10 +4,10 @@ go 1.25.6
|
||||
|
||||
require (
|
||||
git.haelnorr.com/h/golib/env v0.9.1
|
||||
git.haelnorr.com/h/golib/ezconf v0.1.1
|
||||
git.haelnorr.com/h/golib/hlog v0.10.4
|
||||
git.haelnorr.com/h/golib/hws v0.5.0
|
||||
git.haelnorr.com/h/golib/hwsauth v0.6.1
|
||||
git.haelnorr.com/h/golib/ezconf v0.2.1
|
||||
git.haelnorr.com/h/golib/hlog v0.11.0
|
||||
git.haelnorr.com/h/golib/hws v0.6.0
|
||||
git.haelnorr.com/h/golib/hwsauth v0.7.0
|
||||
git.haelnorr.com/h/golib/notify v0.1.0
|
||||
github.com/a-h/templ v0.3.977
|
||||
github.com/coder/websocket v1.8.14
|
||||
|
||||
16
go.sum
16
go.sum
@@ -2,14 +2,14 @@ git.haelnorr.com/h/golib/cookies v0.9.0 h1:Vf+eX1prHkKuGrQon1BHY87yaPc1H+HJFRXDO
|
||||
git.haelnorr.com/h/golib/cookies v0.9.0/go.mod h1:y1385YExI9gLwckCVDCYVcsFXr6N7T3brJjnJD2QIuo=
|
||||
git.haelnorr.com/h/golib/env v0.9.1 h1:2Vsj+mJKnO5f1Md1GO5v9ggLN5zWa0baCewcSHTjoNY=
|
||||
git.haelnorr.com/h/golib/env v0.9.1/go.mod h1:glUQVdA1HMKX1avTDyTyuhcr36SSxZtlJxKDT5KTztg=
|
||||
git.haelnorr.com/h/golib/ezconf v0.1.1 h1:4euTSDb9jvuQQkVq+x5gHoYPYyUZPWxoOSlWCIxTZOs=
|
||||
git.haelnorr.com/h/golib/ezconf v0.1.1/go.mod h1:rETDcjpcEyyeBgCiZSU617wc0XycwZSC5+IAOtXmwP8=
|
||||
git.haelnorr.com/h/golib/hlog v0.10.4 h1:vpCsV/OddjIYx8F48U66WxojjmhEbeLGQAOBG4ViSRQ=
|
||||
git.haelnorr.com/h/golib/hlog v0.10.4/go.mod h1:+wJ8vecQY/JITTXKmI3JfkHiUGyMs7N6wooj2wuWZbc=
|
||||
git.haelnorr.com/h/golib/hws v0.5.0 h1:0CSv2f+dm/KzB/o5o6uXCyvN74iBdMTImhkyAZzU52c=
|
||||
git.haelnorr.com/h/golib/hws v0.5.0/go.mod h1:dxAbbGGNzqLXhZXwgt091QsvsPBdrS+1YsNQNldNVoM=
|
||||
git.haelnorr.com/h/golib/hwsauth v0.6.1 h1:3BiM6hwuYDjgfu02hshvUtr592DnWi9Epj//3N13ti0=
|
||||
git.haelnorr.com/h/golib/hwsauth v0.6.1/go.mod h1:xPdxqHzr1ZU0MHlG4o8r1zEstBu4FJCdaA0ZHSFxmKA=
|
||||
git.haelnorr.com/h/golib/ezconf v0.2.1 h1:axMyKtgO9Zk6E8CrYrLpMzifvpjz73yxCQq0lOtuhck=
|
||||
git.haelnorr.com/h/golib/ezconf v0.2.1/go.mod h1:rETDcjpcEyyeBgCiZSU617wc0XycwZSC5+IAOtXmwP8=
|
||||
git.haelnorr.com/h/golib/hlog v0.11.0 h1:tCT8HWs51Nbin58sCTLcq5re6CZqo5/IHCzk3G+S3vQ=
|
||||
git.haelnorr.com/h/golib/hlog v0.11.0/go.mod h1:HjhXS5G3A0BwOZq7nu2qpNBtvOFiCa1GbAuBRxAkYqs=
|
||||
git.haelnorr.com/h/golib/hws v0.6.0 h1:jwXUqT03PfrexVAC0xKVQWT2CLwN8+TDBsCK3+JWmEE=
|
||||
git.haelnorr.com/h/golib/hws v0.6.0/go.mod h1:iAjdrwYZye2nsvbBGIMzVcfydV4F47qUp10MvimVCOY=
|
||||
git.haelnorr.com/h/golib/hwsauth v0.7.0 h1:2uR7douZfkJ1vORUpvtS50FgGNm0GextDyMlCtrStbo=
|
||||
git.haelnorr.com/h/golib/hwsauth v0.7.0/go.mod h1:VUHQwQiBy6BtY9Iyb+G3j/c/He9PmGNVDlDrWa7Id0U=
|
||||
git.haelnorr.com/h/golib/jwt v0.10.1 h1:1Adxt9H3Y4fWFvFjWpvg/vSFhbgCMDMxgiE3m7KvDMI=
|
||||
git.haelnorr.com/h/golib/jwt v0.10.1/go.mod h1:fbuPrfucT9lL0faV5+Q5Gk9WFJxPlwzRPpbMQKYZok4=
|
||||
git.haelnorr.com/h/golib/notify v0.1.0 h1:xdf6zd21F6n+SuGTeJiuLNMf6zFXMvwpKD0gmNq8N10=
|
||||
|
||||
@@ -36,7 +36,7 @@ func GetConfig(flags *Flags) (*Config, *ezconf.ConfigLoader, error) {
|
||||
}
|
||||
|
||||
loader := ezconf.New()
|
||||
err = loader.RegisterIntegrations(
|
||||
err = loader.AddIntegrations(
|
||||
hlog.NewEZConfIntegration(),
|
||||
hws.NewEZConfIntegration(),
|
||||
hwsauth.NewEZConfIntegration(),
|
||||
|
||||
@@ -6,16 +6,14 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
User string // ENV DB_USER: Database user for authentication (required)
|
||||
Password string // ENV DB_PASSWORD: Database password for authentication (required)
|
||||
Host string // ENV DB_HOST: Database host address (required)
|
||||
Port uint16 // ENV DB_PORT: Database port (default: 5432)
|
||||
DB string // ENV DB_NAME: Database name to connect to (required)
|
||||
SSL string // ENV DB_SSL: SSL mode for connection (default: disable)
|
||||
|
||||
// Backup configuration
|
||||
BackupDir string // ENV DB_BACKUP_DIR: Directory for database backups (default: backups)
|
||||
BackupRetention int // ENV DB_BACKUP_RETENTION: Number of backups to keep (default: 10)
|
||||
User string `ezconf:"DB_USER,required,description:Database user for authentication"`
|
||||
Password string `ezconf:"DB_PASSWORD,required,description:Database password for authentication"`
|
||||
Host string `ezconf:"DB_HOST,required,description:Database host address"`
|
||||
Port uint16 `ezconf:"DB_PORT,default:5432,description:Database port"`
|
||||
DB string `ezconf:"DB_NAME,required,description:Database to connect to"`
|
||||
SSL string `ezconf:"DB_SSL,default:disable,description:SSL Mode"`
|
||||
BackupDir string `ezconf:"DB_BACKUP_DIR,default:backups,description:Directory for database backups"`
|
||||
BackupRetention int `ezconf:"DB_BACKUP_RETENTION,default:10,description:Number of backups to keep"`
|
||||
}
|
||||
|
||||
func ConfigFromEnv() (any, error) {
|
||||
|
||||
@@ -1,41 +1,11 @@
|
||||
package db
|
||||
|
||||
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: "DB", configFunc: ConfigFromEnv}
|
||||
func NewEZConfIntegration() *ezconf.Integration {
|
||||
return ezconf.NewIntegration("db", "DB", &Config{},
|
||||
func() (any, error) { return ConfigFromEnv() })
|
||||
}
|
||||
|
||||
@@ -9,12 +9,13 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
ClientID string // ENV DISCORD_CLIENT_ID: Discord application client ID (required)
|
||||
ClientSecret string // ENV DISCORD_CLIENT_SECRET: Discord application client secret (required)
|
||||
ClientID string `ezconf:"DISCORD_CLIENT_ID,required,description:Discord application client ID"`
|
||||
ClientSecret string `ezconf:"DISCORD_CLIENT_SECRET,required,description:Discord application client secret"`
|
||||
RedirectPath string `ezconf:"DISCORD_REDIRECT_PATH,required,description:Path for the OAuth redirect handler"`
|
||||
BotToken string `ezconf:"DISCORD_BOT_TOKEN,required,description:Token for the discord bot"`
|
||||
GuildID string `ezconf:"DISCORD_GUILD_ID,required,description:ID for the discord server the bot should connect to"`
|
||||
|
||||
OAuthScopes string // Authorisation scopes for OAuth
|
||||
RedirectPath string // ENV DISCORD_REDIRECT_PATH: Path for the OAuth redirect handler (required)
|
||||
BotToken string // ENV DISCORD_BOT_TOKEN: Token for the discord bot (required)
|
||||
GuildID string // ENV DISCORD_GUILD_ID: ID for the discord server the bot should connect to (required)
|
||||
}
|
||||
|
||||
func ConfigFromEnv() (any, error) {
|
||||
|
||||
@@ -1,41 +1,11 @@
|
||||
package discord
|
||||
|
||||
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: "Discord", configFunc: ConfigFromEnv}
|
||||
func NewEZConfIntegration() *ezconf.Integration {
|
||||
return ezconf.NewIntegration("discord", "Discord", &Config{},
|
||||
func() (any, error) { return ConfigFromEnv() })
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */
|
||||
/*! tailwindcss v4.2.1 | MIT License | https://tailwindcss.com */
|
||||
@import url("https://fonts.googleapis.com/css2?family=Ubuntu+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap");
|
||||
@layer properties;
|
||||
@layer theme, base, components, utilities;
|
||||
@@ -248,6 +248,12 @@
|
||||
.inset-0 {
|
||||
inset: calc(var(--spacing) * 0);
|
||||
}
|
||||
.start {
|
||||
inset-inline-start: var(--spacing);
|
||||
}
|
||||
.end {
|
||||
inset-inline-end: var(--spacing);
|
||||
}
|
||||
.end-0 {
|
||||
inset-inline-end: calc(var(--spacing) * 0);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
AdminDiscordID string // ENV ADMIN_DISCORD_ID: Discord ID to grant admin role on first login (required)
|
||||
AdminDiscordID string `ezconf:"ADMIN_DISCORD_ID,required,description:Discord ID to grant admin role on first login"`
|
||||
}
|
||||
|
||||
func ConfigFromEnv() (any, error) {
|
||||
|
||||
@@ -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() })
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
PrivateKey string // ENV OAUTH_PRIVATE_KEY: Private key for signing OAuth state tokens (required)
|
||||
PrivateKey string `ezconf:"OAUTH_PRIVATE_KEY,required,description:Private key for signing OAuth state tokens"`
|
||||
}
|
||||
|
||||
func ConfigFromEnv() (any, error) {
|
||||
|
||||
@@ -1,41 +1,11 @@
|
||||
package oauth
|
||||
|
||||
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: "OAuth", configFunc: ConfigFromEnv}
|
||||
// NewEZConfIntegration creates a new EZConf integration
|
||||
func NewEZConfIntegration() *ezconf.Integration {
|
||||
return ezconf.NewIntegration("oauth", "OAuth", &Config{},
|
||||
func() (any, error) { return ConfigFromEnv() })
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Environment string // ENV SLAPSHOT_ENVIRONMENT: API environment to connect to (default: staging)
|
||||
Key string // ENV SLAPSHOT_API_KEY: API Key for authorisation with the API (required)
|
||||
Environment string `ezconf:"SLAPSHOT_ENVIRONMENT,default:staging,description:API environment to connect to"`
|
||||
Key string `ezconf:"SLAPSHOT_API_KEY,required,description:API Key for authorisation with the API"`
|
||||
}
|
||||
|
||||
func ConfigFromEnv() (any, error) {
|
||||
|
||||
@@ -1,41 +1,9 @@
|
||||
package slapshotapi
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 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
|
||||
}
|
||||
import "git.haelnorr.com/h/golib/ezconf"
|
||||
|
||||
// NewEZConfIntegration creates a new EZConf integration helper
|
||||
func NewEZConfIntegration() EZConfIntegration {
|
||||
return EZConfIntegration{name: "SlapshotAPI", configFunc: ConfigFromEnv}
|
||||
func NewEZConfIntegration() *ezconf.Integration {
|
||||
return ezconf.NewIntegration("slapshotapi", "SlapshotAPI", &Config{},
|
||||
func() (any, error) { return ConfigFromEnv() })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user