Maint: move custom config files to custom package

This commit is contained in:
Quentin McGaw (desktop)
2021-08-18 20:14:02 +00:00
parent f17a4eae3e
commit 996942af47
3 changed files with 7 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
package openvpn package custom
import ( import (
"errors" "errors"
@@ -20,7 +20,7 @@ var (
errExtractConnection = errors.New("cannot extract connection from custom configuration file") errExtractConnection = errors.New("cannot extract connection from custom configuration file")
) )
func processCustomConfig(settings configuration.OpenVPN) ( func ProcessCustomConfig(settings configuration.OpenVPN) (
lines []string, connection models.OpenVPNConnection, err error) { lines []string, connection models.OpenVPNConnection, err error) {
lines, err = readCustomConfigLines(settings.Config) lines, err = readCustomConfigLines(settings.Config)
if err != nil { if err != nil {

View File

@@ -1,4 +1,4 @@
package openvpn package custom
import ( import (
"errors" "errors"
@@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func Test_processCustomConfig(t *testing.T) { func Test_ProcessCustomConfig(t *testing.T) {
t.Parallel() t.Parallel()
file, err := os.CreateTemp("", "") file, err := os.CreateTemp("", "")
@@ -33,7 +33,7 @@ func Test_processCustomConfig(t *testing.T) {
Config: file.Name(), Config: file.Name(),
} }
lines, connection, err := processCustomConfig(settings) lines, connection, err := ProcessCustomConfig(settings)
assert.NoError(t, err) assert.NoError(t, err)
expectedLines := []string{ expectedLines := []string{

View File

@@ -6,6 +6,7 @@ import (
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/openvpn/custom"
"github.com/qdm12/gluetun/internal/provider" "github.com/qdm12/gluetun/internal/provider"
) )
@@ -36,7 +37,7 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
lines = providerConf.BuildConf(connection, openVPNSettings) lines = providerConf.BuildConf(connection, openVPNSettings)
} }
} else { } else {
lines, connection, err = processCustomConfig(openVPNSettings) lines, connection, err = custom.ProcessCustomConfig(openVPNSettings)
} }
if err != nil { if err != nil {
l.crashed(ctx, err) l.crashed(ctx, err)