chore(config): define Source interface locally where needed
This commit is contained in:
@@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/qdm12/dns/pkg/unbound"
|
"github.com/qdm12/dns/pkg/unbound"
|
||||||
"github.com/qdm12/gluetun/internal/alpine"
|
"github.com/qdm12/gluetun/internal/alpine"
|
||||||
"github.com/qdm12/gluetun/internal/cli"
|
"github.com/qdm12/gluetun/internal/cli"
|
||||||
"github.com/qdm12/gluetun/internal/configuration/sources"
|
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||||
"github.com/qdm12/gluetun/internal/configuration/sources/env"
|
"github.com/qdm12/gluetun/internal/configuration/sources/env"
|
||||||
"github.com/qdm12/gluetun/internal/configuration/sources/files"
|
"github.com/qdm12/gluetun/internal/configuration/sources/files"
|
||||||
mux "github.com/qdm12/gluetun/internal/configuration/sources/merge"
|
mux "github.com/qdm12/gluetun/internal/configuration/sources/merge"
|
||||||
@@ -128,7 +128,7 @@ var (
|
|||||||
|
|
||||||
//nolint:gocognit,gocyclo,maintidx
|
//nolint:gocognit,gocyclo,maintidx
|
||||||
func _main(ctx context.Context, buildInfo models.BuildInformation,
|
func _main(ctx context.Context, buildInfo models.BuildInformation,
|
||||||
args []string, logger log.LoggerInterface, source sources.Source,
|
args []string, logger log.LoggerInterface, source Source,
|
||||||
tun Tun, netLinker netLinker, cmder command.RunStarter,
|
tun Tun, netLinker netLinker, cmder command.RunStarter,
|
||||||
cli clier) error {
|
cli clier) error {
|
||||||
if len(args) > 1 { // cli operation
|
if len(args) > 1 { // cli operation
|
||||||
@@ -529,8 +529,8 @@ type Linker interface {
|
|||||||
type clier interface {
|
type clier interface {
|
||||||
ClientKey(args []string) error
|
ClientKey(args []string) error
|
||||||
FormatServers(args []string) error
|
FormatServers(args []string) error
|
||||||
OpenvpnConfig(logger cli.OpenvpnConfigLogger, source sources.Source) error
|
OpenvpnConfig(logger cli.OpenvpnConfigLogger, source cli.Source) error
|
||||||
HealthCheck(ctx context.Context, source sources.Source, warner cli.Warner) error
|
HealthCheck(ctx context.Context, source cli.Source, warner cli.Warner) error
|
||||||
Update(ctx context.Context, args []string, logger cli.UpdaterLogger) error
|
Update(ctx context.Context, args []string, logger cli.UpdaterLogger) error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,3 +538,9 @@ type Tun interface {
|
|||||||
Check(tunDevice string) error
|
Check(tunDevice string) error
|
||||||
Create(tunDevice string) error
|
Create(tunDevice string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Source interface {
|
||||||
|
Read() (settings settings.Settings, err error)
|
||||||
|
ReadHealth() (health settings.Health, err error)
|
||||||
|
String() string
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,11 +6,10 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/configuration/sources"
|
|
||||||
"github.com/qdm12/gluetun/internal/healthcheck"
|
"github.com/qdm12/gluetun/internal/healthcheck"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *CLI) HealthCheck(ctx context.Context, source sources.Source, warner Warner) error {
|
func (c *CLI) HealthCheck(ctx context.Context, source Source, warner Warner) error {
|
||||||
// Extract the health server port from the configuration.
|
// Extract the health server port from the configuration.
|
||||||
config, err := source.ReadHealth()
|
config, err := source.ReadHealth()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package sources
|
package cli
|
||||||
|
|
||||||
import "github.com/qdm12/gluetun/internal/configuration/settings"
|
import "github.com/qdm12/gluetun/internal/configuration/settings"
|
||||||
|
|
||||||
type Source interface {
|
type Source interface {
|
||||||
Read() (settings settings.Settings, err error)
|
Read() (settings settings.Settings, err error)
|
||||||
ReadHealth() (settings settings.Health, err error)
|
ReadHealth() (health settings.Health, err error)
|
||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/configuration/sources"
|
|
||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
"github.com/qdm12/gluetun/internal/openvpn/extract"
|
"github.com/qdm12/gluetun/internal/openvpn/extract"
|
||||||
"github.com/qdm12/gluetun/internal/provider"
|
"github.com/qdm12/gluetun/internal/provider"
|
||||||
@@ -36,7 +35,7 @@ type IPFetcher interface {
|
|||||||
FetchMultiInfo(ctx context.Context, ips []net.IP) (data []ipinfo.Response, err error)
|
FetchMultiInfo(ctx context.Context, ips []net.IP) (data []ipinfo.Response, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CLI) OpenvpnConfig(logger OpenvpnConfigLogger, source sources.Source) error {
|
func (c *CLI) OpenvpnConfig(logger OpenvpnConfigLogger, source Source) error {
|
||||||
storage, err := storage.New(logger, constants.ServersData)
|
storage, err := storage.New(logger, constants.ServersData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
3
internal/configuration/sources/env/reader.go
vendored
3
internal/configuration/sources/env/reader.go
vendored
@@ -2,11 +2,8 @@ package env
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||||
"github.com/qdm12/gluetun/internal/configuration/sources"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ sources.Source = (*Reader)(nil)
|
|
||||||
|
|
||||||
type Reader struct {
|
type Reader struct {
|
||||||
warner Warner
|
warner Warner
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,8 @@ package files
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||||
"github.com/qdm12/gluetun/internal/configuration/sources"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ sources.Source = (*Reader)(nil)
|
|
||||||
|
|
||||||
type Reader struct{}
|
type Reader struct{}
|
||||||
|
|
||||||
func New() *Reader {
|
func New() *Reader {
|
||||||
|
|||||||
@@ -5,16 +5,19 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||||
"github.com/qdm12/gluetun/internal/configuration/sources"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ sources.Source = (*Reader)(nil)
|
type Source interface {
|
||||||
|
Read() (settings settings.Settings, err error)
|
||||||
type Reader struct {
|
ReadHealth() (settings settings.Health, err error)
|
||||||
sources []sources.Source
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(sources ...sources.Source) *Reader {
|
type Reader struct {
|
||||||
|
sources []Source
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(sources ...Source) *Reader {
|
||||||
return &Reader{
|
return &Reader{
|
||||||
sources: sources,
|
sources: sources,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,9 @@ package secrets
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||||
"github.com/qdm12/gluetun/internal/configuration/sources"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ sources.Source = (*Reader)(nil)
|
type Reader struct{}
|
||||||
|
|
||||||
type Reader struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func New() *Reader {
|
func New() *Reader {
|
||||||
return &Reader{}
|
return &Reader{}
|
||||||
|
|||||||
Reference in New Issue
Block a user