style: golangci lint
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
Markus Pesch 2022-03-11 10:51:55 +01:00
parent 85c288970a
commit 7113939121
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
4 changed files with 7 additions and 14 deletions

View File

@ -16,8 +16,10 @@ steps:
cpu: 50
memory: 50M
- name: golang-ci lint
image: docker.io/golangci/golangci-lint:1.44.2-alpine
- name: golangci lint
commands:
- golangci-lint run
image: docker.io/golangci/golangci-lint:v1.44.2-alpine
resources:
limits:
cpu: 100

View File

@ -16,7 +16,6 @@ var (
)
func main() {
switch os.Getenv("DYNDNS_CLIENT_LOGGER_LEVEL") {
case "DEBUG", "debug":
log.SetLevel(log.DebugLevel)

View File

@ -37,7 +37,6 @@ func GetDefaultConfiguration() (*types.Config, error) {
// Read config from a file
func Read(cnfFile string) (*types.Config, error) {
// Load burned in configuration if config not available
if _, err := os.Stat(cnfFile); os.IsNotExist(err) {
if err := os.MkdirAll(filepath.Dir(cnfFile), 0755); err != nil {

View File

@ -48,7 +48,7 @@ func Start(cnf *types.Config) {
for {
interfaces, err := netlink.LinkList()
if err != nil {
log.Fatal("%v", err.Error())
log.Fatalf("%v", err.Error())
}
select {
@ -99,7 +99,7 @@ func Start(cnf *types.Config) {
interfaceLogger.Error(err.Error())
}
} else {
err = removeIPRecords(daemonCtx, interfaceLogger, updaters, cnf.Zones, recordType, update.LinkAddress.IP)
err = removeIPRecords(daemonCtx, interfaceLogger, updaters, cnf.Zones, recordType)
if err != nil {
interfaceLogger.Error(err.Error())
}
@ -146,7 +146,6 @@ func searchInterfaceByIndex(index int, interfaces []netlink.Link) (netlink.Link,
}
func addIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[string]updater.Updater, zones map[string]*types.Zone, recordType string, ip net.IP) error {
var (
errorChannel = make(chan error, len(zones))
wg = new(sync.WaitGroup)
@ -166,7 +165,6 @@ func addIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[string]
wg.Add(1)
go func(ctx context.Context, zoneName string, hostname string, recordType string, ip net.IP, wg *sync.WaitGroup) {
zoneLogger := logEntry.WithFields(log.Fields{
"zone": zoneName,
"hostname": hostname,
@ -186,7 +184,6 @@ func addIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[string]
}
zoneLogger.Info("dns-record successfully updated")
}(ctx, zoneName, hostname, recordType, ip, wg)
}
@ -203,7 +200,6 @@ func addIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[string]
}
func pruneRecords(ctx context.Context, updaters map[string]updater.Updater, zones map[string]*types.Zone) error {
var (
errorChannel = make(chan error, len(zones))
wg = new(sync.WaitGroup)
@ -250,8 +246,7 @@ func pruneRecords(ctx context.Context, updaters map[string]updater.Updater, zone
return nil
}
func removeIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[string]updater.Updater, zones map[string]*types.Zone, recordType string, ip net.IP) error {
func removeIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[string]updater.Updater, zones map[string]*types.Zone, recordType string) error {
var (
errorChannel = make(chan error, len(zones))
wg = new(sync.WaitGroup)
@ -290,7 +285,6 @@ func removeIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[stri
}
zoneLogger.Info("dns-record successfully removed")
}(ctx, zoneName, hostname, recordType, wg)
}
@ -309,7 +303,6 @@ func removeIPRecords(ctx context.Context, logEntry *log.Entry, updaters map[stri
// verifyHostname returns a boolean if the hostname id valid. The hostname does
// not contains any dot or local, localhost, localdomain.
func verifyHostname(hostname string) bool {
if !validHostname.MatchString(hostname) {
return false
}