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 (
"errors"
@@ -20,7 +20,7 @@ var (
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, err = readCustomConfigLines(settings.Config)
if err != nil {

View File

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

View File

@@ -6,6 +6,7 @@ import (
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/openvpn/custom"
"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)
}
} else {
lines, connection, err = processCustomConfig(openVPNSettings)
lines, connection, err = custom.ProcessCustomConfig(openVPNSettings)
}
if err != nil {
l.crashed(ctx, err)