Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: GolangCI-Lint
if: runner.os == 'Linux'
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
with:
version: latest
args: --verbose
Expand Down
30 changes: 23 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
version: "2"
linters:
enable:
- gocyclo
- revive
- misspell
- unused

linters-settings:
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 16
- revive
settings:
gocyclo:
min-complexity: 16
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion checker/consul_leader_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewConsulLeaderChecker(con *vipconfig.Config) (lc *ConsulLeaderChecker, err

// GetChangeNotificationStream checks the status in the loop
func (c *ConsulLeaderChecker) GetChangeNotificationStream(ctx context.Context, out chan<- bool) error {
kv := c.Client.KV()
kv := c.KV()

queryOptions := &api.QueryOptions{
RequireConsistent: true,
Expand Down
2 changes: 1 addition & 1 deletion checker/patroni_leader_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (c *PatroniLeaderChecker) GetChangeNotificationStream(ctx context.Context,
case <-ctx.Done():
return nil
case <-time.After(time.Duration(c.Interval) * time.Millisecond):
r, err := c.Client.Get(c.Endpoints[0] + c.TriggerKey)
r, err := c.Get(c.Endpoints[0] + c.TriggerKey)
if err != nil {
c.Logger.Sugar().Error("patroni REST API error:", err)
continue
Expand Down
6 changes: 3 additions & 3 deletions ipmanager/basicConfigurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type BasicConfigurer struct {
func newBasicConfigurer(config *IPConfiguration) (*BasicConfigurer, error) {
c := &BasicConfigurer{IPConfiguration: config, ntecontext: 0}
if c.Iface.HardwareAddr == nil || c.Iface.HardwareAddr.String() == "00:00:00:00:00:00" {
return nil, errors.New(`Cannot run vip-manager on the loopback device
return nil, errors.New(`cannot run vip-manager on the loopback device
as its hardware address is the local address (00:00:00:00:00:00),
which prohibits sending of gratuitous ARP messages`)
}
Expand Down Expand Up @@ -70,9 +70,9 @@ func (c *BasicConfigurer) createGratuitousARP() ([]byte, error) {
ProtAddressSize: IPv4AddressSize,
Operation: layers.ARPReply, // Gratuitous ARP is sent as a reply
SourceHwAddress: c.Iface.HardwareAddr,
SourceProtAddress: c.IPConfiguration.VIP.AsSlice(),
SourceProtAddress: c.VIP.AsSlice(),
DstHwAddress: c.Iface.HardwareAddr, // Gratuitous ARP targets itself
DstProtAddress: c.IPConfiguration.VIP.AsSlice(),
DstProtAddress: c.VIP.AsSlice(),
}

// Create a packet with the layers
Expand Down
19 changes: 10 additions & 9 deletions ipmanager/hetznerConfigurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (c *HetznerConfigurer) curlQueryFailover(post bool) (string, error) {
}
if user == "" || password == "" {
log.Infoln("Couldn't retrieve username or password from file", credentialsFile)
return "", errors.New("Couldn't retrieve username or password from file")
return "", errors.New("couldn't retrieve username or password from file")
}

/**
Expand All @@ -101,33 +101,33 @@ func (c *HetznerConfigurer) curlQueryFailover(post bool) (string, error) {
myOwnIP := getOutboundIP()
if myOwnIP == nil {
log.Error("Error determining this machine's IP address.")
return "", errors.New("Error determining this machine's IP address")
return "", errors.New("error determining this machine's IP address")
}
log.Infof("my_own_ip: %s\n", myOwnIP.String())

cmd = exec.Command("curl",
"--ipv4",
"-u", user+":"+password,
"https://robot-ws.your-server.de/failover/"+c.IPConfiguration.VIP.String(),
"https://robot-ws.your-server.de/failover/"+c.VIP.String(),
"-d", "active_server_ip="+myOwnIP.String())

log.Debugf("%s %s %s '%s' %s %s %s",
"curl",
"--ipv4",
"-u", user+":XXXXXX",
"https://robot-ws.your-server.de/failover/"+c.IPConfiguration.VIP.String(),
"https://robot-ws.your-server.de/failover/"+c.VIP.String(),
"-d", "active_server_ip="+myOwnIP.String())
} else {
cmd = exec.Command("curl",
"--ipv4",
"-u", user+":"+password,
"https://robot-ws.your-server.de/failover/"+c.IPConfiguration.VIP.String())
"https://robot-ws.your-server.de/failover/"+c.VIP.String())

log.Debugf("%s %s %s %s %s",
"curl",
"--ipv4",
"-u", user+":XXXXXX",
"https://robot-ws.your-server.de/failover/"+c.IPConfiguration.VIP.String())
"https://robot-ws.your-server.de/failover/"+c.VIP.String())
}

out, err := cmd.Output()
Expand Down Expand Up @@ -164,7 +164,7 @@ func (c *HetznerConfigurer) getActiveIPFromJSON(str string) (net.IP, error) {
errormap["status"].(float64),
errormap["code"].(string),
errormap["message"].(string))
return nil, errors.New("Hetzner API returned error response")
return nil, errors.New("error response from Hetzner API returned")
}

if f["failover"] != nil {
Expand Down Expand Up @@ -202,9 +202,10 @@ func (c *HetznerConfigurer) queryAddress() bool {
/** no need to check, we can use "cached" state if set.
* if it is set to UNKNOWN, a check will be done.
*/
if c.cachedState == configured {
switch c.cachedState {
case configured:
return true
} else if c.cachedState == released {
case released:
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion vipconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func NewConfig() (*Config, error) {

// if a configfile has been passed, make viper read it
if err = loadConfigFile(); err != nil {
return nil, fmt.Errorf("Fatal error reading config file: %w", err)
return nil, fmt.Errorf("fatal error reading config file: %w", err)
}

// convert string of csv to String Slice
Expand Down
Loading