From bb6820f26931bece0cdad70d8e74bdd09dc8a20a Mon Sep 17 00:00:00 2001 From: Haelnorr Date: Wed, 25 Feb 2026 22:23:59 +1100 Subject: [PATCH] updated to use new ezconf --- tmdb/api.go | 2 +- tmdb/ezconf.go | 37 +++++-------------------------------- tmdb/go.mod | 2 ++ tmdb/go.sum | 2 ++ 4 files changed, 10 insertions(+), 33 deletions(-) diff --git a/tmdb/api.go b/tmdb/api.go index b80911a..25121b3 100644 --- a/tmdb/api.go +++ b/tmdb/api.go @@ -7,7 +7,7 @@ import ( type API struct { *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) { diff --git a/tmdb/ezconf.go b/tmdb/ezconf.go index ee39ccb..f17e458 100644 --- a/tmdb/ezconf.go +++ b/tmdb/ezconf.go @@ -1,36 +1,9 @@ package tmdb -import "runtime" +import "git.haelnorr.com/h/golib/ezconf" -// EZConfIntegration provides integration with ezconf for automatic configuration -type EZConfIntegration struct{} - -// PackagePath returns the path to the tmdb 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 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{} +// NewEZConfIntegration creates a new EZConf integration +func NewEZConfIntegration() *ezconf.Integration { + return ezconf.NewIntegration("tmdb", "TMDB", &Config{}, + func() (any, error) { return NewAPIConnection() }) } diff --git a/tmdb/go.mod b/tmdb/go.mod index 3886446..472eed3 100644 --- a/tmdb/go.mod +++ b/tmdb/go.mod @@ -6,3 +6,5 @@ require ( git.haelnorr.com/h/golib/env v0.9.1 github.com/pkg/errors v0.9.1 ) + +require git.haelnorr.com/h/golib/ezconf v0.2.1 diff --git a/tmdb/go.sum b/tmdb/go.sum index 6f63fe5..eb4af84 100644 --- a/tmdb/go.sum +++ b/tmdb/go.sum @@ -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/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/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=