Compare commits
1 Commits
hwsauth/v0
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| bb6820f269 |
@@ -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) {
|
||||||
|
|||||||
@@ -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{}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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=
|
||||||
|
|||||||
Reference in New Issue
Block a user