chore: use gofumpt for code formatting

This commit is contained in:
Quentin McGaw
2024-10-11 19:20:48 +00:00
parent 3daf15a612
commit 76a4bb5dc3
289 changed files with 784 additions and 548 deletions

View File

@@ -34,9 +34,7 @@ type WireguardConfig struct {
EndpointPort *string
}
var (
regexINISectionNotExist = regexp.MustCompile(`^section ".+" does not exist$`)
)
var regexINISectionNotExist = regexp.MustCompile(`^section ".+" does not exist$`)
func ParseWireguardConf(path string) (config WireguardConfig, err error) {
iniFile, err := ini.InsensitiveLoad(path)
@@ -68,18 +66,18 @@ func ParseWireguardConf(path string) (config WireguardConfig, err error) {
}
func parseWireguardInterfaceSection(interfaceSection *ini.Section) (
privateKey, addresses *string) {
privateKey, addresses *string,
) {
privateKey = getINIKeyFromSection(interfaceSection, "PrivateKey")
addresses = getINIKeyFromSection(interfaceSection, "Address")
return privateKey, addresses
}
var (
ErrEndpointHostNotIP = errors.New("endpoint host is not an IP")
)
var ErrEndpointHostNotIP = errors.New("endpoint host is not an IP")
func parseWireguardPeerSection(peerSection *ini.Section) (
preSharedKey, publicKey, endpointIP, endpointPort *string) {
preSharedKey, publicKey, endpointIP, endpointPort *string,
) {
preSharedKey = getINIKeyFromSection(peerSection, "PresharedKey")
publicKey = getINIKeyFromSection(peerSection, "PublicKey")
endpoint := getINIKeyFromSection(peerSection, "Endpoint")
@@ -96,9 +94,7 @@ func parseWireguardPeerSection(peerSection *ini.Section) (
return preSharedKey, publicKey, endpointIP, endpointPort
}
var (
regexINIKeyNotExist = regexp.MustCompile(`key ".*" not exists$`)
)
var regexINIKeyNotExist = regexp.MustCompile(`key ".*" not exists$`)
func getINIKeyFromSection(section *ini.Section, key string) (value *string) {
iniKey, err := section.GetKey(key)

View File

@@ -77,7 +77,7 @@ PresharedKey = YJ680VN+dGrdsWNjSFqZ6vvwuiNhbq502ZL3G7Q3o3g=
t.Parallel()
configFile := filepath.Join(t.TempDir(), "wg.conf")
const permission = fs.FileMode(0600)
const permission = fs.FileMode(0o600)
err := os.WriteFile(configFile, []byte(testCase.fileContent), permission)
require.NoError(t, err)

View File

@@ -39,7 +39,7 @@ func Test_Source_Get(t *testing.T) {
"empty_secret_file": {
makeSource: func(tempDir string) (source *Source, err error) {
secretFilepath := filepath.Join(tempDir, "test_file")
const permission = fs.FileMode(0600)
const permission = fs.FileMode(0o600)
err = os.WriteFile(secretFilepath, nil, permission)
if err != nil {
return nil, err
@@ -55,7 +55,7 @@ func Test_Source_Get(t *testing.T) {
"default_secret_file": {
makeSource: func(tempDir string) (source *Source, err error) {
secretFilepath := filepath.Join(tempDir, "test_file")
const permission = fs.FileMode(0600)
const permission = fs.FileMode(0o600)
err = os.WriteFile(secretFilepath, []byte{'A'}, permission)
if err != nil {
return nil, err
@@ -72,7 +72,7 @@ func Test_Source_Get(t *testing.T) {
"env_specified_secret_file": {
makeSource: func(tempDir string) (source *Source, err error) {
secretFilepath := filepath.Join(tempDir, "test_file_custom")
const permission = fs.FileMode(0600)
const permission = fs.FileMode(0o600)
err = os.WriteFile(secretFilepath, []byte{'A'}, permission)
if err != nil {
return nil, err