mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-10 04:30:20 +02:00
chore: do not use sentinel errors when unneeded
- main reason being it's a burden to always define sentinel errors at global scope, wrap them with `%w` instead of using a string directly - only use sentinel errors when it has to be checked using `errors.Is` - replace all usage of these sentinel errors in `fmt.Errorf` with direct strings that were in the sentinel error - exclude the sentinel error definition requirement from .golangci.yml - update unit tests to use ContainersError instead of ErrorIs so it stays as a "not a change detector test" without requiring a sentinel error
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package custom
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
@@ -10,8 +9,6 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
)
|
||||
|
||||
var ErrVPNTypeNotSupported = errors.New("VPN type not supported for custom provider")
|
||||
|
||||
// GetConnection gets the connection from the OpenVPN configuration file.
|
||||
func (p *Provider) GetConnection(selection settings.ServerSelection, _ bool) (
|
||||
connection models.Connection, err error,
|
||||
@@ -22,7 +19,7 @@ func (p *Provider) GetConnection(selection settings.ServerSelection, _ bool) (
|
||||
case vpn.Wireguard, vpn.AmneziaWg:
|
||||
return getWireguardConnection(selection), nil
|
||||
default:
|
||||
return connection, fmt.Errorf("%w: %s", ErrVPNTypeNotSupported, selection.VPN)
|
||||
return connection, fmt.Errorf("VPN type not supported for custom provider: %s", selection.VPN)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package custom
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -12,8 +11,6 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||
)
|
||||
|
||||
var ErrExtractData = errors.New("failed extracting information from custom configuration file")
|
||||
|
||||
func (p *Provider) OpenVPNConfig(connection models.Connection,
|
||||
settings settings.OpenVPN, ipv6Supported bool,
|
||||
) (lines []string) {
|
||||
|
||||
Reference in New Issue
Block a user