updated to use new ezconf

This commit is contained in:
2026-02-25 22:23:59 +11:00
parent 380e366891
commit bb6820f269
4 changed files with 10 additions and 33 deletions

View File

@@ -7,7 +7,7 @@ import (
type API struct { type API struct {
*Config *Config
token string // ENV TMDB_TOKEN: API token for TMDB (required) token string `ezconf:"TMDB_TOKEN,description:API token for TMDB,required"`
} }
func NewAPIConnection() (*API, error) { func NewAPIConnection() (*API, error) {

View File

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

View File

@@ -6,3 +6,5 @@ require (
git.haelnorr.com/h/golib/env v0.9.1 git.haelnorr.com/h/golib/env v0.9.1
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
) )
require git.haelnorr.com/h/golib/ezconf v0.2.1

View File

@@ -1,4 +1,6 @@
git.haelnorr.com/h/golib/env v0.9.1 h1:2Vsj+mJKnO5f1Md1GO5v9ggLN5zWa0baCewcSHTjoNY= 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/env v0.9.1/go.mod h1:glUQVdA1HMKX1avTDyTyuhcr36SSxZtlJxKDT5KTztg=
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=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=